react-native-keyboard-controller 1.14.4 → 1.14.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/react-native-helpers.gradle +5 -11
- package/android/src/main/java/com/reactnativekeyboardcontroller/views/overlay/JSPointerDispatcherCompat.kt +56 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/views/overlay/OverKeyboardViewGroup.kt +10 -7
- package/ios/extensions/Notification.swift +17 -0
- package/ios/observers/KeyboardMovementObserver.swift +4 -13
- package/lib/commonjs/bindings.js +1 -3
- package/lib/commonjs/bindings.js.map +1 -1
- package/lib/commonjs/bindings.native.js +10 -3
- package/lib/commonjs/bindings.native.js.map +1 -1
- package/lib/commonjs/components/KeyboardToolbar/index.js +3 -6
- package/lib/commonjs/components/KeyboardToolbar/index.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/bindings.js +1 -3
- package/lib/module/bindings.js.map +1 -1
- package/lib/module/bindings.native.js +9 -2
- package/lib/module/bindings.native.js.map +1 -1
- package/lib/module/components/KeyboardToolbar/index.js +3 -6
- package/lib/module/components/KeyboardToolbar/index.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/bindings.d.ts +3 -4
- package/lib/typescript/bindings.native.d.ts +3 -3
- package/lib/typescript/components/KeyboardAvoidingView/index.d.ts +4 -4
- package/lib/typescript/components/KeyboardAwareScrollView/index.d.ts +6 -6
- package/lib/typescript/components/KeyboardAwareScrollView/utils.d.ts +1 -1
- package/lib/typescript/components/KeyboardStickyView/index.d.ts +4 -4
- package/lib/typescript/components/KeyboardToolbar/Button.d.ts +2 -1
- package/lib/typescript/internal.d.ts +0 -1
- package/lib/typescript/types.d.ts +3 -1
- package/package.json +6 -4
- package/src/bindings.native.ts +11 -3
- package/src/bindings.ts +0 -2
- package/src/components/KeyboardToolbar/index.tsx +3 -7
- package/src/types.ts +3 -1
- /package/ios/{traversal → protocols}/TextInput.swift +0 -0
|
@@ -4,23 +4,17 @@ def safeAppExtGet(prop, fallback) {
|
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
// Let's detect react-native's directory, it will be used to determine RN's version
|
|
7
|
-
// https://github.com/software-mansion/react-native-reanimated/blob/
|
|
7
|
+
// https://github.com/software-mansion/react-native-reanimated/blob/36c291a15880c78a94dd125c51484630546ceb7c/packages/react-native-reanimated/android/build.gradle#L73
|
|
8
8
|
def resolveReactNativeDirectory() {
|
|
9
9
|
def reactNativeLocation = safeAppExtGet("REACT_NATIVE_NODE_MODULES_DIR", null)
|
|
10
10
|
if (reactNativeLocation != null) {
|
|
11
11
|
return file(reactNativeLocation)
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
//
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return reactNativeFromProjectNodeModules
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
def reactNativeFromNodeModules = file("${projectDir}/../../react-native")
|
|
22
|
-
if (reactNativeFromNodeModules.exists()) {
|
|
23
|
-
return reactNativeFromNodeModules
|
|
14
|
+
// Fallback to node resolver for custom directory structures like monorepos.
|
|
15
|
+
def reactNativePackage = file(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim())
|
|
16
|
+
if (reactNativePackage.exists()) {
|
|
17
|
+
return reactNativePackage.parentFile
|
|
24
18
|
}
|
|
25
19
|
|
|
26
20
|
throw new GradleException(
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
package com.reactnativekeyboardcontroller.views.overlay
|
|
2
|
+
|
|
3
|
+
import android.view.MotionEvent
|
|
4
|
+
import android.view.ViewGroup
|
|
5
|
+
import com.facebook.react.uimanager.JSPointerDispatcher
|
|
6
|
+
import com.facebook.react.uimanager.events.EventDispatcher
|
|
7
|
+
import java.lang.reflect.Method
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Compat layer for `JSPointerDispatcher` interface for RN < 0.72
|
|
11
|
+
*/
|
|
12
|
+
class JSPointerDispatcherCompat(
|
|
13
|
+
viewGroup: ViewGroup,
|
|
14
|
+
) : JSPointerDispatcher(viewGroup) {
|
|
15
|
+
private val handleMotionEventMethod: Method? by lazy {
|
|
16
|
+
try {
|
|
17
|
+
// Try to get the 3-parameter method (for RN >= 0.72)
|
|
18
|
+
JSPointerDispatcher::class.java.getMethod(
|
|
19
|
+
HANDLE_MOTION_EVENT,
|
|
20
|
+
MotionEvent::class.java,
|
|
21
|
+
EventDispatcher::class.java,
|
|
22
|
+
Boolean::class.javaPrimitiveType,
|
|
23
|
+
)
|
|
24
|
+
} catch (_: NoSuchMethodException) {
|
|
25
|
+
try {
|
|
26
|
+
// Fallback to 2-parameter method (for RN < 0.72)
|
|
27
|
+
JSPointerDispatcher::class.java.getMethod(
|
|
28
|
+
HANDLE_MOTION_EVENT,
|
|
29
|
+
MotionEvent::class.java,
|
|
30
|
+
EventDispatcher::class.java,
|
|
31
|
+
)
|
|
32
|
+
} catch (_: NoSuchMethodException) {
|
|
33
|
+
null
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
fun handleMotionEventCompat(
|
|
39
|
+
event: MotionEvent?,
|
|
40
|
+
eventDispatcher: EventDispatcher?,
|
|
41
|
+
isCapture: Boolean,
|
|
42
|
+
) {
|
|
43
|
+
handleMotionEventMethod?.let { method ->
|
|
44
|
+
if (method.parameterCount == RN_72_PARAMS_COUNT) {
|
|
45
|
+
method.invoke(this, event, eventDispatcher, isCapture)
|
|
46
|
+
} else {
|
|
47
|
+
method.invoke(this, event, eventDispatcher)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
companion object {
|
|
53
|
+
private const val HANDLE_MOTION_EVENT = "handleMotionEvent"
|
|
54
|
+
private const val RN_72_PARAMS_COUNT = 3
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -8,7 +8,6 @@ import android.view.View
|
|
|
8
8
|
import android.view.WindowManager
|
|
9
9
|
import com.facebook.react.bridge.UiThreadUtil
|
|
10
10
|
import com.facebook.react.config.ReactFeatureFlags
|
|
11
|
-
import com.facebook.react.uimanager.JSPointerDispatcher
|
|
12
11
|
import com.facebook.react.uimanager.JSTouchDispatcher
|
|
13
12
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
14
13
|
import com.facebook.react.uimanager.UIManagerHelper
|
|
@@ -99,13 +98,13 @@ class OverKeyboardRootViewGroup(
|
|
|
99
98
|
) : ReactViewGroup(reactContext),
|
|
100
99
|
RootViewCompat {
|
|
101
100
|
private val jsTouchDispatcher: JSTouchDispatcher = JSTouchDispatcher(this)
|
|
102
|
-
private var jsPointerDispatcher:
|
|
101
|
+
private var jsPointerDispatcher: JSPointerDispatcherCompat? = null
|
|
103
102
|
internal var eventDispatcher: EventDispatcher? = null
|
|
104
103
|
internal var isAttached = false
|
|
105
104
|
|
|
106
105
|
init {
|
|
107
106
|
if (ReactFeatureFlags.dispatchPointerEvents) {
|
|
108
|
-
jsPointerDispatcher =
|
|
107
|
+
jsPointerDispatcher = JSPointerDispatcherCompat(this)
|
|
109
108
|
}
|
|
110
109
|
}
|
|
111
110
|
|
|
@@ -125,7 +124,7 @@ class OverKeyboardRootViewGroup(
|
|
|
125
124
|
override fun onInterceptTouchEvent(event: MotionEvent): Boolean {
|
|
126
125
|
eventDispatcher?.let { eventDispatcher ->
|
|
127
126
|
jsTouchDispatcher.handleTouchEvent(event, eventDispatcher)
|
|
128
|
-
jsPointerDispatcher?.
|
|
127
|
+
jsPointerDispatcher?.handleMotionEventCompat(event, eventDispatcher, true)
|
|
129
128
|
}
|
|
130
129
|
return super.onInterceptTouchEvent(event)
|
|
131
130
|
}
|
|
@@ -134,7 +133,7 @@ class OverKeyboardRootViewGroup(
|
|
|
134
133
|
override fun onTouchEvent(event: MotionEvent): Boolean {
|
|
135
134
|
eventDispatcher?.let { eventDispatcher ->
|
|
136
135
|
jsTouchDispatcher.handleTouchEvent(event, eventDispatcher)
|
|
137
|
-
jsPointerDispatcher?.
|
|
136
|
+
jsPointerDispatcher?.handleMotionEventCompat(event, eventDispatcher, false)
|
|
138
137
|
}
|
|
139
138
|
super.onTouchEvent(event)
|
|
140
139
|
// In case when there is no children interested in handling touch event, we return true from
|
|
@@ -143,12 +142,16 @@ class OverKeyboardRootViewGroup(
|
|
|
143
142
|
}
|
|
144
143
|
|
|
145
144
|
override fun onInterceptHoverEvent(event: MotionEvent): Boolean {
|
|
146
|
-
eventDispatcher?.let {
|
|
145
|
+
eventDispatcher?.let {
|
|
146
|
+
jsPointerDispatcher?.handleMotionEventCompat(event, it, true)
|
|
147
|
+
}
|
|
147
148
|
return super.onHoverEvent(event)
|
|
148
149
|
}
|
|
149
150
|
|
|
150
151
|
override fun onHoverEvent(event: MotionEvent): Boolean {
|
|
151
|
-
eventDispatcher?.let {
|
|
152
|
+
eventDispatcher?.let {
|
|
153
|
+
jsPointerDispatcher?.handleMotionEventCompat(event, it, false)
|
|
154
|
+
}
|
|
152
155
|
return super.onHoverEvent(event)
|
|
153
156
|
}
|
|
154
157
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Notification.swift
|
|
3
|
+
// Pods
|
|
4
|
+
//
|
|
5
|
+
// Created by Kiryl Ziusko on 04/11/2024.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
extension Notification {
|
|
9
|
+
func keyboardMetaData() -> (Int, NSValue?) {
|
|
10
|
+
let duration = Int(
|
|
11
|
+
(userInfo?[UIResponder.keyboardAnimationDurationUserInfoKey] as? Double ?? 0) * 1000
|
|
12
|
+
)
|
|
13
|
+
let keyboardFrame = userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue
|
|
14
|
+
|
|
15
|
+
return (duration, keyboardFrame)
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -163,7 +163,7 @@ public class KeyboardMovementObserver: NSObject {
|
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
@objc func keyboardWillAppear(_ notification: Notification) {
|
|
166
|
-
let (duration, frame) =
|
|
166
|
+
let (duration, frame) = notification.keyboardMetaData()
|
|
167
167
|
if let keyboardFrame = frame {
|
|
168
168
|
tag = UIResponder.current.reactViewTag
|
|
169
169
|
let keyboardHeight = keyboardFrame.cgRectValue.size.height
|
|
@@ -181,7 +181,7 @@ public class KeyboardMovementObserver: NSObject {
|
|
|
181
181
|
}
|
|
182
182
|
|
|
183
183
|
@objc func keyboardWillDisappear(_ notification: Notification) {
|
|
184
|
-
let (duration, _) =
|
|
184
|
+
let (duration, _) = notification.keyboardMetaData()
|
|
185
185
|
tag = UIResponder.current.reactViewTag
|
|
186
186
|
self.duration = duration
|
|
187
187
|
|
|
@@ -196,7 +196,7 @@ public class KeyboardMovementObserver: NSObject {
|
|
|
196
196
|
|
|
197
197
|
@objc func keyboardDidAppear(_ notification: Notification) {
|
|
198
198
|
let timestamp = Date.currentTimeStamp
|
|
199
|
-
let (duration, frame) =
|
|
199
|
+
let (duration, frame) = notification.keyboardMetaData()
|
|
200
200
|
if let keyboardFrame = frame {
|
|
201
201
|
let (position, _) = keyboardView.frameTransitionInWindow
|
|
202
202
|
let keyboardHeight = keyboardFrame.cgRectValue.size.height
|
|
@@ -219,7 +219,7 @@ public class KeyboardMovementObserver: NSObject {
|
|
|
219
219
|
}
|
|
220
220
|
|
|
221
221
|
@objc func keyboardDidDisappear(_ notification: Notification) {
|
|
222
|
-
let (duration, _) =
|
|
222
|
+
let (duration, _) = notification.keyboardMetaData()
|
|
223
223
|
tag = UIResponder.current.reactViewTag
|
|
224
224
|
|
|
225
225
|
onCancelAnimation()
|
|
@@ -310,15 +310,6 @@ public class KeyboardMovementObserver: NSObject {
|
|
|
310
310
|
)
|
|
311
311
|
}
|
|
312
312
|
|
|
313
|
-
private func metaDataFromNotification(_ notification: Notification) -> (Int, NSValue?) {
|
|
314
|
-
let duration = Int(
|
|
315
|
-
(notification.userInfo?[UIResponder.keyboardAnimationDurationUserInfoKey] as? Double ?? 0) * 1000
|
|
316
|
-
)
|
|
317
|
-
let keyboardFrame = notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue
|
|
318
|
-
|
|
319
|
-
return (duration, keyboardFrame)
|
|
320
|
-
}
|
|
321
|
-
|
|
322
313
|
private func getEventParams(_ height: Double, _ duration: Int) -> [AnyHashable: Any] {
|
|
323
314
|
var data = [AnyHashable: Any]()
|
|
324
315
|
data["height"] = height
|
package/lib/commonjs/bindings.js
CHANGED
|
@@ -10,9 +10,7 @@ const KeyboardController = exports.KeyboardController = {
|
|
|
10
10
|
setDefaultMode: NOOP,
|
|
11
11
|
setInputMode: NOOP,
|
|
12
12
|
dismiss: NOOP,
|
|
13
|
-
setFocusTo: NOOP
|
|
14
|
-
addListener: NOOP,
|
|
15
|
-
removeListeners: NOOP
|
|
13
|
+
setFocusTo: NOOP
|
|
16
14
|
};
|
|
17
15
|
const KeyboardEvents = exports.KeyboardEvents = {
|
|
18
16
|
addListener: () => ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","NOOP","KeyboardController","exports","setDefaultMode","setInputMode","dismiss","setFocusTo","
|
|
1
|
+
{"version":3,"names":["_reactNative","require","NOOP","KeyboardController","exports","setDefaultMode","setInputMode","dismiss","setFocusTo","KeyboardEvents","addListener","remove","FocusedInputEvents","WindowDimensionsEvents","KeyboardControllerView","View","KeyboardGestureArea","RCTOverKeyboardView"],"sources":["bindings.ts"],"sourcesContent":["import { View } from \"react-native\";\n\nimport type {\n FocusedInputEventsModule,\n KeyboardControllerModule,\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 KeyboardController: KeyboardControllerModule = {\n setDefaultMode: NOOP,\n setInputMode: NOOP,\n dismiss: NOOP,\n setFocusTo: 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,IAAAA,YAAA,GAAAC,OAAA;AAaA,MAAMC,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AAEd,MAAMC,kBAA4C,GAAAC,OAAA,CAAAD,kBAAA,GAAG;EAC1DE,cAAc,EAAEH,IAAI;EACpBI,YAAY,EAAEJ,IAAI;EAClBK,OAAO,EAAEL,IAAI;EACbM,UAAU,EAAEN;AACd,CAAC;AACM,MAAMO,cAAoC,GAAAL,OAAA,CAAAK,cAAA,GAAG;EAClDC,WAAW,EAAEA,CAAA,MAAO;IAAEC,MAAM,EAAET;EAAK,CAAC;AACtC,CAAC;AACD;AACA;AACA;AACA;AACO,MAAMU,kBAA4C,GAAAR,OAAA,CAAAQ,kBAAA,GAAG;EAC1DF,WAAW,EAAEA,CAAA,MAAO;IAAEC,MAAM,EAAET;EAAK,CAAC;AACtC,CAAC;AACM,MAAMW,sBAAoD,GAAAT,OAAA,CAAAS,sBAAA,GAAG;EAClEH,WAAW,EAAEA,CAAA,MAAO;IAAEC,MAAM,EAAET;EAAK,CAAC;AACtC,CAAC;AACM,MAAMY,sBAAsB,GAAAV,OAAA,CAAAU,sBAAA,GACjCC,iBAAoD;AAC/C,MAAMC,mBAAmB,GAAAZ,OAAA,CAAAY,mBAAA,GAC9BD,iBAAqD;AAChD,MAAME,mBAAmB,GAAAb,OAAA,CAAAa,mBAAA,GAC9BF,iBAAkD","ignoreList":[]}
|
|
@@ -3,23 +3,30 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.WindowDimensionsEvents = exports.RCTOverKeyboardView = exports.KeyboardGestureArea = exports.KeyboardEvents = exports.KeyboardControllerView = exports.KeyboardController = exports.FocusedInputEvents = void 0;
|
|
6
|
+
exports.WindowDimensionsEvents = exports.RCTOverKeyboardView = exports.KeyboardGestureArea = exports.KeyboardEvents = exports.KeyboardControllerView = exports.KeyboardControllerNative = exports.KeyboardController = exports.FocusedInputEvents = void 0;
|
|
7
7
|
var _reactNative = require("react-native");
|
|
8
8
|
const LINKING_ERROR = `The package 'react-native-keyboard-controller' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
|
|
9
9
|
ios: "- You have run 'pod install'\n",
|
|
10
10
|
default: ""
|
|
11
11
|
}) + "- You rebuilt the app after installing the package\n" + "- You are not using Expo Go\n";
|
|
12
12
|
const RCTKeyboardController = require("./specs/NativeKeyboardController").default;
|
|
13
|
-
const
|
|
13
|
+
const KeyboardControllerNative = exports.KeyboardControllerNative = RCTKeyboardController ? RCTKeyboardController : new Proxy({}, {
|
|
14
14
|
get() {
|
|
15
15
|
throw new Error(LINKING_ERROR);
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
18
|
const KEYBOARD_CONTROLLER_NAMESPACE = "KeyboardController::";
|
|
19
|
-
const eventEmitter = new _reactNative.NativeEventEmitter(
|
|
19
|
+
const eventEmitter = new _reactNative.NativeEventEmitter(KeyboardControllerNative);
|
|
20
20
|
const KeyboardEvents = exports.KeyboardEvents = {
|
|
21
21
|
addListener: (name, cb) => eventEmitter.addListener(KEYBOARD_CONTROLLER_NAMESPACE + name, cb)
|
|
22
22
|
};
|
|
23
|
+
const KeyboardController = exports.KeyboardController = {
|
|
24
|
+
setDefaultMode: KeyboardControllerNative.setDefaultMode,
|
|
25
|
+
setInputMode: KeyboardControllerNative.setInputMode,
|
|
26
|
+
setFocusTo: KeyboardControllerNative.setFocusTo,
|
|
27
|
+
// additional function is needed because of this https://github.com/kirillzyusko/react-native-keyboard-controller/issues/684
|
|
28
|
+
dismiss: () => KeyboardControllerNative.dismiss()
|
|
29
|
+
};
|
|
23
30
|
/**
|
|
24
31
|
* This API is not documented, it's for internal usage only (for now), and is a subject to potential breaking changes in future.
|
|
25
32
|
* Use it with cautious.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","LINKING_ERROR","Platform","select","ios","default","RCTKeyboardController","
|
|
1
|
+
{"version":3,"names":["_reactNative","require","LINKING_ERROR","Platform","select","ios","default","RCTKeyboardController","KeyboardControllerNative","exports","Proxy","get","Error","KEYBOARD_CONTROLLER_NAMESPACE","eventEmitter","NativeEventEmitter","KeyboardEvents","addListener","name","cb","KeyboardController","setDefaultMode","setInputMode","setFocusTo","dismiss","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 KeyboardControllerModule,\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};\nexport const KeyboardController: KeyboardControllerModule = {\n setDefaultMode: KeyboardControllerNative.setDefaultMode,\n setInputMode: KeyboardControllerNative.setInputMode,\n setFocusTo: KeyboardControllerNative.setFocusTo,\n // additional function is needed because of this https://github.com/kirillzyusko/react-native-keyboard-controller/issues/684\n dismiss: () => KeyboardControllerNative.dismiss(),\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\n ? require(\"./specs/KeyboardGestureAreaNativeComponent\").default\n : ({ children }: KeyboardGestureAreaProps) => children;\nexport const RCTOverKeyboardView: React.FC<OverKeyboardViewProps> =\n require(\"./specs/OverKeyboardViewNativeComponent\").default;\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAaA,MAAMC,aAAa,GACjB,2FAA2F,GAC3FC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;A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OAAA,CAAAkB,sBAAA,GACpE1B,OAAO,CAAC,+CAA+C,CAAC,CAACK,OAAO;AAC3D,MAAMsB,mBAAuD,GAAAnB,OAAA,CAAAmB,mBAAA,GAClEzB,qBAAQ,CAAC0B,EAAE,KAAK,SAAS,IAAI1B,qBAAQ,CAAC2B,OAAO,IAAI,EAAE,GAC/C7B,OAAO,CAAC,4CAA4C,CAAC,CAACK,OAAO,GAC7D,CAAC;EAAEyB;AAAmC,CAAC,KAAKA,QAAQ;AACnD,MAAMC,mBAAoD,GAAAvB,OAAA,CAAAuB,mBAAA,GAC/D/B,OAAO,CAAC,yCAAyC,CAAC,CAACK,OAAO","ignoreList":[]}
|
|
@@ -32,9 +32,6 @@ const DEFAULT_OPACITY = "FF";
|
|
|
32
32
|
const offset = {
|
|
33
33
|
closed: KEYBOARD_TOOLBAR_HEIGHT
|
|
34
34
|
};
|
|
35
|
-
const dismissKeyboard = () => _bindings.KeyboardController.dismiss();
|
|
36
|
-
const goToNextField = () => _bindings.KeyboardController.setFocusTo("next");
|
|
37
|
-
const goToPrevField = () => _bindings.KeyboardController.setFocusTo("prev");
|
|
38
35
|
|
|
39
36
|
/**
|
|
40
37
|
* `KeyboardToolbar` is a component that is shown above the keyboard with `Prev`/`Next` and
|
|
@@ -78,19 +75,19 @@ const KeyboardToolbar = ({
|
|
|
78
75
|
const onPressNext = (0, _react.useCallback)(event => {
|
|
79
76
|
onNextCallback === null || onNextCallback === void 0 || onNextCallback(event);
|
|
80
77
|
if (!event.isDefaultPrevented()) {
|
|
81
|
-
|
|
78
|
+
_bindings.KeyboardController.setFocusTo("next");
|
|
82
79
|
}
|
|
83
80
|
}, [onNextCallback]);
|
|
84
81
|
const onPressPrev = (0, _react.useCallback)(event => {
|
|
85
82
|
onPrevCallback === null || onPrevCallback === void 0 || onPrevCallback(event);
|
|
86
83
|
if (!event.isDefaultPrevented()) {
|
|
87
|
-
|
|
84
|
+
_bindings.KeyboardController.setFocusTo("prev");
|
|
88
85
|
}
|
|
89
86
|
}, [onPrevCallback]);
|
|
90
87
|
const onPressDone = (0, _react.useCallback)(event => {
|
|
91
88
|
onDoneCallback === null || onDoneCallback === void 0 || onDoneCallback(event);
|
|
92
89
|
if (!event.isDefaultPrevented()) {
|
|
93
|
-
|
|
90
|
+
_bindings.KeyboardController.dismiss();
|
|
94
91
|
}
|
|
95
92
|
}, [onDoneCallback]);
|
|
96
93
|
return /*#__PURE__*/_react.default.createElement(_KeyboardStickyView.default, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_bindings","_useColorScheme","_interopRequireDefault","_KeyboardStickyView","_Arrow","_Button","_colors","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","_extends","assign","bind","arguments","length","apply","TEST_ID_KEYBOARD_TOOLBAR","TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS","TEST_ID_KEYBOARD_TOOLBAR_NEXT","TEST_ID_KEYBOARD_TOOLBAR_CONTENT","TEST_ID_KEYBOARD_TOOLBAR_DONE","KEYBOARD_TOOLBAR_HEIGHT","DEFAULT_OPACITY","offset","closed","dismissKeyboard","KeyboardController","dismiss","goToNextField","setFocusTo","goToPrevField","KeyboardToolbar","content","theme","colors","doneText","button","icon","showArrows","onNextCallback","onPrevCallback","onDoneCallback","blur","opacity","rest","colorScheme","useColorScheme","inputs","setInputs","useState","current","count","isPrevDisabled","isNextDisabled","useEffect","subscription","FocusedInputEvents","addListener","remove","doneStyle","useMemo","styles","doneButton","color","primary","toolbarStyle","toolbar","backgroundColor","background","ButtonContainer","Button","IconContainer","Arrow","onPressNext","useCallback","event","isDefaultPrevented","onPressPrev","onPressDone","createElement","View","style","testID","Fragment","accessibilityHint","accessibilityLabel","disabled","onPress","type","flex","rippleRadius","doneButtonContainer","Text","maxFontSizeMultiplier","StyleSheet","create","position","bottom","alignItems","width","flexDirection","height","paddingHorizontal","fontWeight","fontSize","marginRight","_default","exports"],"sources":["index.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { StyleSheet, Text, View } from \"react-native\";\n\nimport { FocusedInputEvents, KeyboardController } from \"../../bindings\";\nimport useColorScheme from \"../hooks/useColorScheme\";\nimport KeyboardStickyView from \"../KeyboardStickyView\";\n\nimport Arrow from \"./Arrow\";\nimport Button from \"./Button\";\nimport { colors } from \"./colors\";\n\nimport type { HEX, KeyboardToolbarTheme } from \"./types\";\nimport type { ReactNode } from \"react\";\nimport type { GestureResponderEvent, ViewProps } from \"react-native\";\n\nexport type KeyboardToolbarProps = Omit<\n ViewProps,\n \"style\" | \"testID\" | \"children\"\n> & {\n /** An element that is shown in the middle of the toolbar. */\n content?: JSX.Element | null;\n /** A set of dark/light colors consumed by toolbar component. */\n theme?: KeyboardToolbarTheme;\n /** Custom text for done button. */\n doneText?: ReactNode;\n /** Custom touchable component for toolbar (used for prev/next/done buttons). */\n button?: typeof Button;\n /** Custom icon component used to display next/prev buttons. */\n icon?: typeof Arrow;\n /**\n * Whether to show next and previous buttons. Can be useful to set it to `false` if you have only one input\n * and want to show only `Done` button. Default to `true`.\n */\n showArrows?: boolean;\n /**\n * A callback that is called when the user presses the next button along with the default action.\n */\n onNextCallback?: (event: GestureResponderEvent) => void;\n /**\n * A callback that is called when the user presses the previous button along with the default action.\n */\n onPrevCallback?: (event: GestureResponderEvent) => void;\n /**\n * A callback that is called when the user presses the done button along with the default action.\n */\n onDoneCallback?: (event: GestureResponderEvent) => void;\n /**\n * A component that applies blur effect to the toolbar.\n */\n blur?: JSX.Element | null;\n /**\n * A value for container opacity in hexadecimal format (e.g. `ff`). Default value is `ff`.\n */\n opacity?: HEX;\n};\n\nconst TEST_ID_KEYBOARD_TOOLBAR = \"keyboard.toolbar\";\nconst TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS = `${TEST_ID_KEYBOARD_TOOLBAR}.previous`;\nconst TEST_ID_KEYBOARD_TOOLBAR_NEXT = `${TEST_ID_KEYBOARD_TOOLBAR}.next`;\nconst TEST_ID_KEYBOARD_TOOLBAR_CONTENT = `${TEST_ID_KEYBOARD_TOOLBAR}.content`;\nconst TEST_ID_KEYBOARD_TOOLBAR_DONE = `${TEST_ID_KEYBOARD_TOOLBAR}.done`;\n\nconst KEYBOARD_TOOLBAR_HEIGHT = 42;\nconst DEFAULT_OPACITY: HEX = \"FF\";\nconst offset = { closed: KEYBOARD_TOOLBAR_HEIGHT };\n\nconst dismissKeyboard = () => KeyboardController.dismiss();\nconst goToNextField = () => KeyboardController.setFocusTo(\"next\");\nconst goToPrevField = () => KeyboardController.setFocusTo(\"prev\");\n\n/**\n * `KeyboardToolbar` is a component that is shown above the keyboard with `Prev`/`Next` and\n * `Done` buttons.\n */\nconst KeyboardToolbar: React.FC<KeyboardToolbarProps> = ({\n content,\n theme = colors,\n doneText,\n button,\n icon,\n showArrows = true,\n onNextCallback,\n onPrevCallback,\n onDoneCallback,\n blur = null,\n opacity = DEFAULT_OPACITY,\n ...rest\n}) => {\n const colorScheme = useColorScheme();\n const [inputs, setInputs] = useState({\n current: 0,\n count: 0,\n });\n const isPrevDisabled = inputs.current === 0;\n const isNextDisabled = inputs.current === inputs.count - 1;\n\n useEffect(() => {\n const subscription = FocusedInputEvents.addListener(\"focusDidSet\", (e) => {\n setInputs(e);\n });\n\n return subscription.remove;\n }, []);\n const doneStyle = useMemo(\n () => [styles.doneButton, { color: theme[colorScheme].primary }],\n [colorScheme, theme],\n );\n const toolbarStyle = useMemo(\n () => [\n styles.toolbar,\n {\n backgroundColor: `${theme[colorScheme].background}${opacity}`,\n },\n ],\n [colorScheme, opacity, theme],\n );\n const ButtonContainer = button || Button;\n const IconContainer = icon || Arrow;\n\n const onPressNext = useCallback(\n (event: GestureResponderEvent) => {\n onNextCallback?.(event);\n\n if (!event.isDefaultPrevented()) {\n goToNextField();\n }\n },\n [onNextCallback],\n );\n const onPressPrev = useCallback(\n (event: GestureResponderEvent) => {\n onPrevCallback?.(event);\n\n if (!event.isDefaultPrevented()) {\n goToPrevField();\n }\n },\n [onPrevCallback],\n );\n const onPressDone = useCallback(\n (event: GestureResponderEvent) => {\n onDoneCallback?.(event);\n\n if (!event.isDefaultPrevented()) {\n dismissKeyboard();\n }\n },\n [onDoneCallback],\n );\n\n return (\n <KeyboardStickyView offset={offset}>\n <View {...rest} style={toolbarStyle} testID={TEST_ID_KEYBOARD_TOOLBAR}>\n {blur}\n {showArrows && (\n <>\n <ButtonContainer\n accessibilityHint=\"Moves focus to the previous field\"\n accessibilityLabel=\"Previous\"\n disabled={isPrevDisabled}\n testID={TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS}\n theme={theme}\n onPress={onPressPrev}\n >\n <IconContainer\n disabled={isPrevDisabled}\n theme={theme}\n type=\"prev\"\n />\n </ButtonContainer>\n <ButtonContainer\n accessibilityHint=\"Moves focus to the next field\"\n accessibilityLabel=\"Next\"\n disabled={isNextDisabled}\n testID={TEST_ID_KEYBOARD_TOOLBAR_NEXT}\n theme={theme}\n onPress={onPressNext}\n >\n <IconContainer\n disabled={isNextDisabled}\n theme={theme}\n type=\"next\"\n />\n </ButtonContainer>\n </>\n )}\n\n <View style={styles.flex} testID={TEST_ID_KEYBOARD_TOOLBAR_CONTENT}>\n {content}\n </View>\n <ButtonContainer\n accessibilityHint=\"Closes the keyboard\"\n accessibilityLabel=\"Done\"\n rippleRadius={28}\n style={styles.doneButtonContainer}\n testID={TEST_ID_KEYBOARD_TOOLBAR_DONE}\n theme={theme}\n onPress={onPressDone}\n >\n <Text maxFontSizeMultiplier={1.3} style={doneStyle}>\n {doneText || \"Done\"}\n </Text>\n </ButtonContainer>\n </View>\n </KeyboardStickyView>\n );\n};\n\nconst styles = StyleSheet.create({\n flex: {\n flex: 1,\n },\n toolbar: {\n position: \"absolute\",\n bottom: 0,\n alignItems: \"center\",\n width: \"100%\",\n flexDirection: \"row\",\n height: KEYBOARD_TOOLBAR_HEIGHT,\n paddingHorizontal: 8,\n },\n doneButton: {\n fontWeight: \"600\",\n fontSize: 15,\n },\n doneButtonContainer: {\n marginRight: 8,\n },\n});\n\nexport { colors as DefaultKeyboardToolbarTheme };\nexport default KeyboardToolbar;\n"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,mBAAA,GAAAD,sBAAA,CAAAJ,OAAA;AAEA,IAAAM,MAAA,GAAAF,sBAAA,CAAAJ,OAAA;AACA,IAAAO,OAAA,GAAAH,sBAAA,CAAAJ,OAAA;AACA,IAAAQ,OAAA,GAAAR,OAAA;AAAkC,SAAAI,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,yBAAAH,CAAA,6BAAAI,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAD,wBAAA,YAAAA,CAAAH,CAAA,WAAAA,CAAA,GAAAM,CAAA,GAAAD,CAAA,KAAAL,CAAA;AAAA,SAAAV,wBAAAU,CAAA,EAAAK,CAAA,SAAAA,CAAA,IAAAL,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAE,OAAA,EAAAF,CAAA,QAAAM,CAAA,GAAAH,wBAAA,CAAAE,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAC,GAAA,CAAAP,CAAA,UAAAM,CAAA,CAAAE,GAAA,CAAAR,CAAA,OAAAS,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAf,CAAA,oBA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IACvCC,kBAAkB,EAAC,MAAM;IACzBK,YAAY,EAAE,EAAG;IACjBT,KAAK,EAAEpB,MAAM,CAAC8B,mBAAoB;IAClCT,MAAM,EAAE9D,6BAA8B;IACtCa,KAAK,EAAEA,KAAM;IACbsD,OAAO,EAAET;EAAY,gBAErBnG,MAAA,CAAAa,OAAA,CAAAuF,aAAA,CAACjG,YAAA,CAAA8G,IAAI;IAACC,qBAAqB,EAAE,GAAI;IAACZ,KAAK,EAAEtB;EAAU,GAChDxB,QAAQ,IAAI,MACT,CACS,CACb,CACY,CAAC;AAEzB,CAAC;AAED,MAAM0B,MAAM,GAAGiC,uBAAU,CAACC,MAAM,CAAC;EAC/BN,IAAI,EAAE;IACJA,IAAI,EAAE;EACR,CAAC;EACDvB,OAAO,EAAE;IACP8B,QAAQ,EAAE,UAAU;IACpBC,MAAM,EAAE,CAAC;IACTC,UAAU,EAAE,QAAQ;IACpBC,KAAK,EAAE,MAAM;IACbC,aAAa,EAAE,KAAK;IACpBC,MAAM,EAAEhF,uBAAuB;IAC/BiF,iBAAiB,EAAE;EACrB,CAAC;EACDxC,UAAU,EAAE;IACVyC,UAAU,EAAE,KAAK;IACjBC,QAAQ,EAAE;EACZ,CAAC;EACDb,mBAAmB,EAAE;IACnBc,WAAW,EAAE;EACf;AACF,CAAC,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAnH,OAAA,GAGYuC,eAAe","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_bindings","_useColorScheme","_interopRequireDefault","_KeyboardStickyView","_Arrow","_Button","_colors","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","_extends","assign","bind","arguments","length","apply","TEST_ID_KEYBOARD_TOOLBAR","TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS","TEST_ID_KEYBOARD_TOOLBAR_NEXT","TEST_ID_KEYBOARD_TOOLBAR_CONTENT","TEST_ID_KEYBOARD_TOOLBAR_DONE","KEYBOARD_TOOLBAR_HEIGHT","DEFAULT_OPACITY","offset","closed","KeyboardToolbar","content","theme","colors","doneText","button","icon","showArrows","onNextCallback","onPrevCallback","onDoneCallback","blur","opacity","rest","colorScheme","useColorScheme","inputs","setInputs","useState","current","count","isPrevDisabled","isNextDisabled","useEffect","subscription","FocusedInputEvents","addListener","remove","doneStyle","useMemo","styles","doneButton","color","primary","toolbarStyle","toolbar","backgroundColor","background","ButtonContainer","Button","IconContainer","Arrow","onPressNext","useCallback","event","isDefaultPrevented","KeyboardController","setFocusTo","onPressPrev","onPressDone","dismiss","createElement","View","style","testID","Fragment","accessibilityHint","accessibilityLabel","disabled","onPress","type","flex","rippleRadius","doneButtonContainer","Text","maxFontSizeMultiplier","StyleSheet","create","position","bottom","alignItems","width","flexDirection","height","paddingHorizontal","fontWeight","fontSize","marginRight","_default","exports"],"sources":["index.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { StyleSheet, Text, View } from \"react-native\";\n\nimport { FocusedInputEvents, KeyboardController } from \"../../bindings\";\nimport useColorScheme from \"../hooks/useColorScheme\";\nimport KeyboardStickyView from \"../KeyboardStickyView\";\n\nimport Arrow from \"./Arrow\";\nimport Button from \"./Button\";\nimport { colors } from \"./colors\";\n\nimport type { HEX, KeyboardToolbarTheme } from \"./types\";\nimport type { ReactNode } from \"react\";\nimport type { GestureResponderEvent, ViewProps } from \"react-native\";\n\nexport type KeyboardToolbarProps = Omit<\n ViewProps,\n \"style\" | \"testID\" | \"children\"\n> & {\n /** An element that is shown in the middle of the toolbar. */\n content?: JSX.Element | null;\n /** A set of dark/light colors consumed by toolbar component. */\n theme?: KeyboardToolbarTheme;\n /** Custom text for done button. */\n doneText?: ReactNode;\n /** Custom touchable component for toolbar (used for prev/next/done buttons). */\n button?: typeof Button;\n /** Custom icon component used to display next/prev buttons. */\n icon?: typeof Arrow;\n /**\n * Whether to show next and previous buttons. Can be useful to set it to `false` if you have only one input\n * and want to show only `Done` button. Default to `true`.\n */\n showArrows?: boolean;\n /**\n * A callback that is called when the user presses the next button along with the default action.\n */\n onNextCallback?: (event: GestureResponderEvent) => void;\n /**\n * A callback that is called when the user presses the previous button along with the default action.\n */\n onPrevCallback?: (event: GestureResponderEvent) => void;\n /**\n * A callback that is called when the user presses the done button along with the default action.\n */\n onDoneCallback?: (event: GestureResponderEvent) => void;\n /**\n * A component that applies blur effect to the toolbar.\n */\n blur?: JSX.Element | null;\n /**\n * A value for container opacity in hexadecimal format (e.g. `ff`). Default value is `ff`.\n */\n opacity?: HEX;\n};\n\nconst TEST_ID_KEYBOARD_TOOLBAR = \"keyboard.toolbar\";\nconst TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS = `${TEST_ID_KEYBOARD_TOOLBAR}.previous`;\nconst TEST_ID_KEYBOARD_TOOLBAR_NEXT = `${TEST_ID_KEYBOARD_TOOLBAR}.next`;\nconst TEST_ID_KEYBOARD_TOOLBAR_CONTENT = `${TEST_ID_KEYBOARD_TOOLBAR}.content`;\nconst TEST_ID_KEYBOARD_TOOLBAR_DONE = `${TEST_ID_KEYBOARD_TOOLBAR}.done`;\n\nconst KEYBOARD_TOOLBAR_HEIGHT = 42;\nconst DEFAULT_OPACITY: HEX = \"FF\";\nconst offset = { closed: KEYBOARD_TOOLBAR_HEIGHT };\n\n/**\n * `KeyboardToolbar` is a component that is shown above the keyboard with `Prev`/`Next` and\n * `Done` buttons.\n */\nconst KeyboardToolbar: React.FC<KeyboardToolbarProps> = ({\n content,\n theme = colors,\n doneText,\n button,\n icon,\n showArrows = true,\n onNextCallback,\n onPrevCallback,\n onDoneCallback,\n blur = null,\n opacity = DEFAULT_OPACITY,\n ...rest\n}) => {\n const colorScheme = useColorScheme();\n const [inputs, setInputs] = useState({\n current: 0,\n count: 0,\n });\n const isPrevDisabled = inputs.current === 0;\n const isNextDisabled = inputs.current === inputs.count - 1;\n\n useEffect(() => {\n const subscription = FocusedInputEvents.addListener(\"focusDidSet\", (e) => {\n setInputs(e);\n });\n\n return subscription.remove;\n }, []);\n const doneStyle = useMemo(\n () => [styles.doneButton, { color: theme[colorScheme].primary }],\n [colorScheme, theme],\n );\n const toolbarStyle = useMemo(\n () => [\n styles.toolbar,\n {\n backgroundColor: `${theme[colorScheme].background}${opacity}`,\n },\n ],\n [colorScheme, opacity, theme],\n );\n const ButtonContainer = button || Button;\n const IconContainer = icon || Arrow;\n\n const onPressNext = useCallback(\n (event: GestureResponderEvent) => {\n onNextCallback?.(event);\n\n if (!event.isDefaultPrevented()) {\n KeyboardController.setFocusTo(\"next\");\n }\n },\n [onNextCallback],\n );\n const onPressPrev = useCallback(\n (event: GestureResponderEvent) => {\n onPrevCallback?.(event);\n\n if (!event.isDefaultPrevented()) {\n KeyboardController.setFocusTo(\"prev\");\n }\n },\n [onPrevCallback],\n );\n const onPressDone = useCallback(\n (event: GestureResponderEvent) => {\n onDoneCallback?.(event);\n\n if (!event.isDefaultPrevented()) {\n KeyboardController.dismiss();\n }\n },\n [onDoneCallback],\n );\n\n return (\n <KeyboardStickyView offset={offset}>\n <View {...rest} style={toolbarStyle} testID={TEST_ID_KEYBOARD_TOOLBAR}>\n {blur}\n {showArrows && (\n <>\n <ButtonContainer\n accessibilityHint=\"Moves focus to the previous field\"\n accessibilityLabel=\"Previous\"\n disabled={isPrevDisabled}\n testID={TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS}\n theme={theme}\n onPress={onPressPrev}\n >\n <IconContainer\n disabled={isPrevDisabled}\n theme={theme}\n type=\"prev\"\n />\n </ButtonContainer>\n <ButtonContainer\n accessibilityHint=\"Moves focus to the next field\"\n accessibilityLabel=\"Next\"\n disabled={isNextDisabled}\n testID={TEST_ID_KEYBOARD_TOOLBAR_NEXT}\n theme={theme}\n onPress={onPressNext}\n >\n <IconContainer\n disabled={isNextDisabled}\n theme={theme}\n type=\"next\"\n />\n </ButtonContainer>\n </>\n )}\n\n <View style={styles.flex} testID={TEST_ID_KEYBOARD_TOOLBAR_CONTENT}>\n {content}\n </View>\n <ButtonContainer\n accessibilityHint=\"Closes the keyboard\"\n accessibilityLabel=\"Done\"\n rippleRadius={28}\n style={styles.doneButtonContainer}\n testID={TEST_ID_KEYBOARD_TOOLBAR_DONE}\n theme={theme}\n onPress={onPressDone}\n >\n <Text maxFontSizeMultiplier={1.3} style={doneStyle}>\n {doneText || \"Done\"}\n </Text>\n </ButtonContainer>\n </View>\n </KeyboardStickyView>\n );\n};\n\nconst styles = StyleSheet.create({\n flex: {\n flex: 1,\n },\n toolbar: {\n position: \"absolute\",\n bottom: 0,\n alignItems: \"center\",\n width: \"100%\",\n flexDirection: \"row\",\n height: KEYBOARD_TOOLBAR_HEIGHT,\n paddingHorizontal: 8,\n },\n doneButton: {\n fontWeight: \"600\",\n fontSize: 15,\n },\n doneButtonContainer: {\n marginRight: 8,\n },\n});\n\nexport { colors as DefaultKeyboardToolbarTheme };\nexport default KeyboardToolbar;\n"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,mBAAA,GAAAD,sBAAA,CAAAJ,OAAA;AAEA,IAAAM,MAAA,GAAAF,sBAAA,CAAAJ,OAAA;AACA,IAAAO,OAAA,GAAAH,sBAAA,CAAAJ,OAAA;AACA,IAAAQ,OAAA,GAAAR,OAAA;AAAkC,SAAAI,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,yBAAAH,CAAA,6BAAAI,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAD,wBAAA,YAAAA,CAAAH,CAAA,WAAAA,CAAA,GA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version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { PropsWithChildren } from \"react\";\nimport 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 FocusedInputSelectionChangedEvent = {\n target: number;\n selection: {\n start: {\n x: number;\n y: number;\n position: number;\n };\n end: {\n x: number;\n y: number;\n position: number;\n };\n };\n};\nexport type EventWithName<T> = {\n eventName: string;\n} & T;\n\n// native View/Module declarations\nexport type KeyboardControllerProps = {\n //ref prop\n ref?: React.Ref<React.Component<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 onFocusedInputSelectionChanged?: (\n e: NativeSyntheticEvent<EventWithName<FocusedInputSelectionChangedEvent>>,\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 onFocusedInputSelectionChangedReanimated?: (\n e: NativeSyntheticEvent<EventWithName<FocusedInputSelectionChangedEvent>>,\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 /**\n * Extra distance to the keyboard.\n */\n offset?: number;\n} & ViewProps;\nexport type OverKeyboardViewProps = PropsWithChildren<{\n visible: boolean;\n}>;\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};\nexport type WindowDimensionsAvailableEvents = \"windowDidResize\";\nexport type WindowDimensionsEventData = {\n width: number;\n height: number;\n};\nexport type WindowDimensionsEventsModule = {\n addListener: (\n name: WindowDimensionsAvailableEvents,\n cb: (e: WindowDimensionsEventData) => 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;\nexport type FocusedInputSelectionHandlerHook<TContext, Event> = (\n handlers: {\n onFocusedInputSelectionChanged?: (\n e: FocusedInputSelectionChangedEvent,\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 onSelectionChange: (e: FocusedInputSelectionChangedEvent) => void;\n}>;\nexport type FocusedInputHandlers = Handlers<FocusedInputHandler>;\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { PropsWithChildren } from \"react\";\nimport 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 FocusedInputSelectionChangedEvent = {\n target: number;\n selection: {\n start: {\n x: number;\n y: number;\n position: number;\n };\n end: {\n x: number;\n y: number;\n position: number;\n };\n };\n};\nexport type EventWithName<T> = {\n eventName: string;\n} & T;\n\n// native View/Module declarations\nexport type KeyboardControllerProps = {\n //ref prop\n ref?: React.Ref<React.Component<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 onFocusedInputSelectionChanged?: (\n e: NativeSyntheticEvent<EventWithName<FocusedInputSelectionChangedEvent>>,\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 onFocusedInputSelectionChangedReanimated?: (\n e: NativeSyntheticEvent<EventWithName<FocusedInputSelectionChangedEvent>>,\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 /**\n * Extra distance to the keyboard.\n */\n offset?: number;\n} & ViewProps;\nexport type OverKeyboardViewProps = PropsWithChildren<{\n visible: boolean;\n}>;\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};\nexport type KeyboardControllerNativeModule = {\n // native event module stuff\n addListener: (eventName: string) => void;\n removeListeners: (count: number) => void;\n} & KeyboardControllerModule;\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};\nexport type WindowDimensionsAvailableEvents = \"windowDidResize\";\nexport type WindowDimensionsEventData = {\n width: number;\n height: number;\n};\nexport type WindowDimensionsEventsModule = {\n addListener: (\n name: WindowDimensionsAvailableEvents,\n cb: (e: WindowDimensionsEventData) => 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;\nexport type FocusedInputSelectionHandlerHook<TContext, Event> = (\n handlers: {\n onFocusedInputSelectionChanged?: (\n e: FocusedInputSelectionChangedEvent,\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 onSelectionChange: (e: FocusedInputSelectionChangedEvent) => void;\n}>;\nexport type FocusedInputHandlers = Handlers<FocusedInputHandler>;\n"],"mappings":"","ignoreList":[]}
|
package/lib/module/bindings.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["View","NOOP","KeyboardController","setDefaultMode","setInputMode","dismiss","setFocusTo","
|
|
1
|
+
{"version":3,"names":["View","NOOP","KeyboardController","setDefaultMode","setInputMode","dismiss","setFocusTo","KeyboardEvents","addListener","remove","FocusedInputEvents","WindowDimensionsEvents","KeyboardControllerView","KeyboardGestureArea","RCTOverKeyboardView"],"sources":["bindings.ts"],"sourcesContent":["import { View } from \"react-native\";\n\nimport type {\n FocusedInputEventsModule,\n KeyboardControllerModule,\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 KeyboardController: KeyboardControllerModule = {\n setDefaultMode: NOOP,\n setInputMode: NOOP,\n dismiss: NOOP,\n setFocusTo: 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,kBAA4C,GAAG;EAC1DC,cAAc,EAAEF,IAAI;EACpBG,YAAY,EAAEH,IAAI;EAClBI,OAAO,EAAEJ,IAAI;EACbK,UAAU,EAAEL;AACd,CAAC;AACD,OAAO,MAAMM,cAAoC,GAAG;EAClDC,WAAW,EAAEA,CAAA,MAAO;IAAEC,MAAM,EAAER;EAAK,CAAC;AACtC,CAAC;AACD;AACA;AACA;AACA;AACA,OAAO,MAAMS,kBAA4C,GAAG;EAC1DF,WAAW,EAAEA,CAAA,MAAO;IAAEC,MAAM,EAAER;EAAK,CAAC;AACtC,CAAC;AACD,OAAO,MAAMU,sBAAoD,GAAG;EAClEH,WAAW,EAAEA,CAAA,MAAO;IAAEC,MAAM,EAAER;EAAK,CAAC;AACtC,CAAC;AACD,OAAO,MAAMW,sBAAsB,GACjCZ,IAAoD;AACtD,OAAO,MAAMa,mBAAmB,GAC9Bb,IAAqD;AACvD,OAAO,MAAMc,mBAAmB,GAC9Bd,IAAkD","ignoreList":[]}
|
|
@@ -4,16 +4,23 @@ const LINKING_ERROR = `The package 'react-native-keyboard-controller' doesn't se
|
|
|
4
4
|
default: ""
|
|
5
5
|
}) + "- You rebuilt the app after installing the package\n" + "- You are not using Expo Go\n";
|
|
6
6
|
const RCTKeyboardController = require("./specs/NativeKeyboardController").default;
|
|
7
|
-
export const
|
|
7
|
+
export const KeyboardControllerNative = RCTKeyboardController ? RCTKeyboardController : new Proxy({}, {
|
|
8
8
|
get() {
|
|
9
9
|
throw new Error(LINKING_ERROR);
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
12
|
const KEYBOARD_CONTROLLER_NAMESPACE = "KeyboardController::";
|
|
13
|
-
const eventEmitter = new NativeEventEmitter(
|
|
13
|
+
const eventEmitter = new NativeEventEmitter(KeyboardControllerNative);
|
|
14
14
|
export const KeyboardEvents = {
|
|
15
15
|
addListener: (name, cb) => eventEmitter.addListener(KEYBOARD_CONTROLLER_NAMESPACE + name, cb)
|
|
16
16
|
};
|
|
17
|
+
export const KeyboardController = {
|
|
18
|
+
setDefaultMode: KeyboardControllerNative.setDefaultMode,
|
|
19
|
+
setInputMode: KeyboardControllerNative.setInputMode,
|
|
20
|
+
setFocusTo: KeyboardControllerNative.setFocusTo,
|
|
21
|
+
// additional function is needed because of this https://github.com/kirillzyusko/react-native-keyboard-controller/issues/684
|
|
22
|
+
dismiss: () => KeyboardControllerNative.dismiss()
|
|
23
|
+
};
|
|
17
24
|
/**
|
|
18
25
|
* This API is not documented, it's for internal usage only (for now), and is a subject to potential breaking changes in future.
|
|
19
26
|
* Use it with cautious.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeEventEmitter","Platform","LINKING_ERROR","select","ios","default","RCTKeyboardController","require","
|
|
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","KeyboardController","setDefaultMode","setInputMode","setFocusTo","dismiss","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 KeyboardControllerModule,\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};\nexport const KeyboardController: KeyboardControllerModule = {\n setDefaultMode: KeyboardControllerNative.setDefaultMode,\n setInputMode: KeyboardControllerNative.setInputMode,\n setFocusTo: KeyboardControllerNative.setFocusTo,\n // additional function is needed because of this https://github.com/kirillzyusko/react-native-keyboard-controller/issues/684\n dismiss: () => KeyboardControllerNative.dismiss(),\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\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;AAa3D,MAAMC,aAAa,GACjB,2FAA2F,GAC3FD,QAAQ,CAACE,MAAM,CAAC;EAAEC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CAAC,CAACF,OAAO;AAClE,OAAO,MAAMqB,mBAAuD,GAClEzB,QAAQ,CAAC0B,EAAE,KAAK,SAAS,IAAI1B,QAAQ,CAAC2B,OAAO,IAAI,EAAE,GAC/CrB,OAAO,CAAC,4CAA4C,CAAC,CAACF,OAAO,GAC7D,CAAC;EAAEwB;AAAmC,CAAC,KAAKA,QAAQ;AAC1D,OAAO,MAAMC,mBAAoD,GAC/DvB,OAAO,CAAC,yCAAyC,CAAC,CAACF,OAAO","ignoreList":[]}
|
|
@@ -17,9 +17,6 @@ const DEFAULT_OPACITY = "FF";
|
|
|
17
17
|
const offset = {
|
|
18
18
|
closed: KEYBOARD_TOOLBAR_HEIGHT
|
|
19
19
|
};
|
|
20
|
-
const dismissKeyboard = () => KeyboardController.dismiss();
|
|
21
|
-
const goToNextField = () => KeyboardController.setFocusTo("next");
|
|
22
|
-
const goToPrevField = () => KeyboardController.setFocusTo("prev");
|
|
23
20
|
|
|
24
21
|
/**
|
|
25
22
|
* `KeyboardToolbar` is a component that is shown above the keyboard with `Prev`/`Next` and
|
|
@@ -63,19 +60,19 @@ const KeyboardToolbar = ({
|
|
|
63
60
|
const onPressNext = useCallback(event => {
|
|
64
61
|
onNextCallback === null || onNextCallback === void 0 || onNextCallback(event);
|
|
65
62
|
if (!event.isDefaultPrevented()) {
|
|
66
|
-
|
|
63
|
+
KeyboardController.setFocusTo("next");
|
|
67
64
|
}
|
|
68
65
|
}, [onNextCallback]);
|
|
69
66
|
const onPressPrev = useCallback(event => {
|
|
70
67
|
onPrevCallback === null || onPrevCallback === void 0 || onPrevCallback(event);
|
|
71
68
|
if (!event.isDefaultPrevented()) {
|
|
72
|
-
|
|
69
|
+
KeyboardController.setFocusTo("prev");
|
|
73
70
|
}
|
|
74
71
|
}, [onPrevCallback]);
|
|
75
72
|
const onPressDone = useCallback(event => {
|
|
76
73
|
onDoneCallback === null || onDoneCallback === void 0 || onDoneCallback(event);
|
|
77
74
|
if (!event.isDefaultPrevented()) {
|
|
78
|
-
|
|
75
|
+
KeyboardController.dismiss();
|
|
79
76
|
}
|
|
80
77
|
}, [onDoneCallback]);
|
|
81
78
|
return /*#__PURE__*/React.createElement(KeyboardStickyView, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useCallback","useEffect","useMemo","useState","StyleSheet","Text","View","FocusedInputEvents","KeyboardController","useColorScheme","KeyboardStickyView","Arrow","Button","colors","TEST_ID_KEYBOARD_TOOLBAR","TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS","TEST_ID_KEYBOARD_TOOLBAR_NEXT","TEST_ID_KEYBOARD_TOOLBAR_CONTENT","TEST_ID_KEYBOARD_TOOLBAR_DONE","KEYBOARD_TOOLBAR_HEIGHT","DEFAULT_OPACITY","offset","closed","dismissKeyboard","dismiss","goToNextField","setFocusTo","goToPrevField","KeyboardToolbar","content","theme","doneText","button","icon","showArrows","onNextCallback","onPrevCallback","onDoneCallback","blur","opacity","rest","colorScheme","inputs","setInputs","current","count","isPrevDisabled","isNextDisabled","subscription","addListener","e","remove","doneStyle","styles","doneButton","color","primary","toolbarStyle","toolbar","backgroundColor","background","ButtonContainer","IconContainer","onPressNext","event","isDefaultPrevented","onPressPrev","onPressDone","createElement","_extends","style","testID","Fragment","accessibilityHint","accessibilityLabel","disabled","onPress","type","flex","rippleRadius","doneButtonContainer","maxFontSizeMultiplier","create","position","bottom","alignItems","width","flexDirection","height","paddingHorizontal","fontWeight","fontSize","marginRight","DefaultKeyboardToolbarTheme"],"sources":["index.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { StyleSheet, Text, View } from \"react-native\";\n\nimport { FocusedInputEvents, KeyboardController } from \"../../bindings\";\nimport useColorScheme from \"../hooks/useColorScheme\";\nimport KeyboardStickyView from \"../KeyboardStickyView\";\n\nimport Arrow from \"./Arrow\";\nimport Button from \"./Button\";\nimport { colors } from \"./colors\";\n\nimport type { HEX, KeyboardToolbarTheme } from \"./types\";\nimport type { ReactNode } from \"react\";\nimport type { GestureResponderEvent, ViewProps } from \"react-native\";\n\nexport type KeyboardToolbarProps = Omit<\n ViewProps,\n \"style\" | \"testID\" | \"children\"\n> & {\n /** An element that is shown in the middle of the toolbar. */\n content?: JSX.Element | null;\n /** A set of dark/light colors consumed by toolbar component. */\n theme?: KeyboardToolbarTheme;\n /** Custom text for done button. */\n doneText?: ReactNode;\n /** Custom touchable component for toolbar (used for prev/next/done buttons). */\n button?: typeof Button;\n /** Custom icon component used to display next/prev buttons. */\n icon?: typeof Arrow;\n /**\n * Whether to show next and previous buttons. Can be useful to set it to `false` if you have only one input\n * and want to show only `Done` button. Default to `true`.\n */\n showArrows?: boolean;\n /**\n * A callback that is called when the user presses the next button along with the default action.\n */\n onNextCallback?: (event: GestureResponderEvent) => void;\n /**\n * A callback that is called when the user presses the previous button along with the default action.\n */\n onPrevCallback?: (event: GestureResponderEvent) => void;\n /**\n * A callback that is called when the user presses the done button along with the default action.\n */\n onDoneCallback?: (event: GestureResponderEvent) => void;\n /**\n * A component that applies blur effect to the toolbar.\n */\n blur?: JSX.Element | null;\n /**\n * A value for container opacity in hexadecimal format (e.g. `ff`). Default value is `ff`.\n */\n opacity?: HEX;\n};\n\nconst TEST_ID_KEYBOARD_TOOLBAR = \"keyboard.toolbar\";\nconst TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS = `${TEST_ID_KEYBOARD_TOOLBAR}.previous`;\nconst TEST_ID_KEYBOARD_TOOLBAR_NEXT = `${TEST_ID_KEYBOARD_TOOLBAR}.next`;\nconst TEST_ID_KEYBOARD_TOOLBAR_CONTENT = `${TEST_ID_KEYBOARD_TOOLBAR}.content`;\nconst TEST_ID_KEYBOARD_TOOLBAR_DONE = `${TEST_ID_KEYBOARD_TOOLBAR}.done`;\n\nconst KEYBOARD_TOOLBAR_HEIGHT = 42;\nconst DEFAULT_OPACITY: HEX = \"FF\";\nconst offset = { closed: KEYBOARD_TOOLBAR_HEIGHT };\n\nconst dismissKeyboard = () => KeyboardController.dismiss();\nconst goToNextField = () => KeyboardController.setFocusTo(\"next\");\nconst goToPrevField = () => KeyboardController.setFocusTo(\"prev\");\n\n/**\n * `KeyboardToolbar` is a component that is shown above the keyboard with `Prev`/`Next` and\n * `Done` buttons.\n */\nconst KeyboardToolbar: React.FC<KeyboardToolbarProps> = ({\n content,\n theme = colors,\n doneText,\n button,\n icon,\n showArrows = true,\n onNextCallback,\n onPrevCallback,\n onDoneCallback,\n blur = null,\n opacity = DEFAULT_OPACITY,\n ...rest\n}) => {\n const colorScheme = useColorScheme();\n const [inputs, setInputs] = useState({\n current: 0,\n count: 0,\n });\n const isPrevDisabled = inputs.current === 0;\n const isNextDisabled = inputs.current === inputs.count - 1;\n\n useEffect(() => {\n const subscription = FocusedInputEvents.addListener(\"focusDidSet\", (e) => {\n setInputs(e);\n });\n\n return subscription.remove;\n }, []);\n const doneStyle = useMemo(\n () => [styles.doneButton, { color: theme[colorScheme].primary }],\n [colorScheme, theme],\n );\n const toolbarStyle = useMemo(\n () => [\n styles.toolbar,\n {\n backgroundColor: `${theme[colorScheme].background}${opacity}`,\n },\n ],\n [colorScheme, opacity, theme],\n );\n const ButtonContainer = button || Button;\n const IconContainer = icon || Arrow;\n\n const onPressNext = useCallback(\n (event: GestureResponderEvent) => {\n onNextCallback?.(event);\n\n if (!event.isDefaultPrevented()) {\n goToNextField();\n }\n },\n [onNextCallback],\n );\n const onPressPrev = useCallback(\n (event: GestureResponderEvent) => {\n onPrevCallback?.(event);\n\n if (!event.isDefaultPrevented()) {\n goToPrevField();\n }\n },\n [onPrevCallback],\n );\n const onPressDone = useCallback(\n (event: GestureResponderEvent) => {\n onDoneCallback?.(event);\n\n if (!event.isDefaultPrevented()) {\n dismissKeyboard();\n }\n },\n [onDoneCallback],\n );\n\n return (\n <KeyboardStickyView offset={offset}>\n <View {...rest} style={toolbarStyle} testID={TEST_ID_KEYBOARD_TOOLBAR}>\n {blur}\n {showArrows && (\n <>\n <ButtonContainer\n accessibilityHint=\"Moves focus to the previous field\"\n accessibilityLabel=\"Previous\"\n disabled={isPrevDisabled}\n testID={TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS}\n theme={theme}\n onPress={onPressPrev}\n >\n <IconContainer\n disabled={isPrevDisabled}\n theme={theme}\n type=\"prev\"\n />\n </ButtonContainer>\n <ButtonContainer\n accessibilityHint=\"Moves focus to the next field\"\n accessibilityLabel=\"Next\"\n disabled={isNextDisabled}\n testID={TEST_ID_KEYBOARD_TOOLBAR_NEXT}\n theme={theme}\n onPress={onPressNext}\n >\n <IconContainer\n disabled={isNextDisabled}\n theme={theme}\n type=\"next\"\n />\n </ButtonContainer>\n </>\n )}\n\n <View style={styles.flex} testID={TEST_ID_KEYBOARD_TOOLBAR_CONTENT}>\n {content}\n </View>\n <ButtonContainer\n accessibilityHint=\"Closes the keyboard\"\n accessibilityLabel=\"Done\"\n rippleRadius={28}\n style={styles.doneButtonContainer}\n testID={TEST_ID_KEYBOARD_TOOLBAR_DONE}\n theme={theme}\n onPress={onPressDone}\n >\n <Text maxFontSizeMultiplier={1.3} style={doneStyle}>\n {doneText || \"Done\"}\n </Text>\n </ButtonContainer>\n </View>\n </KeyboardStickyView>\n );\n};\n\nconst styles = StyleSheet.create({\n flex: {\n flex: 1,\n },\n toolbar: {\n position: \"absolute\",\n bottom: 0,\n alignItems: \"center\",\n width: \"100%\",\n flexDirection: \"row\",\n height: KEYBOARD_TOOLBAR_HEIGHT,\n paddingHorizontal: 8,\n },\n doneButton: {\n fontWeight: \"600\",\n fontSize: 15,\n },\n doneButtonContainer: {\n marginRight: 8,\n },\n});\n\nexport { colors as DefaultKeyboardToolbarTheme };\nexport default KeyboardToolbar;\n"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AACxE,SAASC,UAAU,EAAEC,IAAI,EAAEC,IAAI,QAAQ,cAAc;AAErD,SAASC,kBAAkB,EAAEC,kBAAkB,QA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React","useCallback","useEffect","useMemo","useState","StyleSheet","Text","View","FocusedInputEvents","KeyboardController","useColorScheme","KeyboardStickyView","Arrow","Button","colors","TEST_ID_KEYBOARD_TOOLBAR","TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS","TEST_ID_KEYBOARD_TOOLBAR_NEXT","TEST_ID_KEYBOARD_TOOLBAR_CONTENT","TEST_ID_KEYBOARD_TOOLBAR_DONE","KEYBOARD_TOOLBAR_HEIGHT","DEFAULT_OPACITY","offset","closed","KeyboardToolbar","content","theme","doneText","button","icon","showArrows","onNextCallback","onPrevCallback","onDoneCallback","blur","opacity","rest","colorScheme","inputs","setInputs","current","count","isPrevDisabled","isNextDisabled","subscription","addListener","e","remove","doneStyle","styles","doneButton","color","primary","toolbarStyle","toolbar","backgroundColor","background","ButtonContainer","IconContainer","onPressNext","event","isDefaultPrevented","setFocusTo","onPressPrev","onPressDone","dismiss","createElement","_extends","style","testID","Fragment","accessibilityHint","accessibilityLabel","disabled","onPress","type","flex","rippleRadius","doneButtonContainer","maxFontSizeMultiplier","create","position","bottom","alignItems","width","flexDirection","height","paddingHorizontal","fontWeight","fontSize","marginRight","DefaultKeyboardToolbarTheme"],"sources":["index.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { StyleSheet, Text, View } from \"react-native\";\n\nimport { FocusedInputEvents, KeyboardController } from \"../../bindings\";\nimport useColorScheme from \"../hooks/useColorScheme\";\nimport KeyboardStickyView from \"../KeyboardStickyView\";\n\nimport Arrow from \"./Arrow\";\nimport Button from \"./Button\";\nimport { colors } from \"./colors\";\n\nimport type { HEX, KeyboardToolbarTheme } from \"./types\";\nimport type { ReactNode } from \"react\";\nimport type { GestureResponderEvent, ViewProps } from \"react-native\";\n\nexport type KeyboardToolbarProps = Omit<\n ViewProps,\n \"style\" | \"testID\" | \"children\"\n> & {\n /** An element that is shown in the middle of the toolbar. */\n content?: JSX.Element | null;\n /** A set of dark/light colors consumed by toolbar component. */\n theme?: KeyboardToolbarTheme;\n /** Custom text for done button. */\n doneText?: ReactNode;\n /** Custom touchable component for toolbar (used for prev/next/done buttons). */\n button?: typeof Button;\n /** Custom icon component used to display next/prev buttons. */\n icon?: typeof Arrow;\n /**\n * Whether to show next and previous buttons. Can be useful to set it to `false` if you have only one input\n * and want to show only `Done` button. Default to `true`.\n */\n showArrows?: boolean;\n /**\n * A callback that is called when the user presses the next button along with the default action.\n */\n onNextCallback?: (event: GestureResponderEvent) => void;\n /**\n * A callback that is called when the user presses the previous button along with the default action.\n */\n onPrevCallback?: (event: GestureResponderEvent) => void;\n /**\n * A callback that is called when the user presses the done button along with the default action.\n */\n onDoneCallback?: (event: GestureResponderEvent) => void;\n /**\n * A component that applies blur effect to the toolbar.\n */\n blur?: JSX.Element | null;\n /**\n * A value for container opacity in hexadecimal format (e.g. `ff`). Default value is `ff`.\n */\n opacity?: HEX;\n};\n\nconst TEST_ID_KEYBOARD_TOOLBAR = \"keyboard.toolbar\";\nconst TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS = `${TEST_ID_KEYBOARD_TOOLBAR}.previous`;\nconst TEST_ID_KEYBOARD_TOOLBAR_NEXT = `${TEST_ID_KEYBOARD_TOOLBAR}.next`;\nconst TEST_ID_KEYBOARD_TOOLBAR_CONTENT = `${TEST_ID_KEYBOARD_TOOLBAR}.content`;\nconst TEST_ID_KEYBOARD_TOOLBAR_DONE = `${TEST_ID_KEYBOARD_TOOLBAR}.done`;\n\nconst KEYBOARD_TOOLBAR_HEIGHT = 42;\nconst DEFAULT_OPACITY: HEX = \"FF\";\nconst offset = { closed: KEYBOARD_TOOLBAR_HEIGHT };\n\n/**\n * `KeyboardToolbar` is a component that is shown above the keyboard with `Prev`/`Next` and\n * `Done` buttons.\n */\nconst KeyboardToolbar: React.FC<KeyboardToolbarProps> = ({\n content,\n theme = colors,\n doneText,\n button,\n icon,\n showArrows = true,\n onNextCallback,\n onPrevCallback,\n onDoneCallback,\n blur = null,\n opacity = DEFAULT_OPACITY,\n ...rest\n}) => {\n const colorScheme = useColorScheme();\n const [inputs, setInputs] = useState({\n current: 0,\n count: 0,\n });\n const isPrevDisabled = inputs.current === 0;\n const isNextDisabled = inputs.current === inputs.count - 1;\n\n useEffect(() => {\n const subscription = FocusedInputEvents.addListener(\"focusDidSet\", (e) => {\n setInputs(e);\n });\n\n return subscription.remove;\n }, []);\n const doneStyle = useMemo(\n () => [styles.doneButton, { color: theme[colorScheme].primary }],\n [colorScheme, theme],\n );\n const toolbarStyle = useMemo(\n () => [\n styles.toolbar,\n {\n backgroundColor: `${theme[colorScheme].background}${opacity}`,\n },\n ],\n [colorScheme, opacity, theme],\n );\n const ButtonContainer = button || Button;\n const IconContainer = icon || Arrow;\n\n const onPressNext = useCallback(\n (event: GestureResponderEvent) => {\n onNextCallback?.(event);\n\n if (!event.isDefaultPrevented()) {\n KeyboardController.setFocusTo(\"next\");\n }\n },\n [onNextCallback],\n );\n const onPressPrev = useCallback(\n (event: GestureResponderEvent) => {\n onPrevCallback?.(event);\n\n if (!event.isDefaultPrevented()) {\n KeyboardController.setFocusTo(\"prev\");\n }\n },\n [onPrevCallback],\n );\n const onPressDone = useCallback(\n (event: GestureResponderEvent) => {\n onDoneCallback?.(event);\n\n if (!event.isDefaultPrevented()) {\n KeyboardController.dismiss();\n }\n },\n [onDoneCallback],\n );\n\n return (\n <KeyboardStickyView offset={offset}>\n <View {...rest} style={toolbarStyle} testID={TEST_ID_KEYBOARD_TOOLBAR}>\n {blur}\n {showArrows && (\n <>\n <ButtonContainer\n accessibilityHint=\"Moves focus to the previous field\"\n accessibilityLabel=\"Previous\"\n disabled={isPrevDisabled}\n testID={TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS}\n theme={theme}\n onPress={onPressPrev}\n >\n <IconContainer\n disabled={isPrevDisabled}\n theme={theme}\n type=\"prev\"\n />\n </ButtonContainer>\n <ButtonContainer\n accessibilityHint=\"Moves focus to the next field\"\n accessibilityLabel=\"Next\"\n disabled={isNextDisabled}\n testID={TEST_ID_KEYBOARD_TOOLBAR_NEXT}\n theme={theme}\n onPress={onPressNext}\n >\n <IconContainer\n disabled={isNextDisabled}\n theme={theme}\n type=\"next\"\n />\n </ButtonContainer>\n </>\n )}\n\n <View style={styles.flex} testID={TEST_ID_KEYBOARD_TOOLBAR_CONTENT}>\n {content}\n </View>\n <ButtonContainer\n accessibilityHint=\"Closes the keyboard\"\n accessibilityLabel=\"Done\"\n rippleRadius={28}\n style={styles.doneButtonContainer}\n testID={TEST_ID_KEYBOARD_TOOLBAR_DONE}\n theme={theme}\n onPress={onPressDone}\n >\n <Text maxFontSizeMultiplier={1.3} style={doneStyle}>\n {doneText || \"Done\"}\n </Text>\n </ButtonContainer>\n </View>\n </KeyboardStickyView>\n );\n};\n\nconst styles = StyleSheet.create({\n flex: {\n flex: 1,\n },\n toolbar: {\n position: \"absolute\",\n bottom: 0,\n alignItems: \"center\",\n width: \"100%\",\n flexDirection: \"row\",\n height: KEYBOARD_TOOLBAR_HEIGHT,\n paddingHorizontal: 8,\n },\n doneButton: {\n fontWeight: \"600\",\n fontSize: 15,\n },\n doneButtonContainer: {\n marginRight: 8,\n },\n});\n\nexport { colors as DefaultKeyboardToolbarTheme };\nexport default KeyboardToolbar;\n"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AACxE,SAASC,UAAU,EAAEC,IAAI,EAAEC,IAAI,QAAQ,cAAc;AAErD,SAASC,kBAAkB,EAAEC,kBAAkB,QAAQ,gBAAgB;AACvE,OAAOC,cAAc,MAAM,yBAAyB;AACpD,OAAOC,kBAAkB,MAAM,uBAAuB;AAEtD,OAAOC,KAAK,MAAM,SAAS;AAC3B,OAAOC,MAAM,MAAM,UAAU;AAC7B,SAASC,MAAM,QAAQ,UAAU;AA+CjC,MAAMC,wBAAwB,GAAG,kBAAkB;AACnD,MAAMC,iCAAiC,GAAG,GAAGD,wBAAwB,WAAW;AAChF,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B;IAClCT,MAAM,EAAElD,6BAA8B;IACtCO,KAAK,EAAEA,KAAM;IACbgD,OAAO,EAAEV;EAAY,gBAErBhE,KAAA,CAAAkE,aAAA,CAAC5D,IAAI;IAACyE,qBAAqB,EAAE,GAAI;IAACX,KAAK,EAAEpB;EAAU,GAChDrB,QAAQ,IAAI,MACT,CACS,CACb,CACY,CAAC;AAEzB,CAAC;AAED,MAAMsB,MAAM,GAAG5C,UAAU,CAAC2E,MAAM,CAAC;EAC/BJ,IAAI,EAAE;IACJA,IAAI,EAAE;EACR,CAAC;EACDtB,OAAO,EAAE;IACP2B,QAAQ,EAAE,UAAU;IACpBC,MAAM,EAAE,CAAC;IACTC,UAAU,EAAE,QAAQ;IACpBC,KAAK,EAAE,MAAM;IACbC,aAAa,EAAE,KAAK;IACpBC,MAAM,EAAElE,uBAAuB;IAC/BmE,iBAAiB,EAAE;EACrB,CAAC;EACDrC,UAAU,EAAE;IACVsC,UAAU,EAAE,KAAK;IACjBC,QAAQ,EAAE;EACZ,CAAC;EACDX,mBAAmB,EAAE;IACnBY,WAAW,EAAE;EACf;AACF,CAAC,CAAC;AAEF,SAAS5E,MAAM,IAAI6E,2BAA2B;AAC9C,eAAenE,eAAe","ignoreList":[]}
|
package/lib/module/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { PropsWithChildren } from \"react\";\nimport 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 FocusedInputSelectionChangedEvent = {\n target: number;\n selection: {\n start: {\n x: number;\n y: number;\n position: number;\n };\n end: {\n x: number;\n y: number;\n position: number;\n };\n };\n};\nexport type EventWithName<T> = {\n eventName: string;\n} & T;\n\n// native View/Module declarations\nexport type KeyboardControllerProps = {\n //ref prop\n ref?: React.Ref<React.Component<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 onFocusedInputSelectionChanged?: (\n e: NativeSyntheticEvent<EventWithName<FocusedInputSelectionChangedEvent>>,\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 onFocusedInputSelectionChangedReanimated?: (\n e: NativeSyntheticEvent<EventWithName<FocusedInputSelectionChangedEvent>>,\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 /**\n * Extra distance to the keyboard.\n */\n offset?: number;\n} & ViewProps;\nexport type OverKeyboardViewProps = PropsWithChildren<{\n visible: boolean;\n}>;\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};\nexport type WindowDimensionsAvailableEvents = \"windowDidResize\";\nexport type WindowDimensionsEventData = {\n width: number;\n height: number;\n};\nexport type WindowDimensionsEventsModule = {\n addListener: (\n name: WindowDimensionsAvailableEvents,\n cb: (e: WindowDimensionsEventData) => 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;\nexport type FocusedInputSelectionHandlerHook<TContext, Event> = (\n handlers: {\n onFocusedInputSelectionChanged?: (\n e: FocusedInputSelectionChangedEvent,\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 onSelectionChange: (e: FocusedInputSelectionChangedEvent) => void;\n}>;\nexport type FocusedInputHandlers = Handlers<FocusedInputHandler>;\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { PropsWithChildren } from \"react\";\nimport 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 FocusedInputSelectionChangedEvent = {\n target: number;\n selection: {\n start: {\n x: number;\n y: number;\n position: number;\n };\n end: {\n x: number;\n y: number;\n position: number;\n };\n };\n};\nexport type EventWithName<T> = {\n eventName: string;\n} & T;\n\n// native View/Module declarations\nexport type KeyboardControllerProps = {\n //ref prop\n ref?: React.Ref<React.Component<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 onFocusedInputSelectionChanged?: (\n e: NativeSyntheticEvent<EventWithName<FocusedInputSelectionChangedEvent>>,\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 onFocusedInputSelectionChangedReanimated?: (\n e: NativeSyntheticEvent<EventWithName<FocusedInputSelectionChangedEvent>>,\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 /**\n * Extra distance to the keyboard.\n */\n offset?: number;\n} & ViewProps;\nexport type OverKeyboardViewProps = PropsWithChildren<{\n visible: boolean;\n}>;\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};\nexport type KeyboardControllerNativeModule = {\n // native event module stuff\n addListener: (eventName: string) => void;\n removeListeners: (count: number) => void;\n} & KeyboardControllerModule;\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};\nexport type WindowDimensionsAvailableEvents = \"windowDidResize\";\nexport type WindowDimensionsEventData = {\n width: number;\n height: number;\n};\nexport type WindowDimensionsEventsModule = {\n addListener: (\n name: WindowDimensionsAvailableEvents,\n cb: (e: WindowDimensionsEventData) => 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;\nexport type FocusedInputSelectionHandlerHook<TContext, Event> = (\n handlers: {\n onFocusedInputSelectionChanged?: (\n e: FocusedInputSelectionChangedEvent,\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 onSelectionChange: (e: FocusedInputSelectionChangedEvent) => void;\n}>;\nexport type FocusedInputHandlers = Handlers<FocusedInputHandler>;\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import type { FocusedInputEventsModule, KeyboardControllerModule, KeyboardControllerProps, KeyboardEventsModule, KeyboardGestureAreaProps, OverKeyboardViewProps, WindowDimensionsEventsModule } from "./types";
|
|
3
2
|
export declare const KeyboardController: KeyboardControllerModule;
|
|
4
3
|
export declare const KeyboardEvents: KeyboardEventsModule;
|
|
@@ -8,6 +7,6 @@ export declare const KeyboardEvents: KeyboardEventsModule;
|
|
|
8
7
|
*/
|
|
9
8
|
export declare const FocusedInputEvents: FocusedInputEventsModule;
|
|
10
9
|
export declare const WindowDimensionsEvents: WindowDimensionsEventsModule;
|
|
11
|
-
export declare const KeyboardControllerView:
|
|
12
|
-
export declare const KeyboardGestureArea:
|
|
13
|
-
export declare const RCTOverKeyboardView:
|
|
10
|
+
export declare const KeyboardControllerView: React.FC<KeyboardControllerProps>;
|
|
11
|
+
export declare const KeyboardGestureArea: React.FC<KeyboardGestureAreaProps>;
|
|
12
|
+
export declare const RCTOverKeyboardView: React.FC<OverKeyboardViewProps>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export declare const KeyboardController: KeyboardControllerModule;
|
|
1
|
+
import type { FocusedInputEventsModule, KeyboardControllerModule, KeyboardControllerNativeModule, KeyboardControllerProps, KeyboardEventsModule, KeyboardGestureAreaProps, OverKeyboardViewProps, WindowDimensionsEventsModule } from "./types";
|
|
2
|
+
export declare const KeyboardControllerNative: KeyboardControllerNativeModule;
|
|
4
3
|
export declare const KeyboardEvents: KeyboardEventsModule;
|
|
4
|
+
export declare const KeyboardController: KeyboardControllerModule;
|
|
5
5
|
/**
|
|
6
6
|
* This API is not documented, it's for internal usage only (for now), and is a subject to potential breaking changes in future.
|
|
7
7
|
* Use it with cautious.
|
|
@@ -29,7 +29,7 @@ declare const KeyboardAvoidingView: React.ForwardRefExoticComponent<{
|
|
|
29
29
|
/**
|
|
30
30
|
* Specify how to react to the presence of the keyboard.
|
|
31
31
|
*/
|
|
32
|
-
behavior?: "height" | "
|
|
32
|
+
behavior?: "height" | "position" | "padding";
|
|
33
33
|
/**
|
|
34
34
|
* Style of the content container when `behavior` is 'position'.
|
|
35
35
|
*/
|
|
@@ -38,13 +38,13 @@ declare const KeyboardAvoidingView: React.ForwardRefExoticComponent<{
|
|
|
38
38
|
* Controls whether this `KeyboardAvoidingView` instance should take effect.
|
|
39
39
|
* This is useful when more than one is on the screen. Defaults to true.
|
|
40
40
|
*/
|
|
41
|
-
enabled?: boolean
|
|
41
|
+
enabled?: boolean;
|
|
42
42
|
/**
|
|
43
43
|
* Distance between the top of the user screen and the React Native view. This
|
|
44
44
|
* may be non-zero in some cases. Defaults to 0.
|
|
45
45
|
*/
|
|
46
|
-
keyboardVerticalOffset?: number
|
|
46
|
+
keyboardVerticalOffset?: number;
|
|
47
47
|
} & ViewProps & {
|
|
48
|
-
children?: React.ReactNode;
|
|
48
|
+
children?: React.ReactNode | undefined;
|
|
49
49
|
} & React.RefAttributes<View>>;
|
|
50
50
|
export default KeyboardAvoidingView;
|
|
@@ -14,16 +14,16 @@ export type KeyboardAwareScrollViewProps = {
|
|
|
14
14
|
} & ScrollViewProps;
|
|
15
15
|
declare const KeyboardAwareScrollView: React.ForwardRefExoticComponent<{
|
|
16
16
|
/** The distance between keyboard and focused `TextInput` when keyboard is shown. Default is `0`. */
|
|
17
|
-
bottomOffset?: number
|
|
17
|
+
bottomOffset?: number;
|
|
18
18
|
/** Prevents automatic scrolling of the `ScrollView` when the keyboard gets hidden, maintaining the current screen position. Default is `false`. */
|
|
19
|
-
disableScrollOnKeyboardHide?: boolean
|
|
19
|
+
disableScrollOnKeyboardHide?: boolean;
|
|
20
20
|
/** Controls whether this `KeyboardAwareScrollView` instance should take effect. Default is `true` */
|
|
21
|
-
enabled?: boolean
|
|
21
|
+
enabled?: boolean;
|
|
22
22
|
/** Adjusting the bottom spacing of KeyboardAwareScrollView. Default is `0` */
|
|
23
|
-
extraKeyboardSpace?: number
|
|
23
|
+
extraKeyboardSpace?: number;
|
|
24
24
|
/** Custom component for `ScrollView`. Default is `ScrollView` */
|
|
25
|
-
ScrollViewComponent?: React.ComponentType<ScrollViewProps
|
|
25
|
+
ScrollViewComponent?: React.ComponentType<ScrollViewProps>;
|
|
26
26
|
} & ScrollViewProps & {
|
|
27
|
-
children?: React.ReactNode;
|
|
27
|
+
children?: React.ReactNode | undefined;
|
|
28
28
|
} & React.RefAttributes<ScrollView>>;
|
|
29
29
|
export default KeyboardAwareScrollView;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const debounce: <F extends (...args: Parameters<F>) => ReturnType<F>>(worklet: F, wait?: number) => (...args: Parameters<F>) =>
|
|
1
|
+
export declare const debounce: <F extends (...args: Parameters<F>) => ReturnType<F>>(worklet: F, wait?: number) => (...args: Parameters<F>) => ReturnType<F> | void;
|
|
2
2
|
export declare const scrollDistanceWithRespectToSnapPoints: (defaultScrollValue: number, snapPoints?: number[]) => number;
|
|
@@ -23,13 +23,13 @@ declare const KeyboardStickyView: React.ForwardRefExoticComponent<{
|
|
|
23
23
|
/**
|
|
24
24
|
* Adds additional `translateY` when keyboard is close. By default `0`.
|
|
25
25
|
*/
|
|
26
|
-
closed?: number
|
|
26
|
+
closed?: number;
|
|
27
27
|
/**
|
|
28
28
|
* Adds additional `translateY` when keyboard is open. By default `0`.
|
|
29
29
|
*/
|
|
30
|
-
opened?: number
|
|
31
|
-
}
|
|
30
|
+
opened?: number;
|
|
31
|
+
};
|
|
32
32
|
} & ViewProps & {
|
|
33
|
-
children?: React.ReactNode;
|
|
33
|
+
children?: React.ReactNode | undefined;
|
|
34
34
|
} & React.RefAttributes<View>>;
|
|
35
35
|
export default KeyboardStickyView;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { KeyboardToolbarTheme } from "./types";
|
|
3
|
+
import type { PropsWithChildren } from "react";
|
|
3
4
|
import type { GestureResponderEvent, ViewStyle } from "react-native";
|
|
4
5
|
type ButtonProps = {
|
|
5
6
|
disabled?: boolean;
|
|
@@ -11,5 +12,5 @@ type ButtonProps = {
|
|
|
11
12
|
style?: ViewStyle;
|
|
12
13
|
theme: KeyboardToolbarTheme;
|
|
13
14
|
};
|
|
14
|
-
declare const _default: ({ children, onPress, disabled, accessibilityLabel, accessibilityHint, testID, style, }:
|
|
15
|
+
declare const _default: ({ children, onPress, disabled, accessibilityLabel, accessibilityHint, testID, style, }: PropsWithChildren<ButtonProps>) => React.JSX.Element;
|
|
15
16
|
export default _default;
|
|
@@ -83,9 +83,11 @@ export type KeyboardControllerModule = {
|
|
|
83
83
|
setInputMode: (mode: number) => void;
|
|
84
84
|
dismiss: () => void;
|
|
85
85
|
setFocusTo: (direction: Direction) => void;
|
|
86
|
+
};
|
|
87
|
+
export type KeyboardControllerNativeModule = {
|
|
86
88
|
addListener: (eventName: string) => void;
|
|
87
89
|
removeListeners: (count: number) => void;
|
|
88
|
-
};
|
|
90
|
+
} & KeyboardControllerModule;
|
|
89
91
|
export type KeyboardControllerEvents = "keyboardWillShow" | "keyboardDidShow" | "keyboardWillHide" | "keyboardDidHide";
|
|
90
92
|
export type KeyboardEventData = {
|
|
91
93
|
height: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-keyboard-controller",
|
|
3
|
-
"version": "1.14.
|
|
3
|
+
"version": "1.14.5",
|
|
4
4
|
"description": "Keyboard manager which works in identical way on both iOS and Android",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -79,7 +79,8 @@
|
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
81
|
"@commitlint/config-conventional": "^11.0.0",
|
|
82
|
-
"@react-native/
|
|
82
|
+
"@react-native/babel-preset": "0.76.2",
|
|
83
|
+
"@react-native/eslint-config": "0.76.2",
|
|
83
84
|
"@release-it/conventional-changelog": "^2.0.0",
|
|
84
85
|
"@testing-library/react-hooks": "^8.0.1",
|
|
85
86
|
"@types/jest": "^29.2.1",
|
|
@@ -92,6 +93,7 @@
|
|
|
92
93
|
"eslint-config-prettier": "^8.5.0",
|
|
93
94
|
"eslint-import-resolver-typescript": "^3.6.1",
|
|
94
95
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
96
|
+
"eslint-plugin-ft-flow": "^3.0.11",
|
|
95
97
|
"eslint-plugin-import": "^2.28.1",
|
|
96
98
|
"eslint-plugin-jest": "^26.5.3",
|
|
97
99
|
"eslint-plugin-prettier": "^4.2.1",
|
|
@@ -102,12 +104,12 @@
|
|
|
102
104
|
"pod-install": "^0.1.0",
|
|
103
105
|
"prettier": "^2.8.8",
|
|
104
106
|
"react": "18.3.1",
|
|
105
|
-
"react-native": "0.
|
|
107
|
+
"react-native": "0.76.2",
|
|
106
108
|
"react-native-builder-bob": "^0.18.0",
|
|
107
109
|
"react-native-reanimated": "3.16.1",
|
|
108
110
|
"react-test-renderer": "18.2.0",
|
|
109
111
|
"release-it": "^14.2.2",
|
|
110
|
-
"typescript": "5.
|
|
112
|
+
"typescript": "5.6.3"
|
|
111
113
|
},
|
|
112
114
|
"peerDependencies": {
|
|
113
115
|
"react": "*",
|
package/src/bindings.native.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { NativeEventEmitter, Platform } from "react-native";
|
|
|
3
3
|
import type {
|
|
4
4
|
FocusedInputEventsModule,
|
|
5
5
|
KeyboardControllerModule,
|
|
6
|
+
KeyboardControllerNativeModule,
|
|
6
7
|
KeyboardControllerProps,
|
|
7
8
|
KeyboardEventsModule,
|
|
8
9
|
KeyboardGestureAreaProps,
|
|
@@ -19,7 +20,7 @@ const LINKING_ERROR =
|
|
|
19
20
|
const RCTKeyboardController =
|
|
20
21
|
require("./specs/NativeKeyboardController").default;
|
|
21
22
|
|
|
22
|
-
export const
|
|
23
|
+
export const KeyboardControllerNative = (
|
|
23
24
|
RCTKeyboardController
|
|
24
25
|
? RCTKeyboardController
|
|
25
26
|
: new Proxy(
|
|
@@ -30,15 +31,22 @@ export const KeyboardController = (
|
|
|
30
31
|
},
|
|
31
32
|
},
|
|
32
33
|
)
|
|
33
|
-
) as
|
|
34
|
+
) as KeyboardControllerNativeModule;
|
|
34
35
|
|
|
35
36
|
const KEYBOARD_CONTROLLER_NAMESPACE = "KeyboardController::";
|
|
36
|
-
const eventEmitter = new NativeEventEmitter(
|
|
37
|
+
const eventEmitter = new NativeEventEmitter(KeyboardControllerNative);
|
|
37
38
|
|
|
38
39
|
export const KeyboardEvents: KeyboardEventsModule = {
|
|
39
40
|
addListener: (name, cb) =>
|
|
40
41
|
eventEmitter.addListener(KEYBOARD_CONTROLLER_NAMESPACE + name, cb),
|
|
41
42
|
};
|
|
43
|
+
export const KeyboardController: KeyboardControllerModule = {
|
|
44
|
+
setDefaultMode: KeyboardControllerNative.setDefaultMode,
|
|
45
|
+
setInputMode: KeyboardControllerNative.setInputMode,
|
|
46
|
+
setFocusTo: KeyboardControllerNative.setFocusTo,
|
|
47
|
+
// additional function is needed because of this https://github.com/kirillzyusko/react-native-keyboard-controller/issues/684
|
|
48
|
+
dismiss: () => KeyboardControllerNative.dismiss(),
|
|
49
|
+
};
|
|
42
50
|
/**
|
|
43
51
|
* This API is not documented, it's for internal usage only (for now), and is a subject to potential breaking changes in future.
|
|
44
52
|
* Use it with cautious.
|
package/src/bindings.ts
CHANGED
|
@@ -18,8 +18,6 @@ export const KeyboardController: KeyboardControllerModule = {
|
|
|
18
18
|
setInputMode: NOOP,
|
|
19
19
|
dismiss: NOOP,
|
|
20
20
|
setFocusTo: NOOP,
|
|
21
|
-
addListener: NOOP,
|
|
22
|
-
removeListeners: NOOP,
|
|
23
21
|
};
|
|
24
22
|
export const KeyboardEvents: KeyboardEventsModule = {
|
|
25
23
|
addListener: () => ({ remove: NOOP } as EmitterSubscription),
|
|
@@ -64,10 +64,6 @@ const KEYBOARD_TOOLBAR_HEIGHT = 42;
|
|
|
64
64
|
const DEFAULT_OPACITY: HEX = "FF";
|
|
65
65
|
const offset = { closed: KEYBOARD_TOOLBAR_HEIGHT };
|
|
66
66
|
|
|
67
|
-
const dismissKeyboard = () => KeyboardController.dismiss();
|
|
68
|
-
const goToNextField = () => KeyboardController.setFocusTo("next");
|
|
69
|
-
const goToPrevField = () => KeyboardController.setFocusTo("prev");
|
|
70
|
-
|
|
71
67
|
/**
|
|
72
68
|
* `KeyboardToolbar` is a component that is shown above the keyboard with `Prev`/`Next` and
|
|
73
69
|
* `Done` buttons.
|
|
@@ -122,7 +118,7 @@ const KeyboardToolbar: React.FC<KeyboardToolbarProps> = ({
|
|
|
122
118
|
onNextCallback?.(event);
|
|
123
119
|
|
|
124
120
|
if (!event.isDefaultPrevented()) {
|
|
125
|
-
|
|
121
|
+
KeyboardController.setFocusTo("next");
|
|
126
122
|
}
|
|
127
123
|
},
|
|
128
124
|
[onNextCallback],
|
|
@@ -132,7 +128,7 @@ const KeyboardToolbar: React.FC<KeyboardToolbarProps> = ({
|
|
|
132
128
|
onPrevCallback?.(event);
|
|
133
129
|
|
|
134
130
|
if (!event.isDefaultPrevented()) {
|
|
135
|
-
|
|
131
|
+
KeyboardController.setFocusTo("prev");
|
|
136
132
|
}
|
|
137
133
|
},
|
|
138
134
|
[onPrevCallback],
|
|
@@ -142,7 +138,7 @@ const KeyboardToolbar: React.FC<KeyboardToolbarProps> = ({
|
|
|
142
138
|
onDoneCallback?.(event);
|
|
143
139
|
|
|
144
140
|
if (!event.isDefaultPrevented()) {
|
|
145
|
-
|
|
141
|
+
KeyboardController.dismiss();
|
|
146
142
|
}
|
|
147
143
|
},
|
|
148
144
|
[onDoneCallback],
|
package/src/types.ts
CHANGED
|
@@ -121,10 +121,12 @@ export type KeyboardControllerModule = {
|
|
|
121
121
|
// all platforms
|
|
122
122
|
dismiss: () => void;
|
|
123
123
|
setFocusTo: (direction: Direction) => void;
|
|
124
|
+
};
|
|
125
|
+
export type KeyboardControllerNativeModule = {
|
|
124
126
|
// native event module stuff
|
|
125
127
|
addListener: (eventName: string) => void;
|
|
126
128
|
removeListeners: (count: number) => void;
|
|
127
|
-
};
|
|
129
|
+
} & KeyboardControllerModule;
|
|
128
130
|
|
|
129
131
|
// Event module declarations
|
|
130
132
|
export type KeyboardControllerEvents =
|
|
File without changes
|