react-native-keyboard-controller 1.21.0-beta.1 → 1.21.0-beta.2

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 (80) hide show
  1. package/ios/animations/KeyboardAnimation.swift +2 -2
  2. package/ios/animations/SpringAnimation.swift +1 -1
  3. package/ios/animations/TimingAnimation.swift +3 -1
  4. package/ios/delegates/KCTextInputCompositeDelegate.swift +2 -2
  5. package/ios/extensions/CGFloat.swift +3 -1
  6. package/ios/interactive/KeyboardAreaExtender.swift +1 -2
  7. package/ios/observers/FocusedInputObserver.swift +2 -4
  8. package/ios/observers/movement/KeyboardTrackingView.swift +1 -4
  9. package/ios/observers/movement/observer/KeyboardMovementObserver+Interactive.swift +0 -2
  10. package/ios/observers/movement/observer/KeyboardMovementObserver+Listeners.swift +7 -30
  11. package/ios/observers/movement/observer/KeyboardMovementObserver.swift +48 -2
  12. package/ios/protocols/TextInput.swift +1 -1
  13. package/ios/swizzling/UIResponderSwizzle.swift +4 -2
  14. package/ios/traversal/FocusedInputHolder.swift +3 -3
  15. package/ios/traversal/KeyboardView.swift +1 -1
  16. package/ios/traversal/ViewHierarchyNavigator.swift +2 -2
  17. package/ios/views/KeyboardControllerViewManager.swift +5 -5
  18. package/jest/index.js +3 -0
  19. package/lib/commonjs/components/ChatKit/TODO.md +20 -0
  20. package/lib/commonjs/components/ChatKit/hooks.js +13 -0
  21. package/lib/commonjs/components/ChatKit/hooks.js.map +1 -0
  22. package/lib/commonjs/components/ChatKit/index.js +55 -0
  23. package/lib/commonjs/components/ChatKit/index.js.map +1 -0
  24. package/lib/commonjs/components/ChatKit/types.js +6 -0
  25. package/lib/commonjs/components/ChatKit/types.js.map +1 -0
  26. package/lib/commonjs/components/ChatKit/useChatKeyboard/helpers.js +101 -0
  27. package/lib/commonjs/components/ChatKit/useChatKeyboard/helpers.js.map +1 -0
  28. package/lib/commonjs/components/ChatKit/useChatKeyboard/index.js +147 -0
  29. package/lib/commonjs/components/ChatKit/useChatKeyboard/index.js.map +1 -0
  30. package/lib/commonjs/components/KeyboardAwareScrollView/index.js +7 -36
  31. package/lib/commonjs/components/KeyboardAwareScrollView/index.js.map +1 -1
  32. package/lib/commonjs/components/KeyboardStickyView/index.js +7 -5
  33. package/lib/commonjs/components/KeyboardStickyView/index.js.map +1 -1
  34. package/lib/commonjs/components/ScrollViewWithBottomPadding/index.js +38 -14
  35. package/lib/commonjs/components/ScrollViewWithBottomPadding/index.js.map +1 -1
  36. package/lib/commonjs/components/index.js +7 -0
  37. package/lib/commonjs/components/index.js.map +1 -1
  38. package/lib/commonjs/index.js +7 -0
  39. package/lib/commonjs/index.js.map +1 -1
  40. package/lib/module/components/ChatKit/TODO.md +20 -0
  41. package/lib/module/components/ChatKit/hooks.js +2 -0
  42. package/lib/module/components/ChatKit/hooks.js.map +1 -0
  43. package/lib/module/components/ChatKit/index.js +48 -0
  44. package/lib/module/components/ChatKit/index.js.map +1 -0
  45. package/lib/module/components/ChatKit/types.js +2 -0
  46. package/lib/module/components/ChatKit/types.js.map +1 -0
  47. package/lib/module/components/ChatKit/useChatKeyboard/helpers.js +92 -0
  48. package/lib/module/components/ChatKit/useChatKeyboard/helpers.js.map +1 -0
  49. package/lib/module/components/ChatKit/useChatKeyboard/index.js +141 -0
  50. package/lib/module/components/ChatKit/useChatKeyboard/index.js.map +1 -0
  51. package/lib/module/components/KeyboardAwareScrollView/index.js +7 -36
  52. package/lib/module/components/KeyboardAwareScrollView/index.js.map +1 -1
  53. package/lib/module/components/KeyboardStickyView/index.js +7 -5
  54. package/lib/module/components/KeyboardStickyView/index.js.map +1 -1
  55. package/lib/module/components/ScrollViewWithBottomPadding/index.js +38 -14
  56. package/lib/module/components/ScrollViewWithBottomPadding/index.js.map +1 -1
  57. package/lib/module/components/index.js +1 -0
  58. package/lib/module/components/index.js.map +1 -1
  59. package/lib/module/index.js +1 -1
  60. package/lib/module/index.js.map +1 -1
  61. package/lib/typescript/components/ChatKit/hooks.d.ts +2 -0
  62. package/lib/typescript/components/ChatKit/index.d.ts +14 -0
  63. package/lib/typescript/components/ChatKit/types.d.ts +49 -0
  64. package/lib/typescript/components/ChatKit/useChatKeyboard/helpers.d.ts +57 -0
  65. package/lib/typescript/components/ChatKit/useChatKeyboard/index.d.ts +36 -0
  66. package/lib/typescript/components/ScrollViewWithBottomPadding/index.d.ts +6 -1
  67. package/lib/typescript/components/index.d.ts +2 -0
  68. package/lib/typescript/index.d.ts +2 -2
  69. package/package.json +12 -4
  70. package/src/components/ChatKit/TODO.md +20 -0
  71. package/src/components/ChatKit/hooks.ts +2 -0
  72. package/src/components/ChatKit/index.tsx +63 -0
  73. package/src/components/ChatKit/types.ts +50 -0
  74. package/src/components/ChatKit/useChatKeyboard/helpers.ts +118 -0
  75. package/src/components/ChatKit/useChatKeyboard/index.ts +228 -0
  76. package/src/components/KeyboardAwareScrollView/index.tsx +7 -43
  77. package/src/components/KeyboardStickyView/index.tsx +4 -5
  78. package/src/components/ScrollViewWithBottomPadding/index.tsx +66 -17
  79. package/src/components/index.ts +2 -0
  80. package/src/index.ts +2 -0
