react-native-keyboard-controller 1.17.1 → 1.17.3

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 (135) hide show
  1. package/README.md +24 -23
  2. package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/ThemedReactContext.kt +20 -0
  3. package/android/src/main/java/com/reactnativekeyboardcontroller/listeners/KeyboardAnimationCallback.kt +4 -0
  4. package/ios/KeyboardControllerModule.mm +2 -0
  5. package/ios/views/KeyboardControllerView.mm +18 -0
  6. package/ios/views/KeyboardControllerViewManager.swift +19 -0
  7. package/lib/commonjs/animated.js +23 -7
  8. package/lib/commonjs/animated.js.map +1 -1
  9. package/lib/commonjs/bindings.js +19 -0
  10. package/lib/commonjs/bindings.js.map +1 -1
  11. package/lib/commonjs/components/KeyboardAvoidingView/index.js +14 -4
  12. package/lib/commonjs/components/KeyboardAvoidingView/index.js.map +1 -1
  13. package/lib/commonjs/components/KeyboardAwareScrollView/index.js +54 -36
  14. package/lib/commonjs/components/KeyboardAwareScrollView/index.js.map +1 -1
  15. package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +17 -1
  16. package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -1
  17. package/lib/commonjs/components/KeyboardStickyView/index.js +13 -0
  18. package/lib/commonjs/components/KeyboardStickyView/index.js.map +1 -1
  19. package/lib/commonjs/components/KeyboardToolbar/index.js +31 -22
  20. package/lib/commonjs/components/KeyboardToolbar/index.js.map +1 -1
  21. package/lib/commonjs/context.js +16 -0
  22. package/lib/commonjs/context.js.map +1 -1
  23. package/lib/commonjs/hooks/index.js +164 -0
  24. package/lib/commonjs/hooks/index.js.map +1 -1
  25. package/lib/commonjs/hooks/useKeyboardState/index.js +21 -0
  26. package/lib/commonjs/hooks/useKeyboardState/index.js.map +1 -1
  27. package/lib/commonjs/hooks/useWindowDimensions/index.js +29 -6
  28. package/lib/commonjs/hooks/useWindowDimensions/index.js.map +1 -1
  29. package/lib/commonjs/internal.js +21 -0
  30. package/lib/commonjs/internal.js.map +1 -1
  31. package/lib/commonjs/module.js +4 -0
  32. package/lib/commonjs/module.js.map +1 -1
  33. package/lib/commonjs/monkey-patch.android.js +0 -5
  34. package/lib/commonjs/monkey-patch.android.js.map +1 -1
  35. package/lib/commonjs/{types.js → types/hooks.js} +1 -1
  36. package/lib/commonjs/types/hooks.js.map +1 -0
  37. package/lib/commonjs/types/index.js +50 -0
  38. package/lib/commonjs/types/index.js.map +1 -0
  39. package/lib/commonjs/types/internal.js +6 -0
  40. package/lib/commonjs/types/internal.js.map +1 -0
  41. package/lib/commonjs/types/module.js +6 -0
  42. package/lib/commonjs/types/module.js.map +1 -0
  43. package/lib/commonjs/types/views.js +6 -0
  44. package/lib/commonjs/types/views.js.map +1 -0
  45. package/lib/commonjs/views/OverKeyboardView/index.js +18 -4
  46. package/lib/commonjs/views/OverKeyboardView/index.js.map +1 -1
  47. package/lib/module/animated.js +23 -7
  48. package/lib/module/animated.js.map +1 -1
  49. package/lib/module/bindings.js +19 -0
  50. package/lib/module/bindings.js.map +1 -1
  51. package/lib/module/components/KeyboardAvoidingView/index.js +14 -4
  52. package/lib/module/components/KeyboardAvoidingView/index.js.map +1 -1
  53. package/lib/module/components/KeyboardAwareScrollView/index.js +56 -38
  54. package/lib/module/components/KeyboardAwareScrollView/index.js.map +1 -1
  55. package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +17 -1
  56. package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -1
  57. package/lib/module/components/KeyboardStickyView/index.js +13 -0
  58. package/lib/module/components/KeyboardStickyView/index.js.map +1 -1
  59. package/lib/module/components/KeyboardToolbar/index.js +31 -22
  60. package/lib/module/components/KeyboardToolbar/index.js.map +1 -1
  61. package/lib/module/context.js +16 -0
  62. package/lib/module/context.js.map +1 -1
  63. package/lib/module/hooks/index.js +164 -0
  64. package/lib/module/hooks/index.js.map +1 -1
  65. package/lib/module/hooks/useKeyboardState/index.js +21 -0
  66. package/lib/module/hooks/useKeyboardState/index.js.map +1 -1
  67. package/lib/module/hooks/useWindowDimensions/index.js +28 -1
  68. package/lib/module/hooks/useWindowDimensions/index.js.map +1 -1
  69. package/lib/module/internal.js +21 -0
  70. package/lib/module/internal.js.map +1 -1
  71. package/lib/module/module.js +4 -0
  72. package/lib/module/module.js.map +1 -1
  73. package/lib/module/monkey-patch.android.js +0 -5
  74. package/lib/module/monkey-patch.android.js.map +1 -1
  75. package/lib/module/types/hooks.js +2 -0
  76. package/lib/module/types/hooks.js.map +1 -0
  77. package/lib/module/types/index.js +5 -0
  78. package/lib/module/types/index.js.map +1 -0
  79. package/lib/module/types/internal.js +2 -0
  80. package/lib/module/types/internal.js.map +1 -0
  81. package/lib/module/types/module.js +2 -0
  82. package/lib/module/types/module.js.map +1 -0
  83. package/lib/module/types/views.js +2 -0
  84. package/lib/module/types/views.js.map +1 -0
  85. package/lib/module/views/OverKeyboardView/index.js +18 -4
  86. package/lib/module/views/OverKeyboardView/index.js.map +1 -1
  87. package/lib/typescript/animated.d.ts +20 -6
  88. package/lib/typescript/bindings.d.ts +19 -0
  89. package/lib/typescript/components/KeyboardAvoidingView/index.d.ts +11 -2
  90. package/lib/typescript/components/KeyboardAwareScrollView/index.d.ts +23 -6
  91. package/lib/typescript/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.d.ts +17 -1
  92. package/lib/typescript/components/KeyboardStickyView/index.d.ts +15 -2
  93. package/lib/typescript/components/KeyboardToolbar/index.d.ts +13 -2
  94. package/lib/typescript/context.d.ts +32 -0
  95. package/lib/typescript/hooks/index.d.ts +157 -0
  96. package/lib/typescript/hooks/useKeyboardState/index.d.ts +20 -0
  97. package/lib/typescript/hooks/useWindowDimensions/index.d.ts +2 -1
  98. package/lib/typescript/internal.d.ts +21 -0
  99. package/lib/typescript/module.d.ts +3 -0
  100. package/lib/typescript/{types.d.ts → types/hooks.d.ts} +72 -78
  101. package/lib/typescript/types/index.d.ts +4 -0
  102. package/lib/typescript/types/internal.d.ts +17 -0
  103. package/lib/typescript/types/module.d.ts +91 -0
  104. package/lib/typescript/types/views.d.ts +45 -0
  105. package/lib/typescript/views/OverKeyboardView/index.d.ts +14 -1
  106. package/package.json +2 -1
  107. package/src/animated.tsx +27 -12
  108. package/src/bindings.ts +19 -0
  109. package/src/components/KeyboardAvoidingView/index.tsx +14 -4
  110. package/src/components/KeyboardAwareScrollView/index.tsx +60 -40
  111. package/src/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.ts +17 -1
  112. package/src/components/KeyboardStickyView/index.tsx +14 -1
  113. package/src/components/KeyboardToolbar/index.tsx +31 -19
  114. package/src/context.ts +33 -0
  115. package/src/hooks/index.ts +157 -0
  116. package/src/hooks/useKeyboardState/index.ts +20 -0
  117. package/src/hooks/useWindowDimensions/index.ts +41 -1
  118. package/src/internal.ts +21 -0
  119. package/src/module.ts +3 -0
  120. package/src/monkey-patch.android.ts +3 -6
  121. package/src/{types.ts → types/hooks.ts} +72 -105
  122. package/src/types/index.ts +4 -0
  123. package/src/types/internal.ts +24 -0
  124. package/src/types/module.ts +105 -0
  125. package/src/types/views.ts +46 -0
  126. package/src/views/OverKeyboardView/index.tsx +15 -4
  127. package/lib/commonjs/hooks/useWindowDimensions/index.android.js +0 -34
  128. package/lib/commonjs/hooks/useWindowDimensions/index.android.js.map +0 -1
  129. package/lib/commonjs/types.js.map +0 -1
  130. package/lib/module/hooks/useWindowDimensions/index.android.js +0 -27
  131. package/lib/module/hooks/useWindowDimensions/index.android.js.map +0 -1
  132. package/lib/module/types.js +0 -2
  133. package/lib/module/types.js.map +0 -1
  134. package/lib/typescript/hooks/useWindowDimensions/index.android.d.ts +0 -2
  135. package/src/hooks/useWindowDimensions/index.android.ts +0 -38
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { PropsWithChildren } from \"react\";\nimport type {\n EmitterSubscription,\n NativeSyntheticEvent,\n TextInputProps,\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 preserveEdgeToEdge?: 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 /**\n * A corresponding `nativeID` value from the corresponding `TextInput`.\n */\n textInputNativeID?: string;\n} & ViewProps;\nexport type OverKeyboardViewProps = PropsWithChildren<{\n visible: boolean;\n}>;\n\nexport type Direction = \"next\" | \"prev\" | \"current\";\nexport type DismissOptions = {\n keepFocus: boolean;\n};\nexport type KeyboardControllerModule = {\n // android only\n setDefaultMode: () => void;\n setInputMode: (mode: number) => void;\n // all platforms\n dismiss: (options?: DismissOptions) => Promise<void>;\n setFocusTo: (direction: Direction) => void;\n isVisible: () => boolean;\n state: () => KeyboardEventData;\n};\nexport type KeyboardControllerNativeModule = {\n // android only\n setDefaultMode: () => void;\n setInputMode: (mode: number) => 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\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 type: NonNullable<TextInputProps[\"keyboardType\"]>;\n appearance: NonNullable<TextInputProps[\"keyboardAppearance\"]>;\n};\nexport type KeyboardState = {\n isVisible: boolean;\n} & KeyboardEventData;\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,2 +0,0 @@
1
- import type { WindowDimensionsEventData } from "../../types";
2
- export declare const useWindowDimensions: () => WindowDimensionsEventData;
@@ -1,38 +0,0 @@
1
- import { useEffect, useState } from "react";
2
-
3
- import { WindowDimensionsEvents } from "../../bindings";
4
-
5
- import type { WindowDimensionsEventData } from "../../types";
6
-
7
- let initialDimensions: WindowDimensionsEventData = {
8
- width: 0,
9
- height: 0,
10
- };
11
-
12
- WindowDimensionsEvents.addListener("windowDidResize", (e) => {
13
- initialDimensions = e;
14
- });
15
-
16
- export const useWindowDimensions = () => {
17
- const [dimensions, setDimensions] = useState(initialDimensions);
18
-
19
- useEffect(() => {
20
- const subscription = WindowDimensionsEvents.addListener(
21
- "windowDidResize",
22
- (e) => {
23
- setDimensions(e);
24
- },
25
- );
26
-
27
- // we might have missed an update between reading a value in render and
28
- // `addListener` in this handler, so we set it here. If there was
29
- // no change, React will filter out this update as a no-op.
30
- setDimensions(initialDimensions);
31
-
32
- return () => {
33
- subscription.remove();
34
- };
35
- }, []);
36
-
37
- return dimensions;
38
- };