react-native-keyboard-controller 1.7.0 → 1.9.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/README.md +2 -0
- package/android/gradle.properties +1 -1
- package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardControllerViewManager.kt +5 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/events/FocusedInputLayoutChangedEvent.kt +41 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/ThemedReactContext.kt +9 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/View.kt +7 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/listeners/FocusedInputLayoutObserver.kt +93 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/{KeyboardAnimationCallback.kt → listeners/KeyboardAnimationCallback.kt} +86 -55
- package/android/src/main/java/com/reactnativekeyboardcontroller/managers/KeyboardControllerViewManagerImpl.kt +6 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/views/EdgeToEdgeReactViewGroup.kt +120 -50
- package/android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardControllerViewManager.kt +5 -0
- package/ios/Extensions.swift +7 -0
- package/ios/KeyboardController.xcodeproj/project.pbxproj +41 -7
- package/ios/events/FocusedInputLayoutChangedEvent.h +16 -0
- package/ios/events/FocusedInputLayoutChangedEvent.m +75 -0
- package/ios/observers/FocusedInputLayoutObserver.swift +136 -0
- package/ios/{KeyboardControllerView.mm → views/KeyboardControllerView.mm} +54 -3
- package/ios/{KeyboardControllerViewManager.mm → views/KeyboardControllerViewManager.mm} +7 -0
- package/ios/{KeyboardControllerViewManager.swift → views/KeyboardControllerViewManager.swift} +25 -1
- package/jest/index.js +16 -0
- package/lib/commonjs/animated.js +34 -6
- package/lib/commonjs/animated.js.map +1 -1
- package/lib/commonjs/bindings.js.map +1 -1
- package/lib/commonjs/bindings.native.js.map +1 -1
- package/lib/commonjs/components/KeyboardAvoidingView/hooks.js +9 -1
- package/lib/commonjs/components/KeyboardAvoidingView/hooks.js.map +1 -1
- package/lib/commonjs/components/KeyboardAvoidingView/index.js +7 -4
- package/lib/commonjs/components/KeyboardAvoidingView/index.js.map +1 -1
- package/lib/commonjs/components/KeyboardStickyView/index.js +44 -0
- package/lib/commonjs/components/KeyboardStickyView/index.js.map +1 -0
- package/lib/commonjs/components/index.js +7 -0
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/constants.js.map +1 -1
- package/lib/commonjs/context.js +9 -4
- package/lib/commonjs/context.js.map +1 -1
- package/lib/commonjs/hooks.js +16 -1
- package/lib/commonjs/hooks.js.map +1 -1
- package/lib/commonjs/index.js +8 -2
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/internal.js.map +1 -1
- package/lib/commonjs/monkey-patch.android.js +32 -20
- package/lib/commonjs/monkey-patch.android.js.map +1 -1
- package/lib/commonjs/monkey-patch.js +11 -1
- package/lib/commonjs/monkey-patch.js.map +1 -1
- package/lib/commonjs/reanimated.js +5 -2
- package/lib/commonjs/reanimated.js.map +1 -1
- package/lib/commonjs/reanimated.native.js +18 -1
- package/lib/commonjs/reanimated.native.js.map +1 -1
- package/lib/commonjs/replicas.js +1 -1
- package/lib/commonjs/replicas.js.map +1 -1
- package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
- package/lib/commonjs/specs/KeyboardGestureAreaNativeComponent.js.map +1 -1
- package/lib/commonjs/specs/NativeKeyboardController.js.map +1 -1
- package/lib/commonjs/specs/NativeStatusBarManagerCompat.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/animated.js +37 -9
- package/lib/module/animated.js.map +1 -1
- package/lib/module/bindings.js.map +1 -1
- package/lib/module/bindings.native.js +1 -1
- package/lib/module/bindings.native.js.map +1 -1
- package/lib/module/components/KeyboardAvoidingView/hooks.js +9 -1
- package/lib/module/components/KeyboardAvoidingView/hooks.js.map +1 -1
- package/lib/module/components/KeyboardAvoidingView/index.js +9 -6
- package/lib/module/components/KeyboardAvoidingView/index.js.map +1 -1
- package/lib/module/components/KeyboardStickyView/index.js +35 -0
- package/lib/module/components/KeyboardStickyView/index.js.map +1 -0
- package/lib/module/components/index.js +1 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/constants.js.map +1 -1
- package/lib/module/context.js +9 -4
- package/lib/module/context.js.map +1 -1
- package/lib/module/hooks.js +14 -1
- package/lib/module/hooks.js.map +1 -1
- package/lib/module/index.js +1 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/internal.js.map +1 -1
- package/lib/module/monkey-patch.android.js +26 -20
- package/lib/module/monkey-patch.android.js.map +1 -1
- package/lib/module/monkey-patch.js +3 -0
- package/lib/module/monkey-patch.js.map +1 -1
- package/lib/module/reanimated.js +3 -1
- package/lib/module/reanimated.js.map +1 -1
- package/lib/module/reanimated.native.js +16 -0
- package/lib/module/reanimated.native.js.map +1 -1
- package/lib/module/replicas.js +2 -2
- package/lib/module/replicas.js.map +1 -1
- package/lib/module/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
- package/lib/module/specs/KeyboardGestureAreaNativeComponent.js.map +1 -1
- package/lib/module/specs/NativeKeyboardController.js.map +1 -1
- package/lib/module/specs/NativeStatusBarManagerCompat.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/animated.d.ts +8 -1
- package/lib/typescript/components/KeyboardAvoidingView/hooks.d.ts +1 -0
- package/lib/typescript/components/KeyboardAvoidingView/index.d.ts +2 -1
- package/lib/typescript/components/KeyboardStickyView/index.d.ts +20 -0
- package/lib/typescript/components/index.d.ts +1 -0
- package/lib/typescript/context.d.ts +6 -3
- package/lib/typescript/hooks.d.ts +9 -2
- package/lib/typescript/index.d.ts +1 -2
- package/lib/typescript/internal.d.ts +1 -1
- package/lib/typescript/monkey-patch.android.d.ts +2 -1
- package/lib/typescript/monkey-patch.d.ts +2 -0
- package/lib/typescript/reanimated.d.ts +2 -1
- package/lib/typescript/reanimated.native.d.ts +2 -1
- package/lib/typescript/specs/KeyboardControllerViewNativeComponent.d.ts +13 -0
- package/lib/typescript/types.d.ts +17 -0
- package/package.json +9 -28
- package/src/animated.tsx +53 -9
- package/src/bindings.native.ts +1 -1
- package/src/bindings.ts +3 -1
- package/src/components/KeyboardAvoidingView/hooks.ts +9 -1
- package/src/components/KeyboardAvoidingView/index.tsx +15 -13
- package/src/components/KeyboardStickyView/index.tsx +63 -0
- package/src/components/index.ts +1 -0
- package/src/constants.ts +2 -0
- package/src/context.ts +16 -5
- package/src/hooks.ts +16 -6
- package/src/index.ts +1 -3
- package/src/internal.ts +3 -1
- package/src/monkey-patch.android.ts +27 -21
- package/src/monkey-patch.ts +3 -0
- package/src/reanimated.native.ts +30 -1
- package/src/reanimated.ts +13 -2
- package/src/replicas.ts +2 -2
- package/src/specs/KeyboardControllerViewNativeComponent.ts +16 -1
- package/src/specs/KeyboardGestureAreaNativeComponent.ts +2 -1
- package/src/specs/NativeKeyboardController.ts +2 -1
- package/src/specs/NativeStatusBarManagerCompat.ts +2 -1
- package/src/types.ts +28 -1
- /package/ios/{KeyboardMoveEvent.h → events/KeyboardMoveEvent.h} +0 -0
- /package/ios/{KeyboardMoveEvent.m → events/KeyboardMoveEvent.m} +0 -0
- /package/ios/{KeyboardMovementObserver.swift → observers/KeyboardMovementObserver.swift} +0 -0
- /package/ios/{KeyboardControllerView.h → views/KeyboardControllerView.h} +0 -0
|
@@ -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 { 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 https://github.com/software-mansion/react-native-reanimated/pull/4923\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.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,CACH;EAED,oBACE,6BAAC,wBAAe,CAAC,QAAQ;IAAC,KAAK,EAAEV;EAAQ,gBACvC,6BAAC,8BAA8B;IAC7B,wBAAwB,EAAEmB,OAAQ;IAClC,mBAAmB,EAAEH,qBAAQ,CAACC,EAAE,KAAK,KAAK,GAAGR,cAAc,GAAGe,SAAU;IACxE,cAAc,EAAER,qBAAQ,CAACC,EAAE,KAAK,SAAS,GAAGR,cAAc,GAAGe,SAAU;IACvE,yBAAyB,EAAEf,cAAe;IAC1C,wBAAwB,EAAEnB,wBAAyB;IACnD,oBAAoB,EAAED;IACtB;IAAA;IACA,KAAK,EAAEV,MAAM,CAACG;EAAU,GAEvBM,QAAQ,CACsB,eACjC,6BAAC,qBAAQ,CAAC,IAAI;IACZ;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,KAAK,EAAEiB;EAAM,EACb,CACuB;AAE/B,CAAC;AAAC"}
|
|
1
|
+
{"version":3,"names":["KeyboardControllerViewAnimated","Reanimated","createAnimatedComponent","Animated","KeyboardControllerView","styles","StyleSheet","create","container","flex","hidden","display","position","KeyboardProvider","children","statusBarTranslucent","navigationBarTranslucent","enabled","initiallyEnabled","setEnabled","useState","progress","useAnimatedValue","height","progressSV","useSharedValue","heightSV","layout","setHandlers","broadcast","useSharedHandlers","context","useMemo","animated","multiply","reanimated","style","transform","translateX","translateY","onKeyboardMove","event","nativeEvent","useNativeDriver","updateSharedValues","platforms","includes","Platform","OS","value","keyboardHandler","useAnimatedKeyboardHandler","onKeyboardMoveStart","onKeyboardMoveEnd","onKeyboardMoveInteractive","inputHandler","useFocusedInputHandler","onFocusedInputLayoutChanged","e","target","useEffect","applyMonkeyPatch","revertMonkeyPatch","undefined"],"sources":["animated.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useState } from 'react';\nimport { Animated, Platform, StyleSheet } from 'react-native';\nimport Reanimated, { useSharedValue } from 'react-native-reanimated';\n\nimport { KeyboardControllerView } from './bindings';\nimport { KeyboardContext } from './context';\nimport { useAnimatedValue, useSharedHandlers } from './internal';\nimport { applyMonkeyPatch, revertMonkeyPatch } from './monkey-patch';\nimport {\n useAnimatedKeyboardHandler,\n useFocusedInputHandler,\n} from './reanimated';\n\nimport type { KeyboardAnimationContext } from './context';\nimport type {\n FocusedInputLayoutChangedEvent,\n KeyboardControllerProps,\n KeyboardHandler,\n NativeEvent,\n} from './types';\nimport type { ViewStyle } from 'react-native';\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 * A boolean prop indicating whether the module is enabled. It indicate only initial state,\n * i. e. if you try to change this prop after component mount it will not have any effect.\n * To change the property in runtime use `useKeyboardController` hook and `setEnabled` method.\n * Defaults to `true`.\n */\n enabled?: boolean;\n};\n\nexport const KeyboardProvider = ({\n children,\n statusBarTranslucent,\n navigationBarTranslucent,\n enabled: initiallyEnabled = true,\n}: KeyboardProviderProps) => {\n const [enabled, setEnabled] = useState(initiallyEnabled);\n // animated values\n const progress = useAnimatedValue(0);\n const height = useAnimatedValue(0);\n // shared values\n const progressSV = useSharedValue(0);\n const heightSV = useSharedValue(0);\n const layout = useSharedValue<FocusedInputLayoutChangedEvent | null>(null);\n const { setHandlers, broadcast } = useSharedHandlers<KeyboardHandler>();\n // memo\n const context = useMemo<KeyboardAnimationContext>(\n () => ({\n enabled,\n animated: { progress: progress, height: Animated.multiply(height, -1) },\n reanimated: { progress: progressSV, height: heightSV },\n layout,\n setHandlers,\n setEnabled,\n }),\n [enabled]\n );\n const style = useMemo(\n () => [\n styles.hidden,\n { transform: [{ translateX: height }, { translateY: progress }] },\n ],\n []\n );\n const onKeyboardMove = useMemo(\n () =>\n Animated.event(\n [\n {\n nativeEvent: {\n progress,\n height,\n },\n },\n ],\n { 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 keyboardHandler = 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 const inputHandler = useFocusedInputHandler(\n {\n onFocusedInputLayoutChanged: (e) => {\n 'worklet';\n\n if (e.target !== -1) {\n layout.value = e;\n } else {\n layout.value = null;\n }\n },\n },\n []\n );\n // effects\n useEffect(() => {\n if (enabled) {\n applyMonkeyPatch();\n } else {\n revertMonkeyPatch();\n }\n }, [enabled]);\n\n return (\n <KeyboardContext.Provider value={context}>\n <KeyboardControllerViewAnimated\n enabled={enabled}\n onKeyboardMoveReanimated={keyboardHandler}\n onKeyboardMoveStart={Platform.OS === 'ios' ? onKeyboardMove : undefined}\n onKeyboardMove={Platform.OS === 'android' ? onKeyboardMove : undefined}\n onKeyboardMoveInteractive={onKeyboardMove}\n onFocusedInputLayoutChangedReanimated={inputHandler}\n navigationBarTranslucent={navigationBarTranslucent}\n statusBarTranslucent={statusBarTranslucent}\n // @ts-expect-error https://github.com/software-mansion/react-native-reanimated/pull/4923\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;AACA;AAGsB;AAAA;AAWtB,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;AA+BK,MAAMC,gBAAgB,GAAG,QAKH;EAAA,IALI;IAC/BC,QAAQ;IACRC,oBAAoB;IACpBC,wBAAwB;IACxBC,OAAO,EAAEC,gBAAgB,GAAG;EACP,CAAC;EACtB,MAAM,CAACD,OAAO,EAAEE,UAAU,CAAC,GAAG,IAAAC,eAAQ,EAACF,gBAAgB,CAAC;EACxD;EACA,MAAMG,QAAQ,GAAG,IAAAC,0BAAgB,EAAC,CAAC,CAAC;EACpC,MAAMC,MAAM,GAAG,IAAAD,0BAAgB,EAAC,CAAC,CAAC;EAClC;EACA,MAAME,UAAU,GAAG,IAAAC,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AAK,EAAEc;EAAQ,gBACvC,6BAAC,8BAA8B;IAC7B,OAAO,EAAEd,OAAQ;IACjB,wBAAwB,EAAEiC,eAAgB;IAC1C,mBAAmB,EAAEH,qBAAQ,CAACC,EAAE,KAAK,KAAK,GAAGR,cAAc,GAAGuB,SAAU;IACxE,cAAc,EAAEhB,qBAAQ,CAACC,EAAE,KAAK,SAAS,GAAGR,cAAc,GAAGuB,SAAU;IACvE,yBAAyB,EAAEvB,cAAe;IAC1C,qCAAqC,EAAEe,YAAa;IACpD,wBAAwB,EAAEvC,wBAAyB;IACnD,oBAAoB,EAAED;IACtB;IAAA;IACA,KAAK,EAAEV,MAAM,CAACG;EAAU,GAEvBM,QAAQ,CACsB,eACjC,6BAAC,qBAAQ,CAAC,IAAI;IACZ;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,KAAK,EAAEsB;EAAM,EACb,CACuB;AAE/B,CAAC;AAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NOOP","KeyboardController","setDefaultMode","setInputMode","addListener","removeListeners","KeyboardEvents","remove","KeyboardControllerView","View","KeyboardGestureArea"],"sources":["bindings.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"names":["NOOP","KeyboardController","setDefaultMode","setInputMode","addListener","removeListeners","KeyboardEvents","remove","KeyboardControllerView","View","KeyboardGestureArea"],"sources":["bindings.ts"],"sourcesContent":["import { View } from 'react-native';\n\nimport type {\n KeyboardControllerModule,\n KeyboardControllerProps,\n KeyboardEventsModule,\n KeyboardGestureAreaProps,\n} from './types';\nimport type { EmitterSubscription } from 'react-native';\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;AAUA,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"}
|
|
@@ -1 +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 {
|
|
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 { NativeEventEmitter, Platform } 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"}
|
|
@@ -10,11 +10,13 @@ const useKeyboardAnimation = () => {
|
|
|
10
10
|
const heightWhenOpened = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
11
11
|
const height = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
12
12
|
const progress = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
13
|
+
const isClosed = (0, _reactNativeReanimated.useSharedValue)(true);
|
|
13
14
|
(0, _hooks.useKeyboardHandler)({
|
|
14
15
|
onStart: e => {
|
|
15
16
|
'worklet';
|
|
16
17
|
|
|
17
18
|
if (e.height > 0) {
|
|
19
|
+
isClosed.value = false;
|
|
18
20
|
heightWhenOpened.value = e.height;
|
|
19
21
|
}
|
|
20
22
|
},
|
|
@@ -23,12 +25,18 @@ const useKeyboardAnimation = () => {
|
|
|
23
25
|
|
|
24
26
|
progress.value = e.progress;
|
|
25
27
|
height.value = e.height;
|
|
28
|
+
},
|
|
29
|
+
onEnd: e => {
|
|
30
|
+
'worklet';
|
|
31
|
+
|
|
32
|
+
isClosed.value = e.height === 0;
|
|
26
33
|
}
|
|
27
34
|
}, []);
|
|
28
35
|
return {
|
|
29
36
|
height,
|
|
30
37
|
progress,
|
|
31
|
-
heightWhenOpened
|
|
38
|
+
heightWhenOpened,
|
|
39
|
+
isClosed
|
|
32
40
|
};
|
|
33
41
|
};
|
|
34
42
|
exports.useKeyboardAnimation = useKeyboardAnimation;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useKeyboardAnimation","heightWhenOpened","useSharedValue","height","progress","useKeyboardHandler","onStart","e","value","onMove"],"sources":["hooks.ts"],"sourcesContent":["import { useSharedValue } from 'react-native-reanimated';\nimport { useKeyboardHandler } from '../../hooks';\n\nexport const useKeyboardAnimation = () => {\n const heightWhenOpened = useSharedValue(0);\n const height = useSharedValue(0);\n const progress = useSharedValue(0);\n\n useKeyboardHandler(\n {\n onStart: (e) => {\n 'worklet';\n\n if (e.height > 0) {\n heightWhenOpened.value = e.height;\n }\n },\n onMove: (e) => {\n 'worklet';\n\n progress.value = e.progress;\n height.value = e.height;\n },\n },\n []\n );\n\n return { height, progress, heightWhenOpened };\n};\n"],"mappings":";;;;;;AAAA;
|
|
1
|
+
{"version":3,"names":["useKeyboardAnimation","heightWhenOpened","useSharedValue","height","progress","isClosed","useKeyboardHandler","onStart","e","value","onMove","onEnd"],"sources":["hooks.ts"],"sourcesContent":["import { useSharedValue } from 'react-native-reanimated';\n\nimport { useKeyboardHandler } from '../../hooks';\n\nexport const useKeyboardAnimation = () => {\n const heightWhenOpened = useSharedValue(0);\n const height = useSharedValue(0);\n const progress = useSharedValue(0);\n const isClosed = useSharedValue(true);\n\n useKeyboardHandler(\n {\n onStart: (e) => {\n 'worklet';\n\n if (e.height > 0) {\n isClosed.value = false;\n heightWhenOpened.value = e.height;\n }\n },\n onMove: (e) => {\n 'worklet';\n\n progress.value = e.progress;\n height.value = e.height;\n },\n onEnd: (e) => {\n 'worklet';\n\n isClosed.value = e.height === 0;\n },\n },\n []\n );\n\n return { height, progress, heightWhenOpened, isClosed };\n};\n"],"mappings":";;;;;;AAAA;AAEA;AAEO,MAAMA,oBAAoB,GAAG,MAAM;EACxC,MAAMC,gBAAgB,GAAG,IAAAC,qCAAc,EAAC,CAAC,CAAC;EAC1C,MAAMC,MAAM,GAAG,IAAAD,qCAAc,EAAC,CAAC,CAAC;EAChC,MAAME,QAAQ,GAAG,IAAAF,qCAAc,EAAC,CAAC,CAAC;EAClC,MAAMG,QAAQ,GAAG,IAAAH,qCAAc,EAAC,IAAI,CAAC;EAErC,IAAAI,yBAAkB,EAChB;IACEC,OAAO,EAAGC,CAAC,IAAK;MACd,SAAS;;MAET,IAAIA,CAAC,CAACL,MAAM,GAAG,CAAC,EAAE;QAChBE,QAAQ,CAACI,KAAK,GAAG,KAAK;QACtBR,gBAAgB,CAACQ,KAAK,GAAGD,CAAC,CAACL,MAAM;MACnC;IACF,CAAC;IACDO,MAAM,EAAGF,CAAC,IAAK;MACb,SAAS;;MAETJ,QAAQ,CAACK,KAAK,GAAGD,CAAC,CAACJ,QAAQ;MAC3BD,MAAM,CAACM,KAAK,GAAGD,CAAC,CAACL,MAAM;IACzB,CAAC;IACDQ,KAAK,EAAGH,CAAC,IAAK;MACZ,SAAS;;MAETH,QAAQ,CAACI,KAAK,GAAGD,CAAC,CAACL,MAAM,KAAK,CAAC;IACjC;EACF,CAAC,EACD,EAAE,CACH;EAED,OAAO;IAAEA,MAAM;IAAEC,QAAQ;IAAEH,gBAAgB;IAAEI;EAAS,CAAC;AACzD,CAAC;AAAC"}
|
|
@@ -43,10 +43,13 @@ const KeyboardAvoidingView = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) =>
|
|
|
43
43
|
const keyboardY = screenHeight - keyboard.heightWhenOpened.value - keyboardVerticalOffset;
|
|
44
44
|
return Math.max(frame.value.y + frame.value.height - keyboardY, 0);
|
|
45
45
|
}, [screenHeight, keyboardVerticalOffset]);
|
|
46
|
-
const
|
|
47
|
-
if (
|
|
48
|
-
initialFrame.value =
|
|
46
|
+
const onLayoutWorklet = (0, _reactNativeReanimated.useWorkletCallback)(layout => {
|
|
47
|
+
if (keyboard.isClosed.value) {
|
|
48
|
+
initialFrame.value = layout;
|
|
49
49
|
}
|
|
50
|
+
});
|
|
51
|
+
const onLayout = (0, _react.useCallback)(e => {
|
|
52
|
+
(0, _reactNativeReanimated.runOnUI)(onLayoutWorklet)(e.nativeEvent.layout);
|
|
50
53
|
onLayoutProps === null || onLayoutProps === void 0 ? void 0 : onLayoutProps(e);
|
|
51
54
|
}, [onLayoutProps]);
|
|
52
55
|
const animatedStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => {
|
|
@@ -54,7 +57,7 @@ const KeyboardAvoidingView = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) =>
|
|
|
54
57
|
const bottomHeight = enabled ? bottom : 0;
|
|
55
58
|
switch (behavior) {
|
|
56
59
|
case 'height':
|
|
57
|
-
if (
|
|
60
|
+
if (!keyboard.isClosed.value) {
|
|
58
61
|
return {
|
|
59
62
|
height: frame.value.height - bottomHeight,
|
|
60
63
|
flex: 0
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["defaultLayout","x","y","width","height","KeyboardAvoidingView","forwardRef","ref","behavior","children","contentContainerStyle","enabled","keyboardVerticalOffset","style","onLayout","onLayoutProps","props","initialFrame","useSharedValue","frame","useDerivedValue","value","keyboard","useKeyboardAnimation","screenHeight","useWindowDimensions","relativeKeyboardHeight","useWorkletCallback","keyboardY","heightWhenOpened","Math","max","useCallback","e","
|
|
1
|
+
{"version":3,"names":["defaultLayout","x","y","width","height","KeyboardAvoidingView","forwardRef","ref","behavior","children","contentContainerStyle","enabled","keyboardVerticalOffset","style","onLayout","onLayoutProps","props","initialFrame","useSharedValue","frame","useDerivedValue","value","keyboard","useKeyboardAnimation","screenHeight","useWindowDimensions","relativeKeyboardHeight","useWorkletCallback","keyboardY","heightWhenOpened","Math","max","onLayoutWorklet","layout","isClosed","useCallback","e","runOnUI","nativeEvent","animatedStyle","useAnimatedStyle","bottom","interpolate","progress","bottomHeight","flex","paddingBottom","isPositionBehavior","containerStyle","combinedStyles","useMemo"],"sources":["index.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useMemo } from 'react';\nimport { View, useWindowDimensions } from 'react-native';\nimport Reanimated, {\n interpolate,\n runOnUI,\n useAnimatedStyle,\n useDerivedValue,\n useSharedValue,\n useWorkletCallback,\n} from 'react-native-reanimated';\n\nimport { useKeyboardAnimation } from './hooks';\n\nimport type { LayoutRectangle, ViewProps } from 'react-native';\n\ntype Props = {\n /**\n * Specify how to react to the presence of the keyboard.\n */\n behavior?: 'height' | 'position' | 'padding';\n\n /**\n * Style of the content container when `behavior` is 'position'.\n */\n contentContainerStyle?: ViewProps['style'];\n\n /**\n * Controls whether this `KeyboardAvoidingView` instance should take effect.\n * This is useful when more than one is on the screen. Defaults to true.\n */\n enabled?: boolean;\n\n /**\n * Distance between the top of the user screen and the React Native view. This\n * may be non-zero in some cases. Defaults to 0.\n */\n keyboardVerticalOffset?: number;\n} & ViewProps;\n\nconst defaultLayout: LayoutRectangle = {\n x: 0,\n y: 0,\n width: 0,\n height: 0,\n};\n\n/**\n * View that moves out of the way when the keyboard appears by automatically\n * adjusting its height, position, or bottom padding.\n */\nconst KeyboardAvoidingView = forwardRef<View, React.PropsWithChildren<Props>>(\n (\n {\n behavior,\n children,\n contentContainerStyle,\n enabled = true,\n keyboardVerticalOffset = 0,\n style,\n onLayout: onLayoutProps,\n ...props\n },\n ref\n ) => {\n const initialFrame = useSharedValue<LayoutRectangle | null>(null);\n const frame = useDerivedValue(() => initialFrame.value || defaultLayout);\n\n const keyboard = useKeyboardAnimation();\n const { height: screenHeight } = useWindowDimensions();\n\n const relativeKeyboardHeight = useWorkletCallback(() => {\n const keyboardY =\n screenHeight - keyboard.heightWhenOpened.value - keyboardVerticalOffset;\n\n return Math.max(frame.value.y + frame.value.height - keyboardY, 0);\n }, [screenHeight, keyboardVerticalOffset]);\n\n const onLayoutWorklet = useWorkletCallback((layout: LayoutRectangle) => {\n if (keyboard.isClosed.value) {\n initialFrame.value = layout;\n }\n });\n const onLayout = useCallback<NonNullable<ViewProps['onLayout']>>(\n (e) => {\n runOnUI(onLayoutWorklet)(e.nativeEvent.layout);\n onLayoutProps?.(e);\n },\n [onLayoutProps]\n );\n\n const animatedStyle = useAnimatedStyle(() => {\n const bottom = interpolate(\n keyboard.progress.value,\n [0, 1],\n [0, relativeKeyboardHeight()]\n );\n const bottomHeight = enabled ? bottom : 0;\n\n switch (behavior) {\n case 'height':\n if (!keyboard.isClosed.value) {\n return {\n height: frame.value.height - bottomHeight,\n flex: 0,\n };\n }\n\n return {};\n\n case 'position':\n return { bottom: bottomHeight };\n\n case 'padding':\n return { paddingBottom: bottomHeight };\n\n default:\n return {};\n }\n }, [behavior, enabled, relativeKeyboardHeight]);\n const isPositionBehavior = behavior === 'position';\n const containerStyle = isPositionBehavior ? contentContainerStyle : style;\n const combinedStyles = useMemo(\n () => [containerStyle, animatedStyle],\n [containerStyle, animatedStyle]\n );\n\n if (isPositionBehavior) {\n return (\n <View ref={ref} style={style} onLayout={onLayout} {...props}>\n <Reanimated.View style={combinedStyles}>{children}</Reanimated.View>\n </View>\n );\n }\n\n return (\n <Reanimated.View\n // @ts-expect-error because `ref` from reanimated is not compatible with react-native\n ref={ref}\n onLayout={onLayout}\n style={combinedStyles}\n {...props}\n >\n {children}\n </Reanimated.View>\n );\n }\n);\n\nexport default KeyboardAvoidingView;\n"],"mappings":";;;;;;AAAA;AACA;AACA;AASA;AAA+C;AAAA;AAAA;AA4B/C,MAAMA,aAA8B,GAAG;EACrCC,CAAC,EAAE,CAAC;EACJC,CAAC,EAAE,CAAC;EACJC,KAAK,EAAE,CAAC;EACRC,MAAM,EAAE;AACV,CAAC;;AAED;AACA;AACA;AACA;AACA,MAAMC,oBAAoB,gBAAG,IAAAC,iBAAU,EACrC,OAWEC,GAAG,KACA;EAAA,IAXH;IACEC,QAAQ;IACRC,QAAQ;IACRC,qBAAqB;IACrBC,OAAO,GAAG,IAAI;IACdC,sBAAsB,GAAG,CAAC;IAC1BC,KAAK;IACLC,QAAQ,EAAEC,aAAa;IACvB,GAAGC;EACL,CAAC;EAGD,MAAMC,YAAY,GAAG,IAAAC,qCAAc,EAAyB,IAAI,CAAC;EACjE,MAAMC,KAAK,GAAG,IAAAC,sCAAe,EAAC,MAAMH,YAAY,CAACI,KAAK,IAAIrB,aAAa,CAAC;EAExE,MAAMsB,QAAQ,GAAG,IAAAC,2BAAoB,GAAE;EACvC,MAAM;IAAEnB,MAAM,EAAEoB;EAAa,CAAC,GAAG,IAAAC,gCAAmB,GAAE;EAEtD,MAAMC,sBAAsB,GAAG,IAAAC,yCAAkB,EAAC,MAAM;IACtD,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C;MAEX,KAAK,UAAU;QACb,OAAO;UAAEJ,MAAM,EAAEG;QAAa,CAAC;MAEjC,KAAK,SAAS;QACZ,OAAO;UAAEE,aAAa,EAAEF;QAAa,CAAC;MAExC;QACE,OAAO,CAAC,CAAC;IAAC;EAEhB,CAAC,EAAE,CAACpC,QAAQ,EAAEG,OAAO,EAAEe,sBAAsB,CAAC,CAAC;EAC/C,MAAMqB,kBAAkB,GAAGvC,QAAQ,KAAK,UAAU;EAClD,MAAMwC,cAAc,GAAGD,kBAAkB,GAAGrC,qBAAqB,GAAGG,KAAK;EACzE,MAAMoC,cAAc,GAAG,IAAAC,cAAO,EAC5B,MAAM,CAACF,cAAc,EAAET,aAAa,CAAC,EACrC,CAACS,cAAc,EAAET,aAAa,CAAC,CAChC;EAED,IAAIQ,kBAAkB,EAAE;IACtB,oBACE,6BAAC,iBAAI;MAAC,GAAG,EAAExC,GAAI;MAAC,KAAK,EAAEM,KAAM;MAAC,QAAQ,EAAEC;IAAS,GAAKE,KAAK,gBACzD,6BAAC,8BAAU,CAAC,IAAI;MAAC,KAAK,EAAEiC;IAAe,GAAExC,QAAQ,CAAmB,CAC/D;EAEX;EAEA,oBACE,6BAAC,8BAAU,CAAC,IAAI;IACd;IACA,GAAG,EAAEF,GAAI;IACT,QAAQ,EAAEO,QAAS;IACnB,KAAK,EAAEmC;EAAe,GAClBjC,KAAK,GAERP,QAAQ,CACO;AAEtB,CAAC,CACF;AAAC,eAEaJ,oBAAoB;AAAA"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
|
|
9
|
+
var _hooks = require("../../hooks");
|
|
10
|
+
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); }
|
|
11
|
+
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; }
|
|
12
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
13
|
+
const KeyboardStickyView = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
14
|
+
let {
|
|
15
|
+
children,
|
|
16
|
+
offset: {
|
|
17
|
+
closed = 0,
|
|
18
|
+
opened = 0
|
|
19
|
+
} = {},
|
|
20
|
+
style,
|
|
21
|
+
...props
|
|
22
|
+
} = _ref;
|
|
23
|
+
const {
|
|
24
|
+
height,
|
|
25
|
+
progress
|
|
26
|
+
} = (0, _hooks.useReanimatedKeyboardAnimation)();
|
|
27
|
+
const stickyViewStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => {
|
|
28
|
+
const offset = (0, _reactNativeReanimated.interpolate)(progress.value, [0, 1], [closed, opened]);
|
|
29
|
+
return {
|
|
30
|
+
transform: [{
|
|
31
|
+
translateY: height.value + offset
|
|
32
|
+
}]
|
|
33
|
+
};
|
|
34
|
+
}, [closed, opened]);
|
|
35
|
+
const styles = (0, _react.useMemo)(() => [style, stickyViewStyle], [style, stickyViewStyle]);
|
|
36
|
+
return /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, _extends({
|
|
37
|
+
// @ts-expect-error because `ref` from reanimated is not compatible with react-native
|
|
38
|
+
ref: ref,
|
|
39
|
+
style: styles
|
|
40
|
+
}, props), children);
|
|
41
|
+
});
|
|
42
|
+
var _default = KeyboardStickyView;
|
|
43
|
+
exports.default = _default;
|
|
44
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["KeyboardStickyView","forwardRef","ref","children","offset","closed","opened","style","props","height","progress","useReanimatedKeyboardAnimation","stickyViewStyle","useAnimatedStyle","interpolate","value","transform","translateY","styles","useMemo"],"sources":["index.tsx"],"sourcesContent":["import React, { forwardRef, useMemo } from 'react';\nimport Reanimated, {\n interpolate,\n useAnimatedStyle,\n} from 'react-native-reanimated';\n\nimport { useReanimatedKeyboardAnimation } from '../../hooks';\n\nimport type { View, ViewProps } from 'react-native';\n\ntype KeyboardStickyViewProps = {\n /**\n * Specify additional offset to the view for given keyboard state.\n */\n offset?: {\n /**\n * Adds additional `translateY` when keyboard is close. By default `0`.\n */\n closed?: number;\n /**\n * Adds additional `translateY` when keyboard is open. By default `0`.\n */\n opened?: number;\n };\n} & ViewProps;\n\nconst KeyboardStickyView = forwardRef<\n View,\n React.PropsWithChildren<KeyboardStickyViewProps>\n>(\n (\n { children, offset: { closed = 0, opened = 0 } = {}, style, ...props },\n ref\n ) => {\n const { height, progress } = useReanimatedKeyboardAnimation();\n\n const stickyViewStyle = useAnimatedStyle(() => {\n const offset = interpolate(progress.value, [0, 1], [closed, opened]);\n\n return {\n transform: [{ translateY: height.value + offset }],\n };\n }, [closed, opened]);\n\n const styles = useMemo(\n () => [style, stickyViewStyle],\n [style, stickyViewStyle]\n );\n\n return (\n <Reanimated.View\n // @ts-expect-error because `ref` from reanimated is not compatible with react-native\n ref={ref}\n style={styles}\n {...props}\n >\n {children}\n </Reanimated.View>\n );\n }\n);\n\nexport default KeyboardStickyView;\n"],"mappings":";;;;;;AAAA;AACA;AAKA;AAA6D;AAAA;AAAA;AAoB7D,MAAMA,kBAAkB,gBAAG,IAAAC,iBAAU,EAInC,OAEEC,GAAG,KACA;EAAA,IAFH;IAAEC,QAAQ;IAAEC,MAAM,EAAE;MAAEC,MAAM,GAAG,CAAC;MAAEC,MAAM,GAAG;IAAE,CAAC,GAAG,CAAC,CAAC;IAAEC,KAAK;IAAE,GAAGC;EAAM,CAAC;EAGtE,MAAM;IAAEC,MAAM;IAAEC;EAAS,CAAC,GAAG,IAAAC,qCAA8B,GAAE;EAE7D,MAAMC,eAAe,GAAG,IAAAC,uCAAgB,EAAC,MAAM;IAC7C,MAAMT,MAAM,GAAG,IAAAU,kCAAW,EAACJ,QAAQ,CAACK,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAACV,MAAM,EAAEC,MAAM,CAAC,CAAC;IAEpE,OAAO;MACLU,SAAS,EAAE,CAAC;QAAEC,UAAU,EAAER,MAAM,CAACM,KAAK,GAAGX;MAAO,CAAC;IACnD,CAAC;EACH,CAAC,EAAE,CAACC,MAAM,EAAEC,MAAM,CAAC,CAAC;EAEpB,MAAMY,MAAM,GAAG,IAAAC,cAAO,EACpB,MAAM,CAACZ,KAAK,EAAEK,eAAe,CAAC,EAC9B,CAACL,KAAK,EAAEK,eAAe,CAAC,CACzB;EAED,oBACE,6BAAC,8BAAU,CAAC,IAAI;IACd;IACA,GAAG,EAAEV,GAAI;IACT,KAAK,EAAEgB;EAAO,GACVV,KAAK,GAERL,QAAQ,CACO;AAEtB,CAAC,CACF;AAAC,eAEaH,kBAAkB;AAAA"}
|
|
@@ -9,6 +9,13 @@ Object.defineProperty(exports, "KeyboardAvoidingView", {
|
|
|
9
9
|
return _KeyboardAvoidingView.default;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
+
Object.defineProperty(exports, "KeyboardStickyView", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _KeyboardStickyView.default;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
12
18
|
var _KeyboardAvoidingView = _interopRequireDefault(require("./KeyboardAvoidingView"));
|
|
19
|
+
var _KeyboardStickyView = _interopRequireDefault(require("./KeyboardStickyView"));
|
|
13
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
21
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { default as KeyboardAvoidingView } from './KeyboardAvoidingView';\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { default as KeyboardAvoidingView } from './KeyboardAvoidingView';\nexport { default as KeyboardStickyView } from './KeyboardStickyView';\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AACA;AAAqE"}
|
|
@@ -1 +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"}
|
|
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 // temporarily disable this rule to avoid breaking changes.\n // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values\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
|
@@ -7,13 +7,16 @@ exports.useKeyboardContext = exports.KeyboardContext = void 0;
|
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _reactNative = require("react-native");
|
|
9
9
|
const NOOP = () => {};
|
|
10
|
-
const
|
|
11
|
-
value
|
|
10
|
+
const withSharedValue = value => ({
|
|
11
|
+
value,
|
|
12
12
|
addListener: NOOP,
|
|
13
13
|
removeListener: NOOP,
|
|
14
14
|
modify: NOOP
|
|
15
|
-
};
|
|
15
|
+
});
|
|
16
|
+
const DEFAULT_SHARED_VALUE = withSharedValue(0);
|
|
17
|
+
const DEFAULT_LAYOUT = withSharedValue(null);
|
|
16
18
|
const defaultContext = {
|
|
19
|
+
enabled: true,
|
|
17
20
|
animated: {
|
|
18
21
|
progress: new _reactNative.Animated.Value(0),
|
|
19
22
|
height: new _reactNative.Animated.Value(0)
|
|
@@ -22,7 +25,9 @@ const defaultContext = {
|
|
|
22
25
|
progress: DEFAULT_SHARED_VALUE,
|
|
23
26
|
height: DEFAULT_SHARED_VALUE
|
|
24
27
|
},
|
|
25
|
-
|
|
28
|
+
layout: DEFAULT_LAYOUT,
|
|
29
|
+
setHandlers: NOOP,
|
|
30
|
+
setEnabled: NOOP
|
|
26
31
|
};
|
|
27
32
|
const KeyboardContext = /*#__PURE__*/(0, _react.createContext)(defaultContext);
|
|
28
33
|
exports.KeyboardContext = KeyboardContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NOOP","
|
|
1
|
+
{"version":3,"names":["NOOP","withSharedValue","value","addListener","removeListener","modify","DEFAULT_SHARED_VALUE","DEFAULT_LAYOUT","defaultContext","enabled","animated","progress","Animated","Value","height","reanimated","layout","setHandlers","setEnabled","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 { FocusedInputLayoutChangedEvent, KeyboardHandlers } from './types';\nimport type React from 'react';\nimport type { SharedValue } from 'react-native-reanimated';\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 enabled: boolean;\n animated: AnimatedContext;\n reanimated: ReanimatedContext;\n layout: SharedValue<FocusedInputLayoutChangedEvent | null>;\n setHandlers: (handlers: KeyboardHandlers) => void;\n setEnabled: React.Dispatch<React.SetStateAction<boolean>>;\n};\nconst NOOP = () => {};\nconst withSharedValue = <T>(value: T): SharedValue<T> => ({\n value,\n addListener: NOOP,\n removeListener: NOOP,\n modify: NOOP,\n});\nconst DEFAULT_SHARED_VALUE = withSharedValue(0);\nconst DEFAULT_LAYOUT = withSharedValue<FocusedInputLayoutChangedEvent | null>(\n null\n);\nconst defaultContext: KeyboardAnimationContext = {\n enabled: true,\n animated: {\n progress: new Animated.Value(0),\n height: new Animated.Value(0),\n },\n reanimated: {\n progress: DEFAULT_SHARED_VALUE,\n height: DEFAULT_SHARED_VALUE,\n },\n layout: DEFAULT_LAYOUT,\n setHandlers: NOOP,\n setEnabled: NOOP,\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;AAsBA,MAAMA,IAAI,GAAG,MAAM,CAAC,CAAC;AACrB,MAAMC,eAAe,GAAOC,KAAQ,KAAsB;EACxDA,KAAK;EACLC,WAAW,EAAEH,IAAI;EACjBI,cAAc,EAAEJ,IAAI;EACpBK,MAAM,EAAEL;AACV,CAAC,CAAC;AACF,MAAMM,oBAAoB,GAAGL,eAAe,CAAC,CAAC,CAAC;AAC/C,MAAMM,cAAc,GAAGN,eAAe,CACpC,IAAI,CACL;AACD,MAAMO,cAAwC,GAAG;EAC/CC,OAAO,EAAE,IAAI;EACbC,QAAQ,EAAE;IACRC,QAAQ,EAAE,IAAIC,qBAAQ,CAACC,KAAK,CAAC,CAAC,CAAC;IAC/BC,MAAM,EAAE,IAAIF,qBAAQ,CAACC,KAAK,CAAC,CAAC;EAC9B,CAAC;EACDE,UAAU,EAAE;IACVJ,QAAQ,EAAEL,oBAAoB;IAC9BQ,MAAM,EAAER;EACV,CAAC;EACDU,MAAM,EAAET,cAAc;EACtBU,WAAW,EAAEjB,IAAI;EACjBkB,UAAU,EAAElB;AACd,CAAC;AACM,MAAMmB,eAAe,gBAAG,IAAAC,oBAAa,EAACZ,cAAc,CAAC;AAAC;AACtD,MAAMa,kBAAkB,GAAG,MAAM;EACtC,MAAMC,OAAO,GAAG,IAAAC,iBAAU,EAACJ,eAAe,CAAC;EAE3C,IAAIK,OAAO,IAAIF,OAAO,KAAKd,cAAc,EAAE;IACzCiB,OAAO,CAACC,IAAI,CACV,sLAAsL,CACvL;EACH;EAEA,OAAOJ,OAAO;AAChB,CAAC;AAAC"}
|
package/lib/commonjs/hooks.js
CHANGED
|
@@ -5,12 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.useGenericKeyboardHandler = useGenericKeyboardHandler;
|
|
7
7
|
exports.useKeyboardAnimation = void 0;
|
|
8
|
+
exports.useKeyboardController = useKeyboardController;
|
|
8
9
|
exports.useKeyboardHandler = useKeyboardHandler;
|
|
10
|
+
exports.useReanimatedFocusedInput = useReanimatedFocusedInput;
|
|
9
11
|
exports.useResizeMode = exports.useReanimatedKeyboardAnimation = void 0;
|
|
10
12
|
var _react = require("react");
|
|
11
|
-
var _context = require("./context");
|
|
12
13
|
var _bindings = require("./bindings");
|
|
13
14
|
var _constants = require("./constants");
|
|
15
|
+
var _context = require("./context");
|
|
14
16
|
var _utils = require("./utils");
|
|
15
17
|
const useResizeMode = () => {
|
|
16
18
|
(0, _react.useEffect)(() => {
|
|
@@ -49,4 +51,17 @@ function useKeyboardHandler(handler, deps) {
|
|
|
49
51
|
useResizeMode();
|
|
50
52
|
useGenericKeyboardHandler(handler, deps);
|
|
51
53
|
}
|
|
54
|
+
function useKeyboardController() {
|
|
55
|
+
const context = (0, _context.useKeyboardContext)();
|
|
56
|
+
return {
|
|
57
|
+
setEnabled: context.setEnabled,
|
|
58
|
+
enabled: context.enabled
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function useReanimatedFocusedInput() {
|
|
62
|
+
const context = (0, _context.useKeyboardContext)();
|
|
63
|
+
return {
|
|
64
|
+
input: context.layout
|
|
65
|
+
};
|
|
66
|
+
}
|
|
52
67
|
//# sourceMappingURL=hooks.js.map
|
|
@@ -1 +1 @@
|
|
|
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 {
|
|
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","useKeyboardController","setEnabled","enabled","useReanimatedFocusedInput","input","layout"],"sources":["hooks.ts"],"sourcesContent":["import { useEffect } from 'react';\n\nimport { KeyboardController } from './bindings';\nimport { AndroidSoftInputModes } from './constants';\nimport { useKeyboardContext } from './context';\nimport { uuid } from './utils';\n\nimport type { AnimatedContext, ReanimatedContext } from './context';\nimport type { KeyboardHandler } from './types';\nimport type { DependencyList } from 'react';\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\nexport function useKeyboardController() {\n const context = useKeyboardContext();\n\n return { setEnabled: context.setEnabled, enabled: context.enabled };\n}\n\nexport function useReanimatedFocusedInput() {\n const context = useKeyboardContext();\n\n return { input: context.layout };\n}\n"],"mappings":";;;;;;;;;;;AAAA;AAEA;AACA;AACA;AACA;AAMO,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;AAEO,SAASM,qBAAqB,GAAG;EACtC,MAAMb,OAAO,GAAG,IAAAC,2BAAkB,GAAE;EAEpC,OAAO;IAAEa,UAAU,EAAEd,OAAO,CAACc,UAAU;IAAEC,OAAO,EAAEf,OAAO,CAACe;EAAQ,CAAC;AACrE;AAEO,SAASC,yBAAyB,GAAG;EAC1C,MAAMhB,OAAO,GAAG,IAAAC,2BAAkB,GAAE;EAEpC,OAAO;IAAEgB,KAAK,EAAEjB,OAAO,CAACkB;EAAO,CAAC;AAClC"}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -4,7 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
var _exportNames = {
|
|
7
|
-
KeyboardAvoidingView: true
|
|
7
|
+
KeyboardAvoidingView: true,
|
|
8
|
+
KeyboardStickyView: true
|
|
8
9
|
};
|
|
9
10
|
Object.defineProperty(exports, "KeyboardAvoidingView", {
|
|
10
11
|
enumerable: true,
|
|
@@ -12,7 +13,12 @@ Object.defineProperty(exports, "KeyboardAvoidingView", {
|
|
|
12
13
|
return _components.KeyboardAvoidingView;
|
|
13
14
|
}
|
|
14
15
|
});
|
|
15
|
-
|
|
16
|
+
Object.defineProperty(exports, "KeyboardStickyView", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () {
|
|
19
|
+
return _components.KeyboardStickyView;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
16
22
|
var _bindings = require("./bindings");
|
|
17
23
|
Object.keys(_bindings).forEach(function (key) {
|
|
18
24
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from './bindings';\nexport * from './animated';\nexport * from './replicas';\nexport * from './context';\nexport * from './hooks';\nexport * from './constants';\nexport * from './types';\n\nexport { KeyboardAvoidingView, KeyboardStickyView } from './components';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AAEA"}
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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<\n T extends Record<string, (event: NativeEvent) => void>\n>() {\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,S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
|
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.revertMonkeyPatch = exports.applyMonkeyPatch = void 0;
|
|
3
7
|
var NativeAndroidManager = _interopRequireWildcard(require("react-native/Libraries/Components/StatusBar/NativeStatusBarManagerAndroid"));
|
|
4
8
|
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
9
|
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
10
|
// @ts-expect-error because there is no corresponding type definition
|
|
7
11
|
|
|
12
|
+
const DefaultNativeAndroidManager = NativeAndroidManager.default;
|
|
8
13
|
const getConstants = NativeAndroidManager.default.getConstants;
|
|
14
|
+
const RCTStatusBarManagerCompat = require('./specs/NativeStatusBarManagerCompat').default;
|
|
9
15
|
|
|
10
16
|
// On Android < 11 RN uses legacy API which breaks EdgeToEdge mode in RN, so
|
|
11
17
|
// in order to use library on all available platforms we have to monkey patch
|
|
12
18
|
// default RN implementation and use modern `WindowInsetsControllerCompat`.
|
|
13
|
-
const
|
|
14
|
-
NativeAndroidManager.default = {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
19
|
+
const applyMonkeyPatch = () => {
|
|
20
|
+
NativeAndroidManager.default = {
|
|
21
|
+
getConstants,
|
|
22
|
+
setColor(color, animated) {
|
|
23
|
+
RCTStatusBarManagerCompat.setColor(color, animated);
|
|
24
|
+
},
|
|
25
|
+
setTranslucent(translucent) {
|
|
26
|
+
RCTStatusBarManagerCompat.setTranslucent(translucent);
|
|
27
|
+
},
|
|
28
|
+
/**
|
|
29
|
+
* - statusBarStyles can be:
|
|
30
|
+
* - 'default'
|
|
31
|
+
* - 'dark-content'
|
|
32
|
+
*/
|
|
33
|
+
setStyle(statusBarStyle) {
|
|
34
|
+
RCTStatusBarManagerCompat.setStyle(statusBarStyle);
|
|
35
|
+
},
|
|
36
|
+
setHidden(hidden) {
|
|
37
|
+
RCTStatusBarManagerCompat.setHidden(hidden);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
exports.applyMonkeyPatch = applyMonkeyPatch;
|
|
42
|
+
const revertMonkeyPatch = () => {
|
|
43
|
+
NativeAndroidManager.default = DefaultNativeAndroidManager;
|
|
33
44
|
};
|
|
45
|
+
exports.revertMonkeyPatch = revertMonkeyPatch;
|
|
34
46
|
//# sourceMappingURL=monkey-patch.android.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["DefaultNativeAndroidManager","NativeAndroidManager","default","getConstants","RCTStatusBarManagerCompat","require","applyMonkeyPatch","setColor","color","animated","setTranslucent","translucent","setStyle","statusBarStyle","setHidden","hidden","revertMonkeyPatch"],"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 DefaultNativeAndroidManager = NativeAndroidManager.default;\nconst getConstants = NativeAndroidManager.default.getConstants;\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`.\nexport const applyMonkeyPatch = () => {\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};\nexport const revertMonkeyPatch = () => {\n NativeAndroidManager.default = DefaultNativeAndroidManager;\n};\n"],"mappings":";;;;;;AACA;AAAkH;AAAA;AADlH;;AAGA,MAAMA,2BAA2B,GAAGC,oBAAoB,CAACC,OAAO;AAChE,MAAMC,YAAY,GAAGF,oBAAoB,CAACC,OAAO,CAACC,YAAY;AAC9D,MAAMC,yBAAyB,GAC7BC,OAAO,CAAC,sCAAsC,CAAC,CAACH,OAAO;;AAEzD;AACA;AACA;AACO,MAAMI,gBAAgB,GAAG,MAAM;EACpCL,oBAAoB,CAACC,OAAO,GAAG;IAC7BC,YAAY;IACZI,QAAQ,CAACC,KAAa,EAAEC,QAAiB,EAAQ;MAC/CL,yBAAyB,CAACG,QAAQ,CAACC,KAAK,EAAEC,QAAQ,CAAC;IACrD,CAAC;IAEDC,cAAc,CAACC,WAAoB,EAAQ;MACzCP,yBAAyB,CAACM,cAAc,CAACC,WAAW,CAAC;IACvD,CAAC;IAED;AACJ;AACA;AACA;AACA;IACIC,QAAQ,CAACC,cAAuB,EAAQ;MACtCT,yBAAyB,CAACQ,QAAQ,CAACC,cAAc,CAAC;IACpD,CAAC;IAEDC,SAAS,CAACC,MAAe,EAAQ;MAC/BX,yBAAyB,CAACU,SAAS,CAACC,MAAM,CAAC;IAC7C;EACF,CAAC;AACH,CAAC;AAAC;AACK,MAAMC,iBAAiB,GAAG,MAAM;EACrCf,oBAAoB,CAACC,OAAO,GAAGF,2BAA2B;AAC5D,CAAC;AAAC"}
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
-
// stub for all platforms
|
|
2
1
|
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.revertMonkeyPatch = exports.applyMonkeyPatch = void 0;
|
|
7
|
+
// stub for all platforms
|
|
8
|
+
const NOOP = () => {};
|
|
9
|
+
const applyMonkeyPatch = NOOP;
|
|
10
|
+
exports.applyMonkeyPatch = applyMonkeyPatch;
|
|
11
|
+
const revertMonkeyPatch = NOOP;
|
|
12
|
+
exports.revertMonkeyPatch = revertMonkeyPatch;
|
|
3
13
|
//# sourceMappingURL=monkey-patch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["monkey-patch.ts"],"sourcesContent":["// stub for all platforms\n"],"mappings":"AAAA;
|
|
1
|
+
{"version":3,"names":["NOOP","applyMonkeyPatch","revertMonkeyPatch"],"sources":["monkey-patch.ts"],"sourcesContent":["// stub for all platforms\nconst NOOP = () => {};\nexport const applyMonkeyPatch = NOOP;\nexport const revertMonkeyPatch = NOOP;\n"],"mappings":";;;;;;AAAA;AACA,MAAMA,IAAI,GAAG,MAAM,CAAC,CAAC;AACd,MAAMC,gBAAgB,GAAGD,IAAI;AAAC;AAC9B,MAAME,iBAAiB,GAAGF,IAAI;AAAC"}
|
|
@@ -3,7 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.useAnimatedKeyboardHandler = void 0;
|
|
7
|
-
const
|
|
6
|
+
exports.useFocusedInputHandler = exports.useAnimatedKeyboardHandler = void 0;
|
|
7
|
+
const NOOP = () => () => {};
|
|
8
|
+
const useAnimatedKeyboardHandler = NOOP;
|
|
8
9
|
exports.useAnimatedKeyboardHandler = useAnimatedKeyboardHandler;
|
|
10
|
+
const useFocusedInputHandler = NOOP;
|
|
11
|
+
exports.useFocusedInputHandler = useFocusedInputHandler;
|
|
9
12
|
//# sourceMappingURL=reanimated.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useAnimatedKeyboardHandler"],"sources":["reanimated.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"names":["NOOP","useAnimatedKeyboardHandler","useFocusedInputHandler"],"sources":["reanimated.ts"],"sourcesContent":["import type {\n EventWithName,\n FocusedInputHandlerHook,\n FocusedInputLayoutChangedEvent,\n KeyboardHandlerHook,\n NativeEvent,\n} from './types';\n\nconst NOOP = () => () => {};\nexport const useAnimatedKeyboardHandler: KeyboardHandlerHook<\n Record<string, unknown>,\n EventWithName<NativeEvent>\n> = NOOP;\nexport const useFocusedInputHandler: FocusedInputHandlerHook<\n Record<string, unknown>,\n EventWithName<FocusedInputLayoutChangedEvent>\n> = NOOP;\n"],"mappings":";;;;;;AAQA,MAAMA,IAAI,GAAG,MAAM,MAAM,CAAC,CAAC;AACpB,MAAMC,0BAGZ,GAAGD,IAAI;AAAC;AACF,MAAME,sBAGZ,GAAGF,IAAI;AAAC"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.useAnimatedKeyboardHandler = void 0;
|
|
6
|
+
exports.useFocusedInputHandler = exports.useAnimatedKeyboardHandler = void 0;
|
|
7
7
|
var _reactNativeReanimated = require("react-native-reanimated");
|
|
8
8
|
const useAnimatedKeyboardHandler = (handlers, dependencies) => {
|
|
9
9
|
const {
|
|
@@ -34,4 +34,21 @@ const useAnimatedKeyboardHandler = (handlers, dependencies) => {
|
|
|
34
34
|
}, ['onKeyboardMoveStart', 'onKeyboardMove', 'onKeyboardMoveEnd', 'onKeyboardMoveInteractive'], doDependenciesDiffer);
|
|
35
35
|
};
|
|
36
36
|
exports.useAnimatedKeyboardHandler = useAnimatedKeyboardHandler;
|
|
37
|
+
const useFocusedInputHandler = (handlers, dependencies) => {
|
|
38
|
+
const {
|
|
39
|
+
context,
|
|
40
|
+
doDependenciesDiffer
|
|
41
|
+
} = (0, _reactNativeReanimated.useHandler)(handlers, dependencies);
|
|
42
|
+
return (0, _reactNativeReanimated.useEvent)(event => {
|
|
43
|
+
'worklet';
|
|
44
|
+
|
|
45
|
+
const {
|
|
46
|
+
onFocusedInputLayoutChanged
|
|
47
|
+
} = handlers;
|
|
48
|
+
if (onFocusedInputLayoutChanged && event.eventName.endsWith('onFocusedInputLayoutChanged')) {
|
|
49
|
+
onFocusedInputLayoutChanged(event, context);
|
|
50
|
+
}
|
|
51
|
+
}, ['onFocusedInputLayoutChanged'], doDependenciesDiffer);
|
|
52
|
+
};
|
|
53
|
+
exports.useFocusedInputHandler = useFocusedInputHandler;
|
|
37
54
|
//# sourceMappingURL=reanimated.native.js.map
|