@@ -6,11 +6,12 @@ import { ClippingScrollView } from "../../bindings";
6
6
 
7
7
  import styles from "./styles";
8
8
 
9
- import type { ScrollViewProps } from "react-native";
9
+ import type { ScrollViewProps, StyleProp, ViewStyle } from "react-native";
10
10
  import type { SharedValue } from "react-native-reanimated";
11
11
 
12
+ const OS = Platform.OS;
12
13
  const ReanimatedClippingScrollView =
13
- Platform.OS === "android"
14
+ OS === "android"
14
15
  ? Reanimated.createAnimatedComponent(ClippingScrollView)
15
16
  : ClippingScrollView;
16
17
 
@@ -25,7 +26,12 @@ export type AnimatedScrollViewComponent = React.ForwardRefExoticComponent<
25
26
  type ScrollViewWithBottomPaddingProps = {
26
27
  ScrollViewComponent: AnimatedScrollViewComponent;
27
28
  children?: React.ReactNode;
29
+ inverted?: boolean;
28
30
  bottomPadding: SharedValue<number>;
31
+ /** Absolute Y content offset (iOS only, for ChatKit). */
32
+ contentOffsetY?: SharedValue<number>;
33
+ /** Style applied to the container wrapper (Android only, for ChatKit translateY). */
34
+ containerStyle?: StyleProp<ViewStyle>;
29
35
  } & ScrollViewProps;
30
36
 
31
37
  const ScrollViewWithBottomPadding = forwardRef<
@@ -33,35 +39,78 @@ const ScrollViewWithBottomPadding = forwardRef<
33
39
  ScrollViewWithBottomPaddingProps
