react-native-keyboard-controller 1.10.6 → 1.11.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 +1 -0
- package/android/build.gradle +6 -0
- package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardControllerModule.kt +4 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/events/FocusedInputLayoutChangedEvent.kt +2 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/EditText.kt +22 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/ThemedReactContext.kt +9 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/listeners/FocusedInputObserver.kt +20 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/listeners/KeyboardAnimationCallback.kt +7 -13
- package/android/src/main/java/com/reactnativekeyboardcontroller/modules/KeyboardControllerModuleImpl.kt +15 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/traversal/FocusedInputHolder.kt +16 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/traversal/ViewHierarchyNavigator.kt +101 -0
- package/android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardControllerModule.kt +5 -0
- package/android/src/test/java/com/reactnativekeyboardcontroller/traversal/ViewHierarchyNavigatorTest.kt +188 -0
- package/ios/.swiftlint.yml +4 -0
- package/ios/Extensions.swift +29 -0
- package/ios/KeyboardController.xcodeproj/project.pbxproj +20 -0
- package/ios/KeyboardControllerModule.mm +18 -0
- package/ios/events/FocusedInputLayoutChangedEvent.m +3 -0
- package/ios/observers/FocusedInputObserver.swift +20 -4
- package/ios/observers/KeyboardMovementObserver.swift +5 -4
- package/ios/traversal/FocusedInputHolder.swift +32 -0
- package/ios/traversal/TextInput.swift +26 -0
- package/ios/traversal/ViewHierarchyNavigator.swift +116 -0
- package/ios/views/KeyboardControllerView.mm +5 -0
- package/ios/views/KeyboardControllerViewManager.swift +4 -1
- package/jest/index.js +20 -0
- package/lib/commonjs/bindings.js +12 -1
- package/lib/commonjs/bindings.js.map +1 -1
- package/lib/commonjs/bindings.native.js +11 -2
- package/lib/commonjs/bindings.native.js.map +1 -1
- package/lib/commonjs/components/KeyboardAwareScrollView/index.js +18 -6
- package/lib/commonjs/components/KeyboardAwareScrollView/index.js.map +1 -1
- package/lib/commonjs/components/KeyboardToolbar/Arrow.js +79 -0
- package/lib/commonjs/components/KeyboardToolbar/Arrow.js.map +1 -0
- package/lib/commonjs/components/KeyboardToolbar/Button.js +74 -0
- package/lib/commonjs/components/KeyboardToolbar/Button.js.map +1 -0
- package/lib/commonjs/components/KeyboardToolbar/colors.js +41 -0
- package/lib/commonjs/components/KeyboardToolbar/colors.js.map +1 -0
- package/lib/commonjs/components/KeyboardToolbar/index.js +136 -0
- package/lib/commonjs/components/KeyboardToolbar/index.js.map +1 -0
- package/lib/commonjs/components/hooks/useColorScheme.js +11 -0
- package/lib/commonjs/components/hooks/useColorScheme.js.map +1 -0
- package/lib/commonjs/components/hooks/useKeyboardInterpolation.js +3 -2
- package/lib/commonjs/components/hooks/useKeyboardInterpolation.js.map +1 -1
- package/lib/commonjs/components/index.js +21 -0
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/index.js +22 -13
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
- package/lib/commonjs/specs/NativeKeyboardController.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/bindings.js +10 -0
- package/lib/module/bindings.js.map +1 -1
- package/lib/module/bindings.native.js +9 -1
- package/lib/module/bindings.native.js.map +1 -1
- package/lib/module/components/KeyboardAwareScrollView/index.js +18 -6
- package/lib/module/components/KeyboardAwareScrollView/index.js.map +1 -1
- package/lib/module/components/KeyboardToolbar/Arrow.js +69 -0
- package/lib/module/components/KeyboardToolbar/Arrow.js.map +1 -0
- package/lib/module/components/KeyboardToolbar/Button.js +64 -0
- package/lib/module/components/KeyboardToolbar/Button.js.map +1 -0
- package/lib/module/components/KeyboardToolbar/colors.js +34 -0
- package/lib/module/components/KeyboardToolbar/colors.js.map +1 -0
- package/lib/module/components/KeyboardToolbar/index.js +121 -0
- package/lib/module/components/KeyboardToolbar/index.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/hooks/useKeyboardInterpolation.js +3 -2
- package/lib/module/components/hooks/useKeyboardInterpolation.js.map +1 -1
- package/lib/module/components/index.js +1 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/index.js +3 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
- package/lib/module/specs/NativeKeyboardController.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/bindings.d.ts +6 -1
- package/lib/typescript/bindings.native.d.ts +6 -1
- package/lib/typescript/components/KeyboardToolbar/Arrow.d.ts +9 -0
- package/lib/typescript/components/KeyboardToolbar/Button.d.ts +15 -0
- package/lib/typescript/components/KeyboardToolbar/colors.d.ts +17 -0
- package/lib/typescript/components/KeyboardToolbar/index.d.ts +25 -0
- package/lib/typescript/components/hooks/useColorScheme.d.ts +2 -0
- package/lib/typescript/components/index.d.ts +1 -0
- package/lib/typescript/index.d.ts +1 -2
- package/lib/typescript/specs/KeyboardControllerViewNativeComponent.d.ts +1 -0
- package/lib/typescript/specs/NativeKeyboardController.d.ts +1 -0
- package/lib/typescript/types.d.ts +11 -0
- package/package.json +5 -1
- package/src/bindings.native.ts +11 -1
- package/src/bindings.ts +9 -0
- package/src/components/KeyboardAwareScrollView/index.tsx +22 -2
- package/src/components/KeyboardToolbar/Arrow.tsx +80 -0
- package/src/components/KeyboardToolbar/Button.tsx +98 -0
- package/src/components/KeyboardToolbar/colors.ts +51 -0
- package/src/components/KeyboardToolbar/index.tsx +154 -0
- package/src/components/hooks/useColorScheme.ts +5 -0
- package/src/components/hooks/useKeyboardInterpolation.ts +3 -2
- package/src/components/index.ts +5 -0
- package/src/index.ts +4 -1
- package/src/specs/KeyboardControllerViewNativeComponent.ts +1 -0
- package/src/specs/NativeKeyboardController.ts +1 -0
- package/src/types.ts +14 -0
- package/lib/commonjs/replicas.js +0 -125
- package/lib/commonjs/replicas.js.map +0 -1
- package/lib/module/replicas.js +0 -115
- package/lib/module/replicas.js.map +0 -1
- package/lib/typescript/replicas.d.ts +0 -38
- package/src/replicas.ts +0 -154
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_reactNativeReanimated","_reactNativeKeyboardController","useKeyboardInterpolation","nextKeyboardHeight","useSharedValue","prevKeyboardHeight","lastInterpolation","shouldUseInternalInterpolation","interpolate","keyboardPosition","output","Platform","OS","interpolateREA","value","useKeyboardHandler","onStart","e","keyboardWillBeHidden","height","onEnd","_default","exports","default"],"sources":["useKeyboardInterpolation.ts"],"sourcesContent":["import { Platform } from \"react-native\";\nimport {\n interpolate as interpolateREA,\n useSharedValue,\n} from \"react-native-reanimated\";\n\nimport { useKeyboardHandler } from \"react-native-keyboard-controller\";\n\ntype KeyboardInterpolationOutput = [number, number];\n\n/**\n * Hook that can be used for interpolation keyboard movement. The main concern is the thing\n * when keyboard is opened and gets resized on Android. Let's say we are interpolating from\n * closed to open [0, 200] and we want to interpolate it to [0, 230] (to achieve nice parallax effect).\n * Then let's say keyboard changes its height to 220 (and we want to interpolate the value to 250, +30\n * to keyboard height). If we interpolate based on `progress` value, then we will have a jump on first frame:\n * the last interpolated position was 230, now we will interpolate to 250, but first frame will be calculated\n * as 200 / 220 * 250 = 227 (and last interpolated position was 230) so we will have a jump.\n *\n * This hook handles it, and when keyboard changes its size it does an interpolation as:\n * [200, 220] -> [230, 250], i. e. we preserve last interpolated value and use it as initial value for interpolation\n * and because of that we will not have a jump and animation will start from the last frame and will be smooth.\n *\n * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/315\n */\nconst useKeyboardInterpolation = () => {\n // keyboard heights\n const nextKeyboardHeight = useSharedValue(0);\n const prevKeyboardHeight = useSharedValue(0);\n // save latest interpolated position\n const lastInterpolation = useSharedValue(0);\n // boolean flag indicating which output range should be used\n const shouldUseInternalInterpolation = useSharedValue(false);\n\n const interpolate = (\n keyboardPosition: number,\n output: KeyboardInterpolationOutput,\n ) => {\n \"worklet\";\n\n // on iOS it's safe to interpolate between 0 and `fullKeyboardSize` because when\n // keyboard resized we will not have intermediate values and transition will be instant\n // see: https://github.com/kirillzyusko/react-native-keyboard-controller/issues/327\n if (Platform.OS === \"ios\") {\n return interpolateREA(\n keyboardPosition,\n [0, nextKeyboardHeight.value],\n output,\n );\n }\n\n
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_reactNativeReanimated","_reactNativeKeyboardController","useKeyboardInterpolation","nextKeyboardHeight","useSharedValue","prevKeyboardHeight","lastInterpolation","shouldUseInternalInterpolation","interpolate","keyboardPosition","output","Platform","OS","interpolateREA","value","interpolation","useKeyboardHandler","onStart","e","keyboardWillBeHidden","height","onEnd","_default","exports","default"],"sources":["useKeyboardInterpolation.ts"],"sourcesContent":["import { Platform } from \"react-native\";\nimport {\n interpolate as interpolateREA,\n useSharedValue,\n} from \"react-native-reanimated\";\n\nimport { useKeyboardHandler } from \"react-native-keyboard-controller\";\n\ntype KeyboardInterpolationOutput = [number, number];\n\n/**\n * Hook that can be used for interpolation keyboard movement. The main concern is the thing\n * when keyboard is opened and gets resized on Android. Let's say we are interpolating from\n * closed to open [0, 200] and we want to interpolate it to [0, 230] (to achieve nice parallax effect).\n * Then let's say keyboard changes its height to 220 (and we want to interpolate the value to 250, +30\n * to keyboard height). If we interpolate based on `progress` value, then we will have a jump on first frame:\n * the last interpolated position was 230, now we will interpolate to 250, but first frame will be calculated\n * as 200 / 220 * 250 = 227 (and last interpolated position was 230) so we will have a jump.\n *\n * This hook handles it, and when keyboard changes its size it does an interpolation as:\n * [200, 220] -> [230, 250], i. e. we preserve last interpolated value and use it as initial value for interpolation\n * and because of that we will not have a jump and animation will start from the last frame and will be smooth.\n *\n * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/315\n */\nconst useKeyboardInterpolation = () => {\n // keyboard heights\n const nextKeyboardHeight = useSharedValue(0);\n const prevKeyboardHeight = useSharedValue(0);\n // save latest interpolated position\n const lastInterpolation = useSharedValue(0);\n // boolean flag indicating which output range should be used\n const shouldUseInternalInterpolation = useSharedValue(false);\n\n const interpolate = (\n keyboardPosition: number,\n output: KeyboardInterpolationOutput,\n ) => {\n \"worklet\";\n\n // on iOS it's safe to interpolate between 0 and `fullKeyboardSize` because when\n // keyboard resized we will not have intermediate values and transition will be instant\n // see: https://github.com/kirillzyusko/react-native-keyboard-controller/issues/327\n if (Platform.OS === \"ios\") {\n return interpolateREA(\n keyboardPosition,\n [0, nextKeyboardHeight.value],\n output,\n );\n }\n\n const interpolation = interpolateREA(\n keyboardPosition,\n [prevKeyboardHeight.value, nextKeyboardHeight.value],\n shouldUseInternalInterpolation.value\n ? [lastInterpolation.value, output[1]]\n : output,\n );\n lastInterpolation.value = interpolation;\n\n return interpolation;\n };\n\n useKeyboardHandler(\n {\n onStart: (e) => {\n \"worklet\";\n\n const keyboardWillBeHidden = e.height === 0;\n\n // keyboard will be hidden\n if (keyboardWillBeHidden) {\n shouldUseInternalInterpolation.value = false;\n prevKeyboardHeight.value = 0;\n }\n\n // keyboard will change its size\n if (\n // keyboard is shown on screen\n nextKeyboardHeight.value !== 0 &&\n // it really changes size (handles iOS case when after interactive keyboard gets shown again)\n nextKeyboardHeight.value !== e.height &&\n // keyboard is not hiding\n !keyboardWillBeHidden\n ) {\n prevKeyboardHeight.value = nextKeyboardHeight.value;\n shouldUseInternalInterpolation.value = true;\n }\n\n // keyboard will show or change size\n if (!keyboardWillBeHidden) {\n nextKeyboardHeight.value = e.height;\n }\n },\n onEnd: (e) => {\n \"worklet\";\n\n // handles case show -> resize -> hide -> show\n // here we reset value to 0 when keyboard is hidden\n nextKeyboardHeight.value = e.height;\n },\n },\n [],\n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;;MAE3C;MACA,IAAID,oBAAoB,EAAE;QACxBZ,8BAA8B,CAACO,KAAK,GAAG,KAAK;QAC5CT,kBAAkB,CAACS,KAAK,GAAG,CAAC;MAC9B;;MAEA;MACA;MACE;MACAX,kBAAkB,CAACW,KAAK,KAAK,CAAC;MAC9B;MACAX,kBAAkB,CAACW,KAAK,KAAKI,CAAC,CAACE,MAAM;MACrC;MACA,CAACD,oBAAoB,EACrB;QACAd,kBAAkB,CAACS,KAAK,GAAGX,kBAAkB,CAACW,KAAK;QACnDP,8BAA8B,CAACO,KAAK,GAAG,IAAI;MAC7C;;MAEA;MACA,IAAI,CAACK,oBAAoB,EAAE;QACzBhB,kBAAkB,CAACW,KAAK,GAAGI,CAAC,CAACE,MAAM;MACrC;IACF,CAAC;IACDC,KAAK,EAAGH,CAAC,IAAK;MACZ,SAAS;;MAET;MACA;MACAf,kBAAkB,CAACW,KAAK,GAAGI,CAAC,CAACE,MAAM;IACrC;EACF,CAAC,EACD,EACF,CAAC;EAED,OAAO;IAAEZ;EAAY,CAAC;AACxB,CAAC;AAAC,IAAAc,QAAA,GAEapB,wBAAwB;AAAAqB,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
|
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
Object.defineProperty(exports, "DefaultKeyboardToolbarTheme", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _KeyboardToolbar.DefaultKeyboardToolbarTheme;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
6
12
|
Object.defineProperty(exports, "KeyboardAvoidingView", {
|
|
7
13
|
enumerable: true,
|
|
8
14
|
get: function () {
|
|
@@ -21,8 +27,23 @@ Object.defineProperty(exports, "KeyboardStickyView", {
|
|
|
21
27
|
return _KeyboardStickyView.default;
|
|
22
28
|
}
|
|
23
29
|
});
|
|
30
|
+
Object.defineProperty(exports, "KeyboardToolbar", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _KeyboardToolbar.default;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "KeyboardToolbarProps", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return _KeyboardToolbar.KeyboardToolbarProps;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
24
42
|
var _KeyboardAvoidingView = _interopRequireDefault(require("./KeyboardAvoidingView"));
|
|
25
43
|
var _KeyboardStickyView = _interopRequireDefault(require("./KeyboardStickyView"));
|
|
26
44
|
var _KeyboardAwareScrollView = _interopRequireDefault(require("./KeyboardAwareScrollView"));
|
|
45
|
+
var _KeyboardToolbar = _interopRequireWildcard(require("./KeyboardToolbar"));
|
|
46
|
+
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); }
|
|
47
|
+
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; }
|
|
27
48
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
28
49
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_KeyboardAvoidingView","_interopRequireDefault","require","_KeyboardStickyView","_KeyboardAwareScrollView","obj","__esModule","default"],"sources":["index.ts"],"sourcesContent":["export { default as KeyboardAvoidingView } from \"./KeyboardAvoidingView\";\nexport { default as KeyboardStickyView } from \"./KeyboardStickyView\";\nexport { default as KeyboardAwareScrollView } from \"./KeyboardAwareScrollView\";\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_KeyboardAvoidingView","_interopRequireDefault","require","_KeyboardStickyView","_KeyboardAwareScrollView","_KeyboardToolbar","_interopRequireWildcard","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set"],"sources":["index.ts"],"sourcesContent":["export { default as KeyboardAvoidingView } from \"./KeyboardAvoidingView\";\nexport { default as KeyboardStickyView } from \"./KeyboardStickyView\";\nexport { default as KeyboardAwareScrollView } from \"./KeyboardAwareScrollView\";\nexport {\n default as KeyboardToolbar,\n DefaultKeyboardToolbarTheme,\n KeyboardToolbarProps,\n} from \"./KeyboardToolbar\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,qBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,wBAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,gBAAA,GAAAC,uBAAA,CAAAJ,OAAA;AAI2B,SAAAK,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAF,wBAAAM,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAX,GAAA,QAAAW,GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAd,GAAA,EAAAW,GAAA,SAAAI,IAAA,GAAAR,qBAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAV,GAAA,EAAAW,GAAA,cAAAI,IAAA,KAAAA,IAAA,CAAAV,GAAA,IAAAU,IAAA,CAAAC,GAAA,KAAAR,MAAA,CAAAC,cAAA,CAAAH,MAAA,EAAAK,GAAA,EAAAI,IAAA,YAAAT,MAAA,CAAAK,GAAA,IAAAX,GAAA,CAAAW,GAAA,SAAAL,MAAA,CAAAJ,OAAA,GAAAF,GAAA,MAAAG,KAAA,IAAAA,KAAA,CAAAa,GAAA,CAAAhB,GAAA,EAAAM,MAAA,YAAAA,MAAA;AAAA,SAAAjB,uBAAAW,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA"}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -6,8 +6,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
var _exportNames = {
|
|
7
7
|
KeyboardAvoidingView: true,
|
|
8
8
|
KeyboardStickyView: true,
|
|
9
|
-
KeyboardAwareScrollView: true
|
|
9
|
+
KeyboardAwareScrollView: true,
|
|
10
|
+
KeyboardToolbar: true,
|
|
11
|
+
DefaultKeyboardToolbarTheme: true,
|
|
12
|
+
KeyboardToolbarProps: true
|
|
10
13
|
};
|
|
14
|
+
Object.defineProperty(exports, "DefaultKeyboardToolbarTheme", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () {
|
|
17
|
+
return _components.DefaultKeyboardToolbarTheme;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
11
20
|
Object.defineProperty(exports, "KeyboardAvoidingView", {
|
|
12
21
|
enumerable: true,
|
|
13
22
|
get: function () {
|
|
@@ -26,6 +35,18 @@ Object.defineProperty(exports, "KeyboardStickyView", {
|
|
|
26
35
|
return _components.KeyboardStickyView;
|
|
27
36
|
}
|
|
28
37
|
});
|
|
38
|
+
Object.defineProperty(exports, "KeyboardToolbar", {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
get: function () {
|
|
41
|
+
return _components.KeyboardToolbar;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
Object.defineProperty(exports, "KeyboardToolbarProps", {
|
|
45
|
+
enumerable: true,
|
|
46
|
+
get: function () {
|
|
47
|
+
return _components.KeyboardToolbarProps;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
29
50
|
var _bindings = require("./bindings");
|
|
30
51
|
Object.keys(_bindings).forEach(function (key) {
|
|
31
52
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -50,18 +71,6 @@ Object.keys(_animated).forEach(function (key) {
|
|
|
50
71
|
}
|
|
51
72
|
});
|
|
52
73
|
});
|
|
53
|
-
var _replicas = require("./replicas");
|
|
54
|
-
Object.keys(_replicas).forEach(function (key) {
|
|
55
|
-
if (key === "default" || key === "__esModule") return;
|
|
56
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
57
|
-
if (key in exports && exports[key] === _replicas[key]) return;
|
|
58
|
-
Object.defineProperty(exports, key, {
|
|
59
|
-
enumerable: true,
|
|
60
|
-
get: function () {
|
|
61
|
-
return _replicas[key];
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
74
|
var _context = require("./context");
|
|
66
75
|
Object.keys(_context).forEach(function (key) {
|
|
67
76
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_bindings","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_animated","
|
|
1
|
+
{"version":3,"names":["_bindings","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_animated","_context","_hooks","_constants","_types","_components"],"sources":["index.ts"],"sourcesContent":["export * from \"./bindings\";\nexport * from \"./animated\";\nexport * from \"./context\";\nexport * from \"./hooks\";\nexport * from \"./constants\";\nexport * from \"./types\";\n\nexport {\n KeyboardAvoidingView,\n KeyboardStickyView,\n KeyboardAwareScrollView,\n // keyboard toolbar\n KeyboardToolbar,\n DefaultKeyboardToolbarTheme,\n KeyboardToolbarProps,\n} from \"./components\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,SAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAL,SAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAb,SAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,SAAA,GAAAb,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAW,SAAA,EAAAV,OAAA,WAAAC,GAAA;EAAA,IAAAA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ACA,IAAAY,UAAA,GAAAhB,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAc,UAAA,EAAAb,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAY,UAAA,CAAAZ,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAI,UAAA,CAAAZ,GAAA;IAAA;EAAA;AAAA;AACA,IAAAa,MAAA,GAAAjB,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAe,MAAA,EAAAd,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAa,MAAA,CAAAb,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAK,MAAA,CAAAb,GAAA;IAAA;EAAA;AAAA;AAEA,IAAAc,WAAA,GAAAlB,OAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_codegenNativeComponent","_interopRequireDefault","require","obj","__esModule","default","_default","codegenNativeComponent","exports"],"sources":["KeyboardControllerViewNativeComponent.ts"],"sourcesContent":["import codegenNativeComponent from \"react-native/Libraries/Utilities/codegenNativeComponent\";\n\nimport type { HostComponent } from \"react-native\";\nimport type { ViewProps } from \"react-native/Libraries/Components/View/ViewPropTypes\";\nimport type {\n DirectEventHandler,\n Double,\n Int32,\n} from \"react-native/Libraries/Types/CodegenTypes\";\n\ntype KeyboardMoveEvent = Readonly<{\n height: Double;\n progress: Double;\n duration: Int32;\n target: Int32;\n}>;\n\ntype FocusedInputLayoutChangedEvent = Readonly<{\n target: Int32;\n layout: {\n x: Double;\n y: Double;\n width: Double;\n height: Double;\n absoluteX: Double;\n absoluteY: Double;\n };\n}>;\n\ntype FocusedInputTextChangedEvent = Readonly<{\n text: string;\n}>;\n\nexport interface NativeProps extends ViewProps {\n // props\n enabled?: boolean;\n statusBarTranslucent?: boolean;\n navigationBarTranslucent?: boolean;\n // callbacks\n /// keyboard\n onKeyboardMoveStart?: DirectEventHandler<KeyboardMoveEvent>;\n onKeyboardMove?: DirectEventHandler<KeyboardMoveEvent>;\n onKeyboardMoveEnd?: DirectEventHandler<KeyboardMoveEvent>;\n onKeyboardMoveInteractive?: DirectEventHandler<KeyboardMoveEvent>;\n /// focused input\n onFocusedInputLayoutChanged?: DirectEventHandler<FocusedInputLayoutChangedEvent>;\n onFocusedInputTextChanged?: DirectEventHandler<FocusedInputTextChangedEvent>;\n}\n\nexport default codegenNativeComponent<NativeProps>(\n \"KeyboardControllerView\",\n) as HostComponent<NativeProps>;\n"],"mappings":";;;;;;AAAA,IAAAA,uBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA6F,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,IAAAG,QAAA,
|
|
1
|
+
{"version":3,"names":["_codegenNativeComponent","_interopRequireDefault","require","obj","__esModule","default","_default","codegenNativeComponent","exports"],"sources":["KeyboardControllerViewNativeComponent.ts"],"sourcesContent":["import codegenNativeComponent from \"react-native/Libraries/Utilities/codegenNativeComponent\";\n\nimport type { HostComponent } from \"react-native\";\nimport type { ViewProps } from \"react-native/Libraries/Components/View/ViewPropTypes\";\nimport type {\n DirectEventHandler,\n Double,\n Int32,\n} from \"react-native/Libraries/Types/CodegenTypes\";\n\ntype KeyboardMoveEvent = Readonly<{\n height: Double;\n progress: Double;\n duration: Int32;\n target: Int32;\n}>;\n\ntype FocusedInputLayoutChangedEvent = Readonly<{\n target: Int32;\n parentScrollViewTarget: Int32;\n layout: {\n x: Double;\n y: Double;\n width: Double;\n height: Double;\n absoluteX: Double;\n absoluteY: Double;\n };\n}>;\n\ntype FocusedInputTextChangedEvent = Readonly<{\n text: string;\n}>;\n\nexport interface NativeProps extends ViewProps {\n // props\n enabled?: boolean;\n statusBarTranslucent?: boolean;\n navigationBarTranslucent?: boolean;\n // callbacks\n /// keyboard\n onKeyboardMoveStart?: DirectEventHandler<KeyboardMoveEvent>;\n onKeyboardMove?: DirectEventHandler<KeyboardMoveEvent>;\n onKeyboardMoveEnd?: DirectEventHandler<KeyboardMoveEvent>;\n onKeyboardMoveInteractive?: DirectEventHandler<KeyboardMoveEvent>;\n /// focused input\n onFocusedInputLayoutChanged?: DirectEventHandler<FocusedInputLayoutChangedEvent>;\n onFocusedInputTextChanged?: DirectEventHandler<FocusedInputTextChangedEvent>;\n}\n\nexport default codegenNativeComponent<NativeProps>(\n \"KeyboardControllerView\",\n) as HostComponent<NativeProps>;\n"],"mappings":";;;;;;AAAA,IAAAA,uBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA6F,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,IAAAG,QAAA,GAkD9E,IAAAC,+BAAsB,EACnC,wBACF,CAAC;AAAAC,OAAA,CAAAH,OAAA,GAAAC,QAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_default","TurboModuleRegistry","get","exports","default"],"sources":["NativeKeyboardController.ts"],"sourcesContent":["import { TurboModuleRegistry } from \"react-native\";\n\nimport type { TurboModule } from \"react-native\";\n\nexport interface Spec extends TurboModule {\n readonly getConstants: () => {};\n\n // methods\n setInputMode(mode: number): void;\n setDefaultMode(): void;\n dismiss(): void;\n\n // event emitter\n addListener: (eventName: string) => void;\n removeListeners: (count: number) => void;\n}\n\nexport default TurboModuleRegistry.get<Spec>(\"KeyboardController\");\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAAmD,IAAAC,QAAA,
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_default","TurboModuleRegistry","get","exports","default"],"sources":["NativeKeyboardController.ts"],"sourcesContent":["import { TurboModuleRegistry } from \"react-native\";\n\nimport type { TurboModule } from \"react-native\";\n\nexport interface Spec extends TurboModule {\n readonly getConstants: () => {};\n\n // methods\n setInputMode(mode: number): void;\n setDefaultMode(): void;\n dismiss(): void;\n setFocusTo(direction: string): void;\n\n // event emitter\n addListener: (eventName: string) => void;\n removeListeners: (count: number) => void;\n}\n\nexport default TurboModuleRegistry.get<Spec>(\"KeyboardController\");\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAAmD,IAAAC,QAAA,GAkBpCC,gCAAmB,CAACC,GAAG,CAAO,oBAAoB,CAAC;AAAAC,OAAA,CAAAC,OAAA,GAAAJ,QAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type {\n EmitterSubscription,\n NativeSyntheticEvent,\n ViewProps,\n} from \"react-native\";\n\n// DirectEventHandler events declaration\nexport type NativeEvent = {\n progress: number;\n height: number;\n duration: number;\n target: number;\n};\nexport type FocusedInputLayoutChangedEvent = {\n target: number;\n layout: {\n x: number;\n y: number;\n width: number;\n height: number;\n absoluteX: number;\n absoluteY: number;\n };\n};\nexport type FocusedInputTextChangedEvent = {\n text: string;\n};\nexport type EventWithName<T> = {\n eventName: string;\n} & T;\n\n// native View/Module declarations\nexport type KeyboardControllerProps = {\n // callback props\n onKeyboardMoveStart?: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>,\n ) => void;\n onKeyboardMove?: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>,\n ) => void;\n onKeyboardMoveEnd?: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>,\n ) => void;\n onKeyboardMoveInteractive?: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>,\n ) => void;\n onFocusedInputLayoutChanged?: (\n e: NativeSyntheticEvent<EventWithName<FocusedInputLayoutChangedEvent>>,\n ) => void;\n onFocusedInputTextChanged?: (\n e: NativeSyntheticEvent<EventWithName<FocusedInputTextChangedEvent>>,\n ) => void;\n // fake props used to activate reanimated bindings\n onKeyboardMoveReanimated?: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>,\n ) => void;\n onFocusedInputLayoutChangedReanimated?: (\n e: NativeSyntheticEvent<EventWithName<FocusedInputLayoutChangedEvent>>,\n ) => void;\n onFocusedInputTextChangedReanimated?: (\n e: NativeSyntheticEvent<EventWithName<FocusedInputTextChangedEvent>>,\n ) => void;\n // props\n statusBarTranslucent?: boolean;\n navigationBarTranslucent?: boolean;\n enabled?: boolean;\n} & ViewProps;\n\nexport type KeyboardGestureAreaProps = {\n interpolator: \"ios\" | \"linear\";\n /**\n * Whether to allow to show a keyboard from dismissed state by swipe up.\n * Default to `false`.\n */\n showOnSwipeUp?: boolean;\n /**\n * Whether to allow to control a keyboard by gestures. The strategy how\n * it should be controlled is determined by `interpolator` property.\n * Defaults to `true`.\n */\n enableSwipeToDismiss?: boolean;\n} & ViewProps;\n\nexport type KeyboardControllerModule = {\n // android only\n setDefaultMode: () => void;\n setInputMode: (mode: number) => void;\n // all platforms\n dismiss: () => void;\n // native event module stuff\n addListener: (eventName: string) => void;\n removeListeners: (count: number) => void;\n};\n\n// Event module declarations\nexport type KeyboardControllerEvents =\n | \"keyboardWillShow\"\n | \"keyboardDidShow\"\n | \"keyboardWillHide\"\n | \"keyboardDidHide\";\nexport type KeyboardEventData = {\n height: number;\n duration: number;\n timestamp: number;\n target: number;\n};\nexport type KeyboardEventsModule = {\n addListener: (\n name: KeyboardControllerEvents,\n cb: (e: KeyboardEventData) => void,\n ) => EmitterSubscription;\n};\n\n// reanimated hook declaration\nexport type KeyboardHandlerHook<TContext, Event> = (\n handlers: {\n onKeyboardMoveStart?: (e: NativeEvent, context: TContext) => void;\n onKeyboardMove?: (e: NativeEvent, context: TContext) => void;\n onKeyboardMoveEnd?: (e: NativeEvent, context: TContext) => void;\n onKeyboardMoveInteractive?: (e: NativeEvent, context: TContext) => void;\n },\n dependencies?: unknown[],\n) => (e: NativeSyntheticEvent<Event>) => void;\nexport type FocusedInputLayoutHandlerHook<TContext, Event> = (\n handlers: {\n onFocusedInputLayoutChanged?: (\n e: FocusedInputLayoutChangedEvent,\n context: TContext,\n ) => void;\n },\n dependencies?: unknown[],\n) => (e: NativeSyntheticEvent<Event>) => void;\nexport type FocusedInputTextHandlerHook<TContext, Event> = (\n handlers: {\n onFocusedInputTextChanged?: (\n e: FocusedInputTextChangedEvent,\n context: TContext,\n ) => void;\n },\n dependencies?: unknown[],\n) => (e: NativeSyntheticEvent<Event>) => void;\n\n// package types\nexport type Handlers<T> = Record<string, T | undefined>;\nexport type KeyboardHandler = Partial<{\n onStart: (e: NativeEvent) => void;\n onMove: (e: NativeEvent) => void;\n onEnd: (e: NativeEvent) => void;\n onInteractive: (e: NativeEvent) => void;\n}>;\nexport type KeyboardHandlers = Handlers<KeyboardHandler>;\nexport type FocusedInputHandler = Partial<{\n onChangeText: (e: FocusedInputTextChangedEvent) => void;\n}>;\nexport type FocusedInputHandlers = Handlers<FocusedInputHandler>;\n"],"mappings":""}
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type {\n EmitterSubscription,\n NativeSyntheticEvent,\n ViewProps,\n} from \"react-native\";\n\n// DirectEventHandler events declaration\nexport type NativeEvent = {\n progress: number;\n height: number;\n duration: number;\n target: number;\n};\nexport type FocusedInputLayoutChangedEvent = {\n target: number;\n parentScrollViewTarget: number;\n layout: {\n x: number;\n y: number;\n width: number;\n height: number;\n absoluteX: number;\n absoluteY: number;\n };\n};\nexport type FocusedInputTextChangedEvent = {\n text: string;\n};\nexport type EventWithName<T> = {\n eventName: string;\n} & T;\n\n// native View/Module declarations\nexport type KeyboardControllerProps = {\n // callback props\n onKeyboardMoveStart?: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>,\n ) => void;\n onKeyboardMove?: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>,\n ) => void;\n onKeyboardMoveEnd?: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>,\n ) => void;\n onKeyboardMoveInteractive?: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>,\n ) => void;\n onFocusedInputLayoutChanged?: (\n e: NativeSyntheticEvent<EventWithName<FocusedInputLayoutChangedEvent>>,\n ) => void;\n onFocusedInputTextChanged?: (\n e: NativeSyntheticEvent<EventWithName<FocusedInputTextChangedEvent>>,\n ) => void;\n // fake props used to activate reanimated bindings\n onKeyboardMoveReanimated?: (\n e: NativeSyntheticEvent<EventWithName<NativeEvent>>,\n ) => void;\n onFocusedInputLayoutChangedReanimated?: (\n e: NativeSyntheticEvent<EventWithName<FocusedInputLayoutChangedEvent>>,\n ) => void;\n onFocusedInputTextChangedReanimated?: (\n e: NativeSyntheticEvent<EventWithName<FocusedInputTextChangedEvent>>,\n ) => void;\n // props\n statusBarTranslucent?: boolean;\n navigationBarTranslucent?: boolean;\n enabled?: boolean;\n} & ViewProps;\n\nexport type KeyboardGestureAreaProps = {\n interpolator: \"ios\" | \"linear\";\n /**\n * Whether to allow to show a keyboard from dismissed state by swipe up.\n * Default to `false`.\n */\n showOnSwipeUp?: boolean;\n /**\n * Whether to allow to control a keyboard by gestures. The strategy how\n * it should be controlled is determined by `interpolator` property.\n * Defaults to `true`.\n */\n enableSwipeToDismiss?: boolean;\n} & ViewProps;\n\nexport type Direction = \"next\" | \"prev\" | \"current\";\nexport type KeyboardControllerModule = {\n // android only\n setDefaultMode: () => void;\n setInputMode: (mode: number) => void;\n // all platforms\n dismiss: () => void;\n setFocusTo: (direction: Direction) => void;\n // native event module stuff\n addListener: (eventName: string) => void;\n removeListeners: (count: number) => void;\n};\n\n// Event module declarations\nexport type KeyboardControllerEvents =\n | \"keyboardWillShow\"\n | \"keyboardDidShow\"\n | \"keyboardWillHide\"\n | \"keyboardDidHide\";\nexport type KeyboardEventData = {\n height: number;\n duration: number;\n timestamp: number;\n target: number;\n};\nexport type KeyboardEventsModule = {\n addListener: (\n name: KeyboardControllerEvents,\n cb: (e: KeyboardEventData) => void,\n ) => EmitterSubscription;\n};\nexport type FocusedInputAvailableEvents = \"focusDidSet\";\nexport type FocusedInputEventData = {\n current: number;\n count: number;\n};\nexport type FocusedInputEventsModule = {\n addListener: (\n name: FocusedInputAvailableEvents,\n cb: (e: FocusedInputEventData) => void,\n ) => EmitterSubscription;\n};\n\n// reanimated hook declaration\nexport type KeyboardHandlerHook<TContext, Event> = (\n handlers: {\n onKeyboardMoveStart?: (e: NativeEvent, context: TContext) => void;\n onKeyboardMove?: (e: NativeEvent, context: TContext) => void;\n onKeyboardMoveEnd?: (e: NativeEvent, context: TContext) => void;\n onKeyboardMoveInteractive?: (e: NativeEvent, context: TContext) => void;\n },\n dependencies?: unknown[],\n) => (e: NativeSyntheticEvent<Event>) => void;\nexport type FocusedInputLayoutHandlerHook<TContext, Event> = (\n handlers: {\n onFocusedInputLayoutChanged?: (\n e: FocusedInputLayoutChangedEvent,\n context: TContext,\n ) => void;\n },\n dependencies?: unknown[],\n) => (e: NativeSyntheticEvent<Event>) => void;\nexport type FocusedInputTextHandlerHook<TContext, Event> = (\n handlers: {\n onFocusedInputTextChanged?: (\n e: FocusedInputTextChangedEvent,\n context: TContext,\n ) => void;\n },\n dependencies?: unknown[],\n) => (e: NativeSyntheticEvent<Event>) => void;\n\n// package types\nexport type Handlers<T> = Record<string, T | undefined>;\nexport type KeyboardHandler = Partial<{\n onStart: (e: NativeEvent) => void;\n onMove: (e: NativeEvent) => void;\n onEnd: (e: NativeEvent) => void;\n onInteractive: (e: NativeEvent) => void;\n}>;\nexport type KeyboardHandlers = Handlers<KeyboardHandler>;\nexport type FocusedInputHandler = Partial<{\n onChangeText: (e: FocusedInputTextChangedEvent) => void;\n}>;\nexport type FocusedInputHandlers = Handlers<FocusedInputHandler>;\n"],"mappings":""}
|
package/lib/module/bindings.js
CHANGED
|
@@ -4,6 +4,7 @@ export const KeyboardController = {
|
|
|
4
4
|
setDefaultMode: NOOP,
|
|
5
5
|
setInputMode: NOOP,
|
|
6
6
|
dismiss: NOOP,
|
|
7
|
+
setFocusTo: NOOP,
|
|
7
8
|
addListener: NOOP,
|
|
8
9
|
removeListeners: NOOP
|
|
9
10
|
};
|
|
@@ -12,6 +13,15 @@ export const KeyboardEvents = {
|
|
|
12
13
|
remove: NOOP
|
|
13
14
|
})
|
|
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
|
+
};
|
|
15
25
|
export const KeyboardControllerView = View;
|
|
16
26
|
export const KeyboardGestureArea = View;
|
|
17
27
|
//# sourceMappingURL=bindings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["View","NOOP","KeyboardController","setDefaultMode","setInputMode","dismiss","addListener","removeListeners","KeyboardEvents","remove","KeyboardControllerView","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 dismiss: 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,SAASA,IAAI,QAAQ,cAAc;
|
|
1
|
+
{"version":3,"names":["View","NOOP","KeyboardController","setDefaultMode","setInputMode","dismiss","setFocusTo","addListener","removeListeners","KeyboardEvents","remove","FocusedInputEvents","KeyboardControllerView","KeyboardGestureArea"],"sources":["bindings.ts"],"sourcesContent":["import { View } from \"react-native\";\n\nimport type {\n FocusedInputEventsModule,\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 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 KeyboardControllerView =\n View as unknown as React.FC<KeyboardControllerProps>;\nexport const KeyboardGestureArea =\n View as unknown as React.FC<KeyboardGestureAreaProps>;\n"],"mappings":"AAAA,SAASA,IAAI,QAAQ,cAAc;AAWnC,MAAMC,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AACrB,OAAO,MAAMC,kBAA4C,GAAG;EAC1DC,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,sBAAsB,GACjCZ,IAAoD;AACtD,OAAO,MAAMa,mBAAmB,GAC9Bb,IAAqD"}
|
|
@@ -9,9 +9,17 @@ export const KeyboardController = RCTKeyboardController ? RCTKeyboardController
|
|
|
9
9
|
throw new Error(LINKING_ERROR);
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
+
const KEYBOARD_CONTROLLER_NAMESPACE = "KeyboardController::";
|
|
12
13
|
const eventEmitter = new NativeEventEmitter(KeyboardController);
|
|
13
14
|
export const KeyboardEvents = {
|
|
14
|
-
addListener: (name, cb) => eventEmitter.addListener(
|
|
15
|
+
addListener: (name, cb) => eventEmitter.addListener(KEYBOARD_CONTROLLER_NAMESPACE + name, cb)
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* This API is not documented, it's for internal usage only (for now), and is a subject to potential breaking changes in future.
|
|
19
|
+
* Use it with cautious.
|
|
20
|
+
*/
|
|
21
|
+
export const FocusedInputEvents = {
|
|
22
|
+
addListener: (name, cb) => eventEmitter.addListener(KEYBOARD_CONTROLLER_NAMESPACE + name, cb)
|
|
15
23
|
};
|
|
16
24
|
export const KeyboardControllerView = require("./specs/KeyboardControllerViewNativeComponent").default;
|
|
17
25
|
export const KeyboardGestureArea = Platform.OS === "android" && Platform.Version >= 30 ? require("./specs/KeyboardGestureAreaNativeComponent").default : _ref => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeEventEmitter","Platform","LINKING_ERROR","select","ios","default","RCTKeyboardController","require","KeyboardController","Proxy","get","Error","eventEmitter","KeyboardEvents","addListener","name","cb","KeyboardControllerView","KeyboardGestureArea","OS","Version","_ref","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(\
|
|
1
|
+
{"version":3,"names":["NativeEventEmitter","Platform","LINKING_ERROR","select","ios","default","RCTKeyboardController","require","KeyboardController","Proxy","get","Error","KEYBOARD_CONTROLLER_NAMESPACE","eventEmitter","KeyboardEvents","addListener","name","cb","FocusedInputEvents","KeyboardControllerView","KeyboardGestureArea","OS","Version","_ref","children"],"sources":["bindings.native.ts"],"sourcesContent":["import { NativeEventEmitter, Platform } from \"react-native\";\n\nimport type {\n FocusedInputEventsModule,\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 KEYBOARD_CONTROLLER_NAMESPACE = \"KeyboardController::\";\nconst eventEmitter = new NativeEventEmitter(KeyboardController);\n\nexport const KeyboardEvents: KeyboardEventsModule = {\n addListener: (name, cb) =>\n eventEmitter.addListener(KEYBOARD_CONTROLLER_NAMESPACE + name, cb),\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 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,SAASA,kBAAkB,EAAEC,QAAQ,QAAQ,cAAc;AAU3D,MAAMC,aAAa,GAChB,2FAA0F,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;AACrD,OAAO,MAAMG,kBAAkB,GAC7BF,qBAAqB,GACjBA,qBAAqB,GACrB,IAAIG,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACT,aAAa,CAAC;EAChC;AACF,CACF,CACuB;AAE7B,MAAMU,6BAA6B,GAAG,sBAAsB;AAC5D,MAAMC,YAAY,GAAG,IAAIb,kBAAkB,CAACQ,kBAAkB,CAAC;AAE/D,OAAO,MAAMM,cAAoC,GAAG;EAClDC,WAAW,EAAEA,CAACC,IAAI,EAAEC,EAAE,KACpBJ,YAAY,CAACE,WAAW,CAACH,6BAA6B,GAAGI,IAAI,EAAEC,EAAE;AACrE,CAAC;AACD;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,sBAAyD,GACpEZ,OAAO,CAAC,+CAA+C,CAAC,CAACF,OAAO;AAClE,OAAO,MAAMe,mBAAuD,GAClEnB,QAAQ,CAACoB,EAAE,KAAK,SAAS,IAAIpB,QAAQ,CAACqB,OAAO,IAAI,EAAE,GAC/Cf,OAAO,CAAC,4CAA4C,CAAC,CAACF,OAAO,GAC7DkB,IAAA;EAAA,IAAC;IAAEC;EAAmC,CAAC,GAAAD,IAAA;EAAA,OAAKC,QAAQ;AAAA"}
|
|
@@ -46,12 +46,14 @@ import { debounce } from "./utils";
|
|
|
46
46
|
const KeyboardAwareScrollView = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
47
47
|
let {
|
|
48
48
|
children,
|
|
49
|
+
onLayout,
|
|
49
50
|
bottomOffset = 0,
|
|
50
51
|
disableScrollOnKeyboardHide = false,
|
|
51
52
|
enabled = true,
|
|
52
53
|
...rest
|
|
53
54
|
} = _ref;
|
|
54
55
|
const scrollViewAnimatedRef = useAnimatedRef();
|
|
56
|
+
const scrollViewTarget = useSharedValue(null);
|
|
55
57
|
const scrollPosition = useSharedValue(0);
|
|
56
58
|
const position = useSharedValue(0);
|
|
57
59
|
const currentKeyboardFrameHeight = useSharedValue(0);
|
|
@@ -80,6 +82,10 @@ const KeyboardAwareScrollView = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
80
82
|
}
|
|
81
83
|
scrollViewAnimatedRef(assignedRef);
|
|
82
84
|
}, []);
|
|
85
|
+
const onScrollViewLayout = useCallback(e => {
|
|
86
|
+
scrollViewTarget.value = e.nativeEvent.target;
|
|
87
|
+
onLayout === null || onLayout === void 0 ? void 0 : onLayout(e);
|
|
88
|
+
}, [onLayout]);
|
|
83
89
|
|
|
84
90
|
/**
|
|
85
91
|
* Function that will scroll a ScrollView as keyboard gets moving
|
|
@@ -87,14 +93,19 @@ const KeyboardAwareScrollView = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
87
93
|
const maybeScroll = useCallback(function (e) {
|
|
88
94
|
"worklet";
|
|
89
95
|
|
|
90
|
-
var _layout$value, _layout$value2;
|
|
96
|
+
var _layout$value, _layout$value2, _layout$value3;
|
|
91
97
|
let animated = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
92
98
|
if (!enabled) {
|
|
93
99
|
return 0;
|
|
94
100
|
}
|
|
101
|
+
|
|
102
|
+
// input belongs to ScrollView
|
|
103
|
+
if (((_layout$value = layout.value) === null || _layout$value === void 0 ? void 0 : _layout$value.parentScrollViewTarget) !== scrollViewTarget.value) {
|
|
104
|
+
return 0;
|
|
105
|
+
}
|
|
95
106
|
const visibleRect = height - keyboardHeight.value;
|
|
96
|
-
const absoluteY = ((_layout$
|
|
97
|
-
const inputHeight = ((_layout$
|
|
107
|
+
const absoluteY = ((_layout$value2 = layout.value) === null || _layout$value2 === void 0 ? void 0 : _layout$value2.layout.absoluteY) || 0;
|
|
108
|
+
const inputHeight = ((_layout$value3 = layout.value) === null || _layout$value3 === void 0 ? void 0 : _layout$value3.layout.height) || 0;
|
|
98
109
|
const point = absoluteY + inputHeight;
|
|
99
110
|
if (visibleRect - point <= bottomOffset) {
|
|
100
111
|
const interpolatedScrollTo = interpolate(e, [initialKeyboardSize.value, keyboardHeight.value], [0, keyboardHeight.value - (height - point) + bottomOffset]);
|
|
@@ -114,8 +125,8 @@ const KeyboardAwareScrollView = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
114
125
|
|
|
115
126
|
// if typing a text caused layout shift, then we need to ignore this handler
|
|
116
127
|
// because this event will be handled in `useAnimatedReaction` below
|
|
117
|
-
var _layout$
|
|
118
|
-
if (((_layout$
|
|
128
|
+
var _layout$value4, _input$value;
|
|
129
|
+
if (((_layout$value4 = layout.value) === null || _layout$value4 === void 0 ? void 0 : _layout$value4.layout.height) !== ((_input$value = input.value) === null || _input$value === void 0 ? void 0 : _input$value.layout.height)) {
|
|
119
130
|
return;
|
|
120
131
|
}
|
|
121
132
|
const prevScrollPosition = scrollPosition.value;
|
|
@@ -206,7 +217,8 @@ const KeyboardAwareScrollView = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
206
217
|
return /*#__PURE__*/React.createElement(Reanimated.ScrollView, _extends({
|
|
207
218
|
ref: onRef
|
|
208
219
|
}, rest, {
|
|
209
|
-
// @ts-expect-error
|
|
220
|
+
// @ts-expect-error https://github.com/facebook/react-native/pull/42785
|
|
221
|
+
onLayout: onScrollViewLayout,
|
|
210
222
|
onScrollReanimated: onScroll,
|
|
211
223
|
scrollEventThrottle: 16
|
|
212
224
|
}), children, /*#__PURE__*/React.createElement(Reanimated.View, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","forwardRef","useCallback","useMemo","useWindowDimensions","Reanimated","interpolate","scrollTo","useAnimatedReaction","useAnimatedRef","useAnimatedScrollHandler","useAnimatedStyle","useSharedValue","useFocusedInputHandler","useReanimatedFocusedInput","useSmoothKeyboardHandler","debounce","KeyboardAwareScrollView","_ref","ref","children","bottomOffset","disableScrollOnKeyboardHide","enabled","rest","scrollViewAnimatedRef","scrollPosition","position","currentKeyboardFrameHeight","keyboardHeight","keyboardWillAppear","tag","initialKeyboardSize","scrollBeforeKeyboardMovement","input","layout","height","onScroll","e","value","contentOffset","y","onRef","assignedRef","current","maybeScroll","_layout$value","_layout$value2","animated","arguments","length","undefined","visibleRect","absoluteY","inputHeight","point","interpolatedScrollTo","targetScrollY","Math","max","positionOnScreen","topOfScreen","onChangeText","_layout$value3","_input$value","prevScrollPosition","prevLayout","onChangeTextHandler","onStart","keyboardWillChangeSize","keyboardWillHide","focusWasChanged","target","onMove","onEnd","previous","view","paddingBottom","createElement","ScrollView","_extends","onScrollReanimated","scrollEventThrottle","View","style"],"sources":["index.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useMemo } from \"react\";\nimport { useWindowDimensions } from \"react-native\";\nimport Reanimated, {\n interpolate,\n scrollTo,\n useAnimatedReaction,\n useAnimatedRef,\n useAnimatedScrollHandler,\n useAnimatedStyle,\n useSharedValue,\n} from \"react-native-reanimated\";\n\nimport {\n useFocusedInputHandler,\n useReanimatedFocusedInput,\n} from \"react-native-keyboard-controller\";\n\nimport { useSmoothKeyboardHandler } from \"./useSmoothKeyboardHandler\";\nimport { debounce } from \"./utils\";\n\nimport type { ScrollView, ScrollViewProps } from \"react-native\";\nimport type { FocusedInputLayoutChangedEvent } from \"react-native-keyboard-controller\";\n\ntype KeyboardAwareScrollViewProps = {\n /** The distance between keyboard and focused `TextInput` when keyboard is shown. Default is `0`. */\n bottomOffset?: number;\n /** Prevents automatic scrolling of the `ScrollView` when the keyboard gets hidden, maintaining the current screen position. Default is `false`. */\n disableScrollOnKeyboardHide?: boolean;\n /** Controls whether this `KeyboardAwareScrollView` instance should take effect. Default is `true` */\n enabled?: boolean;\n} & ScrollViewProps;\n\n/*\n * Everything begins from `onStart` handler. This handler is called every time,\n * when keyboard changes its size or when focused `TextInput` was changed. In\n * this handler we are calculating/memoizing values which later will be used\n * during layout movement. For that we calculate:\n * - layout of focused field (`layout`) - to understand whether there will be overlap\n * - initial keyboard size (`initialKeyboardSize`) - used in scroll interpolation\n * - future keyboard height (`keyboardHeight`) - used in scroll interpolation\n * - current scroll position (`scrollPosition`) - used to scroll from this point\n *\n * Once we've calculated all necessary variables - we can actually start to use them.\n * It happens in `onMove` handler - this function simply calls `maybeScroll` with\n * current keyboard frame height. This functions makes the smooth transition.\n *\n * When the transition has finished we go to `onEnd` handler. In this handler\n * we verify, that the current field is not overlapped within a keyboard frame.\n * For full `onStart`/`onMove`/`onEnd` flow it may look like a redundant thing,\n * however there could be some cases, when `onMove` is not called:\n * - on iOS when TextInput was changed - keyboard transition is instant\n * - on Android when TextInput was changed and keyboard size wasn't changed\n * So `onEnd` handler handle the case, when `onMove` wasn't triggered.\n *\n * ====================================================================================================================+\n * -----------------------------------------------------Flow chart-----------------------------------------------------+\n * ====================================================================================================================+\n *\n * +============================+ +============================+ +==================================+\n * + User Press on TextInput + => + Keyboard starts showing + => + As keyboard moves frame by frame + =>\n * + + + (run `onStart`) + + `onMove` is getting called +\n * +============================+ +============================+ +==================================+\n *\n *\n * +============================+ +============================+ +=====================================+\n * + Keyboard is shown and we + => + User moved focus to + => + Only `onStart`/`onEnd` maybe called +\n * + call `onEnd` handler + + another `TextInput` + + (without involving `onMove`) +\n * +============================+ +============================+ +=====================================+\n *\n */\nconst KeyboardAwareScrollView = forwardRef<\n ScrollView,\n React.PropsWithChildren<KeyboardAwareScrollViewProps>\n>(\n (\n {\n children,\n bottomOffset = 0,\n disableScrollOnKeyboardHide = false,\n enabled = true,\n ...rest\n },\n ref,\n ) => {\n const scrollViewAnimatedRef = useAnimatedRef<Reanimated.ScrollView>();\n const scrollPosition = useSharedValue(0);\n const position = useSharedValue(0);\n const currentKeyboardFrameHeight = useSharedValue(0);\n const keyboardHeight = useSharedValue(0);\n const keyboardWillAppear = useSharedValue(false);\n const tag = useSharedValue(-1);\n const initialKeyboardSize = useSharedValue(0);\n const scrollBeforeKeyboardMovement = useSharedValue(0);\n const { input } = useReanimatedFocusedInput();\n const layout = useSharedValue<FocusedInputLayoutChangedEvent | null>(null);\n\n const { height } = useWindowDimensions();\n\n const onScroll = useAnimatedScrollHandler(\n {\n onScroll: (e) => {\n position.value = e.contentOffset.y;\n },\n },\n [],\n );\n\n const onRef = useCallback((assignedRef: Reanimated.ScrollView) => {\n if (typeof ref === \"function\") {\n ref(assignedRef);\n } else if (ref) {\n ref.current = assignedRef;\n }\n\n scrollViewAnimatedRef(assignedRef);\n }, []);\n\n /**\n * Function that will scroll a ScrollView as keyboard gets moving\n */\n const maybeScroll = useCallback(\n (e: number, animated: boolean = false) => {\n \"worklet\";\n\n if (!enabled) {\n return 0;\n }\n\n const visibleRect = height - keyboardHeight.value;\n const absoluteY = layout.value?.layout.absoluteY || 0;\n const inputHeight = layout.value?.layout.height || 0;\n const point = absoluteY + inputHeight;\n\n if (visibleRect - point <= bottomOffset) {\n const interpolatedScrollTo = interpolate(\n e,\n [initialKeyboardSize.value, keyboardHeight.value],\n [0, keyboardHeight.value - (height - point) + bottomOffset],\n );\n const targetScrollY =\n Math.max(interpolatedScrollTo, 0) + scrollPosition.value;\n scrollTo(scrollViewAnimatedRef, 0, targetScrollY, animated);\n\n return interpolatedScrollTo;\n }\n\n if (absoluteY < 0) {\n const positionOnScreen = visibleRect - inputHeight - bottomOffset;\n const topOfScreen = scrollPosition.value + absoluteY;\n\n scrollTo(\n scrollViewAnimatedRef,\n 0,\n topOfScreen - positionOnScreen,\n animated,\n );\n }\n\n return 0;\n },\n [bottomOffset, enabled],\n );\n\n const onChangeText = useCallback(() => {\n \"worklet\";\n\n // if typing a text caused layout shift, then we need to ignore this handler\n // because this event will be handled in `useAnimatedReaction` below\n if (layout.value?.layout.height !== input.value?.layout.height) {\n return;\n }\n\n const prevScrollPosition = scrollPosition.value;\n const prevLayout = layout.value;\n\n scrollPosition.value = position.value;\n layout.value = input.value;\n maybeScroll(keyboardHeight.value, true);\n scrollPosition.value = prevScrollPosition;\n layout.value = prevLayout;\n }, [maybeScroll]);\n\n const onChangeTextHandler = useMemo(\n () => debounce(onChangeText, 200),\n [onChangeText],\n );\n\n useFocusedInputHandler(\n {\n onChangeText: onChangeTextHandler,\n },\n [onChangeTextHandler],\n );\n\n useSmoothKeyboardHandler(\n enabled\n ? {\n onStart: (e) => {\n \"worklet\";\n\n const keyboardWillChangeSize =\n keyboardHeight.value !== e.height && e.height > 0;\n keyboardWillAppear.value =\n e.height > 0 && keyboardHeight.value === 0;\n const keyboardWillHide = e.height === 0;\n const focusWasChanged =\n (tag.value !== e.target && e.target !== -1) ||\n keyboardWillChangeSize;\n\n if (keyboardWillChangeSize) {\n initialKeyboardSize.value = keyboardHeight.value;\n }\n\n if (keyboardWillHide) {\n // on back transition need to interpolate as [0, keyboardHeight]\n initialKeyboardSize.value = 0;\n scrollPosition.value = scrollBeforeKeyboardMovement.value;\n }\n\n if (\n keyboardWillAppear.value ||\n keyboardWillChangeSize ||\n focusWasChanged\n ) {\n // persist scroll value\n scrollPosition.value = position.value;\n // just persist height - later will be used in interpolation\n keyboardHeight.value = e.height;\n }\n\n // focus was changed\n if (focusWasChanged) {\n tag.value = e.target;\n\n // save position of focused text input when keyboard starts to move\n layout.value = input.value;\n // save current scroll position - when keyboard will hide we'll reuse\n // this value to achieve smooth hide effect\n scrollBeforeKeyboardMovement.value = position.value;\n }\n\n if (focusWasChanged && !keyboardWillAppear.value) {\n // update position on scroll value, so `onEnd` handler\n // will pick up correct values\n position.value += maybeScroll(e.height, true);\n }\n },\n onMove: (e) => {\n \"worklet\";\n\n currentKeyboardFrameHeight.value = e.height;\n\n // if the user has set disableScrollOnKeyboardHide, only auto-scroll when the keyboard opens\n if (!disableScrollOnKeyboardHide || keyboardWillAppear.value) {\n maybeScroll(e.height);\n }\n },\n onEnd: (e) => {\n \"worklet\";\n\n keyboardHeight.value = e.height;\n scrollPosition.value = position.value;\n },\n }\n : {},\n [height, maybeScroll, disableScrollOnKeyboardHide, enabled],\n );\n\n useAnimatedReaction(\n () => input.value,\n (current, previous) => {\n if (\n current?.target === previous?.target &&\n current?.layout.height !== previous?.layout.height\n ) {\n const prevLayout = layout.value;\n\n layout.value = input.value;\n scrollPosition.value += maybeScroll(keyboardHeight.value, true);\n layout.value = prevLayout;\n }\n },\n [],\n );\n\n const view = useAnimatedStyle(\n () => ({\n // animations become laggy when scrolling to the end of the `ScrollView` (when the last input is focused)\n // this happens because the layout recalculates on every frame. To avoid this we slightly increase padding\n // by `+1`. In this way we assure, that `scrollTo` will never scroll to the end, because it uses interpolation\n // from 0 to `keyboardHeight`, and here our padding is `keyboardHeight + 1`. It allows us not to re-run layout\n // re-calculation on every animation frame and it helps to achieve smooth animation.\n // see: https://github.com/kirillzyusko/react-native-keyboard-controller/pull/342\n paddingBottom: currentKeyboardFrameHeight.value + 1,\n }),\n [],\n );\n\n return (\n <Reanimated.ScrollView\n ref={onRef}\n {...rest}\n // @ts-expect-error `onScrollReanimated` is a fake prop needed for reanimated to intercept scroll events\n onScrollReanimated={onScroll}\n scrollEventThrottle={16}\n >\n {children}\n <Reanimated.View style={view} />\n </Reanimated.ScrollView>\n );\n },\n);\n\nexport default KeyboardAwareScrollView;\n"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,UAAU,EAAEC,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAC/D,SAASC,mBAAmB,QAAQ,cAAc;AAClD,OAAOC,UAAU,IACfC,WAAW,EACXC,QAAQ,EACRC,mBAAmB,EACnBC,cAAc,EACdC,wBAAwB,EACxBC,gBAAgB,EAChBC,cAAc,QACT,yBAAyB;AAEhC,SACEC,sBAAsB,EACtBC,yBAAyB,QACpB,kCAAkC;AAEzC,SAASC,wBAAwB,QAAQ,4BAA4B;AACrE,SAASC,QAAQ,QAAQ,SAAS;AAclC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,uBAAuB,gBAAGhB,UAAU,CAIxC,CAAAiB,IAAA,EAQEC,GAAG,KACA;EAAA,IARH;IACEC,QAAQ;IACRC,YAAY,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EAED,oBACEvC,KAAA,CAAA8E,aAAA,CAACzE,UAAU,CAAC0E,UAAU,EAAAC,QAAA;IACpB7D,GAAG,EAAEuB;EAAM,GACPlB,IAAI;IACR;IACAyD,kBAAkB,EAAE5C,QAAS;IAC7B6C,mBAAmB,EAAE;EAAG,IAEvB9D,QAAQ,eACTpB,KAAA,CAAA8E,aAAA,CAACzE,UAAU,CAAC8E,IAAI;IAACC,KAAK,EAAER;EAAK,CAAE,CACV,CAAC;AAE5B,CACF,CAAC;AAED,eAAe3D,uBAAuB"}
|
|
1
|
+
{"version":3,"names":["React","forwardRef","useCallback","useMemo","useWindowDimensions","Reanimated","interpolate","scrollTo","useAnimatedReaction","useAnimatedRef","useAnimatedScrollHandler","useAnimatedStyle","useSharedValue","useFocusedInputHandler","useReanimatedFocusedInput","useSmoothKeyboardHandler","debounce","KeyboardAwareScrollView","_ref","ref","children","onLayout","bottomOffset","disableScrollOnKeyboardHide","enabled","rest","scrollViewAnimatedRef","scrollViewTarget","scrollPosition","position","currentKeyboardFrameHeight","keyboardHeight","keyboardWillAppear","tag","initialKeyboardSize","scrollBeforeKeyboardMovement","input","layout","height","onScroll","e","value","contentOffset","y","onRef","assignedRef","current","onScrollViewLayout","nativeEvent","target","maybeScroll","_layout$value","_layout$value2","_layout$value3","animated","arguments","length","undefined","parentScrollViewTarget","visibleRect","absoluteY","inputHeight","point","interpolatedScrollTo","targetScrollY","Math","max","positionOnScreen","topOfScreen","onChangeText","_layout$value4","_input$value","prevScrollPosition","prevLayout","onChangeTextHandler","onStart","keyboardWillChangeSize","keyboardWillHide","focusWasChanged","onMove","onEnd","previous","view","paddingBottom","createElement","ScrollView","_extends","onScrollReanimated","scrollEventThrottle","View","style"],"sources":["index.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useMemo } from \"react\";\nimport { useWindowDimensions } from \"react-native\";\nimport Reanimated, {\n interpolate,\n scrollTo,\n useAnimatedReaction,\n useAnimatedRef,\n useAnimatedScrollHandler,\n useAnimatedStyle,\n useSharedValue,\n} from \"react-native-reanimated\";\n\nimport {\n useFocusedInputHandler,\n useReanimatedFocusedInput,\n} from \"react-native-keyboard-controller\";\n\nimport { useSmoothKeyboardHandler } from \"./useSmoothKeyboardHandler\";\nimport { debounce } from \"./utils\";\n\nimport type {\n LayoutChangeEvent,\n ScrollView,\n ScrollViewProps,\n} from \"react-native\";\nimport type { FocusedInputLayoutChangedEvent } from \"react-native-keyboard-controller\";\n\ntype KeyboardAwareScrollViewProps = {\n /** The distance between keyboard and focused `TextInput` when keyboard is shown. Default is `0`. */\n bottomOffset?: number;\n /** Prevents automatic scrolling of the `ScrollView` when the keyboard gets hidden, maintaining the current screen position. Default is `false`. */\n disableScrollOnKeyboardHide?: boolean;\n /** Controls whether this `KeyboardAwareScrollView` instance should take effect. Default is `true` */\n enabled?: boolean;\n} & ScrollViewProps;\n\n/*\n * Everything begins from `onStart` handler. This handler is called every time,\n * when keyboard changes its size or when focused `TextInput` was changed. In\n * this handler we are calculating/memoizing values which later will be used\n * during layout movement. For that we calculate:\n * - layout of focused field (`layout`) - to understand whether there will be overlap\n * - initial keyboard size (`initialKeyboardSize`) - used in scroll interpolation\n * - future keyboard height (`keyboardHeight`) - used in scroll interpolation\n * - current scroll position (`scrollPosition`) - used to scroll from this point\n *\n * Once we've calculated all necessary variables - we can actually start to use them.\n * It happens in `onMove` handler - this function simply calls `maybeScroll` with\n * current keyboard frame height. This functions makes the smooth transition.\n *\n * When the transition has finished we go to `onEnd` handler. In this handler\n * we verify, that the current field is not overlapped within a keyboard frame.\n * For full `onStart`/`onMove`/`onEnd` flow it may look like a redundant thing,\n * however there could be some cases, when `onMove` is not called:\n * - on iOS when TextInput was changed - keyboard transition is instant\n * - on Android when TextInput was changed and keyboard size wasn't changed\n * So `onEnd` handler handle the case, when `onMove` wasn't triggered.\n *\n * ====================================================================================================================+\n * -----------------------------------------------------Flow chart-----------------------------------------------------+\n * ====================================================================================================================+\n *\n * +============================+ +============================+ +==================================+\n * + User Press on TextInput + => + Keyboard starts showing + => + As keyboard moves frame by frame + =>\n * + + + (run `onStart`) + + `onMove` is getting called +\n * +============================+ +============================+ +==================================+\n *\n *\n * +============================+ +============================+ +=====================================+\n * + Keyboard is shown and we + => + User moved focus to + => + Only `onStart`/`onEnd` maybe called +\n * + call `onEnd` handler + + another `TextInput` + + (without involving `onMove`) +\n * +============================+ +============================+ +=====================================+\n *\n */\nconst KeyboardAwareScrollView = forwardRef<\n ScrollView,\n React.PropsWithChildren<KeyboardAwareScrollViewProps>\n>(\n (\n {\n children,\n onLayout,\n bottomOffset = 0,\n disableScrollOnKeyboardHide = false,\n enabled = true,\n ...rest\n },\n ref,\n ) => {\n const scrollViewAnimatedRef = useAnimatedRef<Reanimated.ScrollView>();\n const scrollViewTarget = useSharedValue<number | null>(null);\n const scrollPosition = useSharedValue(0);\n const position = useSharedValue(0);\n const currentKeyboardFrameHeight = useSharedValue(0);\n const keyboardHeight = useSharedValue(0);\n const keyboardWillAppear = useSharedValue(false);\n const tag = useSharedValue(-1);\n const initialKeyboardSize = useSharedValue(0);\n const scrollBeforeKeyboardMovement = useSharedValue(0);\n const { input } = useReanimatedFocusedInput();\n const layout = useSharedValue<FocusedInputLayoutChangedEvent | null>(null);\n\n const { height } = useWindowDimensions();\n\n const onScroll = useAnimatedScrollHandler(\n {\n onScroll: (e) => {\n position.value = e.contentOffset.y;\n },\n },\n [],\n );\n\n const onRef = useCallback((assignedRef: Reanimated.ScrollView) => {\n if (typeof ref === \"function\") {\n ref(assignedRef);\n } else if (ref) {\n ref.current = assignedRef;\n }\n\n scrollViewAnimatedRef(assignedRef);\n }, []);\n const onScrollViewLayout = useCallback(\n (e: LayoutChangeEvent & { nativeEvent: { target: number } }) => {\n scrollViewTarget.value = e.nativeEvent.target;\n\n onLayout?.(e);\n },\n [onLayout],\n );\n\n /**\n * Function that will scroll a ScrollView as keyboard gets moving\n */\n const maybeScroll = useCallback(\n (e: number, animated: boolean = false) => {\n \"worklet\";\n\n if (!enabled) {\n return 0;\n }\n\n // input belongs to ScrollView\n if (layout.value?.parentScrollViewTarget !== scrollViewTarget.value) {\n return 0;\n }\n\n const visibleRect = height - keyboardHeight.value;\n const absoluteY = layout.value?.layout.absoluteY || 0;\n const inputHeight = layout.value?.layout.height || 0;\n const point = absoluteY + inputHeight;\n\n if (visibleRect - point <= bottomOffset) {\n const interpolatedScrollTo = interpolate(\n e,\n [initialKeyboardSize.value, keyboardHeight.value],\n [0, keyboardHeight.value - (height - point) + bottomOffset],\n );\n const targetScrollY =\n Math.max(interpolatedScrollTo, 0) + scrollPosition.value;\n scrollTo(scrollViewAnimatedRef, 0, targetScrollY, animated);\n\n return interpolatedScrollTo;\n }\n\n if (absoluteY < 0) {\n const positionOnScreen = visibleRect - inputHeight - bottomOffset;\n const topOfScreen = scrollPosition.value + absoluteY;\n\n scrollTo(\n scrollViewAnimatedRef,\n 0,\n topOfScreen - positionOnScreen,\n animated,\n );\n }\n\n return 0;\n },\n [bottomOffset, enabled],\n );\n\n const onChangeText = useCallback(() => {\n \"worklet\";\n\n // if typing a text caused layout shift, then we need to ignore this handler\n // because this event will be handled in `useAnimatedReaction` below\n if (layout.value?.layout.height !== input.value?.layout.height) {\n return;\n }\n\n const prevScrollPosition = scrollPosition.value;\n const prevLayout = layout.value;\n\n scrollPosition.value = position.value;\n layout.value = input.value;\n maybeScroll(keyboardHeight.value, true);\n scrollPosition.value = prevScrollPosition;\n layout.value = prevLayout;\n }, [maybeScroll]);\n\n const onChangeTextHandler = useMemo(\n () => debounce(onChangeText, 200),\n [onChangeText],\n );\n\n useFocusedInputHandler(\n {\n onChangeText: onChangeTextHandler,\n },\n [onChangeTextHandler],\n );\n\n useSmoothKeyboardHandler(\n enabled\n ? {\n onStart: (e) => {\n \"worklet\";\n\n const keyboardWillChangeSize =\n keyboardHeight.value !== e.height && e.height > 0;\n keyboardWillAppear.value =\n e.height > 0 && keyboardHeight.value === 0;\n const keyboardWillHide = e.height === 0;\n const focusWasChanged =\n (tag.value !== e.target && e.target !== -1) ||\n keyboardWillChangeSize;\n\n if (keyboardWillChangeSize) {\n initialKeyboardSize.value = keyboardHeight.value;\n }\n\n if (keyboardWillHide) {\n // on back transition need to interpolate as [0, keyboardHeight]\n initialKeyboardSize.value = 0;\n scrollPosition.value = scrollBeforeKeyboardMovement.value;\n }\n\n if (\n keyboardWillAppear.value ||\n keyboardWillChangeSize ||\n focusWasChanged\n ) {\n // persist scroll value\n scrollPosition.value = position.value;\n // just persist height - later will be used in interpolation\n keyboardHeight.value = e.height;\n }\n\n // focus was changed\n if (focusWasChanged) {\n tag.value = e.target;\n\n // save position of focused text input when keyboard starts to move\n layout.value = input.value;\n // save current scroll position - when keyboard will hide we'll reuse\n // this value to achieve smooth hide effect\n scrollBeforeKeyboardMovement.value = position.value;\n }\n\n if (focusWasChanged && !keyboardWillAppear.value) {\n // update position on scroll value, so `onEnd` handler\n // will pick up correct values\n position.value += maybeScroll(e.height, true);\n }\n },\n onMove: (e) => {\n \"worklet\";\n\n currentKeyboardFrameHeight.value = e.height;\n\n // if the user has set disableScrollOnKeyboardHide, only auto-scroll when the keyboard opens\n if (!disableScrollOnKeyboardHide || keyboardWillAppear.value) {\n maybeScroll(e.height);\n }\n },\n onEnd: (e) => {\n \"worklet\";\n\n keyboardHeight.value = e.height;\n scrollPosition.value = position.value;\n },\n }\n : {},\n [height, maybeScroll, disableScrollOnKeyboardHide, enabled],\n );\n\n useAnimatedReaction(\n () => input.value,\n (current, previous) => {\n if (\n current?.target === previous?.target &&\n current?.layout.height !== previous?.layout.height\n ) {\n const prevLayout = layout.value;\n\n layout.value = input.value;\n scrollPosition.value += maybeScroll(keyboardHeight.value, true);\n layout.value = prevLayout;\n }\n },\n [],\n );\n\n const view = useAnimatedStyle(\n () => ({\n // animations become laggy when scrolling to the end of the `ScrollView` (when the last input is focused)\n // this happens because the layout recalculates on every frame. To avoid this we slightly increase padding\n // by `+1`. In this way we assure, that `scrollTo` will never scroll to the end, because it uses interpolation\n // from 0 to `keyboardHeight`, and here our padding is `keyboardHeight + 1`. It allows us not to re-run layout\n // re-calculation on every animation frame and it helps to achieve smooth animation.\n // see: https://github.com/kirillzyusko/react-native-keyboard-controller/pull/342\n paddingBottom: currentKeyboardFrameHeight.value + 1,\n }),\n [],\n );\n\n return (\n <Reanimated.ScrollView\n ref={onRef}\n {...rest}\n // @ts-expect-error https://github.com/facebook/react-native/pull/42785\n onLayout={onScrollViewLayout}\n onScrollReanimated={onScroll}\n scrollEventThrottle={16}\n >\n {children}\n <Reanimated.View style={view} />\n </Reanimated.ScrollView>\n );\n },\n);\n\nexport default KeyboardAwareScrollView;\n"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,UAAU,EAAEC,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAC/D,SAASC,mBAAmB,QAAQ,cAAc;AAClD,OAAOC,UAAU,IACfC,WAAW,EACXC,QAAQ,EACRC,mBAAmB,EACnBC,cAAc,EACdC,wBAAwB,EACxBC,gBAAgB,EAChBC,cAAc,QACT,yBAAyB;AAEhC,SACEC,sBAAsB,EACtBC,yBAAyB,QACpB,kCAAkC;AAEzC,SAASC,wBAAwB,QAAQ,4BAA4B;AACrE,SAASC,QAAQ,QAAQ,SAAS;AAkBlC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,uBAAuB,gBAAGhB,UAAU,CAIxC,CAAAiB,IAAA,EASEC,GAAG,KACA;EAAA,IATH;IACEC,QAAQ;IACRC,QAAQ;IACRC,YAAY,GAAG,CAAC;IAChBC,2BAA2B,GAAG,KAAK;IACnCC,OAAO,GAAG,IAAI;IACd,GAAGC;EACL,CAAC,GAAAP,IAAA;EAGD,MAAMQ,qBAAqB,GAAGjB,cAAc,CAAwB,CAAC;EACrE,MAAMkB,gBA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IAAIS,WAAW,CAACnB,cAAc,CAACU,KAAK,EAAE,IAAI,CAAC;MAC/DJ,MAAM,CAACI,KAAK,GAAGgC,UAAU;IAC3B;EACF,CAAC,EACD,EACF,CAAC;EAED,MAAMS,IAAI,GAAGvE,gBAAgB,CAC3B,OAAO;IACL;IACA;IACA;IACA;IACA;IACA;IACAwE,aAAa,EAAErD,0BAA0B,CAACW,KAAK,GAAG;EACpD,CAAC,CAAC,EACF,EACF,CAAC;EAED,oBACEzC,KAAA,CAAAoF,aAAA,CAAC/E,UAAU,CAACgF,UAAU,EAAAC,QAAA;IACpBnE,GAAG,EAAEyB;EAAM,GACPnB,IAAI;IACR;IACAJ,QAAQ,EAAE0B,kBAAmB;IAC7BwC,kBAAkB,EAAEhD,QAAS;IAC7BiD,mBAAmB,EAAE;EAAG,IAEvBpE,QAAQ,eACTpB,KAAA,CAAAoF,aAAA,CAAC/E,UAAU,CAACoF,IAAI;IAACC,KAAK,EAAER;EAAK,CAAE,CACV,CAAC;AAE5B,CACF,CAAC;AAED,eAAejE,uBAAuB"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import React, { useMemo } from "react";
|
|
2
|
+
import { Animated, StyleSheet, View } from "react-native";
|
|
3
|
+
import useColorScheme from "../hooks/useColorScheme";
|
|
4
|
+
const ArrowComponent = _ref => {
|
|
5
|
+
let {
|
|
6
|
+
type,
|
|
7
|
+
disabled,
|
|
8
|
+
theme
|
|
9
|
+
} = _ref;
|
|
10
|
+
const colorScheme = useColorScheme();
|
|
11
|
+
const color = useMemo(() => ({
|
|
12
|
+
backgroundColor: disabled ? theme[colorScheme].disabled : theme[colorScheme].primary
|
|
13
|
+
}), [disabled, theme, colorScheme]);
|
|
14
|
+
const left = useMemo(() => [styles.arrowLeftLine, color], [color]);
|
|
15
|
+
const right = useMemo(() => [styles.arrowRightLine, color], [color]);
|
|
16
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
17
|
+
style: type === "next" ? styles.arrowDownContainer : styles.arrowUpContainer
|
|
18
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
19
|
+
style: styles.arrow
|
|
20
|
+
}, /*#__PURE__*/React.createElement(Animated.View, {
|
|
21
|
+
style: left
|
|
22
|
+
}), /*#__PURE__*/React.createElement(Animated.View, {
|
|
23
|
+
style: right
|
|
24
|
+
})));
|
|
25
|
+
};
|
|
26
|
+
const arrowLine = {
|
|
27
|
+
width: 13,
|
|
28
|
+
height: 2,
|
|
29
|
+
borderRadius: 1
|
|
30
|
+
};
|
|
31
|
+
const arrowUpContainer = {
|
|
32
|
+
marginHorizontal: 5,
|
|
33
|
+
width: 30,
|
|
34
|
+
height: 30,
|
|
35
|
+
justifyContent: "center",
|
|
36
|
+
alignItems: "center"
|
|
37
|
+
};
|
|
38
|
+
const styles = StyleSheet.create({
|
|
39
|
+
arrowUpContainer: arrowUpContainer,
|
|
40
|
+
arrowDownContainer: {
|
|
41
|
+
...arrowUpContainer,
|
|
42
|
+
transform: [{
|
|
43
|
+
rotate: "180deg"
|
|
44
|
+
}]
|
|
45
|
+
},
|
|
46
|
+
arrow: {
|
|
47
|
+
width: 20,
|
|
48
|
+
height: 20,
|
|
49
|
+
flexDirection: "row",
|
|
50
|
+
alignItems: "center",
|
|
51
|
+
justifyContent: "space-between"
|
|
52
|
+
},
|
|
53
|
+
arrowLeftLine: {
|
|
54
|
+
...arrowLine,
|
|
55
|
+
transform: [{
|
|
56
|
+
rotate: "-45deg"
|
|
57
|
+
}],
|
|
58
|
+
left: -0.5
|
|
59
|
+
},
|
|
60
|
+
arrowRightLine: {
|
|
61
|
+
...arrowLine,
|
|
62
|
+
transform: [{
|
|
63
|
+
rotate: "45deg"
|
|
64
|
+
}],
|
|
65
|
+
left: -5.5
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
export default ArrowComponent;
|
|
69
|
+
//# sourceMappingURL=Arrow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useMemo","Animated","StyleSheet","View","useColorScheme","ArrowComponent","_ref","type","disabled","theme","colorScheme","color","backgroundColor","primary","left","styles","arrowLeftLine","right","arrowRightLine","createElement","style","arrowDownContainer","arrowUpContainer","arrow","arrowLine","width","height","borderRadius","marginHorizontal","justifyContent","alignItems","create","transform","rotate","flexDirection"],"sources":["Arrow.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport { Animated, StyleSheet, View } from \"react-native\";\n\nimport useColorScheme from \"../hooks/useColorScheme\";\n\nimport type { KeyboardToolbarTheme } from \"./colors\";\nimport type { ViewStyle } from \"react-native\";\n\ntype ArrowProps = {\n type: \"prev\" | \"next\";\n disabled?: boolean;\n theme: KeyboardToolbarTheme;\n};\n\nconst ArrowComponent: React.FC<ArrowProps> = ({ type, disabled, theme }) => {\n const colorScheme = useColorScheme();\n\n const color = useMemo(\n () => ({\n backgroundColor: disabled\n ? theme[colorScheme].disabled\n : theme[colorScheme].primary,\n }),\n [disabled, theme, colorScheme],\n );\n const left = useMemo(() => [styles.arrowLeftLine, color], [color]);\n const right = useMemo(() => [styles.arrowRightLine, color], [color]);\n\n return (\n <View\n style={\n type === \"next\" ? styles.arrowDownContainer : styles.arrowUpContainer\n }\n >\n <View style={styles.arrow}>\n <Animated.View style={left} />\n <Animated.View style={right} />\n </View>\n </View>\n );\n};\n\nconst arrowLine: ViewStyle = {\n width: 13,\n height: 2,\n borderRadius: 1,\n};\nconst arrowUpContainer: ViewStyle = {\n marginHorizontal: 5,\n width: 30,\n height: 30,\n justifyContent: \"center\",\n alignItems: \"center\",\n};\nconst styles = StyleSheet.create({\n arrowUpContainer: arrowUpContainer,\n arrowDownContainer: {\n ...arrowUpContainer,\n transform: [{ rotate: \"180deg\" }],\n },\n arrow: {\n width: 20,\n height: 20,\n flexDirection: \"row\",\n alignItems: \"center\",\n justifyContent: \"space-between\",\n },\n arrowLeftLine: {\n ...arrowLine,\n transform: [{ rotate: \"-45deg\" }],\n left: -0.5,\n },\n arrowRightLine: {\n ...arrowLine,\n transform: [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AM,CAAE,CAC1B,CACF,CAAC;AAEX,CAAC;AAED,MAAMO,SAAoB,GAAG;EAC3BC,KAAK,EAAE,EAAE;EACTC,MAAM,EAAE,CAAC;EACTC,YAAY,EAAE;AAChB,CAAC;AACD,MAAML,gBAA2B,GAAG;EAClCM,gBAAgB,EAAE,CAAC;EACnBH,KAAK,EAAE,EAAE;EACTC,MAAM,EAAE,EAAE;EACVG,cAAc,EAAE,QAAQ;EACxBC,UAAU,EAAE;AACd,CAAC;AACD,MAAMf,MAAM,GAAGb,UAAU,CAAC6B,MAAM,CAAC;EAC/BT,gBAAgB,EAAEA,gBAAgB;EAClCD,kBAAkB,EAAE;IAClB,GAAGC,gBAAgB;IACnBU,SAAS,EAAE,CAAC;MAAEC,MAAM,EAAE;IAAS,CAAC;EAClC,CAAC;EACDV,KAAK,EAAE;IACLE,KAAK,EAAE,EAAE;IACTC,MAAM,EAAE,EAAE;IACVQ,aAAa,EAAE,KAAK;IACpBJ,UAAU,EAAE,QAAQ;IACpBD,cAAc,EAAE;EAClB,CAAC;EACDb,aAAa,EAAE;IACb,GAAGQ,SAAS;IACZQ,SAAS,EAAE,CAAC;MAAEC,MAAM,EAAE;IAAS,CAAC,CAAC;IACjCnB,IAAI,EAAE,CAAC;EACT,CAAC;EACDI,cAAc,EAAE;IACd,GAAGM,SAAS;IACZQ,SAAS,EAAE,CAAC;MAAEC,MAAM,EAAE;IAAQ,CAAC,CAAC;IAChCnB,IAAI,EAAE,CAAC;EACT;AACF,CAAC,CAAC;AAEF,eAAeT,cAAc"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import React, { useMemo } from "react";
|
|
2
|
+
import { Platform, TouchableNativeFeedback, TouchableOpacity, View } from "react-native";
|
|
3
|
+
import useColorScheme from "../hooks/useColorScheme";
|
|
4
|
+
const ButtonIOS = _ref => {
|
|
5
|
+
let {
|
|
6
|
+
children,
|
|
7
|
+
onPress,
|
|
8
|
+
disabled,
|
|
9
|
+
accessibilityLabel,
|
|
10
|
+
accessibilityHint,
|
|
11
|
+
testID,
|
|
12
|
+
style
|
|
13
|
+
} = _ref;
|
|
14
|
+
// immediately switch to plain view to avoid animation flickering
|
|
15
|
+
// when fade out animation happens and view becomes disabled
|
|
16
|
+
const Container = disabled ? View : TouchableOpacity;
|
|
17
|
+
const accessibilityState = useMemo(() => ({
|
|
18
|
+
disabled
|
|
19
|
+
}), [disabled]);
|
|
20
|
+
return /*#__PURE__*/React.createElement(Container, {
|
|
21
|
+
accessibilityState: accessibilityState,
|
|
22
|
+
accessibilityRole: "button",
|
|
23
|
+
accessibilityLabel: accessibilityLabel,
|
|
24
|
+
accessibilityHint: accessibilityHint,
|
|
25
|
+
onPress: onPress,
|
|
26
|
+
style: style,
|
|
27
|
+
testID: testID
|
|
28
|
+
}, children);
|
|
29
|
+
};
|
|
30
|
+
const ButtonAndroid = _ref2 => {
|
|
31
|
+
let {
|
|
32
|
+
children,
|
|
33
|
+
onPress,
|
|
34
|
+
disabled,
|
|
35
|
+
accessibilityLabel,
|
|
36
|
+
accessibilityHint,
|
|
37
|
+
testID,
|
|
38
|
+
rippleRadius = 18,
|
|
39
|
+
style,
|
|
40
|
+
theme
|
|
41
|
+
} = _ref2;
|
|
42
|
+
const colorScheme = useColorScheme();
|
|
43
|
+
const accessibilityState = useMemo(() => ({
|
|
44
|
+
disabled
|
|
45
|
+
}), [disabled]);
|
|
46
|
+
const ripple = useMemo(() => TouchableNativeFeedback.Ripple(theme[colorScheme].ripple, true, rippleRadius), [colorScheme, rippleRadius, theme]);
|
|
47
|
+
return /*#__PURE__*/React.createElement(TouchableNativeFeedback, {
|
|
48
|
+
accessibilityState: accessibilityState,
|
|
49
|
+
accessibilityRole: "button",
|
|
50
|
+
accessibilityLabel: accessibilityLabel,
|
|
51
|
+
accessibilityHint: accessibilityHint,
|
|
52
|
+
onPress: onPress,
|
|
53
|
+
background: ripple,
|
|
54
|
+
testID: testID,
|
|
55
|
+
style: style
|
|
56
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
57
|
+
style: style
|
|
58
|
+
}, children));
|
|
59
|
+
};
|
|
60
|
+
export default Platform.select({
|
|
61
|
+
android: ButtonAndroid,
|
|
62
|
+
default: ButtonIOS
|
|
63
|
+
});
|
|
64
|
+
//# sourceMappingURL=Button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useMemo","Platform","TouchableNativeFeedback","TouchableOpacity","View","useColorScheme","ButtonIOS","_ref","children","onPress","disabled","accessibilityLabel","accessibilityHint","testID","style","Container","accessibilityState","createElement","accessibilityRole","ButtonAndroid","_ref2","rippleRadius","theme","colorScheme","ripple","Ripple","background","select","android","default"],"sources":["Button.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport {\n Platform,\n TouchableNativeFeedback,\n TouchableOpacity,\n View,\n} from \"react-native\";\n\nimport useColorScheme from \"../hooks/useColorScheme\";\n\nimport type { KeyboardToolbarTheme } from \"./colors\";\nimport type { PropsWithChildren } from \"react\";\nimport type { ViewStyle } from \"react-native\";\n\ntype ButtonProps = {\n disabled?: boolean;\n onPress: () => void;\n accessibilityLabel: string;\n accessibilityHint: string;\n testID: string;\n rippleRadius?: number;\n style?: ViewStyle;\n theme: KeyboardToolbarTheme;\n};\n\nconst ButtonIOS = ({\n children,\n onPress,\n disabled,\n accessibilityLabel,\n accessibilityHint,\n testID,\n style,\n}: PropsWithChildren<ButtonProps>) => {\n // immediately switch to plain view to avoid animation flickering\n // when fade out animation happens and view becomes disabled\n const Container = disabled\n ? (View as unknown as typeof TouchableOpacity)\n : TouchableOpacity;\n const accessibilityState = useMemo(() => ({ disabled }), [disabled]);\n\n return (\n <Container\n accessibilityState={accessibilityState}\n accessibilityRole=\"button\"\n accessibilityLabel={accessibilityLabel}\n accessibilityHint={accessibilityHint}\n onPress={onPress}\n style={style}\n testID={testID}\n >\n {children}\n </Container>\n );\n};\nconst ButtonAndroid = ({\n children,\n onPress,\n disabled,\n accessibilityLabel,\n accessibilityHint,\n testID,\n rippleRadius = 18,\n style,\n theme,\n}: PropsWithChildren<ButtonProps>) => {\n const colorScheme = useColorScheme();\n const accessibilityState = useMemo(() => ({ disabled }), [disabled]);\n const ripple = useMemo(\n () =>\n TouchableNativeFeedback.Ripple(\n theme[colorScheme].ripple,\n true,\n rippleRadius,\n ),\n [colorScheme, rippleRadius, theme],\n );\n\n return (\n <TouchableNativeFeedback\n accessibilityState={accessibilityState}\n accessibilityRole=\"button\"\n accessibilityLabel={accessibilityLabel}\n accessibilityHint={accessibilityHint}\n onPress={onPress}\n background={ripple}\n testID={testID}\n style={style}\n >\n <View style={style}>{children}</View>\n </TouchableNativeFeedback>\n );\n};\n\nexport default Platform.select({\n android: ButtonAndroid,\n default: ButtonIOS,\n});\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,OAAO,QAAQ,OAAO;AACtC,SACEC,QAAQ,EACRC,uBAAuB,EACvBC,gBAAgB,EAChBC,IAAI,QACC,cAAc;AAErB,OAAOC,cAAc,MAAM,yBAAyB;AAiBpD,MAAMC,SAAS,GAAGC,IAAA,IAQoB;EAAA,IARnB;IACjBC,QAAQ;IACRC,OAAO;IACPC,QAAQ;IACRC,kBAAkB;IAClBC,iBAAiB;IACjBC,MAAM;IACNC;EAC8B,CAAC,GAAAP,IAAA;EAC/B;EACA;EACA,MAAMQ,SAAS,GAAGL,QAAQ,GACrBN,IAAI,GACLD,gBAAgB;EACpB,MAAMa,kBAAkB,GAAGhB,OAAO,CAAC,OAAO;IAAEU;EAAS,CAAC,CAAC,EAAE,CAACA,QAAQ,CAAC,CAAC;EAEpE,oBACEX,KAAA,CAAAkB,aAAA,CAACF,SAAS;IACRC,kBAAkB,EAAEA,kBAAmB;IACvCE,iBAAiB,EAAC,QAAQ;IAC1BP,kBAAkB,EAAEA,kBAAmB;IACvCC,iBAAiB,EAAEA,iBAAkB;IACrCH,OAAO,EAAEA,OAAQ;IACjBK,KAAK,EAAEA,KAAM;IACbD,MAAM,EAAEA;EAAO,GAEdL,QACQ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