react-native-keyboard-controller 1.18.6 → 1.19.1

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 (109) hide show
  1. package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardControllerModule.kt +5 -2
  2. package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/EditText.kt +8 -1
  3. package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/View.kt +41 -0
  4. package/android/src/main/java/com/reactnativekeyboardcontroller/modules/KeyboardControllerModuleImpl.kt +25 -5
  5. package/android/src/main/java/com/reactnativekeyboardcontroller/modules/statusbar/StatusBarManagerCompatModuleImpl.kt +4 -4
  6. package/android/src/main/java/com/reactnativekeyboardcontroller/views/EdgeToEdgeReactViewGroup.kt +2 -8
  7. package/android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardControllerModule.kt +5 -2
  8. package/ios/KeyboardControllerModule.mm +3 -3
  9. package/ios/KeyboardControllerModuleImpl.swift +26 -16
  10. package/ios/delegates/KCTextInputCompositeDelegate.swift +13 -0
  11. package/ios/extensions/UITextInput.swift +5 -0
  12. package/ios/observers/movement/KeyboardTrackingView.swift +23 -11
  13. package/ios/views/KeyboardControllerView.mm +6 -1
  14. package/ios/views/KeyboardControllerViewManager.swift +2 -1
  15. package/ios/views/KeyboardExtenderContainerView.swift +1 -1
  16. package/ios/views/KeyboardExtenderManager.mm +1 -2
  17. package/lib/commonjs/animated.js +1 -2
  18. package/lib/commonjs/animated.js.map +1 -1
  19. package/lib/commonjs/components/KeyboardAvoidingView/index.js +1 -2
  20. package/lib/commonjs/components/KeyboardAvoidingView/index.js.map +1 -1
  21. package/lib/commonjs/components/KeyboardAwareScrollView/index.js +1 -2
  22. package/lib/commonjs/components/KeyboardAwareScrollView/index.js.map +1 -1
  23. package/lib/commonjs/components/KeyboardStickyView/index.js +1 -2
  24. package/lib/commonjs/components/KeyboardStickyView/index.js.map +1 -1
  25. package/lib/commonjs/components/KeyboardToolbar/Arrow.js +1 -2
  26. package/lib/commonjs/components/KeyboardToolbar/Arrow.js.map +1 -1
  27. package/lib/commonjs/components/KeyboardToolbar/Button.js +1 -2
  28. package/lib/commonjs/components/KeyboardToolbar/Button.js.map +1 -1
  29. package/lib/commonjs/components/KeyboardToolbar/compound/components/Background.js +13 -0
  30. package/lib/commonjs/components/KeyboardToolbar/compound/components/Background.js.map +1 -0
  31. package/lib/commonjs/components/KeyboardToolbar/compound/components/Content.js +25 -0
  32. package/lib/commonjs/components/KeyboardToolbar/compound/components/Content.js.map +1 -0
  33. package/lib/commonjs/components/KeyboardToolbar/compound/components/Done.js +61 -0
  34. package/lib/commonjs/components/KeyboardToolbar/compound/components/Done.js.map +1 -0
  35. package/lib/commonjs/components/KeyboardToolbar/compound/components/Next.js +52 -0
  36. package/lib/commonjs/components/KeyboardToolbar/compound/components/Next.js.map +1 -0
  37. package/lib/commonjs/components/KeyboardToolbar/compound/components/Prev.js +52 -0
  38. package/lib/commonjs/components/KeyboardToolbar/compound/components/Prev.js.map +1 -0
  39. package/lib/commonjs/components/KeyboardToolbar/compound/components/index.js +42 -0
  40. package/lib/commonjs/components/KeyboardToolbar/compound/components/index.js.map +1 -0
  41. package/lib/commonjs/components/KeyboardToolbar/compound/components/types.js +6 -0
  42. package/lib/commonjs/components/KeyboardToolbar/compound/components/types.js.map +1 -0
  43. package/lib/commonjs/components/KeyboardToolbar/compound/context.js +17 -0
  44. package/lib/commonjs/components/KeyboardToolbar/compound/context.js.map +1 -0
  45. package/lib/commonjs/components/KeyboardToolbar/index.js +76 -78
  46. package/lib/commonjs/components/KeyboardToolbar/index.js.map +1 -1
  47. package/lib/commonjs/components/KeyboardToolbar/types.js.map +1 -1
  48. package/lib/commonjs/components/index.js +1 -2
  49. package/lib/commonjs/components/index.js.map +1 -1
  50. package/lib/commonjs/hooks/useWindowDimensions/index.js +3 -3
  51. package/lib/commonjs/hooks/useWindowDimensions/index.js.map +1 -1
  52. package/lib/commonjs/module.js +2 -1
  53. package/lib/commonjs/module.js.map +1 -1
  54. package/lib/commonjs/specs/NativeKeyboardController.js.map +1 -1
  55. package/lib/commonjs/types/module.js.map +1 -1
  56. package/lib/commonjs/views/OverKeyboardView/index.js +1 -2
  57. package/lib/commonjs/views/OverKeyboardView/index.js.map +1 -1
  58. package/lib/module/components/KeyboardToolbar/compound/components/Background.js +6 -0
  59. package/lib/module/components/KeyboardToolbar/compound/components/Background.js.map +1 -0
  60. package/lib/module/components/KeyboardToolbar/compound/components/Content.js +18 -0
  61. package/lib/module/components/KeyboardToolbar/compound/components/Content.js.map +1 -0
  62. package/lib/module/components/KeyboardToolbar/compound/components/Done.js +54 -0
  63. package/lib/module/components/KeyboardToolbar/compound/components/Done.js.map +1 -0
  64. package/lib/module/components/KeyboardToolbar/compound/components/Next.js +44 -0
  65. package/lib/module/components/KeyboardToolbar/compound/components/Next.js.map +1 -0
  66. package/lib/module/components/KeyboardToolbar/compound/components/Prev.js +45 -0
  67. package/lib/module/components/KeyboardToolbar/compound/components/Prev.js.map +1 -0
  68. package/lib/module/components/KeyboardToolbar/compound/components/index.js +6 -0
  69. package/lib/module/components/KeyboardToolbar/compound/components/index.js.map +1 -0
  70. package/lib/module/components/KeyboardToolbar/compound/components/types.js +2 -0
  71. package/lib/module/components/KeyboardToolbar/compound/components/types.js.map +1 -0
  72. package/lib/module/components/KeyboardToolbar/compound/context.js +10 -0
  73. package/lib/module/components/KeyboardToolbar/compound/context.js.map +1 -0
  74. package/lib/module/components/KeyboardToolbar/index.js +78 -79
  75. package/lib/module/components/KeyboardToolbar/index.js.map +1 -1
  76. package/lib/module/components/KeyboardToolbar/types.js.map +1 -1
  77. package/lib/module/hooks/useWindowDimensions/index.js +3 -3
  78. package/lib/module/hooks/useWindowDimensions/index.js.map +1 -1
  79. package/lib/module/module.js +2 -1
  80. package/lib/module/module.js.map +1 -1
  81. package/lib/module/specs/NativeKeyboardController.js.map +1 -1
  82. package/lib/module/types/module.js.map +1 -1
  83. package/lib/typescript/components/KeyboardToolbar/compound/components/Background.d.ts +6 -0
  84. package/lib/typescript/components/KeyboardToolbar/compound/components/Content.d.ts +7 -0
  85. package/lib/typescript/components/KeyboardToolbar/compound/components/Done.d.ts +7 -0
  86. package/lib/typescript/components/KeyboardToolbar/compound/components/Next.d.ts +4 -0
  87. package/lib/typescript/components/KeyboardToolbar/compound/components/Prev.d.ts +4 -0
  88. package/lib/typescript/components/KeyboardToolbar/compound/components/index.d.ts +5 -0
  89. package/lib/typescript/components/KeyboardToolbar/compound/components/types.d.ts +14 -0
  90. package/lib/typescript/components/KeyboardToolbar/compound/context.d.ts +9 -0
  91. package/lib/typescript/components/KeyboardToolbar/index.d.ts +13 -54
  92. package/lib/typescript/components/KeyboardToolbar/types.d.ts +92 -5
  93. package/lib/typescript/specs/NativeKeyboardController.d.ts +1 -1
  94. package/lib/typescript/types/module.d.ts +5 -1
  95. package/package.json +8 -8
  96. package/src/components/KeyboardToolbar/compound/components/Background.tsx +9 -0
  97. package/src/components/KeyboardToolbar/compound/components/Content.tsx +25 -0
  98. package/src/components/KeyboardToolbar/compound/components/Done.tsx +70 -0
  99. package/src/components/KeyboardToolbar/compound/components/Next.tsx +55 -0
  100. package/src/components/KeyboardToolbar/compound/components/Prev.tsx +56 -0
  101. package/src/components/KeyboardToolbar/compound/components/index.ts +5 -0
  102. package/src/components/KeyboardToolbar/compound/components/types.ts +15 -0
  103. package/src/components/KeyboardToolbar/compound/context.ts +25 -0
  104. package/src/components/KeyboardToolbar/index.tsx +105 -165
  105. package/src/components/KeyboardToolbar/types.ts +101 -5
  106. package/src/hooks/useWindowDimensions/index.ts +3 -3
  107. package/src/module.ts +3 -2
  108. package/src/specs/NativeKeyboardController.ts +1 -1
  109. package/src/types/module.ts +5 -1
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["module.ts"],"sourcesContent":["import type { EmitterSubscription, TextInputProps } from \"react-native\";\n\n// Event module declarations\nexport type KeyboardControllerEvents =\n | \"keyboardWillShow\"\n | \"keyboardDidShow\"\n | \"keyboardWillHide\"\n | \"keyboardDidHide\";\nexport type KeyboardEventData = {\n /** Height of the keyboard. */\n height: number;\n /** Duration of the keyboard animation. */\n duration: number;\n /** Timestamp of the last keyboard event. */\n timestamp: number;\n /** Tag of the focused `TextInput`. */\n target: number;\n /** `keyboardType` property from focused `TextInput`. */\n type: NonNullable<TextInputProps[\"keyboardType\"]>;\n /** Keyboard appearance. Can be one of `dark` or `light`. */\n appearance: \"dark\" | \"light\";\n};\n/**\n * An object that represent current keyboard state.\n */\nexport type KeyboardState = {\n /** Whether the keyboard is currently visible. */\n isVisible: boolean;\n} & KeyboardEventData;\nexport type KeyboardEventsModule = {\n /**\n * The `addListener` function connects a JavaScript function to an identified native\n * keyboard notification event.\n *\n * This function then returns the reference to the listener.\n *\n * `name` is the string that identifies the event you're listening for. This\n * can be any of the following:\n *\n * - `keyboardWillShow`;\n * - `keyboardDidShow`;\n * - `keyboardWillHide`;\n * - `keyboardDidHide`.\n */\n addListener: (\n name: KeyboardControllerEvents,\n cb: (e: KeyboardEventData) => void,\n ) => EmitterSubscription;\n};\nexport type Direction = \"next\" | \"prev\" | \"current\";\nexport type DismissOptions = {\n /**\n * A boolean property indicating whether focus should be kept on the input after dismissing the keyboard. Default is `false`.\n */\n keepFocus: boolean;\n};\nexport type KeyboardControllerModule = {\n // android only\n /**\n * Sets default `windowSoftInputMode` (the one that declared in `AndroidManifest.xml`).\n *\n * @platform android\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#setdefaultmode-|docs} page for more details.\n */\n setDefaultMode: () => void;\n /**\n * Changes `windowSoftInputMode` on Android.\n *\n * @platform android\n * @see AndroidSoftInputModes for all possible values and {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#setinputmode-|docs} page for more details.\n */\n setInputMode: (mode: number) => void;\n // ios only\n /**\n * A method that preloads the keyboard. It's useful when you want to avoid a delay when the user focuses the first input.\n *\n * @platform ios\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#preload-|docs} page for more details.\n */\n preload: () => void;\n // all platforms\n /**\n * Dismisses the active keyboard. Removes a focus by default, but allows to pass `{keepFocus: true}` to keep focus.\n *\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#dismiss|docs} page for more details.\n */\n dismiss: (options?: DismissOptions) => Promise<void>;\n /**\n * Moves focus to the specified direction (`next`, `prev` or `current` to restore a focus).\n *\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#setfocusto|docs} page for more details.\n */\n setFocusTo: (direction: Direction) => void;\n /**\n * Whether the keyboard is fully visible.\n *\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#isvisible|docs} page for more details.\n */\n isVisible: () => boolean;\n /**\n * Method that returns current keyboard state.\n *\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#state|docs} page for more details.\n */\n state: () => KeyboardEventData;\n};\nexport type KeyboardControllerNativeModule = {\n // android only\n setDefaultMode: () => void;\n setInputMode: (mode: number) => void;\n // ios only\n preload: () => void;\n // all platforms\n dismiss: (keepFocus: boolean) => void;\n setFocusTo: (direction: Direction) => void;\n // native event module stuff\n addListener: (eventName: string) => void;\n removeListeners: (count: number) => void;\n};\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["module.ts"],"sourcesContent":["import type { EmitterSubscription, TextInputProps } from \"react-native\";\n\n// Event module declarations\nexport type KeyboardControllerEvents =\n | \"keyboardWillShow\"\n | \"keyboardDidShow\"\n | \"keyboardWillHide\"\n | \"keyboardDidHide\";\nexport type KeyboardEventData = {\n /** Height of the keyboard. */\n height: number;\n /** Duration of the keyboard animation. */\n duration: number;\n /** Timestamp of the last keyboard event. */\n timestamp: number;\n /** Tag of the focused `TextInput`. */\n target: number;\n /** `keyboardType` property from focused `TextInput`. */\n type: NonNullable<TextInputProps[\"keyboardType\"]>;\n /** Keyboard appearance. Can be one of `dark` or `light`. */\n appearance: \"dark\" | \"light\";\n};\n/**\n * An object that represent current keyboard state.\n */\nexport type KeyboardState = {\n /** Whether the keyboard is currently visible. */\n isVisible: boolean;\n} & KeyboardEventData;\nexport type KeyboardEventsModule = {\n /**\n * The `addListener` function connects a JavaScript function to an identified native\n * keyboard notification event.\n *\n * This function then returns the reference to the listener.\n *\n * `name` is the string that identifies the event you're listening for. This\n * can be any of the following:\n *\n * - `keyboardWillShow`;\n * - `keyboardDidShow`;\n * - `keyboardWillHide`;\n * - `keyboardDidHide`.\n */\n addListener: (\n name: KeyboardControllerEvents,\n cb: (e: KeyboardEventData) => void,\n ) => EmitterSubscription;\n};\nexport type Direction = \"next\" | \"prev\" | \"current\";\nexport type DismissOptions = {\n /**\n * A boolean property indicating whether focus should be kept on the input after dismissing the keyboard. Default is `false`.\n */\n keepFocus: boolean;\n /**\n * A boolean property controlling whether dismissal should be animated. Default is `true`.\n */\n animated: boolean;\n};\nexport type KeyboardControllerModule = {\n // android only\n /**\n * Sets default `windowSoftInputMode` (the one that declared in `AndroidManifest.xml`).\n *\n * @platform android\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#setdefaultmode-|docs} page for more details.\n */\n setDefaultMode: () => void;\n /**\n * Changes `windowSoftInputMode` on Android.\n *\n * @platform android\n * @see AndroidSoftInputModes for all possible values and {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#setinputmode-|docs} page for more details.\n */\n setInputMode: (mode: number) => void;\n // ios only\n /**\n * A method that preloads the keyboard. It's useful when you want to avoid a delay when the user focuses the first input.\n *\n * @platform ios\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#preload-|docs} page for more details.\n */\n preload: () => void;\n // all platforms\n /**\n * Dismisses the active keyboard. Removes a focus by default, but allows to pass `{keepFocus: true}` to keep focus.\n *\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#dismiss|docs} page for more details.\n */\n dismiss: (options?: DismissOptions) => Promise<void>;\n /**\n * Moves focus to the specified direction (`next`, `prev` or `current` to restore a focus).\n *\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#setfocusto|docs} page for more details.\n */\n setFocusTo: (direction: Direction) => void;\n /**\n * Whether the keyboard is fully visible.\n *\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#isvisible|docs} page for more details.\n */\n isVisible: () => boolean;\n /**\n * Method that returns current keyboard state.\n *\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#state|docs} page for more details.\n */\n state: () => KeyboardEventData;\n};\nexport type KeyboardControllerNativeModule = {\n // android only\n setDefaultMode: () => void;\n setInputMode: (mode: number) => void;\n // ios only\n preload: () => void;\n // all platforms\n dismiss: (keepFocus: boolean, animated: boolean) => void;\n setFocusTo: (direction: Direction) => void;\n // native event module stuff\n addListener: (eventName: string) => void;\n removeListeners: (count: number) => void;\n};\n"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ import React from "react";
2
+ import type { ReactNode } from "react";
3
+ declare const Background: React.FC<{
4
+ children: ReactNode;
5
+ }>;
6
+ export default Background;
@@ -0,0 +1,7 @@
1
+ import React from "react";
2
+ import type { ReactNode } from "react";
3
+ import type { ViewProps } from "react-native";
4
+ declare const Content: React.FC<ViewProps & {
5
+ children?: ReactNode;
6
+ }>;
7
+ export default Content;
@@ -0,0 +1,7 @@
1
+ import React from "react";
2
+ import type { ButtonSubProps } from "./types";
3
+ import type { ReactNode } from "react";
4
+ declare const Done: React.FC<Omit<ButtonSubProps, "icon"> & {
5
+ text?: ReactNode;
6
+ }>;
7
+ export default Done;
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import type { ButtonSubProps } from "./types";
3
+ declare const Next: React.FC<ButtonSubProps>;
4
+ export default Next;
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import type { ButtonSubProps } from "./types";
3
+ declare const Prev: React.FC<ButtonSubProps>;
4
+ export default Prev;
@@ -0,0 +1,5 @@
1
+ export { default as Background } from "./Background";
2
+ export { default as Content } from "./Content";
3
+ export { default as Done } from "./Done";
4
+ export { default as Next } from "./Next";
5
+ export { default as Prev } from "./Prev";
@@ -0,0 +1,14 @@
1
+ import type Arrow from "../../Arrow";
2
+ import type Button from "../../Button";
3
+ import type { ReactNode } from "react";
4
+ import type { GestureResponderEvent, ViewStyle } from "react-native";
5
+ export type ButtonSubProps = {
6
+ children?: ReactNode;
7
+ onPress?: (event: GestureResponderEvent) => void;
8
+ disabled?: boolean;
9
+ testID?: string;
10
+ rippleRadius?: number;
11
+ style?: ViewStyle;
12
+ button?: typeof Button;
13
+ icon?: typeof Arrow;
14
+ };
@@ -0,0 +1,9 @@
1
+ import type { KeyboardToolbarTheme } from "../types";
2
+ type ToolbarContextType = {
3
+ theme: KeyboardToolbarTheme;
4
+ isPrevDisabled: boolean;
5
+ isNextDisabled: boolean;
6
+ };
7
+ export declare const ToolbarContext: import("react").Context<ToolbarContextType | undefined>;
8
+ export declare const useToolbarContext: () => ToolbarContextType;
9
+ export {};
@@ -1,56 +1,7 @@
1
1
  import React from "react";
2
- import Arrow from "./Arrow";
3
- import Button from "./Button";
4
2
  import { colors } from "./colors";
5
- import type { HEX, KeyboardToolbarTheme } from "./types";
6
- import type { KeyboardStickyViewProps } from "../KeyboardStickyView";
7
- import type { ReactNode } from "react";
8
- import type { GestureResponderEvent, ViewProps } from "react-native";
9
- type SafeAreaInsets = {
10
- left: number;
11
- right: number;
12
- };
13
- export type KeyboardToolbarProps = Omit<ViewProps, "style" | "testID" | "children"> & {
14
- /** An element that is shown in the middle of the toolbar. */
15
- content?: React.JSX.Element | null;
16
- /** A set of dark/light colors consumed by toolbar component. */
17
- theme?: KeyboardToolbarTheme;
18
- /** Custom text for done button. */
19
- doneText?: ReactNode;
20
- /** Custom touchable component for toolbar (used for prev/next/done buttons). */
21
- button?: typeof Button;
22
- /** Custom icon component used to display next/prev buttons. */
23
- icon?: typeof Arrow;
24
- /**
25
- * Whether to show next and previous buttons. Can be useful to set it to `false` if you have only one input
26
- * and want to show only `Done` button. Default to `true`.
27
- */
28
- showArrows?: boolean;
29
- /**
30
- * A callback that is called when the user presses the next button along with the default action.
31
- */
32
- onNextCallback?: (event: GestureResponderEvent) => void;
33
- /**
34
- * A callback that is called when the user presses the previous button along with the default action.
35
- */
36
- onPrevCallback?: (event: GestureResponderEvent) => void;
37
- /**
38
- * A callback that is called when the user presses the done button along with the default action.
39
- */
40
- onDoneCallback?: (event: GestureResponderEvent) => void;
41
- /**
42
- * A component that applies blur effect to the toolbar.
43
- */
44
- blur?: React.JSX.Element | null;
45
- /**
46
- * A value for container opacity in hexadecimal format (e.g. `ff`). Default value is `ff`.
47
- */
48
- opacity?: HEX;
49
- /**
50
- * A object containing `left`/`right` properties. Used to specify proper container padding in landscape mode.
51
- */
52
- insets?: SafeAreaInsets;
53
- } & Pick<KeyboardStickyViewProps, "offset" | "enabled">;
3
+ import { Background, Content, Done, Next, Prev } from "./compound/components";
4
+ import type { KeyboardToolbarProps } from "./types";
54
5
  /**
55
6
  * `KeyboardToolbar` is a component that is shown above the keyboard with `Prev`/`Next` buttons from left and
56
7
  * `Done` button from the right (to dismiss the keyboard). Allows to add customizable content (yours UI elements) in the middle.
@@ -60,9 +11,17 @@ export type KeyboardToolbarProps = Omit<ViewProps, "style" | "testID" | "childre
60
11
  * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/components/keyboard-toolbar|Documentation} page for more details.
61
12
  * @example
62
13
  * ```tsx
63
- * <KeyboardToolbar doneText="Close" />
14
+ * <KeyboardToolbar>
15
+ * <KeyboardToolbar.Done text="Close" />
16
+ * </KeyboardToolbar>
64
17
  * ```
65
18
  */
66
- declare const KeyboardToolbar: React.FC<KeyboardToolbarProps>;
67
- export { colors as DefaultKeyboardToolbarTheme };
19
+ declare const KeyboardToolbar: React.FC<KeyboardToolbarProps> & {
20
+ Background: typeof Background;
21
+ Content: typeof Content;
22
+ Prev: typeof Prev;
23
+ Next: typeof Next;
24
+ Done: typeof Done;
25
+ };
26
+ export { colors as DefaultKeyboardToolbarTheme, KeyboardToolbarProps };
68
27
  export default KeyboardToolbar;
@@ -1,12 +1,16 @@
1
- import type { ColorValue } from "react-native";
1
+ import type Arrow from "./Arrow";
2
+ import type Button from "./Button";
3
+ import type { KeyboardStickyViewProps } from "../KeyboardStickyView";
4
+ import type { ReactNode } from "react";
5
+ import type { ColorValue, GestureResponderEvent, ViewProps } from "react-native";
2
6
  type Theme = {
3
- /** Color for arrow when it's enabled */
7
+ /** Color for arrow when it's enabled. */
4
8
  primary: ColorValue;
5
- /** Color for arrow when it's disabled */
9
+ /** Color for arrow when it's disabled. */
6
10
  disabled: ColorValue;
7
- /** Keyboard toolbar background color */
11
+ /** Keyboard toolbar background color. */
8
12
  background: string;
9
- /** Color for ripple effect (on button touch) on Android */
13
+ /** Color for ripple effect (on button touch) on Android. */
10
14
  ripple: ColorValue;
11
15
  };
12
16
  export type KeyboardToolbarTheme = {
@@ -15,4 +19,87 @@ export type KeyboardToolbarTheme = {
15
19
  };
16
20
  type HexSymbol = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "A" | "B" | "C" | "D" | "E" | "F" | "a" | "b" | "c" | "d" | "e" | "f";
17
21
  export type HEX = `${HexSymbol}${HexSymbol}`;
22
+ type SafeAreaInsets = {
23
+ left: number;
24
+ right: number;
25
+ };
26
+ export type KeyboardToolbarProps = Omit<ViewProps, "style" | "testID" | "children"> & {
27
+ /**
28
+ * An element that is shown in the middle of the toolbar.
29
+ *
30
+ * @deprecated Use compound API with `<KeyboardToolbar.Content />` component instead.
31
+ */
32
+ content?: React.JSX.Element | null;
33
+ /** A set of dark/light colors consumed by toolbar component. */
34
+ theme?: KeyboardToolbarTheme;
35
+ /**
36
+ * Custom text for done button.
37
+ *
38
+ * @deprecated Use compound API with `<KeyboardToolbar.Done />` component and `text` prop instead.
39
+ */
40
+ doneText?: ReactNode;
41
+ /**
42
+ * Custom touchable component for toolbar (used for prev/next/done buttons).
43
+ *
44
+ * @deprecated Use `button` property for corresponding element instead:
45
+ * ```tsx
46
+ * <KeyboardToolbar>
47
+ * <KeyboardToolbar.Prev button={MyCustomButton} />
48
+ * </KeyboardToolbar>
49
+ * ```.
50
+ */
51
+ button?: typeof Button;
52
+ /**
53
+ * Custom icon component used to display next/prev buttons.
54
+ *
55
+ * @deprecated Use `icon` property for corresponding element instead:
56
+ * ```tsx
57
+ * <KeyboardToolbar>
58
+ * <KeyboardToolbar.Prev icon={MyCustomIcon} />
59
+ * </KeyboardToolbar>
60
+ * ```.
61
+ */
62
+ icon?: typeof Arrow;
63
+ /**
64
+ * Whether to show next and previous buttons. Can be useful to set it to `false` if you have only one input
65
+ * and want to show only `Done` button. Default to `true`.
66
+ *
67
+ * @deprecated Use compound API and conditional rendering for `<KeyboardToolbar.Next />` and `<KeyboardToolbar.Prev />`.
68
+ */
69
+ showArrows?: boolean;
70
+ /**
71
+ * A callback that is called when the user presses the next button along with the default action.
72
+ *
73
+ * @deprecated Use compound API with `<KeyboardToolbar.Next />` and `onPress` callback instead.
74
+ */
75
+ onNextCallback?: (event: GestureResponderEvent) => void;
76
+ /**
77
+ * A callback that is called when the user presses the previous button along with the default action.
78
+ *
79
+ * @deprecated Use compound API with `<KeyboardToolbar.Prev />` and `onPress` callback instead.
80
+ */
81
+ onPrevCallback?: (event: GestureResponderEvent) => void;
82
+ /**
83
+ * A callback that is called when the user presses the done button along with the default action.
84
+ *
85
+ * @deprecated Use compound API with `<KeyboardToolbar.Done />` and `onPress` callback instead.
86
+ */
87
+ onDoneCallback?: (event: GestureResponderEvent) => void;
88
+ /**
89
+ * A component that applies blur effect to the toolbar.
90
+ *
91
+ * @deprecated Use compound API and `<KeyboardToolbar.Effect />` instead.
92
+ */
93
+ blur?: React.JSX.Element | null;
94
+ /**
95
+ * A value for container opacity in hexadecimal format (e.g. `ff`). Default value is `ff`.
96
+ */
97
+ opacity?: HEX;
98
+ /**
99
+ * A object containing `left`/`right` properties. Used to specify proper container padding in landscape mode.
100
+ */
101
+ insets?: SafeAreaInsets;
102
+ /** JSX children in case if compound API is used. */
103
+ children?: ReactNode;
104
+ } & Pick<KeyboardStickyViewProps, "offset" | "enabled">;
18
105
  export {};
@@ -4,7 +4,7 @@ export interface Spec extends TurboModule {
4
4
  setInputMode(mode: number): void;
5
5
  setDefaultMode(): void;
6
6
  preload(): void;
7
- dismiss(keepFocus: boolean): void;
7
+ dismiss(keepFocus: boolean, animated: boolean): void;
8
8
  setFocusTo(direction: string): void;
9
9
  addListener: (eventName: string) => void;
10
10
  removeListeners: (count: number) => void;
@@ -44,6 +44,10 @@ export type DismissOptions = {
44
44
  * A boolean property indicating whether focus should be kept on the input after dismissing the keyboard. Default is `false`.
45
45
  */
46
46
  keepFocus: boolean;
47
+ /**
48
+ * A boolean property controlling whether dismissal should be animated. Default is `true`.
49
+ */
50
+ animated: boolean;
47
51
  };
48
52
  export type KeyboardControllerModule = {
49
53
  /**
@@ -96,7 +100,7 @@ export type KeyboardControllerNativeModule = {
96
100
  setDefaultMode: () => void;
97
101
  setInputMode: (mode: number) => void;
98
102
  preload: () => void;
99
- dismiss: (keepFocus: boolean) => void;
103
+ dismiss: (keepFocus: boolean, animated: boolean) => void;
100
104
  setFocusTo: (direction: Direction) => void;
101
105
  addListener: (eventName: string) => void;
102
106
  removeListeners: (count: number) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-keyboard-controller",
3
- "version": "1.18.6",
3
+ "version": "1.19.1",
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",
@@ -41,7 +41,7 @@
41
41
  "typescript": "tsc --noEmit --project tsconfig.build.json",
42
42
  "lint": "eslint --quiet \"**/*.{js,ts,tsx}\"",
43
43
  "lint-clang": "find ios/ -iname *.h -o -iname *.m -o -iname *.mm | grep -v -e Pods -e build | xargs clang-format -i -n --Werror",
44
- "prepare": "bob build",
44
+ "prepare": "bob build > /dev/null 2>&1",
45
45
  "release": "release-it",
46
46
  "example": "yarn --cwd example",
47
47
  "pods": "cd example && pod-install --quiet",
@@ -85,8 +85,8 @@
85
85
  },
86
86
  "devDependencies": {
87
87
  "@commitlint/config-conventional": "^11.0.0",
88
- "@react-native/babel-preset": "0.78.0",
89
- "@react-native/eslint-config": "0.78.0",
88
+ "@react-native/babel-preset": "0.81.4",
89
+ "@react-native/eslint-config": "0.81.4",
90
90
  "@release-it/conventional-changelog": "^2.0.0",
91
91
  "@testing-library/react-hooks": "^8.0.1",
92
92
  "@types/jest": "^29.5.13",
@@ -111,13 +111,13 @@
111
111
  "jest": "^29.6.3",
112
112
  "pod-install": "^0.1.0",
113
113
  "prettier": "^2.8.8",
114
- "react": "19.0.0",
115
- "react-native": "0.78.0",
114
+ "react": "19.1.0",
115
+ "react-native": "0.81.4",
116
116
  "react-native-builder-bob": "^0.18.0",
117
- "react-native-reanimated": "3.17.0",
117
+ "react-native-reanimated": "3.19.2",
118
118
  "react-test-renderer": "19.0.0",
119
119
  "release-it": "^14.2.2",
120
- "typescript": "5.6.3"
120
+ "typescript": "5.8.3"
121
121
  },
122
122
  "peerDependencies": {
123
123
  "react": "*",
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+
3
+ import type { ReactNode } from "react";
4
+
5
+ const Background: React.FC<{ children: ReactNode }> = ({ children }) => (
6
+ <>{children}</>
7
+ );
8
+
9
+ export default Background;
@@ -0,0 +1,25 @@
1
+ import React from "react";
2
+ import { StyleSheet, View } from "react-native";
3
+
4
+ import { TEST_ID_KEYBOARD_TOOLBAR_CONTENT } from "../../constants";
5
+
6
+ import type { ReactNode } from "react";
7
+ import type { ViewProps } from "react-native";
8
+
9
+ const Content: React.FC<ViewProps & { children?: ReactNode }> = ({
10
+ children,
11
+ }) => {
12
+ return (
13
+ <View style={styles.flex} testID={TEST_ID_KEYBOARD_TOOLBAR_CONTENT}>
14
+ {children}
15
+ </View>
16
+ );
17
+ };
18
+
19
+ const styles = StyleSheet.create({
20
+ flex: {
21
+ flex: 1,
22
+ },
23
+ });
24
+
25
+ export default Content;
@@ -0,0 +1,70 @@
1
+ import React from "react";
2
+ import { useCallback, useMemo } from "react";
3
+ import { StyleSheet, Text } from "react-native";
4
+
5
+ import { useKeyboardState } from "../../../../hooks";
6
+ import { KeyboardController } from "../../../../module";
7
+ import Button from "../../Button";
8
+ import { TEST_ID_KEYBOARD_TOOLBAR_DONE } from "../../constants";
9
+ import { useToolbarContext } from "../context";
10
+
11
+ import type { ButtonSubProps } from "./types";
12
+ import type { ReactNode } from "react";
13
+ import type { GestureResponderEvent } from "react-native";
14
+
15
+ const Done: React.FC<Omit<ButtonSubProps, "icon"> & { text?: ReactNode }> = ({
16
+ children,
17
+ onPress,
18
+ rippleRadius = 28,
19
+ text,
20
+ button: ButtonContainer = Button,
21
+ }) => {
22
+ const colorScheme = useKeyboardState((state) => state.appearance);
23
+ const context = useToolbarContext();
24
+ const { theme } = context;
25
+
26
+ const doneStyle = useMemo(
27
+ () => [styles.doneButton, { color: theme[colorScheme].primary }],
28
+ [colorScheme, theme],
29
+ );
30
+
31
+ const onPressDone = useCallback(
32
+ (event: GestureResponderEvent) => {
33
+ onPress?.(event);
34
+
35
+ if (!event.isDefaultPrevented()) {
36
+ KeyboardController.dismiss();
37
+ }
38
+ },
39
+ [onPress],
40
+ );
41
+
42
+ return (
43
+ <ButtonContainer
44
+ accessibilityHint="Closes the keyboard"
45
+ accessibilityLabel="Done"
46
+ rippleRadius={rippleRadius}
47
+ style={styles.doneButtonContainer}
48
+ testID={TEST_ID_KEYBOARD_TOOLBAR_DONE}
49
+ theme={theme}
50
+ onPress={onPressDone}
51
+ >
52
+ <Text maxFontSizeMultiplier={1.3} style={doneStyle}>
53
+ {children ?? text ?? "Done"}
54
+ </Text>
55
+ </ButtonContainer>
56
+ );
57
+ };
58
+
59
+ const styles = StyleSheet.create({
60
+ doneButton: {
61
+ fontWeight: "600",
62
+ fontSize: 15,
63
+ },
64
+ doneButtonContainer: {
65
+ marginRight: 16,
66
+ marginLeft: 8,
67
+ },
68
+ });
69
+
70
+ export default Done;
@@ -0,0 +1,55 @@
1
+ import React, { useCallback } from "react";
2
+
3
+ import { KeyboardController } from "../../../../module";
4
+ import Arrow from "../../Arrow";
5
+ import Button from "../../Button";
6
+ import { TEST_ID_KEYBOARD_TOOLBAR_NEXT } from "../../constants";
7
+ import { useToolbarContext } from "../context";
8
+
9
+ import type { ButtonSubProps } from "./types";
10
+ import type { GestureResponderEvent } from "react-native";
11
+
12
+ const Next: React.FC<ButtonSubProps> = ({
13
+ children,
14
+ onPress,
15
+ disabled,
16
+ rippleRadius,
17
+ style,
18
+ button: ButtonContainer = Button,
19
+ icon: IconContainer = Arrow,
20
+ }) => {
21
+ const context = useToolbarContext();
22
+ const { theme, isNextDisabled } = context;
23
+
24
+ const isDisabled = disabled ?? isNextDisabled;
25
+
26
+ const onPressNext = useCallback(
27
+ (event: GestureResponderEvent) => {
28
+ onPress?.(event);
29
+
30
+ if (!event.isDefaultPrevented()) {
31
+ KeyboardController.setFocusTo("next");
32
+ }
33
+ },
34
+ [onPress],
35
+ );
36
+
37
+ return (
38
+ <ButtonContainer
39
+ accessibilityHint="Moves focus to the next field"
40
+ accessibilityLabel="Next"
41
+ disabled={isDisabled}
42
+ rippleRadius={rippleRadius}
43
+ style={style}
44
+ testID={TEST_ID_KEYBOARD_TOOLBAR_NEXT}
45
+ theme={theme}
46
+ onPress={onPressNext}
47
+ >
48
+ {children ?? (
49
+ <IconContainer disabled={isDisabled} theme={theme} type="next" />
50
+ )}
51
+ </ButtonContainer>
52
+ );
53
+ };
54
+
55
+ export default Next;
@@ -0,0 +1,56 @@
1
+ import React from "react";
2
+ import { useCallback } from "react";
3
+
4
+ import { KeyboardController } from "../../../../module";
5
+ import Arrow from "../../Arrow";
6
+ import Button from "../../Button";
7
+ import { TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS } from "../../constants";
8
+ import { useToolbarContext } from "../context";
9
+
10
+ import type { ButtonSubProps } from "./types";
11
+ import type { GestureResponderEvent } from "react-native";
12
+
13
+ const Prev: React.FC<ButtonSubProps> = ({
14
+ children,
15
+ onPress: onPressCallback,
16
+ disabled,
17
+ rippleRadius,
18
+ style,
19
+ button: ButtonContainer = Button,
20
+ icon: IconContainer = Arrow,
21
+ }) => {
22
+ const context = useToolbarContext();
23
+ const { theme, isPrevDisabled } = context;
24
+
25
+ const isDisabled = disabled ?? isPrevDisabled;
26
+
27
+ const onPressPrev = useCallback(
28
+ (event: GestureResponderEvent) => {
29
+ onPressCallback?.(event);
30
+
31
+ if (!event.isDefaultPrevented()) {
32
+ KeyboardController.setFocusTo("prev");
33
+ }
34
+ },
35
+ [onPressCallback],
36
+ );
37
+
38
+ return (
39
+ <ButtonContainer
40
+ accessibilityHint="Moves focus to the previous field"
41
+ accessibilityLabel="Previous"
42
+ disabled={isDisabled}
43
+ rippleRadius={rippleRadius}
44
+ style={style}
45
+ testID={TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS}
46
+ theme={theme}
47
+ onPress={onPressPrev}
48
+ >
49
+ {children ?? (
50
+ <IconContainer disabled={isDisabled} theme={theme} type="prev" />
51
+ )}
52
+ </ButtonContainer>
53
+ );
54
+ };
55
+
56
+ export default Prev;
@@ -0,0 +1,5 @@
1
+ export { default as Background } from "./Background";
2
+ export { default as Content } from "./Content";
3
+ export { default as Done } from "./Done";
4
+ export { default as Next } from "./Next";
5
+ export { default as Prev } from "./Prev";
@@ -0,0 +1,15 @@
1
+ import type Arrow from "../../Arrow";
2
+ import type Button from "../../Button";
3
+ import type { ReactNode } from "react";
4
+ import type { GestureResponderEvent, ViewStyle } from "react-native";
5
+
6
+ export type ButtonSubProps = {
7
+ children?: ReactNode;
8
+ onPress?: (event: GestureResponderEvent) => void;
9
+ disabled?: boolean;
10
+ testID?: string;
11
+ rippleRadius?: number;
12
+ style?: ViewStyle;
13
+ button?: typeof Button;
14
+ icon?: typeof Arrow;
15
+ };
@@ -0,0 +1,25 @@
1
+ import { createContext, useContext } from "react";
2
+
3
+ import type { KeyboardToolbarTheme } from "../types";
4
+
5
+ type ToolbarContextType = {
6
+ theme: KeyboardToolbarTheme;
7
+ isPrevDisabled: boolean;
8
+ isNextDisabled: boolean;
9
+ };
10
+
11
+ export const ToolbarContext = createContext<ToolbarContextType | undefined>(
12
+ undefined,
13
+ );
14
+
15
+ export const useToolbarContext = () => {
16
+ const context = useContext(ToolbarContext);
17
+
18
+ if (!context) {
19
+ throw new Error(
20
+ "KeyboardToolbar.* component must be used inside <KeyboardToolbar>",
21
+ );
22
+ }
23
+
24
+ return context;
25
+ };