34
40
  >(
35
41
  (
36
- { ScrollViewComponent, bottomPadding, contentInset, children, ...rest },
42
+ {
43
+ ScrollViewComponent,
44
+ bottomPadding,
45
+ contentInset,
46
+ scrollIndicatorInsets,
47
+ inverted,
48
+ contentOffsetY,
49
+ containerStyle,
50
+ children,
51
+ style,
52
+ ...rest
53
+ },
37
54
  ref,
38
55
  ) => {
39
- const animatedProps = useAnimatedProps(
40
- () => ({
56
+ const animatedProps = useAnimatedProps(() => {
57
+ const bottom = inverted
58
+ ? 0
59
+ : bottomPadding.value + (contentInset?.bottom || 0);
60
+ const top = !inverted
61
+ ? 0
62
+ : bottomPadding.value + (contentInset?.top || 0);
63
+
64
+ const result: Record<string, unknown> = {
41
65
  // iOS prop
42
66
  contentInset: {
43
- bottom: bottomPadding.value + (contentInset?.bottom || 0),
44
- top: contentInset?.top,
67
+ bottom: bottom,
68
+ top: top,
45
69
  right: contentInset?.right,
46
70
  left: contentInset?.left,
47
71
  },
72
+ scrollIndicatorInsets: {
73
+ bottom: bottom,
74
+ top: top,
75
+ right: scrollIndicatorInsets?.right,
76
+ left: scrollIndicatorInsets?.left,
77
+ },
48
78
  // Android prop
49
79
  contentInsetBottom: bottomPadding.value,
50
- }),
51
- [
52
- contentInset?.bottom,
53
- contentInset?.top,
54
- contentInset?.right,
55
- contentInset?.left,
56
- ],
57
- );
80
+ };
81
+
82
+ if (contentOffsetY) {
83
+ result.contentOffset = { x: 0, y: contentOffsetY.value };
84
+ }
85
+
86
+ return result;
87
+ }, [
88
+ contentInset?.bottom,
89
+ contentInset?.top,
90
+ contentInset?.right,
91
+ contentInset?.left,
92
+ scrollIndicatorInsets?.bottom,
93
+ scrollIndicatorInsets?.top,
94
+ scrollIndicatorInsets?.right,
95
+ scrollIndicatorInsets?.left,
96
+ inverted,
97
+ contentOffsetY,
98
+ ]);
58
99
 
59
100
  return (
60
101
  <ReanimatedClippingScrollView
61
102
  animatedProps={animatedProps}
62
- style={styles.container}
103
+ style={[
104
+ styles.container,
105
+ OS === "android" ? containerStyle : undefined,
106
+ ]}
63
107
  >
64
- <ScrollViewComponent ref={ref} animatedProps={animatedProps} {...rest}>
108
+ <ScrollViewComponent
109
+ ref={ref}
110
+ animatedProps={animatedProps}
111
+ style={style}
112
+ {...rest}
113
+ >
65
114
  {children}
66
115
  </ScrollViewComponent>
67
116
  </ReanimatedClippingScrollView>
@@ -5,6 +5,7 @@ export {
5
5
  default as KeyboardToolbar,
6
6
  DefaultKeyboardToolbarTheme,
7
7
  } from "./KeyboardToolbar";
8
+ export { default as ChatKit } from "./ChatKit";
8
9
  export type { KeyboardAvoidingViewProps } from "./KeyboardAvoidingView";
9
10
  export type { KeyboardStickyViewProps } from "./KeyboardStickyView";
10
11
  export type {
@@ -12,3 +13,4 @@ export type {
12
13
  KeyboardAwareScrollViewRef,
13
14
  } from "./KeyboardAwareScrollView";
14
15
  export type { KeyboardToolbarProps } from "./KeyboardToolbar";
16
+ export type { ChatKitScrollViewProps } from "./ChatKit/types";
package/src/index.ts CHANGED
@@ -8,6 +8,7 @@ export * from "./types";
8
8
  export * from "./compat";
9
9
 
10
10
  export {
11
+ ChatKit,
11
12
  KeyboardAvoidingView,
12
13
  KeyboardStickyView,
13
14
  KeyboardAwareScrollView,
@@ -16,6 +17,7 @@ export {
16
17
  DefaultKeyboardToolbarTheme,
17
18
  } from "./components";
18
19
  export type {
20
+ ChatKitScrollViewProps,
19
21
  KeyboardAvoidingViewProps,
20
22
  KeyboardStickyViewProps,
21
23
  KeyboardAwareScrollViewProps,