react-native-keyboard-controller 1.21.4 → 1.21.6

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.
Files changed (56) hide show
  1. package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/ReactContext.kt +10 -0
  2. package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/View.kt +0 -40
  3. package/android/src/main/java/com/reactnativekeyboardcontroller/modules/KeyboardControllerModuleImpl.kt +3 -11
  4. package/android/src/main/java/com/reactnativekeyboardcontroller/views/ClippingScrollViewDecoratorView.kt +1 -1
  5. package/android/src/main/java/com/reactnativekeyboardcontroller/views/EdgeToEdgeReactViewGroup.kt +19 -22
  6. package/lib/commonjs/components/KeyboardChatScrollView/index.js +3 -2
  7. package/lib/commonjs/components/KeyboardChatScrollView/index.js.map +1 -1
  8. package/lib/commonjs/components/KeyboardChatScrollView/types.js.map +1 -1
  9. package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/index.ios.js +3 -3
  10. package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/index.ios.js.map +1 -1
  11. package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/index.js +4 -4
  12. package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/index.js.map +1 -1
  13. package/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/types.js.map +1 -1
  14. package/lib/commonjs/components/KeyboardChatScrollView/useExtraContentPadding/index.js +2 -2
  15. package/lib/commonjs/components/KeyboardChatScrollView/useExtraContentPadding/index.js.map +1 -1
  16. package/lib/commonjs/components/KeyboardToolbar/index.js +12 -3
  17. package/lib/commonjs/components/KeyboardToolbar/index.js.map +1 -1
  18. package/lib/commonjs/components/ScrollViewWithBottomPadding/index.js +1 -10
  19. package/lib/commonjs/components/ScrollViewWithBottomPadding/index.js.map +1 -1
  20. package/lib/commonjs/hooks/useKeyboardState/index.js +1 -7
  21. package/lib/commonjs/hooks/useKeyboardState/index.js.map +1 -1
  22. package/lib/commonjs/module.js +1 -1
  23. package/lib/commonjs/module.js.map +1 -1
  24. package/lib/module/components/KeyboardChatScrollView/index.js +3 -2
  25. package/lib/module/components/KeyboardChatScrollView/index.js.map +1 -1
  26. package/lib/module/components/KeyboardChatScrollView/types.js.map +1 -1
  27. package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/index.ios.js +3 -3
  28. package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/index.ios.js.map +1 -1
  29. package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/index.js +4 -4
  30. package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/index.js.map +1 -1
  31. package/lib/module/components/KeyboardChatScrollView/useChatKeyboard/types.js.map +1 -1
  32. package/lib/module/components/KeyboardChatScrollView/useExtraContentPadding/index.js +2 -2
  33. package/lib/module/components/KeyboardChatScrollView/useExtraContentPadding/index.js.map +1 -1
  34. package/lib/module/components/KeyboardToolbar/index.js +12 -3
  35. package/lib/module/components/KeyboardToolbar/index.js.map +1 -1
  36. package/lib/module/components/ScrollViewWithBottomPadding/index.js +2 -11
  37. package/lib/module/components/ScrollViewWithBottomPadding/index.js.map +1 -1
  38. package/lib/module/hooks/useKeyboardState/index.js +1 -7
  39. package/lib/module/hooks/useKeyboardState/index.js.map +1 -1
  40. package/lib/module/module.js +1 -1
  41. package/lib/module/module.js.map +1 -1
  42. package/lib/typescript/components/KeyboardChatScrollView/index.d.ts +1 -1
  43. package/lib/typescript/components/KeyboardChatScrollView/types.d.ts +1 -1
  44. package/lib/typescript/components/KeyboardChatScrollView/useChatKeyboard/types.d.ts +1 -1
  45. package/lib/typescript/components/KeyboardChatScrollView/useExtraContentPadding/index.d.ts +1 -1
  46. package/package.json +1 -1
  47. package/src/components/KeyboardChatScrollView/index.tsx +5 -2
  48. package/src/components/KeyboardChatScrollView/types.ts +1 -1
  49. package/src/components/KeyboardChatScrollView/useChatKeyboard/index.ios.ts +3 -3
  50. package/src/components/KeyboardChatScrollView/useChatKeyboard/index.ts +4 -4
  51. package/src/components/KeyboardChatScrollView/useChatKeyboard/types.ts +1 -1
  52. package/src/components/KeyboardChatScrollView/useExtraContentPadding/index.ts +3 -3
  53. package/src/components/KeyboardToolbar/index.tsx +13 -4
  54. package/src/components/ScrollViewWithBottomPadding/index.tsx +2 -12
  55. package/src/hooks/useKeyboardState/index.ts +1 -8
  56. package/src/module.ts +1 -1
@@ -26,7 +26,7 @@ type UseExtraContentPaddingOptions = {
26
26
  contentOffsetY?: SharedValue<number>;
27
27
  inverted: boolean;
28
28
  keyboardLiftBehavior: KeyboardLiftBehavior;
29
- freeze: boolean;
29
+ freeze: SharedValue<boolean>;
30
30
  };
