react-native-keyboard-controller 1.12.6 → 1.12.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/java/com/reactnativekeyboardcontroller/listeners/FocusedInputObserver.kt +2 -0
- package/ios/core/KeyboardAnimation.swift +1 -1
- package/ios/core/TimingAnimation.swift +108 -0
- package/ios/extensions/UIApplication.swift +29 -0
- package/ios/observers/FocusedInputObserver.swift +2 -0
- package/ios/observers/KeyboardMovementObserver.swift +12 -5
- package/ios/traversal/ViewHierarchyNavigator.swift +1 -1
- package/lib/commonjs/animated.js +1 -0
- package/lib/commonjs/animated.js.map +1 -1
- package/lib/commonjs/components/KeyboardAvoidingView/hooks.js +1 -0
- package/lib/commonjs/components/KeyboardAvoidingView/hooks.js.map +1 -1
- package/lib/commonjs/components/KeyboardAvoidingView/index.js +1 -0
- package/lib/commonjs/components/KeyboardAvoidingView/index.js.map +1 -1
- package/lib/commonjs/components/KeyboardAwareScrollView/index.js +35 -10
- package/lib/commonjs/components/KeyboardAwareScrollView/index.js.map +1 -1
- package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +1 -0
- package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -1
- package/lib/commonjs/internal.js +1 -0
- package/lib/commonjs/internal.js.map +1 -1
- package/lib/module/animated.js +1 -0
- package/lib/module/animated.js.map +1 -1
- package/lib/module/components/KeyboardAvoidingView/hooks.js +1 -0
- package/lib/module/components/KeyboardAvoidingView/hooks.js.map +1 -1
- package/lib/module/components/KeyboardAvoidingView/index.js +1 -0
- package/lib/module/components/KeyboardAvoidingView/index.js.map +1 -1
- package/lib/module/components/KeyboardAwareScrollView/index.js +35 -10
- package/lib/module/components/KeyboardAwareScrollView/index.js.map +1 -1
- package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +1 -0
- package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -1
- package/lib/module/internal.js +1 -0
- package/lib/module/internal.js.map +1 -1
- package/package.json +4 -1
- package/src/animated.tsx +1 -0
- package/src/components/KeyboardAvoidingView/hooks.ts +1 -0
- package/src/components/KeyboardAvoidingView/index.tsx +1 -0
- package/src/components/KeyboardAwareScrollView/index.tsx +43 -10
- package/src/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.ts +1 -0
- package/src/internal.ts +1 -0
|
@@ -24,7 +24,10 @@ import type {
|
|
|
24
24
|
ScrollView,
|
|
25
25
|
ScrollViewProps,
|
|
26
26
|
} from "react-native";
|
|
27
|
-
import type {
|
|
27
|
+
import type {
|
|
28
|
+
FocusedInputLayoutChangedEvent,
|
|
29
|
+
FocusedInputSelectionChangedEvent,
|
|
30
|
+
} from "react-native-keyboard-controller";
|
|
28
31
|
|
|
29
32
|
export type KeyboardAwareScrollViewProps = {
|
|
30
33
|
/** The distance between keyboard and focused `TextInput` when keyboard is shown. Default is `0`. */
|
|
@@ -183,6 +186,32 @@ const KeyboardAwareScrollView = forwardRef<
|
|
|
183
186
|
[bottomOffset, enabled, height, rest.snapToOffsets],
|
|
184
187
|
);
|
|
185
188
|
|
|
189
|
+
const scrollFromCurrentPosition = useCallback(
|
|
190
|
+
(customHeight?: number) => {
|
|
191
|
+
"worklet";
|
|
192
|
+
|
|
193
|
+
const prevScrollPosition = scrollPosition.value;
|
|
194
|
+
const prevLayout = layout.value;
|
|
195
|
+
|
|
196
|
+
if (!input.value?.layout) {
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// eslint-disable-next-line react-compiler/react-compiler
|
|
201
|
+
layout.value = {
|
|
202
|
+
...input.value,
|
|
203
|
+
layout: {
|
|
204
|
+
...input.value.layout,
|
|
205
|
+
height: customHeight ?? input.value.layout.height,
|
|
206
|
+
},
|
|
207
|
+
};
|
|
208
|
+
scrollPosition.value = position.value;
|
|
209
|
+
maybeScroll(keyboardHeight.value, true);
|
|
210
|
+
scrollPosition.value = prevScrollPosition;
|
|
211
|
+
layout.value = prevLayout;
|
|
212
|
+
},
|
|
213
|
+
[maybeScroll],
|
|
214
|
+
);
|
|
186
215
|
const onChangeText = useCallback(() => {
|
|
187
216
|
"worklet";
|
|
188
217
|
|
|
@@ -192,15 +221,18 @@ const KeyboardAwareScrollView = forwardRef<
|
|
|
192
221
|
return;
|
|
193
222
|
}
|
|
194
223
|
|
|
195
|
-
|
|
196
|
-
|
|
224
|
+
scrollFromCurrentPosition();
|
|
225
|
+
}, [scrollFromCurrentPosition]);
|
|
226
|
+
const onSelectionChange = useCallback(
|
|
227
|
+
(e: FocusedInputSelectionChangedEvent) => {
|
|
228
|
+
"worklet";
|
|
197
229
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
230
|
+
if (e.selection.start.position !== e.selection.end.position) {
|
|
231
|
+
scrollFromCurrentPosition(e.selection.end.y);
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
[scrollFromCurrentPosition],
|
|
235
|
+
);
|
|
204
236
|
|
|
205
237
|
const onChangeTextHandler = useMemo(
|
|
206
238
|
() => debounce(onChangeText, 200),
|
|
@@ -210,8 +242,9 @@ const KeyboardAwareScrollView = forwardRef<
|
|
|
210
242
|
useFocusedInputHandler(
|
|
211
243
|
{
|
|
212
244
|
onChangeText: onChangeTextHandler,
|
|
245
|
+
onSelectionChange: onSelectionChange,
|
|
213
246
|
},
|
|
214
|
-
[onChangeTextHandler],
|
|
247
|
+
[onChangeTextHandler, onSelectionChange],
|
|
215
248
|
);
|
|
216
249
|
|
|
217
250
|
useSmoothKeyboardHandler(
|
|
@@ -65,6 +65,7 @@ export const useSmoothKeyboardHandler: typeof useKeyboardHandler = (
|
|
|
65
65
|
// dispatch `onEnd`
|
|
66
66
|
if (evt.height === height.value) {
|
|
67
67
|
handler.onEnd?.(evt);
|
|
68
|
+
// eslint-disable-next-line react-compiler/react-compiler
|
|
68
69
|
persistedHeight.value = height.value;
|
|
69
70
|
}
|
|
70
71
|
},
|
package/src/internal.ts
CHANGED
|
@@ -37,6 +37,7 @@ export function useSharedHandlers<
|
|
|
37
37
|
// that it will have all of them) and then update them in worklet thread (calls are
|
|
38
38
|
// happening in FIFO order, so we will always have actual value).
|
|
39
39
|
const updateSharedHandlers = () => {
|
|
40
|
+
// eslint-disable-next-line react-compiler/react-compiler
|
|
40
41
|
handlers.value = jsHandlers.current;
|
|
41
42
|
};
|
|
42
43
|
const setHandlers = useCallback((handler: Handlers<T>) => {
|