@react-native-ohos/react-native-keyboard-controller 1.16.6-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.OpenSource +11 -0
- package/README.md +19 -0
- package/harmony/keyboard_controller/BuildProfile.ets +17 -0
- package/harmony/keyboard_controller/Index.ets +7 -0
- package/harmony/keyboard_controller/ResourceTable.txt +1 -0
- package/harmony/keyboard_controller/build-profile.json5 +31 -0
- package/harmony/keyboard_controller/consumer-rules.txt +0 -0
- package/harmony/keyboard_controller/hvigorfile.ts +6 -0
- package/harmony/keyboard_controller/obfuscation-rules.txt +18 -0
- package/harmony/keyboard_controller/oh-package.json5 +11 -0
- package/harmony/keyboard_controller/src/main/cpp/CMakeLists.txt +7 -0
- package/harmony/keyboard_controller/src/main/cpp/EventEmitters.cpp +96 -0
- package/harmony/keyboard_controller/src/main/cpp/EventEmitters.h +90 -0
- package/harmony/keyboard_controller/src/main/cpp/KeyboardControllerViewComponentDescriptor.h +73 -0
- package/harmony/keyboard_controller/src/main/cpp/KeyboardControllerViewComponentInstance.cpp +172 -0
- package/harmony/keyboard_controller/src/main/cpp/KeyboardControllerViewComponentInstance.h +76 -0
- package/harmony/keyboard_controller/src/main/cpp/KeyboardControllerViewJSIBinder.h +44 -0
- package/harmony/keyboard_controller/src/main/cpp/KeyboardGestureAreaComponentDescriptor.h +58 -0
- package/harmony/keyboard_controller/src/main/cpp/KeyboardGestureAreaComponentInstance.cpp +87 -0
- package/harmony/keyboard_controller/src/main/cpp/KeyboardGestureAreaComponentInstance.h +62 -0
- package/harmony/keyboard_controller/src/main/cpp/KeyboardGestureAreaJSIBinder.h +39 -0
- package/harmony/keyboard_controller/src/main/cpp/RNKeyboardController.cpp +25 -0
- package/harmony/keyboard_controller/src/main/cpp/RNKeyboardController.h +27 -0
- package/harmony/keyboard_controller/src/main/cpp/RNStatusBarManagerCompat.cpp +24 -0
- package/harmony/keyboard_controller/src/main/cpp/RNStatusBarManagerCompat.h +28 -0
- package/harmony/keyboard_controller/src/main/cpp/keyboardControllerPackage.cpp +43 -0
- package/harmony/keyboard_controller/src/main/cpp/keyboardControllerPackage.h +56 -0
- package/harmony/keyboard_controller/src/main/ets/Logger.ts +46 -0
- package/harmony/keyboard_controller/src/main/ets/RNKeyboardControllerPackage.ts +45 -0
- package/harmony/keyboard_controller/src/main/ets/RNKeyboardControllerTurboModule.ts +238 -0
- package/harmony/keyboard_controller/src/main/ets/RNStatusBarManagerCompatTurboModule.ts +98 -0
- package/harmony/keyboard_controller/src/main/ets/Type.ts +41 -0
- package/harmony/keyboard_controller/src/main/module.json5 +11 -0
- package/harmony/keyboard_controller/src/main/resources/base/element/string.json +8 -0
- package/harmony/keyboard_controller/src/main/resources/en_US/element/string.json +8 -0
- package/harmony/keyboard_controller/src/main/resources/zh_CN/element/string.json +8 -0
- package/harmony/keyboard_controller/ts.ts +9 -0
- package/harmony/keyboard_controller.har +0 -0
- package/lib/commonjs/animated.js +176 -0
- package/lib/commonjs/animated.js.map +1 -0
- package/lib/commonjs/bindings.js +39 -0
- package/lib/commonjs/bindings.js.map +1 -0
- package/lib/commonjs/bindings.native.js +39 -0
- package/lib/commonjs/bindings.native.js.map +1 -0
- package/lib/commonjs/components/KeyboardAvoidingView/hooks.js +126 -0
- package/lib/commonjs/components/KeyboardAvoidingView/hooks.js.map +1 -0
- package/lib/commonjs/components/KeyboardAvoidingView/index.js +120 -0
- package/lib/commonjs/components/KeyboardAvoidingView/index.js.map +1 -0
- package/lib/commonjs/components/KeyboardAwareScrollView/index.js +262 -0
- package/lib/commonjs/components/KeyboardAwareScrollView/index.js.map +1 -0
- package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +110 -0
- package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -0
- package/lib/commonjs/components/KeyboardAwareScrollView/utils.js +37 -0
- package/lib/commonjs/components/KeyboardAwareScrollView/utils.js.map +1 -0
- package/lib/commonjs/components/KeyboardStickyView/index.js +41 -0
- package/lib/commonjs/components/KeyboardStickyView/index.js.map +1 -0
- package/lib/commonjs/components/KeyboardToolbar/Arrow.js +76 -0
- package/lib/commonjs/components/KeyboardToolbar/Arrow.js.map +1 -0
- package/lib/commonjs/components/KeyboardToolbar/Button.js +70 -0
- package/lib/commonjs/components/KeyboardToolbar/Button.js.map +1 -0
- package/lib/commonjs/components/KeyboardToolbar/colors.js +21 -0
- package/lib/commonjs/components/KeyboardToolbar/colors.js.map +1 -0
- package/lib/commonjs/components/KeyboardToolbar/colors.native.js +40 -0
- package/lib/commonjs/components/KeyboardToolbar/colors.native.js.map +1 -0
- package/lib/commonjs/components/KeyboardToolbar/index.js +161 -0
- package/lib/commonjs/components/KeyboardToolbar/index.js.map +1 -0
- package/lib/commonjs/components/KeyboardToolbar/types.js +6 -0
- package/lib/commonjs/components/KeyboardToolbar/types.js.map +1 -0
- package/lib/commonjs/components/hooks/useColorScheme.js +10 -0
- package/lib/commonjs/components/hooks/useColorScheme.js.map +1 -0
- package/lib/commonjs/components/index.js +42 -0
- package/lib/commonjs/components/index.js.map +1 -0
- package/lib/commonjs/constants.js +27 -0
- package/lib/commonjs/constants.js.map +1 -0
- package/lib/commonjs/context.js +45 -0
- package/lib/commonjs/context.js.map +1 -0
- package/lib/commonjs/hooks/index.js +104 -0
- package/lib/commonjs/hooks/index.js.map +1 -0
- package/lib/commonjs/hooks/useWindowDimensions/index.android.js +34 -0
- package/lib/commonjs/hooks/useWindowDimensions/index.android.js.map +1 -0
- package/lib/commonjs/hooks/useWindowDimensions/index.js +13 -0
- package/lib/commonjs/hooks/useWindowDimensions/index.js.map +1 -0
- package/lib/commonjs/index.js +136 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/internal.js +73 -0
- package/lib/commonjs/internal.js.map +1 -0
- package/lib/commonjs/module.js +47 -0
- package/lib/commonjs/module.js.map +1 -0
- package/lib/commonjs/monkey-patch.android.js +57 -0
- package/lib/commonjs/monkey-patch.android.js.map +1 -0
- package/lib/commonjs/monkey-patch.js +11 -0
- package/lib/commonjs/monkey-patch.js.map +1 -0
- package/lib/commonjs/reanimated.js +12 -0
- package/lib/commonjs/reanimated.js.map +1 -0
- package/lib/commonjs/reanimated.native.js +88 -0
- package/lib/commonjs/reanimated.native.js.map +1 -0
- package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js +10 -0
- package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js.map +1 -0
- package/lib/commonjs/specs/KeyboardGestureAreaNativeComponent.js +12 -0
- package/lib/commonjs/specs/KeyboardGestureAreaNativeComponent.js.map +1 -0
- package/lib/commonjs/specs/NativeKeyboardController.js +9 -0
- package/lib/commonjs/specs/NativeKeyboardController.js.map +1 -0
- package/lib/commonjs/specs/NativeStatusBarManagerCompat.js +9 -0
- package/lib/commonjs/specs/NativeStatusBarManagerCompat.js.map +1 -0
- package/lib/commonjs/specs/OverKeyboardViewNativeComponent.js +10 -0
- package/lib/commonjs/specs/OverKeyboardViewNativeComponent.js.map +1 -0
- package/lib/commonjs/types.js +6 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/commonjs/utils.js +9 -0
- package/lib/commonjs/utils.js.map +1 -0
- package/lib/commonjs/views/OverKeyboardView/index.js +42 -0
- package/lib/commonjs/views/OverKeyboardView/index.js.map +1 -0
- package/lib/commonjs/views/index.js +14 -0
- package/lib/commonjs/views/index.js.map +1 -0
- package/lib/module/animated.js +168 -0
- package/lib/module/animated.js.map +1 -0
- package/lib/module/bindings.js +33 -0
- package/lib/module/bindings.js.map +1 -0
- package/lib/module/bindings.native.js +33 -0
- package/lib/module/bindings.native.js.map +1 -0
- package/lib/module/components/KeyboardAvoidingView/hooks.js +118 -0
- package/lib/module/components/KeyboardAvoidingView/hooks.js.map +1 -0
- package/lib/module/components/KeyboardAvoidingView/index.js +113 -0
- package/lib/module/components/KeyboardAvoidingView/index.js.map +1 -0
- package/lib/module/components/KeyboardAwareScrollView/index.js +255 -0
- package/lib/module/components/KeyboardAwareScrollView/index.js.map +1 -0
- package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +103 -0
- package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -0
- package/lib/module/components/KeyboardAwareScrollView/utils.js +29 -0
- package/lib/module/components/KeyboardAwareScrollView/utils.js.map +1 -0
- package/lib/module/components/KeyboardStickyView/index.js +34 -0
- package/lib/module/components/KeyboardStickyView/index.js.map +1 -0
- package/lib/module/components/KeyboardToolbar/Arrow.js +68 -0
- package/lib/module/components/KeyboardToolbar/Arrow.js.map +1 -0
- package/lib/module/components/KeyboardToolbar/Button.js +62 -0
- package/lib/module/components/KeyboardToolbar/Button.js.map +1 -0
- package/lib/module/components/KeyboardToolbar/colors.js +15 -0
- package/lib/module/components/KeyboardToolbar/colors.js.map +1 -0
- package/lib/module/components/KeyboardToolbar/colors.native.js +34 -0
- package/lib/module/components/KeyboardToolbar/colors.native.js.map +1 -0
- package/lib/module/components/KeyboardToolbar/index.js +149 -0
- package/lib/module/components/KeyboardToolbar/index.js.map +1 -0
- package/lib/module/components/KeyboardToolbar/types.js +2 -0
- package/lib/module/components/KeyboardToolbar/types.js.map +1 -0
- package/lib/module/components/hooks/useColorScheme.js +4 -0
- package/lib/module/components/hooks/useColorScheme.js.map +1 -0
- package/lib/module/components/index.js +5 -0
- package/lib/module/components/index.js.map +1 -0
- package/lib/module/constants.js +21 -0
- package/lib/module/constants.js.map +1 -0
- package/lib/module/context.js +38 -0
- package/lib/module/context.js.map +1 -0
- package/lib/module/hooks/index.js +68 -0
- package/lib/module/hooks/index.js.map +1 -0
- package/lib/module/hooks/useWindowDimensions/index.android.js +27 -0
- package/lib/module/hooks/useWindowDimensions/index.android.js.map +1 -0
- package/lib/module/hooks/useWindowDimensions/index.js +2 -0
- package/lib/module/hooks/useWindowDimensions/index.js.map +1 -0
- package/lib/module/index.js +12 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/internal.js +66 -0
- package/lib/module/internal.js.map +1 -0
- package/lib/module/module.js +41 -0
- package/lib/module/module.js.map +1 -0
- package/lib/module/monkey-patch.android.js +47 -0
- package/lib/module/monkey-patch.android.js.map +1 -0
- package/lib/module/monkey-patch.js +5 -0
- package/lib/module/monkey-patch.js.map +1 -0
- package/lib/module/reanimated.js +6 -0
- package/lib/module/reanimated.js.map +1 -0
- package/lib/module/reanimated.native.js +78 -0
- package/lib/module/reanimated.native.js.map +1 -0
- package/lib/module/specs/KeyboardControllerViewNativeComponent.js +3 -0
- package/lib/module/specs/KeyboardControllerViewNativeComponent.js.map +1 -0
- package/lib/module/specs/KeyboardGestureAreaNativeComponent.js +5 -0
- package/lib/module/specs/KeyboardGestureAreaNativeComponent.js.map +1 -0
- package/lib/module/specs/NativeKeyboardController.js +3 -0
- package/lib/module/specs/NativeKeyboardController.js.map +1 -0
- package/lib/module/specs/NativeStatusBarManagerCompat.js +3 -0
- package/lib/module/specs/NativeStatusBarManagerCompat.js.map +1 -0
- package/lib/module/specs/OverKeyboardViewNativeComponent.js +3 -0
- package/lib/module/specs/OverKeyboardViewNativeComponent.js.map +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/utils.js +2 -0
- package/lib/module/utils.js.map +1 -0
- package/lib/module/views/OverKeyboardView/index.js +35 -0
- package/lib/module/views/OverKeyboardView/index.js.map +1 -0
- package/lib/module/views/index.js +2 -0
- package/lib/module/views/index.js.map +1 -0
- package/lib/typescript/animated.d.ts +39 -0
- package/lib/typescript/bindings.d.ts +12 -0
- package/lib/typescript/bindings.native.d.ts +12 -0
- package/lib/typescript/components/KeyboardAvoidingView/hooks.d.ts +10 -0
- package/lib/typescript/components/KeyboardAvoidingView/index.d.ts +40 -0
- package/lib/typescript/components/KeyboardAwareScrollView/index.d.ts +29 -0
- package/lib/typescript/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.d.ts +6 -0
- package/lib/typescript/components/KeyboardAwareScrollView/utils.d.ts +2 -0
- package/lib/typescript/components/KeyboardStickyView/index.d.ts +39 -0
- package/lib/typescript/components/KeyboardToolbar/Arrow.d.ts +9 -0
- package/lib/typescript/components/KeyboardToolbar/Button.d.ts +16 -0
- package/lib/typescript/components/KeyboardToolbar/colors.d.ts +2 -0
- package/lib/typescript/components/KeyboardToolbar/colors.native.d.ts +2 -0
- package/lib/typescript/components/KeyboardToolbar/index.d.ts +52 -0
- package/lib/typescript/components/KeyboardToolbar/types.d.ts +18 -0
- package/lib/typescript/components/hooks/useColorScheme.d.ts +2 -0
- package/lib/typescript/components/index.d.ts +8 -0
- package/lib/typescript/constants.d.ts +16 -0
- package/lib/typescript/context.d.ts +23 -0
- package/lib/typescript/hooks/index.d.ts +17 -0
- package/lib/typescript/hooks/useWindowDimensions/index.android.d.ts +2 -0
- package/lib/typescript/hooks/useWindowDimensions/index.d.ts +1 -0
- package/lib/typescript/index.d.ts +10 -0
- package/lib/typescript/internal.d.ts +30 -0
- package/lib/typescript/module.d.ts +2 -0
- package/lib/typescript/monkey-patch.android.d.ts +2 -0
- package/lib/typescript/monkey-patch.d.ts +2 -0
- package/lib/typescript/reanimated.d.ts +5 -0
- package/lib/typescript/reanimated.native.d.ts +7 -0
- package/lib/typescript/specs/KeyboardControllerViewNativeComponent.d.ts +54 -0
- package/lib/typescript/specs/KeyboardGestureAreaNativeComponent.d.ts +12 -0
- package/lib/typescript/specs/NativeKeyboardController.d.ts +12 -0
- package/lib/typescript/specs/NativeStatusBarManagerCompat.d.ts +10 -0
- package/lib/typescript/specs/OverKeyboardViewNativeComponent.d.ts +7 -0
- package/lib/typescript/types.d.ts +161 -0
- package/lib/typescript/utils.d.ts +1 -0
- package/lib/typescript/views/OverKeyboardView/index.d.ts +5 -0
- package/lib/typescript/views/index.d.ts +1 -0
- package/package.json +173 -0
- package/react-native-keyboard-controller.podspec +61 -0
- package/src/animated.tsx +256 -0
- package/src/bindings.native.ts +62 -0
- package/src/bindings.ts +42 -0
- package/src/components/KeyboardAvoidingView/hooks.ts +123 -0
- package/src/components/KeyboardAvoidingView/index.tsx +188 -0
- package/src/components/KeyboardAwareScrollView/index.tsx +389 -0
- package/src/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.ts +133 -0
- package/src/components/KeyboardAwareScrollView/utils.ts +41 -0
- package/src/components/KeyboardStickyView/index.tsx +66 -0
- package/src/components/KeyboardToolbar/Arrow.tsx +80 -0
- package/src/components/KeyboardToolbar/Button.tsx +98 -0
- package/src/components/KeyboardToolbar/colors.native.ts +37 -0
- package/src/components/KeyboardToolbar/colors.ts +16 -0
- package/src/components/KeyboardToolbar/index.tsx +223 -0
- package/src/components/KeyboardToolbar/types.ts +40 -0
- package/src/components/hooks/useColorScheme.ts +5 -0
- package/src/components/index.ts +11 -0
- package/src/constants.ts +19 -0
- package/src/context.ts +68 -0
- package/src/hooks/index.ts +90 -0
- package/src/hooks/useWindowDimensions/index.android.ts +38 -0
- package/src/hooks/useWindowDimensions/index.ts +1 -0
- package/src/index.ts +23 -0
- package/src/internal.ts +84 -0
- package/src/module.ts +52 -0
- package/src/monkey-patch.android.ts +44 -0
- package/src/monkey-patch.ts +4 -0
- package/src/reanimated.native.ts +132 -0
- package/src/reanimated.ts +29 -0
- package/src/specs/KeyboardControllerViewNativeComponent.ts +71 -0
- package/src/specs/KeyboardGestureAreaNativeComponent.ts +20 -0
- package/src/specs/NativeKeyboardController.ts +19 -0
- package/src/specs/NativeStatusBarManagerCompat.ts +14 -0
- package/src/specs/OverKeyboardViewNativeComponent.ts +12 -0
- package/src/types.ts +243 -0
- package/src/utils.ts +1 -0
- package/src/views/OverKeyboardView/index.tsx +43 -0
- package/src/views/index.ts +1 -0
|
@@ -0,0 +1,42 @@
|
|
|
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 _reactNative = require("react-native");
|
|
9
|
+
var _bindings = require("../../bindings");
|
|
10
|
+
var _hooks = require("../../hooks");
|
|
11
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
12
|
+
const OverKeyboardView = ({
|
|
13
|
+
children,
|
|
14
|
+
visible
|
|
15
|
+
}) => {
|
|
16
|
+
const {
|
|
17
|
+
height,
|
|
18
|
+
width
|
|
19
|
+
} = (0, _hooks.useWindowDimensions)();
|
|
20
|
+
const inner = (0, _react.useMemo)(() => ({
|
|
21
|
+
height,
|
|
22
|
+
width
|
|
23
|
+
}), [height, width]);
|
|
24
|
+
const style = (0, _react.useMemo)(() => [styles.absolute,
|
|
25
|
+
// On iOS - stretch view to full window dimensions to make yoga work
|
|
26
|
+
// On Android Fabric we temporarily use the same approach
|
|
27
|
+
// @ts-expect-error `_IS_FABRIC` is injected by REA
|
|
28
|
+
_reactNative.Platform.OS === "ios" || global._IS_FABRIC ? inner : undefined], [inner]);
|
|
29
|
+
return /*#__PURE__*/_react.default.createElement(_bindings.RCTOverKeyboardView, {
|
|
30
|
+
visible: visible
|
|
31
|
+
}, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
32
|
+
collapsable: false,
|
|
33
|
+
style: style
|
|
34
|
+
}, children));
|
|
35
|
+
};
|
|
36
|
+
const styles = _reactNative.StyleSheet.create({
|
|
37
|
+
absolute: {
|
|
38
|
+
position: "absolute"
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
var _default = exports.default = OverKeyboardView;
|
|
42
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_bindings","_hooks","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","OverKeyboardView","children","visible","height","width","useWindowDimensions","inner","useMemo","style","styles","absolute","Platform","OS","global","_IS_FABRIC","undefined","createElement","RCTOverKeyboardView","View","collapsable","StyleSheet","create","position","_default","exports"],"sources":["index.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport { Platform, StyleSheet, View } from \"react-native\";\n\nimport { RCTOverKeyboardView } from \"../../bindings\";\nimport { useWindowDimensions } from \"../../hooks\";\n\nimport type { OverKeyboardViewProps } from \"../../types\";\nimport type { PropsWithChildren } from \"react\";\n\nconst OverKeyboardView = ({\n children,\n visible,\n}: PropsWithChildren<OverKeyboardViewProps>) => {\n const { height, width } = useWindowDimensions();\n const inner = useMemo(() => ({ height, width }), [height, width]);\n const style = useMemo(\n () => [\n styles.absolute,\n // On iOS - stretch view to full window dimensions to make yoga work\n // On Android Fabric we temporarily use the same approach\n // @ts-expect-error `_IS_FABRIC` is injected by REA\n Platform.OS === \"ios\" || global._IS_FABRIC ? inner : undefined,\n ],\n [inner],\n );\n\n return (\n <RCTOverKeyboardView visible={visible}>\n {/* `OverKeyboardView` should always have a single child */}\n <View collapsable={false} style={style}>\n {children}\n </View>\n </RCTOverKeyboardView>\n );\n};\n\nconst styles = StyleSheet.create({\n absolute: {\n position: \"absolute\",\n },\n});\n\nexport default OverKeyboardView;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAAkD,SAAAD,wBAAAK,CAAA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GAAG,IAAAD,cAAO,EACnB,MAAM,CACJE,MAAM,CAACC,QAAQ;EACf;EACA;EACA;EACAC,qBAAQ,CAACC,EAAE,KAAK,KAAK,IAAIC,MAAM,CAACC,UAAU,GAAGR,KAAK,GAAGS,SAAS,CAC/D,EACD,CAACT,KAAK,CACR,CAAC;EAED,oBACE/B,MAAA,CAAAgB,OAAA,CAAAyB,aAAA,CAACrC,SAAA,CAAAsC,mBAAmB;IAACf,OAAO,EAAEA;EAAQ,gBAEpC3B,MAAA,CAAAgB,OAAA,CAAAyB,aAAA,CAACtC,YAAA,CAAAwC,IAAI;IAACC,WAAW,EAAE,KAAM;IAACX,KAAK,EAAEA;EAAM,GACpCP,QACG,CACa,CAAC;AAE1B,CAAC;AAED,MAAMQ,MAAM,GAAGW,uBAAU,CAACC,MAAM,CAAC;EAC/BX,QAAQ,EAAE;IACRY,QAAQ,EAAE;EACZ;AACF,CAAC,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAjC,OAAA,GAEYS,gBAAgB","ignoreList":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "OverKeyboardView", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _OverKeyboardView.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _OverKeyboardView = _interopRequireDefault(require("./OverKeyboardView"));
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_OverKeyboardView","_interopRequireDefault","require","e","__esModule","default"],"sources":["index.ts"],"sourcesContent":["export { default as OverKeyboardView } from \"./OverKeyboardView\";\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAiE,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA","ignoreList":[]}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import React, { useEffect, useMemo, useState } from "react";
|
|
2
|
+
import { Animated, Platform, StyleSheet } from "react-native";
|
|
3
|
+
import Reanimated, { useSharedValue } from "react-native-reanimated";
|
|
4
|
+
import { KeyboardControllerView } from "./bindings";
|
|
5
|
+
import { KeyboardContext } from "./context";
|
|
6
|
+
import { useAnimatedValue, useSharedHandlers } from "./internal";
|
|
7
|
+
import { applyMonkeyPatch, revertMonkeyPatch } from "./monkey-patch";
|
|
8
|
+
import { useAnimatedKeyboardHandler, useFocusedInputLayoutHandler, useFocusedInputSelectionHandler, useFocusedInputTextHandler } from "./reanimated";
|
|
9
|
+
const KeyboardControllerViewAnimated = Reanimated.createAnimatedComponent(Animated.createAnimatedComponent(KeyboardControllerView));
|
|
10
|
+
const styles = StyleSheet.create({
|
|
11
|
+
container: {
|
|
12
|
+
flex: 1
|
|
13
|
+
},
|
|
14
|
+
hidden: {
|
|
15
|
+
display: "none",
|
|
16
|
+
position: "absolute"
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
// capture `Platform.OS` in separate variable to avoid deep workletization of entire RN package
|
|
20
|
+
// see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/393 and https://github.com/kirillzyusko/react-native-keyboard-controller/issues/294 for more details
|
|
21
|
+
const OS = Platform.OS;
|
|
22
|
+
export const KeyboardProvider = ({
|
|
23
|
+
children,
|
|
24
|
+
statusBarTranslucent,
|
|
25
|
+
navigationBarTranslucent,
|
|
26
|
+
preserveEdgeToEdge = true,
|
|
27
|
+
enabled: initiallyEnabled = true
|
|
28
|
+
}) => {
|
|
29
|
+
// state
|
|
30
|
+
const [enabled, setEnabled] = useState(initiallyEnabled);
|
|
31
|
+
// animated values
|
|
32
|
+
const progress = useAnimatedValue(0);
|
|
33
|
+
const height = useAnimatedValue(0);
|
|
34
|
+
// shared values
|
|
35
|
+
const progressSV = useSharedValue(0);
|
|
36
|
+
const heightSV = useSharedValue(0);
|
|
37
|
+
const layout = useSharedValue(null);
|
|
38
|
+
const [setKeyboardHandlers, broadcastKeyboardEvents] = useSharedHandlers();
|
|
39
|
+
const [setInputHandlers, broadcastInputEvents] = useSharedHandlers();
|
|
40
|
+
// memo
|
|
41
|
+
const context = useMemo(() => ({
|
|
42
|
+
enabled,
|
|
43
|
+
animated: {
|
|
44
|
+
progress: progress,
|
|
45
|
+
height: Animated.multiply(height, -1)
|
|
46
|
+
},
|
|
47
|
+
reanimated: {
|
|
48
|
+
progress: progressSV,
|
|
49
|
+
height: heightSV
|
|
50
|
+
},
|
|
51
|
+
layout,
|
|
52
|
+
setKeyboardHandlers,
|
|
53
|
+
setInputHandlers,
|
|
54
|
+
setEnabled
|
|
55
|
+
}), [enabled]);
|
|
56
|
+
const style = useMemo(() => [styles.hidden, {
|
|
57
|
+
transform: [{
|
|
58
|
+
translateX: height
|
|
59
|
+
}, {
|
|
60
|
+
translateY: progress
|
|
61
|
+
}]
|
|
62
|
+
}], []);
|
|
63
|
+
const onKeyboardMove = useMemo(() => Animated.event([{
|
|
64
|
+
nativeEvent: {
|
|
65
|
+
progress,
|
|
66
|
+
height
|
|
67
|
+
}
|
|
68
|
+
}], {
|
|
69
|
+
useNativeDriver: Platform.OS == 'harmony' ? false : true
|
|
70
|
+
}), []);
|
|
71
|
+
// handlers
|
|
72
|
+
const updateSharedValues = (event, platforms) => {
|
|
73
|
+
"worklet";
|
|
74
|
+
|
|
75
|
+
if (platforms.includes(OS)) {
|
|
76
|
+
// eslint-disable-next-line react-compiler/react-compiler
|
|
77
|
+
progressSV.value = event.progress;
|
|
78
|
+
heightSV.value = -event.height;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
const keyboardHandler = useAnimatedKeyboardHandler({
|
|
82
|
+
onKeyboardMoveStart: event => {
|
|
83
|
+
"worklet";
|
|
84
|
+
|
|
85
|
+
broadcastKeyboardEvents("onStart", event);
|
|
86
|
+
updateSharedValues(event, ["ios"]);
|
|
87
|
+
},
|
|
88
|
+
onKeyboardMove: event => {
|
|
89
|
+
"worklet";
|
|
90
|
+
|
|
91
|
+
broadcastKeyboardEvents("onMove", event);
|
|
92
|
+
updateSharedValues(event, ["android"]);
|
|
93
|
+
},
|
|
94
|
+
onKeyboardMoveEnd: event => {
|
|
95
|
+
"worklet";
|
|
96
|
+
|
|
97
|
+
broadcastKeyboardEvents("onEnd", event);
|
|
98
|
+
updateSharedValues(event, ['harmony']);
|
|
99
|
+
},
|
|
100
|
+
onKeyboardMoveInteractive: event => {
|
|
101
|
+
"worklet";
|
|
102
|
+
|
|
103
|
+
updateSharedValues(event, ["android", "ios"]);
|
|
104
|
+
broadcastKeyboardEvents("onInteractive", event);
|
|
105
|
+
}
|
|
106
|
+
}, []);
|
|
107
|
+
const inputLayoutHandler = useFocusedInputLayoutHandler({
|
|
108
|
+
onFocusedInputLayoutChanged: e => {
|
|
109
|
+
"worklet";
|
|
110
|
+
|
|
111
|
+
if (e.target !== -1) {
|
|
112
|
+
layout.value = e;
|
|
113
|
+
} else {
|
|
114
|
+
layout.value = null;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}, []);
|
|
118
|
+
const inputTextHandler = useFocusedInputTextHandler({
|
|
119
|
+
onFocusedInputTextChanged: e => {
|
|
120
|
+
"worklet";
|
|
121
|
+
|
|
122
|
+
broadcastInputEvents("onChangeText", e);
|
|
123
|
+
}
|
|
124
|
+
}, []);
|
|
125
|
+
const inputSelectionHandler = useFocusedInputSelectionHandler({
|
|
126
|
+
onFocusedInputSelectionChanged: e => {
|
|
127
|
+
"worklet";
|
|
128
|
+
|
|
129
|
+
broadcastInputEvents("onSelectionChange", e);
|
|
130
|
+
}
|
|
131
|
+
}, []);
|
|
132
|
+
// effects
|
|
133
|
+
useEffect(() => {
|
|
134
|
+
if (enabled) {
|
|
135
|
+
applyMonkeyPatch();
|
|
136
|
+
} else {
|
|
137
|
+
revertMonkeyPatch();
|
|
138
|
+
}
|
|
139
|
+
}, [enabled]);
|
|
140
|
+
return /*#__PURE__*/React.createElement(KeyboardContext.Provider, {
|
|
141
|
+
value: context
|
|
142
|
+
}, /*#__PURE__*/React.createElement(KeyboardControllerViewAnimated, {
|
|
143
|
+
enabled: enabled,
|
|
144
|
+
onKeyboardMoveReanimated: keyboardHandler,
|
|
145
|
+
onKeyboardMoveStart: OS === "ios" ? onKeyboardMove : undefined,
|
|
146
|
+
onKeyboardMove: OS === "android" ? onKeyboardMove : undefined,
|
|
147
|
+
onKeyboardMoveInteractive: onKeyboardMove,
|
|
148
|
+
onKeyboardMoveEnd: OS === "harmony" ? onKeyboardMove : undefined,
|
|
149
|
+
onFocusedInputLayoutChangedReanimated: inputLayoutHandler,
|
|
150
|
+
onFocusedInputTextChangedReanimated: inputTextHandler,
|
|
151
|
+
onFocusedInputSelectionChangedReanimated: inputSelectionHandler,
|
|
152
|
+
navigationBarTranslucent: navigationBarTranslucent,
|
|
153
|
+
statusBarTranslucent: statusBarTranslucent,
|
|
154
|
+
preserveEdgeToEdge: preserveEdgeToEdge,
|
|
155
|
+
style: styles.container
|
|
156
|
+
}, /*#__PURE__*/React.createElement(Reanimated.View, null, children)), /*#__PURE__*/React.createElement(Animated.View, {
|
|
157
|
+
// we are using this small hack, because if the component (where
|
|
158
|
+
// animated value has been used) is unmounted, then animation will
|
|
159
|
+
// stop receiving events (seems like it's react-native optimization).
|
|
160
|
+
// So we need to keep a reference to the animated value, to keep it's
|
|
161
|
+
// always mounted (keep a reference to an animated value).
|
|
162
|
+
//
|
|
163
|
+
// To test why it's needed, try to open screen which consumes Animated.Value
|
|
164
|
+
// then close it and open it again (for example 'Animated transition').
|
|
165
|
+
style: style
|
|
166
|
+
}));
|
|
167
|
+
};
|
|
168
|
+
//# sourceMappingURL=animated.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useEffect","useMemo","useState","Animated","Platform","StyleSheet","Reanimated","useSharedValue","KeyboardControllerView","KeyboardContext","useAnimatedValue","useSharedHandlers","applyMonkeyPatch","revertMonkeyPatch","useAnimatedKeyboardHandler","useFocusedInputLayoutHandler","useFocusedInputSelectionHandler","useFocusedInputTextHandler","KeyboardControllerViewAnimated","createAnimatedComponent","styles","create","container","flex","hidden","display","position","OS","KeyboardProvider","children","statusBarTranslucent","navigationBarTranslucent","preserveEdgeToEdge","enabled","initiallyEnabled","setEnabled","progress","height","progressSV","heightSV","layout","setKeyboardHandlers","broadcastKeyboardEvents","setInputHandlers","broadcastInputEvents","context","animated","multiply","reanimated","style","transform","translateX","translateY","onKeyboardMove","event","nativeEvent","useNativeDriver","updateSharedValues","platforms","includes","value","keyboardHandler","onKeyboardMoveStart","onKeyboardMoveEnd","onKeyboardMoveInteractive","inputLayoutHandler","onFocusedInputLayoutChanged","e","target","inputTextHandler","onFocusedInputTextChanged","inputSelectionHandler","onFocusedInputSelectionChanged","createElement","Provider","onKeyboardMoveReanimated","undefined","onFocusedInputLayoutChangedReanimated","onFocusedInputTextChangedReanimated","onFocusedInputSelectionChangedReanimated","View"],"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 useFocusedInputLayoutHandler,\n useFocusedInputSelectionHandler,\n useFocusedInputTextHandler,\n} from \"./reanimated\";\n\nimport type { KeyboardAnimationContext } from \"./context\";\nimport type {\n FocusedInputHandler,\n FocusedInputLayoutChangedEvent,\n KeyboardControllerProps,\n KeyboardHandler,\n NativeEvent,\n} from \"./types\";\nimport type { ViewStyle } from \"react-native\";\n\nconst 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 property indicating whether to keep edge-to-edge mode always enabled (even when you disable the module).\n * Defaults to `false`.\n *\n * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/592\n * @platform android\n */\n preserveEdgeToEdge?: 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\n// capture `Platform.OS` in separate variable to avoid deep workletization of entire RN package\n// see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/393 and https://github.com/kirillzyusko/react-native-keyboard-controller/issues/294 for more details\nconst OS = Platform.OS;\n\nexport const KeyboardProvider = ({\n children,\n statusBarTranslucent,\n navigationBarTranslucent,\n preserveEdgeToEdge = true,\n enabled: initiallyEnabled = true,\n}: KeyboardProviderProps) => {\n // state\n const [enabled, setEnabled] = useState(initiallyEnabled);\n // animated values\n const progress = useAnimatedValue(0);\n const height = useAnimatedValue(0);\n // shared values\n const progressSV = useSharedValue(0);\n const heightSV = useSharedValue(0);\n const layout = useSharedValue<FocusedInputLayoutChangedEvent | null>(null);\n const [setKeyboardHandlers, broadcastKeyboardEvents] =\n useSharedHandlers<KeyboardHandler>();\n const [setInputHandlers, broadcastInputEvents] =\n useSharedHandlers<FocusedInputHandler>();\n // memo\n const context = useMemo<KeyboardAnimationContext>(\n () => ({\n enabled,\n animated: { progress: progress, height: Animated.multiply(height,-1) },\n reanimated: { progress: progressSV, height: heightSV },\n layout,\n setKeyboardHandlers,\n setInputHandlers,\n setEnabled,\n }),\n [enabled],\n );\n const style = useMemo(\n () => [\n styles.hidden,\n { transform: [{ translateX: height }, { translateY: progress }] },\n ],\n [],\n );\n const onKeyboardMove = useMemo(\n () =>\n Animated.event(\n [\n {\n nativeEvent: {\n progress,\n height,\n },\n },\n ],\n { useNativeDriver:Platform.OS as string=='harmony'?false:true },\n ),\n [],\n );\n // handlers\n const updateSharedValues = (event: NativeEvent, platforms: string[]) => {\n \"worklet\";\n\n if (platforms.includes(OS)) {\n // eslint-disable-next-line react-compiler/react-compiler\n progressSV.value = event.progress;\n heightSV.value = -event.height;\n }\n };\n const keyboardHandler = useAnimatedKeyboardHandler(\n {\n onKeyboardMoveStart: (event: NativeEvent) => {\n \"worklet\";\n\n broadcastKeyboardEvents(\"onStart\", event);\n updateSharedValues(event, [\"ios\"]);\n },\n onKeyboardMove: (event: NativeEvent) => {\n \"worklet\";\n\n broadcastKeyboardEvents(\"onMove\", event);\n updateSharedValues(event, [\"android\"]);\n },\n onKeyboardMoveEnd: (event: NativeEvent) => {\n \"worklet\";\n broadcastKeyboardEvents(\"onEnd\", event);\n updateSharedValues(event, ['harmony']);\n },\n onKeyboardMoveInteractive: (event: NativeEvent) => {\n \"worklet\";\n\n updateSharedValues(event, [\"android\", \"ios\"]);\n broadcastKeyboardEvents(\"onInteractive\", event);\n },\n },\n [],\n );\n const inputLayoutHandler = useFocusedInputLayoutHandler(\n {\n onFocusedInputLayoutChanged: (e) => {\n \"worklet\";\n\n if (e.target !== -1) {\n layout.value = e;\n } else {\n layout.value = null;\n }\n },\n },\n [],\n );\n const inputTextHandler = useFocusedInputTextHandler(\n {\n onFocusedInputTextChanged: (e) => {\n \"worklet\";\n\n broadcastInputEvents(\"onChangeText\", e);\n },\n },\n [],\n );\n const inputSelectionHandler = useFocusedInputSelectionHandler(\n {\n onFocusedInputSelectionChanged: (e) => {\n \"worklet\";\n broadcastInputEvents(\"onSelectionChange\", e);\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={OS === \"ios\" ? onKeyboardMove : undefined}\n onKeyboardMove={OS === \"android\" ? onKeyboardMove : undefined}\n onKeyboardMoveInteractive={onKeyboardMove}\n onKeyboardMoveEnd={ OS as string === \"harmony\"?onKeyboardMove:undefined}\n onFocusedInputLayoutChangedReanimated={inputLayoutHandler}\n onFocusedInputTextChangedReanimated={inputTextHandler}\n onFocusedInputSelectionChangedReanimated={inputSelectionHandler}\n navigationBarTranslucent={navigationBarTranslucent}\n statusBarTranslucent={statusBarTranslucent}\n preserveEdgeToEdge={preserveEdgeToEdge}\n style={styles.container}\n >\n <Reanimated.View>{children}</Reanimated.View>\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"],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Q,CAAC6E,IAAI;IACZ;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA/B,KAAK,EAAEA;EAAM,CACd,CACuB,CAAC;AAE/B,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { View } from "react-native";
|
|
2
|
+
const NOOP = () => {};
|
|
3
|
+
export const KeyboardControllerNative = {
|
|
4
|
+
setDefaultMode: NOOP,
|
|
5
|
+
setInputMode: NOOP,
|
|
6
|
+
dismiss: NOOP,
|
|
7
|
+
setFocusTo: NOOP,
|
|
8
|
+
addListener: NOOP,
|
|
9
|
+
removeListeners: NOOP
|
|
10
|
+
};
|
|
11
|
+
export const KeyboardEvents = {
|
|
12
|
+
addListener: () => ({
|
|
13
|
+
remove: NOOP
|
|
14
|
+
})
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* This API is not documented, it's for internal usage only (for now), and is a subject to potential breaking changes in future.
|
|
18
|
+
* Use it with cautious.
|
|
19
|
+
*/
|
|
20
|
+
export const FocusedInputEvents = {
|
|
21
|
+
addListener: () => ({
|
|
22
|
+
remove: NOOP
|
|
23
|
+
})
|
|
24
|
+
};
|
|
25
|
+
export const WindowDimensionsEvents = {
|
|
26
|
+
addListener: () => ({
|
|
27
|
+
remove: NOOP
|
|
28
|
+
})
|
|
29
|
+
};
|
|
30
|
+
export const KeyboardControllerView = View;
|
|
31
|
+
export const KeyboardGestureArea = View;
|
|
32
|
+
export const RCTOverKeyboardView = View;
|
|
33
|
+
//# sourceMappingURL=bindings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["View","NOOP","KeyboardControllerNative","setDefaultMode","setInputMode","dismiss","setFocusTo","addListener","removeListeners","KeyboardEvents","remove","FocusedInputEvents","WindowDimensionsEvents","KeyboardControllerView","KeyboardGestureArea","RCTOverKeyboardView"],"sources":["bindings.ts"],"sourcesContent":["import { View } from \"react-native\";\n\nimport type {\n FocusedInputEventsModule,\n KeyboardControllerNativeModule,\n KeyboardControllerProps,\n KeyboardEventsModule,\n KeyboardGestureAreaProps,\n OverKeyboardViewProps,\n WindowDimensionsEventsModule,\n} from \"./types\";\nimport type { EmitterSubscription } from \"react-native\";\n\nconst NOOP = () => {};\n\nexport const KeyboardControllerNative: KeyboardControllerNativeModule = {\n setDefaultMode: NOOP,\n setInputMode: NOOP,\n dismiss: NOOP,\n setFocusTo: NOOP,\n addListener: NOOP,\n removeListeners: NOOP,\n};\nexport const KeyboardEvents: KeyboardEventsModule = {\n addListener: () => ({ remove: NOOP } as EmitterSubscription),\n};\n/**\n * This API is not documented, it's for internal usage only (for now), and is a subject to potential breaking changes in future.\n * Use it with cautious.\n */\nexport const FocusedInputEvents: FocusedInputEventsModule = {\n addListener: () => ({ remove: NOOP } as EmitterSubscription),\n};\nexport const WindowDimensionsEvents: WindowDimensionsEventsModule = {\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>;\nexport const RCTOverKeyboardView =\n View as unknown as React.FC<OverKeyboardViewProps>;\n"],"mappings":"AAAA,SAASA,IAAI,QAAQ,cAAc;AAanC,MAAMC,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AAErB,OAAO,MAAMC,wBAAwD,GAAG;EACtEC,cAAc,EAAEF,IAAI;EACpBG,YAAY,EAAEH,IAAI;EAClBI,OAAO,EAAEJ,IAAI;EACbK,UAAU,EAAEL,IAAI;EAChBM,WAAW,EAAEN,IAAI;EACjBO,eAAe,EAAEP;AACnB,CAAC;AACD,OAAO,MAAMQ,cAAoC,GAAG;EAClDF,WAAW,EAAEA,CAAA,MAAO;IAAEG,MAAM,EAAET;EAAK,CAAC;AACtC,CAAC;AACD;AACA;AACA;AACA;AACA,OAAO,MAAMU,kBAA4C,GAAG;EAC1DJ,WAAW,EAAEA,CAAA,MAAO;IAAEG,MAAM,EAAET;EAAK,CAAC;AACtC,CAAC;AACD,OAAO,MAAMW,sBAAoD,GAAG;EAClEL,WAAW,EAAEA,CAAA,MAAO;IAAEG,MAAM,EAAET;EAAK,CAAC;AACtC,CAAC;AACD,OAAO,MAAMY,sBAAsB,GACjCb,IAAoD;AACtD,OAAO,MAAMc,mBAAmB,GAC9Bd,IAAqD;AACvD,OAAO,MAAMe,mBAAmB,GAC9Bf,IAAkD","ignoreList":[]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { NativeEventEmitter, Platform } from "react-native";
|
|
2
|
+
const LINKING_ERROR = `The package 'react-native-keyboard-controller' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
|
|
3
|
+
ios: "- You have run 'pod install'\n",
|
|
4
|
+
default: ""
|
|
5
|
+
}) + "- You rebuilt the app after installing the package\n" + "- You are not using Expo Go\n";
|
|
6
|
+
const RCTKeyboardController = require("./specs/NativeKeyboardController").default;
|
|
7
|
+
export const KeyboardControllerNative = RCTKeyboardController ? RCTKeyboardController : new Proxy({}, {
|
|
8
|
+
get() {
|
|
9
|
+
throw new Error(LINKING_ERROR);
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
const KEYBOARD_CONTROLLER_NAMESPACE = "KeyboardController::";
|
|
13
|
+
const eventEmitter = new NativeEventEmitter(KeyboardControllerNative);
|
|
14
|
+
export const KeyboardEvents = {
|
|
15
|
+
addListener: (name, cb) => eventEmitter.addListener(KEYBOARD_CONTROLLER_NAMESPACE + name, cb)
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* This API is not documented, it's for internal usage only (for now), and is a subject to potential breaking changes in future.
|
|
20
|
+
* Use it with cautious.
|
|
21
|
+
*/
|
|
22
|
+
export const FocusedInputEvents = {
|
|
23
|
+
addListener: (name, cb) => eventEmitter.addListener(KEYBOARD_CONTROLLER_NAMESPACE + name, cb)
|
|
24
|
+
};
|
|
25
|
+
export const WindowDimensionsEvents = {
|
|
26
|
+
addListener: (name, cb) => eventEmitter.addListener(KEYBOARD_CONTROLLER_NAMESPACE + name, cb)
|
|
27
|
+
};
|
|
28
|
+
export const KeyboardControllerView = require("./specs/KeyboardControllerViewNativeComponent").default;
|
|
29
|
+
export const KeyboardGestureArea = Platform.OS === "android" && Platform.Version >= 30 || Platform.OS === "ios" ? require("./specs/KeyboardGestureAreaNativeComponent").default : ({
|
|
30
|
+
children
|
|
31
|
+
}) => children;
|
|
32
|
+
export const RCTOverKeyboardView = require("./specs/OverKeyboardViewNativeComponent").default;
|
|
33
|
+
//# sourceMappingURL=bindings.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["NativeEventEmitter","Platform","LINKING_ERROR","select","ios","default","RCTKeyboardController","require","KeyboardControllerNative","Proxy","get","Error","KEYBOARD_CONTROLLER_NAMESPACE","eventEmitter","KeyboardEvents","addListener","name","cb","FocusedInputEvents","WindowDimensionsEvents","KeyboardControllerView","KeyboardGestureArea","OS","Version","children","RCTOverKeyboardView"],"sources":["bindings.native.ts"],"sourcesContent":["import { NativeEventEmitter, Platform } from \"react-native\";\n\nimport type {\n FocusedInputEventsModule,\n KeyboardControllerNativeModule,\n KeyboardControllerProps,\n KeyboardEventsModule,\n KeyboardGestureAreaProps,\n OverKeyboardViewProps,\n WindowDimensionsEventsModule,\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;\n\nexport const KeyboardControllerNative = (\n RCTKeyboardController\n ? RCTKeyboardController\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n },\n )\n) as KeyboardControllerNativeModule;\n\nconst KEYBOARD_CONTROLLER_NAMESPACE = \"KeyboardController::\";\nconst eventEmitter = new NativeEventEmitter(KeyboardControllerNative);\n\nexport const KeyboardEvents: KeyboardEventsModule = {\n addListener: (name, cb) =>\n eventEmitter.addListener(KEYBOARD_CONTROLLER_NAMESPACE + name, cb),\n};\n\n/**\n * This API is not documented, it's for internal usage only (for now), and is a subject to potential breaking changes in future.\n * Use it with cautious.\n */\nexport const FocusedInputEvents: FocusedInputEventsModule = {\n addListener: (name, cb) =>\n eventEmitter.addListener(KEYBOARD_CONTROLLER_NAMESPACE + name, cb),\n};\nexport const WindowDimensionsEvents: WindowDimensionsEventsModule = {\n addListener: (name, cb) =>\n eventEmitter.addListener(KEYBOARD_CONTROLLER_NAMESPACE + 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) || Platform.OS === \"ios\"\n ? require(\"./specs/KeyboardGestureAreaNativeComponent\").default\n : ({ children }: KeyboardGestureAreaProps) => children;\nexport const RCTOverKeyboardView: React.FC<OverKeyboardViewProps> =\n require(\"./specs/OverKeyboardViewNativeComponent\").default;\n"],"mappings":"AAAA,SAASA,kBAAkB,EAAEC,QAAQ,QAAQ,cAAc;AAY3D,MAAMC,aAAa,GACjB,2FAA2F,GAC3FD,QAAQ,CAACE,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;AAErD,OAAO,MAAMG,wBAAwB,GACnCF,qBAAqB,GACjBA,qBAAqB,GACrB,IAAIG,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACT,aAAa,CAAC;EAChC;AACF,CACF,CAC6B;AAEnC,MAAMU,6BAA6B,GAAG,sBAAsB;AAC5D,MAAMC,YAAY,GAAG,IAAIb,kBAAkB,CAACQ,wBAAwB,CAAC;AAErE,OAAO,MAAMM,cAAoC,GAAG;EAClDC,WAAW,EAAEA,CAACC,IAAI,EAAEC,EAAE,KACpBJ,YAAY,CAACE,WAAW,CAACH,6BAA6B,GAAGI,IAAI,EAAEC,EAAE;AACrE,CAAC;;AAED;AACA;AACA;AACA;AACA,OAAO,MAAMC,kBAA4C,GAAG;EAC1DH,WAAW,EAAEA,CAACC,IAAI,EAAEC,EAAE,KACpBJ,YAAY,CAACE,WAAW,CAACH,6BAA6B,GAAGI,IAAI,EAAEC,EAAE;AACrE,CAAC;AACD,OAAO,MAAME,sBAAoD,GAAG;EAClEJ,WAAW,EAAEA,CAACC,IAAI,EAAEC,EAAE,KACpBJ,YAAY,CAACE,WAAW,CAACH,6BAA6B,GAAGI,IAAI,EAAEC,EAAE;AACrE,CAAC;AACD,OAAO,MAAMG,sBAAyD,GACpEb,OAAO,CAAC,+CAA+C,CAAC,CAACF,OAAO;AAClE,OAAO,MAAMgB,mBAAuD,GACjEpB,QAAQ,CAACqB,EAAE,KAAK,SAAS,IAAIrB,QAAQ,CAACsB,OAAO,IAAI,EAAE,IAAKtB,QAAQ,CAACqB,EAAE,KAAK,KAAK,GAC1Ef,OAAO,CAAC,4CAA4C,CAAC,CAACF,OAAO,GAC7D,CAAC;EAAEmB;AAAmC,CAAC,KAAKA,QAAQ;AAC1D,OAAO,MAAMC,mBAAoD,GAC/DlB,OAAO,CAAC,yCAAyC,CAAC,CAACF,OAAO","ignoreList":[]}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { useSharedValue } from "react-native-reanimated";
|
|
2
|
+
import { useKeyboardHandler } from "../../hooks";
|
|
3
|
+
import { useKeyboardContext } from "../../context";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import { Platform } from "react-native";
|
|
6
|
+
const OS = Platform.OS;
|
|
7
|
+
export const useKeyboardAnimation = () => {
|
|
8
|
+
const {
|
|
9
|
+
reanimated
|
|
10
|
+
} = useKeyboardContext();
|
|
11
|
+
// calculate it only once on mount, to avoid `SharedValue` reads during a render
|
|
12
|
+
const [initialHeight] = useState(() => -reanimated.height.value);
|
|
13
|
+
const [initialProgress] = useState(() => reanimated.progress.value);
|
|
14
|
+
const heightWhenOpened = useSharedValue(initialHeight);
|
|
15
|
+
const height = useSharedValue(initialHeight);
|
|
16
|
+
const progress = useSharedValue(initialProgress);
|
|
17
|
+
const isClosed = useSharedValue(initialProgress === 0);
|
|
18
|
+
useKeyboardHandler({
|
|
19
|
+
onStart: e => {
|
|
20
|
+
"worklet";
|
|
21
|
+
|
|
22
|
+
if (e.height > 0) {
|
|
23
|
+
// eslint-disable-next-line react-compiler/react-compiler
|
|
24
|
+
isClosed.value = false;
|
|
25
|
+
heightWhenOpened.value = e.height;
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
onMove: e => {
|
|
29
|
+
"worklet";
|
|
30
|
+
|
|
31
|
+
progress.value = e.progress;
|
|
32
|
+
height.value = e.height;
|
|
33
|
+
},
|
|
34
|
+
onInteractive: e => {
|
|
35
|
+
"worklet";
|
|
36
|
+
|
|
37
|
+
progress.value = e.progress;
|
|
38
|
+
height.value = e.height;
|
|
39
|
+
},
|
|
40
|
+
onEnd: e => {
|
|
41
|
+
"worklet";
|
|
42
|
+
|
|
43
|
+
if (Platform.OS === 'harmony') {
|
|
44
|
+
heightWhenOpened.value = e.height;
|
|
45
|
+
}
|
|
46
|
+
isClosed.value = e.height === 0;
|
|
47
|
+
|
|
48
|
+
// `height` update happens in `onMove` handler
|
|
49
|
+
// in `onEnd` we need to update only if `onMove`
|
|
50
|
+
// wasn't called (i. e. duration === 0)
|
|
51
|
+
//
|
|
52
|
+
// we can not call this code without condition below
|
|
53
|
+
// because in some corner cases (iOS with `secureTextEntry`)
|
|
54
|
+
// `onEnd` can be emitted before `onMove` and in this case
|
|
55
|
+
// it may lead to choppy/glitchy/jumpy UI
|
|
56
|
+
// see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/327
|
|
57
|
+
if (e.duration === 0) {
|
|
58
|
+
progress.value = e.progress;
|
|
59
|
+
height.value = e.height;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}, []);
|
|
63
|
+
return {
|
|
64
|
+
height,
|
|
65
|
+
progress,
|
|
66
|
+
heightWhenOpened,
|
|
67
|
+
isClosed
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
export const useTranslateAnimation = () => {
|
|
71
|
+
const {
|
|
72
|
+
reanimated
|
|
73
|
+
} = useKeyboardContext();
|
|
74
|
+
|
|
75
|
+
// calculate it only once on mount, to avoid `SharedValue` reads during a render
|
|
76
|
+
const [initialProgress] = useState(() => reanimated.progress.value);
|
|
77
|
+
const padding = useSharedValue(initialProgress);
|
|
78
|
+
const translate = useSharedValue(0);
|
|
79
|
+
useKeyboardHandler({
|
|
80
|
+
onStart: e => {
|
|
81
|
+
"worklet";
|
|
82
|
+
|
|
83
|
+
if (e.height === 0) {
|
|
84
|
+
// eslint-disable-next-line react-compiler/react-compiler
|
|
85
|
+
padding.value = 0;
|
|
86
|
+
}
|
|
87
|
+
if (OS === "ios") {
|
|
88
|
+
translate.value = e.progress;
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
onMove: e => {
|
|
92
|
+
"worklet";
|
|
93
|
+
|
|
94
|
+
if (OS === "android") {
|
|
95
|
+
translate.value = e.progress;
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
onInteractive: e => {
|
|
99
|
+
"worklet";
|
|
100
|
+
|
|
101
|
+
padding.value = 0;
|
|
102
|
+
translate.value = e.progress;
|
|
103
|
+
},
|
|
104
|
+
onEnd: e => {
|
|
105
|
+
"worklet";
|
|
106
|
+
|
|
107
|
+
padding.value = e.progress;
|
|
108
|
+
if (OS === "android") {
|
|
109
|
+
translate.value = e.progress;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}, []);
|
|
113
|
+
return {
|
|
114
|
+
translate,
|
|
115
|
+
padding
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
//# sourceMappingURL=hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useSharedValue","useKeyboardHandler","useKeyboardContext","useState","Platform","OS","useKeyboardAnimation","reanimated","initialHeight","height","value","initialProgress","progress","heightWhenOpened","isClosed","onStart","e","onMove","onInteractive","onEnd","duration","useTranslateAnimation","padding","translate"],"sources":["hooks.ts"],"sourcesContent":["import { useSharedValue } from \"react-native-reanimated\";\n\nimport {useKeyboardHandler} from \"../../hooks\";\nimport {useKeyboardContext} from \"../../context\";\nimport { useState } from \"react\";\nimport { Platform } from \"react-native\";\n\nconst OS = Platform.OS;\n\nexport const useKeyboardAnimation = () => {\n const { reanimated } = useKeyboardContext();\n // calculate it only once on mount, to avoid `SharedValue` reads during a render\n const [initialHeight] = useState(() => -reanimated.height.value);\n const [initialProgress] = useState(() => reanimated.progress.value);\n\n const heightWhenOpened = useSharedValue(initialHeight);\n const height = useSharedValue(initialHeight);\n const progress = useSharedValue(initialProgress);\n const isClosed = useSharedValue(initialProgress === 0);\n\n useKeyboardHandler(\n {\n onStart: (e) => {\n \"worklet\";\n\n if (e.height > 0) {\n // eslint-disable-next-line react-compiler/react-compiler\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 onInteractive: (e) => {\n \"worklet\";\n\n progress.value = e.progress;\n height.value = e.height;\n },\n onEnd: (e) => {\n \"worklet\";\n if(Platform.OS as string === 'harmony'){\n heightWhenOpened.value = e.height;\n }\n \n isClosed.value = e.height === 0;\n\n // `height` update happens in `onMove` handler\n // in `onEnd` we need to update only if `onMove`\n // wasn't called (i. e. duration === 0)\n //\n // we can not call this code without condition below\n // because in some corner cases (iOS with `secureTextEntry`)\n // `onEnd` can be emitted before `onMove` and in this case\n // it may lead to choppy/glitchy/jumpy UI\n // see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/327\n if (e.duration === 0) {\n progress.value = e.progress;\n height.value = e.height;\n }\n },\n },\n [],\n );\n\n return { height, progress, heightWhenOpened, isClosed };\n};\n\nexport const useTranslateAnimation = () => {\n const { reanimated } = useKeyboardContext();\n\n // calculate it only once on mount, to avoid `SharedValue` reads during a render\n const [initialProgress] = useState(() => reanimated.progress.value);\n\n const padding = useSharedValue(initialProgress);\n const translate = useSharedValue(0);\n\n useKeyboardHandler(\n {\n onStart: (e) => {\n \"worklet\";\n\n if (e.height === 0) {\n // eslint-disable-next-line react-compiler/react-compiler\n padding.value = 0;\n }\n if (OS === \"ios\") {\n translate.value = e.progress;\n }\n },\n onMove: (e) => {\n \"worklet\";\n\n if (OS === \"android\") {\n translate.value = e.progress;\n }\n },\n onInteractive: (e) => {\n \"worklet\";\n\n padding.value = 0;\n\n translate.value = e.progress;\n },\n onEnd: (e) => {\n \"worklet\";\n\n padding.value = e.progress;\n\n if (OS === \"android\") {\n translate.value = e.progress;\n }\n },\n },\n [],\n );\n\n return { translate, padding };\n};\n"],"mappings":"AAAA,SAASA,cAAc,QAAQ,yBAAyB;AAExD,SAAQC,kBAAkB,QAAO,aAAa;AAC9C,SAAQC,kBAAkB,QAAO,eAAe;AAChD,SAASC,QAAQ,QAAQ,OAAO;AAChC,SAASC,QAAQ,QAAQ,cAAc;AAEvC,MAAMC,EAAE,GAAGD,QAAQ,CAACC,EAAE;AAEtB,OAAO,MAAMC,oBAAoB,GAAGA,CAAA,KAAM;EACxC,MAAM;IAAEC;EAAW,CAAC,GAAGL,kBAAkB,CAAC,CAAC;EAC3C;EACA,MAAM,CAACM,aAAa,CAAC,GAAGL,QAAQ,CAAC,MAAM,CAACI,UAAU,CAACE,MAAM,CAACC,KAAK,CAAC;EAChE,MAAM,CAACC,eAAe,CAAC,GAAGR,QAAQ,CAAC,MAAMI,UAAU,CAACK,QAAQ,CAACF,KAAK,CAAC;EA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EAAQ,CAAC;AAC/B,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
+
import React, { forwardRef, useCallback, useMemo } from "react";
|
|
3
|
+
import { View } from "react-native";
|
|
4
|
+
import Reanimated, { interpolate, runOnUI, useAnimatedStyle, useDerivedValue, useSharedValue } from "react-native-reanimated";
|
|
5
|
+
import { useWindowDimensions } from "../../hooks";
|
|
6
|
+
import { useKeyboardAnimation, useTranslateAnimation } from "./hooks";
|
|
7
|
+
const defaultLayout = {
|
|
8
|
+
x: 0,
|
|
9
|
+
y: 0,
|
|
10
|
+
width: 0,
|
|
11
|
+
height: 0
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* View that moves out of the way when the keyboard appears by automatically
|
|
16
|
+
* adjusting its height, position, or bottom padding.
|
|
17
|
+
*/
|
|
18
|
+
const KeyboardAvoidingView = /*#__PURE__*/forwardRef(({
|
|
19
|
+
behavior,
|
|
20
|
+
children,
|
|
21
|
+
contentContainerStyle,
|
|
22
|
+
enabled = true,
|
|
23
|
+
keyboardVerticalOffset = 0,
|
|
24
|
+
style,
|
|
25
|
+
onLayout: onLayoutProps,
|
|
26
|
+
...props
|
|
27
|
+
}, ref) => {
|
|
28
|
+
const initialFrame = useSharedValue(null);
|
|
29
|
+
const frame = useDerivedValue(() => initialFrame.value || defaultLayout);
|
|
30
|
+
const {
|
|
31
|
+
translate,
|
|
32
|
+
padding
|
|
33
|
+
} = useTranslateAnimation();
|
|
34
|
+
const keyboard = useKeyboardAnimation();
|
|
35
|
+
const {
|
|
36
|
+
height: screenHeight
|
|
37
|
+
} = useWindowDimensions();
|
|
38
|
+
const relativeKeyboardHeight = useCallback(() => {
|
|
39
|
+
"worklet";
|
|
40
|
+
|
|
41
|
+
const keyboardY = screenHeight - keyboard.heightWhenOpened.value - keyboardVerticalOffset;
|
|
42
|
+
return Math.max(frame.value.y + frame.value.height - keyboardY, 0);
|
|
43
|
+
}, [screenHeight, keyboardVerticalOffset]);
|
|
44
|
+
const interpolateToRelativeKeyboardHeight = useCallback(value => {
|
|
45
|
+
"worklet";
|
|
46
|
+
|
|
47
|
+
return interpolate(value, [0, 1], [0, relativeKeyboardHeight()]);
|
|
48
|
+
}, [relativeKeyboardHeight]);
|
|
49
|
+
const onLayoutWorklet = useCallback(layout => {
|
|
50
|
+
"worklet";
|
|
51
|
+
|
|
52
|
+
if (keyboard.isClosed.value || initialFrame.value === null) {
|
|
53
|
+
// eslint-disable-next-line react-compiler/react-compiler
|
|
54
|
+
initialFrame.value = layout;
|
|
55
|
+
}
|
|
56
|
+
}, []);
|
|
57
|
+
const onLayout = useCallback(e => {
|
|
58
|
+
runOnUI(onLayoutWorklet)(e.nativeEvent.layout);
|
|
59
|
+
onLayoutProps === null || onLayoutProps === void 0 || onLayoutProps(e);
|
|
60
|
+
}, [onLayoutProps]);
|
|
61
|
+
const animatedStyle = useAnimatedStyle(() => {
|
|
62
|
+
const bottom = interpolateToRelativeKeyboardHeight(keyboard.progress.value);
|
|
63
|
+
const translateY = interpolateToRelativeKeyboardHeight(translate.value);
|
|
64
|
+
const paddingBottom = interpolateToRelativeKeyboardHeight(padding.value);
|
|
65
|
+
const bottomHeight = enabled ? bottom : 0;
|
|
66
|
+
switch (behavior) {
|
|
67
|
+
case "height":
|
|
68
|
+
if (!keyboard.isClosed.value) {
|
|
69
|
+
return {
|
|
70
|
+
height: frame.value.height - bottomHeight,
|
|
71
|
+
flex: 0
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
return {};
|
|
75
|
+
case "position":
|
|
76
|
+
return {
|
|
77
|
+
bottom: bottomHeight
|
|
78
|
+
};
|
|
79
|
+
case "padding":
|
|
80
|
+
return {
|
|
81
|
+
paddingBottom: bottomHeight
|
|
82
|
+
};
|
|
83
|
+
case "translate-with-padding":
|
|
84
|
+
return {
|
|
85
|
+
paddingBottom: paddingBottom,
|
|
86
|
+
transform: [{
|
|
87
|
+
translateY: -translateY
|
|
88
|
+
}]
|
|
89
|
+
};
|
|
90
|
+
default:
|
|
91
|
+
return {};
|
|
92
|
+
}
|
|
93
|
+
}, [behavior, enabled, interpolateToRelativeKeyboardHeight]);
|
|
94
|
+
const isPositionBehavior = behavior === "position";
|
|
95
|
+
const containerStyle = isPositionBehavior ? contentContainerStyle : style;
|
|
96
|
+
const combinedStyles = useMemo(() => [containerStyle, animatedStyle], [containerStyle, animatedStyle]);
|
|
97
|
+
if (isPositionBehavior) {
|
|
98
|
+
return /*#__PURE__*/React.createElement(View, _extends({
|
|
99
|
+
ref: ref,
|
|
100
|
+
style: style,
|
|
101
|
+
onLayout: onLayout
|
|
102
|
+
}, props), /*#__PURE__*/React.createElement(Reanimated.View, {
|
|
103
|
+
style: combinedStyles
|
|
104
|
+
}, children));
|
|
105
|
+
}
|
|
106
|
+
return /*#__PURE__*/React.createElement(Reanimated.View, _extends({
|
|
107
|
+
ref: ref,
|
|
108
|
+
onLayout: onLayout,
|
|
109
|
+
style: combinedStyles
|
|
110
|
+
}, props), children);
|
|
111
|
+
});
|
|
112
|
+
export default KeyboardAvoidingView;
|
|
113
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","forwardRef","useCallback","useMemo","View","Reanimated","interpolate","runOnUI","useAnimatedStyle","useDerivedValue","useSharedValue","useWindowDimensions","useKeyboardAnimation","useTranslateAnimation","defaultLayout","x","y","width","height","KeyboardAvoidingView","behavior","children","contentContainerStyle","enabled","keyboardVerticalOffset","style","onLayout","onLayoutProps","props","ref","initialFrame","frame","value","translate","padding","keyboard","screenHeight","relativeKeyboardHeight","keyboardY","heightWhenOpened","Math","max","interpolateToRelativeKeyboardHeight","onLayoutWorklet","layout","isClosed","e","nativeEvent","animatedStyle","bottom","progress","translateY","paddingBottom","bottomHeight","flex","transform","isPositionBehavior","containerStyle","combinedStyles","createElement","_extends"],"sources":["index.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useMemo } from \"react\";\nimport { View } from \"react-native\";\nimport Reanimated, {\n interpolate,\n runOnUI,\n useAnimatedStyle,\n useDerivedValue,\n useSharedValue,\n} from \"react-native-reanimated\";\n\nimport { useWindowDimensions } from \"../../hooks\";\n\nimport { useKeyboardAnimation, useTranslateAnimation } from \"./hooks\";\n\nimport type { LayoutRectangle, ViewProps } from \"react-native\";\n\nexport type KeyboardAvoidingViewBaseProps = {\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\nexport type KeyboardAvoidingViewProps = KeyboardAvoidingViewBaseProps &\n (\n | {\n /**\n * Specify how to react to the presence of the keyboard.\n */\n behavior?: \"position\";\n\n /**\n * Style of the content container when `behavior` is 'position'.\n */\n contentContainerStyle?: ViewProps[\"style\"];\n }\n | {\n /**\n * Specify how to react to the presence of the keyboard.\n */\n behavior?: \"height\" | \"padding\" | \"translate-with-padding\";\n\n /**\n * `contentContainerStyle` is not allowed for these behaviors.\n */\n contentContainerStyle?: never;\n }\n );\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<\n View,\n React.PropsWithChildren<KeyboardAvoidingViewProps>\n>(\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 { translate, padding } = useTranslateAnimation();\n const keyboard = useKeyboardAnimation();\n const { height: screenHeight } = useWindowDimensions();\n\n const relativeKeyboardHeight = useCallback(() => {\n \"worklet\";\n\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 const interpolateToRelativeKeyboardHeight = useCallback(\n (value: number) => {\n \"worklet\";\n\n return interpolate(value, [0, 1], [0, relativeKeyboardHeight()]);\n },\n [relativeKeyboardHeight],\n );\n\n const onLayoutWorklet = useCallback((layout: LayoutRectangle) => {\n \"worklet\";\n\n if (keyboard.isClosed.value || initialFrame.value === null) {\n // eslint-disable-next-line react-compiler/react-compiler\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 = interpolateToRelativeKeyboardHeight(\n keyboard.progress.value,\n );\n const translateY = interpolateToRelativeKeyboardHeight(translate.value);\n const paddingBottom = interpolateToRelativeKeyboardHeight(padding.value);\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 case \"translate-with-padding\":\n return {\n paddingBottom: paddingBottom,\n transform: [{ translateY: -translateY}],\n };\n\n default:\n return {};\n }\n }, [behavior, enabled, interpolateToRelativeKeyboardHeight]);\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 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,OAAOA,KAAK,IAAIC,UAAU,EAAEC,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAC/D,SAASC,IAAI,QAAQ,cAAc;AACnC,OAAOC,UAAU,IACfC,WAAW,EACXC,OAAO,EACPC,gBAAgB,EAChBC,eAAe,EACfC,cAAc,QACT,yBAAyB;AAEhC,SAASC,mBAAmB,QAAQ,aAAa;AAEjD,SAASC,oBAAoB,EAAEC,qBAAqB,QAAQ,SAAS;AA4CrE,MAAMC,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,gBAAGlB,UAAU,CAIrC,CACE;EACEmB,QAAQ;EACRC,QAAQ;EACRC,qBAAqB;EACrBC,OAAO,GAAG,IAAI;EACdC,sBAAsB,GAAG,CAAC;EAC1BC,KAAK;EACLC,QAAQ,EAAEC,aAAa;EACvB,GAAGC;AACL,CAAC,EACDC,GAAG,KACA;EACH,MAAMC,YAAY,GAAGpB,cAAc,CAAyB,IAAI,CAAC;EACjE,MAAMqB,KAAK,GAAGtB,eAAe,CAAC,MAAMqB,YAAY,CAACE,KAAK,IAAIlB,aAAa,CAAC;EAExE,MAAM;IAAEmB,SAAS;IAAEC;EAAQ,CAAC,GAAGrB,qBAAqB,CAAC,CAAC;EACtD,MAAMsB,QAAQ,GAAGvB,oBAAoB,CAAC,CAAC;EACvC,MAAM;IAAEM,MAAM,EAA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