31
31
 
32
32
  /**
@@ -81,7 +81,7 @@ function useExtraContentPadding(options: UseExtraContentPaddingOptions): void {
81
81
  useAnimatedReaction(
82
82
  () => extraContentPadding.value,
83
83
  (current, previous) => {
84
- if (freeze || previous === null) {
84
+ if (freeze.value || previous === null) {
85
85
  return;
86
86
  }
87
87
 
@@ -141,7 +141,7 @@ function useExtraContentPadding(options: UseExtraContentPaddingOptions): void {
141
141
  scrollToTarget(target);
142
142
  }
143
143
  },
144
- [inverted, keyboardLiftBehavior, freeze],
144
+ [inverted, keyboardLiftBehavior],
145
145
  );
146
146
  }
147
147
 
@@ -99,11 +99,13 @@ const KeyboardToolbar: React.FC<KeyboardToolbarProps> & {
99
99
  );
100
100
  const containerStyle = useMemo(
101
101
  () => [
102
+ // CRUCIAL: gives the native view real bounds
103
+ styles.sticky,
102
104
  KEYBOARD_HAS_ROUNDED_CORNERS
103
- ? {
104
- marginLeft: (insets?.left ?? 0) + 16,
105
- marginRight: (insets?.right ?? 0) + 16,
106
- }
105
+ ? ({
106
+ left: (insets?.left ?? 0) + 16,
107
+ right: (insets?.right ?? 0) + 16,
108
+ } as const)
107
109
  : null,
108
110
  ],
109
111
  [insets],
@@ -207,6 +209,13 @@ const KeyboardToolbar: React.FC<KeyboardToolbarProps> & {
207
209
  };
208
210
 
209
211
  const styles = StyleSheet.create({
212
+ sticky: {
213
+ position: "absolute",
214
+ left: 0,
215
+ right: 0,
216
+ bottom: 0,
217
+ height: KEYBOARD_TOOLBAR_HEIGHT,
218
+ },
210
219
  toolbar: {
211
220
  position: "absolute",
212
221
  bottom: 0,
@@ -1,5 +1,5 @@
1
1
  import React, { forwardRef } from "react";
2
- import { Platform, View } from "react-native";
2
+ import { Platform } from "react-native";
3
3
  import Reanimated, {
4
4
  useAnimatedProps,
5
5
  useSharedValue,
@@ -125,17 +125,7 @@ const ScrollViewWithBottomPadding = forwardRef<
125
125
  style={styles.container}
126
126
  >
127
127
  <ScrollViewComponent ref={ref} animatedProps={animatedProps} {...rest}>
128
- {inverted ? (
129
- // The only thing it can break is `StickyHeader`, but it's already broken in FlatList and other lists
130
- // don't support this functionality, so we can add additional view here
131
- // The correct fix would be to add a new prop in ScrollView that allows
132
- // to customize children extraction logic and skip custom view
133
- <View collapsable={false} nativeID="container">
134
- {children}
135
- </View>
136
- ) : (
137
- children
138
- )}
128
+ {children}
139
129
  </ScrollViewComponent>
140
130
  </ReanimatedClippingScrollView>
141
131
  );
@@ -5,7 +5,7 @@ import { KeyboardController } from "../../module";
5
5
 
6
6
  import type { IKeyboardState } from "../../types";
7
7
 
8
- const EVENTS = ["keyboardDidShow", "keyboardDidHide"] as const;
8
+ const EVENTS = ["keyboardWillShow", "keyboardDidHide"] as const;
9
9
 
10
10
  const getLatestState = () => ({
11
11
  ...KeyboardController.state(),
@@ -53,12 +53,6 @@ function useKeyboardState<T = IKeyboardState>(
53
53
  setState(selector(getLatestState())),
54
54
  ),
55
55
  );
56
- // update `appearance` prematurely
57
- const willShowSubscription = KeyboardEvents.addListener(
58
- "keyboardWillShow",
59
- (e) =>
60
- setState(selector({ ...getLatestState(), appearance: e.appearance })),
61
- );
62
56
 
63
57
  // we might have missed an update between reading a value in render and
64
58
  // `addListener` in this handler, so we set it here. If there was
@@ -67,7 +61,6 @@ function useKeyboardState<T = IKeyboardState>(
67
61
 
68
62
  return () => {
69
63
  subscriptions.forEach((subscription) => subscription.remove());
70
- willShowSubscription.remove();
71
64
  };
72
65
  }, []);
73
66
 
package/src/module.ts CHANGED
@@ -21,7 +21,7 @@ KeyboardEvents.addListener("keyboardDidHide", (e) => {
21
21
  lastState = e;
22
22
  });
23
23
 
24
- KeyboardEvents.addListener("keyboardDidShow", (e) => {
24
+ KeyboardEvents.addListener("keyboardWillShow", (e) => {
25
25
  isClosed = false;
26
26
  lastState = e;
27
27
  });