react-native-keyboard-controller 1.14.4 → 1.15.0

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 (95) hide show
  1. package/android/build.gradle +3 -2
  2. package/android/gradle.properties +1 -0
  3. package/android/react-native-helpers.gradle +5 -11
  4. package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardControllerModule.kt +2 -2
  5. package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/EditText.kt +35 -0
  6. package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/ThemedReactContext.kt +18 -0
  7. package/android/src/main/java/com/reactnativekeyboardcontroller/listeners/KeyboardAnimationCallback.kt +5 -0
  8. package/android/src/main/java/com/reactnativekeyboardcontroller/modal/ModalAttachedWatcher.kt +9 -6
  9. package/android/src/main/java/com/reactnativekeyboardcontroller/modules/KeyboardControllerModuleImpl.kt +13 -4
  10. package/android/src/main/java/com/reactnativekeyboardcontroller/views/overlay/JSPointerDispatcherCompat.kt +56 -0
  11. package/android/src/main/java/com/reactnativekeyboardcontroller/views/overlay/OverKeyboardViewGroup.kt +10 -7
  12. package/android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardControllerModule.kt +2 -2
  13. package/ios/KeyboardControllerModule.mm +3 -3
  14. package/ios/KeyboardControllerModuleImpl.swift +66 -0
  15. package/ios/events/KeyboardEventEmitterPayload.swift +23 -0
  16. package/ios/extensions/Notification.swift +17 -0
  17. package/ios/extensions/UIKeyboardAppearance.swift +21 -0
  18. package/ios/extensions/UIKeyboardType.swift +30 -0
  19. package/ios/observers/KeyboardMovementObserver.swift +8 -27
  20. package/ios/{traversal → protocols}/TextInput.swift +5 -1
  21. package/ios/traversal/ViewHierarchyNavigator.swift +4 -1
  22. package/jest/index.js +20 -15
  23. package/lib/commonjs/animated.js +6 -0
  24. package/lib/commonjs/animated.js.map +1 -1
  25. package/lib/commonjs/bindings.js +2 -2
  26. package/lib/commonjs/bindings.js.map +1 -1
  27. package/lib/commonjs/bindings.native.js +4 -3
  28. package/lib/commonjs/bindings.native.js.map +1 -1
  29. package/lib/commonjs/components/KeyboardAvoidingView/index.js.map +1 -1
  30. package/lib/commonjs/components/KeyboardStickyView/index.js +3 -2
  31. package/lib/commonjs/components/KeyboardStickyView/index.js.map +1 -1
  32. package/lib/commonjs/components/KeyboardToolbar/index.js +14 -9
  33. package/lib/commonjs/components/KeyboardToolbar/index.js.map +1 -1
  34. package/lib/commonjs/hooks/index.js +3 -3
  35. package/lib/commonjs/hooks/index.js.map +1 -1
  36. package/lib/commonjs/hooks/useWindowDimensions/index.android.js +5 -0
  37. package/lib/commonjs/hooks/useWindowDimensions/index.android.js.map +1 -1
  38. package/lib/commonjs/index.js +12 -0
  39. package/lib/commonjs/index.js.map +1 -1
  40. package/lib/commonjs/internal.js +2 -2
  41. package/lib/commonjs/internal.js.map +1 -1
  42. package/lib/commonjs/module.js +45 -0
  43. package/lib/commonjs/module.js.map +1 -0
  44. package/lib/commonjs/specs/NativeKeyboardController.js.map +1 -1
  45. package/lib/commonjs/types.js.map +1 -1
  46. package/lib/module/animated.js +6 -0
  47. package/lib/module/animated.js.map +1 -1
  48. package/lib/module/bindings.js +1 -1
  49. package/lib/module/bindings.js.map +1 -1
  50. package/lib/module/bindings.native.js +3 -2
  51. package/lib/module/bindings.native.js.map +1 -1
  52. package/lib/module/components/KeyboardAvoidingView/index.js.map +1 -1
  53. package/lib/module/components/KeyboardStickyView/index.js +3 -2
  54. package/lib/module/components/KeyboardStickyView/index.js.map +1 -1
  55. package/lib/module/components/KeyboardToolbar/index.js +15 -10
  56. package/lib/module/components/KeyboardToolbar/index.js.map +1 -1
  57. package/lib/module/hooks/index.js +1 -1
  58. package/lib/module/hooks/index.js.map +1 -1
  59. package/lib/module/hooks/useWindowDimensions/index.android.js +5 -0
  60. package/lib/module/hooks/useWindowDimensions/index.android.js.map +1 -1
  61. package/lib/module/index.js +1 -0
  62. package/lib/module/index.js.map +1 -1
  63. package/lib/module/internal.js +2 -2
  64. package/lib/module/internal.js.map +1 -1
  65. package/lib/module/module.js +39 -0
  66. package/lib/module/module.js.map +1 -0
  67. package/lib/module/specs/NativeKeyboardController.js.map +1 -1
  68. package/lib/module/types.js.map +1 -1
  69. package/lib/typescript/bindings.d.ts +5 -6
  70. package/lib/typescript/bindings.native.d.ts +2 -3
  71. package/lib/typescript/components/KeyboardAvoidingView/index.d.ts +14 -24
  72. package/lib/typescript/components/KeyboardAwareScrollView/index.d.ts +6 -6
  73. package/lib/typescript/components/KeyboardAwareScrollView/utils.d.ts +1 -1
  74. package/lib/typescript/components/KeyboardStickyView/index.d.ts +8 -4
  75. package/lib/typescript/components/KeyboardToolbar/Button.d.ts +2 -1
  76. package/lib/typescript/components/KeyboardToolbar/index.d.ts +2 -1
  77. package/lib/typescript/index.d.ts +1 -0
  78. package/lib/typescript/internal.d.ts +0 -1
  79. package/lib/typescript/module.d.ts +2 -0
  80. package/lib/typescript/specs/NativeKeyboardController.d.ts +1 -1
  81. package/lib/typescript/types.d.ts +15 -2
  82. package/package.json +6 -4
  83. package/src/animated.tsx +6 -0
  84. package/src/bindings.native.ts +5 -4
  85. package/src/bindings.ts +2 -2
  86. package/src/components/KeyboardAvoidingView/index.tsx +27 -11
  87. package/src/components/KeyboardStickyView/index.tsx +12 -3
  88. package/src/components/KeyboardToolbar/index.tsx +14 -11
  89. package/src/hooks/index.ts +1 -1
  90. package/src/hooks/useWindowDimensions/index.android.ts +5 -0
  91. package/src/index.ts +1 -0
  92. package/src/internal.ts +2 -2
  93. package/src/module.ts +50 -0
  94. package/src/specs/NativeKeyboardController.ts +1 -1
  95. package/src/types.ts +17 -1
@@ -1 +1 @@
1
- {"version":3,"names":["KeyboardAvoidingView","KeyboardStickyView","KeyboardAwareScrollView","KeyboardToolbar","DefaultKeyboardToolbarTheme","OverKeyboardView"],"sources":["index.ts"],"sourcesContent":["export * from \"./bindings\";\nexport * from \"./animated\";\nexport * from \"./context\";\nexport * from \"./hooks\";\nexport * from \"./constants\";\nexport * from \"./types\";\n\nexport {\n KeyboardAvoidingView,\n KeyboardStickyView,\n KeyboardAwareScrollView,\n // keyboard toolbar\n KeyboardToolbar,\n DefaultKeyboardToolbarTheme,\n} from \"./components\";\nexport type {\n KeyboardAvoidingViewProps,\n KeyboardStickyViewProps,\n KeyboardAwareScrollViewProps,\n KeyboardToolbarProps,\n} from \"./components\";\nexport { OverKeyboardView } from \"./views\";\n"],"mappings":"AAAA,cAAc,YAAY;AAC1B,cAAc,YAAY;AAC1B,cAAc,WAAW;AACzB,cAAc,SAAS;AACvB,cAAc,aAAa;AAC3B,cAAc,SAAS;AAEvB,SACEA,oBAAoB,EACpBC,kBAAkB,EAClBC,uBAAuB;AACvB;AACAC,eAAe,EACfC,2BAA2B,QACtB,cAAc;AAOrB,SAASC,gBAAgB,QAAQ,SAAS","ignoreList":[]}
1
+ {"version":3,"names":["KeyboardAvoidingView","KeyboardStickyView","KeyboardAwareScrollView","KeyboardToolbar","DefaultKeyboardToolbarTheme","OverKeyboardView"],"sources":["index.ts"],"sourcesContent":["export * from \"./bindings\";\nexport * from \"./animated\";\nexport * from \"./context\";\nexport * from \"./hooks\";\nexport * from \"./constants\";\nexport * from \"./module\";\nexport * from \"./types\";\n\nexport {\n KeyboardAvoidingView,\n KeyboardStickyView,\n KeyboardAwareScrollView,\n // keyboard toolbar\n KeyboardToolbar,\n DefaultKeyboardToolbarTheme,\n} from \"./components\";\nexport type {\n KeyboardAvoidingViewProps,\n KeyboardStickyViewProps,\n KeyboardAwareScrollViewProps,\n KeyboardToolbarProps,\n} from \"./components\";\nexport { OverKeyboardView } from \"./views\";\n"],"mappings":"AAAA,cAAc,YAAY;AAC1B,cAAc,YAAY;AAC1B,cAAc,WAAW;AACzB,cAAc,SAAS;AACvB,cAAc,aAAa;AAC3B,cAAc,UAAU;AACxB,cAAc,SAAS;AAEvB,SACEA,oBAAoB,EACpBC,kBAAkB,EAClBC,uBAAuB;AACvB;AACAC,eAAe,EACfC,2BAA2B,QACtB,cAAc;AAOrB,SAASC,gBAAgB,QAAQ,SAAS","ignoreList":[]}
@@ -25,8 +25,8 @@ export function useEventHandlerRegistration(map, viewTagRef) {
25
25
  if (viewTagRef.current) {
26
26
  attachWorkletHandlers();
27
27
  } else {
28
- // view may not be mounted yet - defer registration to next event loop
29
- setImmediate(attachWorkletHandlers);
28
+ // view may not be mounted yet - defer registration until call-stack becomes empty
29
+ queueMicrotask(attachWorkletHandlers);
30
30
  }
31
31
  return () => {
32
32
  ids.forEach(id => id ? unregisterEventHandler(id) : null);
@@ -1 +1 @@
1
- {"version":3,"names":["useRef","Animated","findNodeHandle","registerEventHandler","unregisterEventHandler","useEventHandlerRegistration","map","viewTagRef","onRegisterHandler","handler","ids","attachWorkletHandlers","viewTag","current","__DEV__","console","warn","push","Object","keys","handlerName","eventName","get","functionToCall","event","setImmediate","forEach","id","useAnimatedValue","initialValue","config","ref","Value"],"sources":["internal.ts"],"sourcesContent":["import { useRef } from \"react\";\nimport { Animated, findNodeHandle } from \"react-native\";\n\nimport { registerEventHandler, unregisterEventHandler } from \"./event-handler\";\n\ntype EventHandler = (event: never) => void;\ntype ComponentOrHandle = Parameters<typeof findNodeHandle>[0];\n\nexport function useEventHandlerRegistration<\n H extends Partial<Record<string, EventHandler>>,\n>(\n map: Map<keyof H, string>,\n viewTagRef: React.MutableRefObject<ComponentOrHandle>,\n) {\n const onRegisterHandler = (handler: H) => {\n const ids: (number | null)[] = [];\n const attachWorkletHandlers = () => {\n const viewTag = findNodeHandle(viewTagRef.current);\n\n if (__DEV__ && !viewTag) {\n console.warn(\n \"Can not attach worklet handlers for `react-native-keyboard-controller` because view tag can not be resolved. Be sure that `KeyboardProvider` is fully mounted before registering handlers. If you think it is a bug in library, please open an issue.\",\n );\n }\n\n ids.push(\n ...Object.keys(handler).map((handlerName) => {\n const eventName = map.get(handlerName as keyof H);\n const functionToCall = handler[handlerName as keyof H];\n\n if (eventName && viewTag) {\n return registerEventHandler(\n (event: Parameters<NonNullable<H[keyof H]>>[0]) => {\n \"worklet\";\n\n functionToCall?.(event);\n },\n eventName,\n viewTag,\n );\n }\n\n return null;\n }),\n );\n };\n\n if (viewTagRef.current) {\n attachWorkletHandlers();\n } else {\n // view may not be mounted yet - defer registration to next event loop\n setImmediate(attachWorkletHandlers);\n }\n\n return () => {\n ids.forEach((id) => (id ? unregisterEventHandler(id) : null));\n };\n };\n\n return onRegisterHandler;\n}\n\n/**\n * TS variant of `useAnimatedValue` hook which is added in RN 0.71\n * A better alternative of storing animated values in refs, since\n * it doesn't recreate a new `Animated.Value` object on every re-render\n * and therefore consumes less memory. We can not use a variant from\n * RN, since this library supports earlier versions of RN.\n *\n * @see https://github.com/facebook/react-native/commit/e22217fe8b9455e32695f88ca835e11442b0a937\n */\nexport function useAnimatedValue(\n initialValue: number,\n config?: Animated.AnimatedConfig,\n): Animated.Value {\n const ref = useRef<Animated.Value | null>(null);\n\n if (ref.current === null) {\n ref.current = new Animated.Value(initialValue, config);\n }\n\n return ref.current;\n}\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,OAAO;AAC9B,SAASC,QAAQ,EAAEC,cAAc,QAAQ,cAAc;AAEvD,SAASC,oBAAoB,EAAEC,sBAAsB,QAAQ,iBAAiB;AAK9E,OAAO,SAASC,2BAA2BA,CAGzCC,GAAyB,EACzBC,UAAqD,EACrD;EACA,MAAMC,iBAAiB,GAAIC,OAAU,IAAK;IACxC,MAAMC,GAAsB,GAAG,EAAE;IACjC,MAAMC,qBAAqB,GAAGA,CAAA,KAAM;MAClC,MAAMC,OAAO,GAAGV,cAAc,CAACK,UAAU,CAACM,OAAO,CAAC;MAElD,IAAIC,OAAO,IAAI,CAACF,OAAO,EAAE;QACvBG,OAAO,CAACC,IAAI,CACV,uPACF,CAAC;MACH;MAEAN,GAAG,CAACO,IAAI,CACN,GAAGC,MAAM,CAACC,IAAI,CAACV,OAAO,CAAC,CAACH,GAAG,CAAEc,WAAW,IAAK;QAC3C,MAAMC,SAAS,GAAGf,GAAG,CAACgB,GAAG,CAACF,WAAsB,CAAC;QACjD,MAAMG,cAAc,GAAGd,OAAO,CAACW,WAAW,CAAY;QAEtD,IAAIC,SAAS,IAAIT,OAAO,EAAE;UACxB,OAAOT,oBAAoB,CACxBqB,KAA6C,IAAK;YACjD,SAAS;;YAETD,cAAc,aAAdA,cAAc,eAAdA,cAAc,CAAGC,KAAK,CAAC;UACzB,CAAC,EACDH,SAAS,EACTT,OACF,CAAC;QACH;QAEA,OAAO,IAAI;MACb,CAAC,CACH,CAAC;IACH,CAAC;IAED,IAAIL,UAAU,CAACM,OAAO,EAAE;MACtBF,qBAAqB,CAAC,CAAC;IACzB,CAAC,MAAM;MACL;MACAc,YAAY,CAACd,qBAAqB,CAAC;IACrC;IAEA,OAAO,MAAM;MACXD,GAAG,CAACgB,OAAO,CAAEC,EAAE,IAAMA,EAAE,GAAGvB,sBAAsB,CAACuB,EAAE,CAAC,GAAG,IAAK,CAAC;IAC/D,CAAC;EACH,CAAC;EAED,OAAOnB,iBAAiB;AAC1B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASoB,gBAAgBA,CAC9BC,YAAoB,EACpBC,MAAgC,EAChB;EAChB,MAAMC,GAAG,GAAG/B,MAAM,CAAwB,IAAI,CAAC;EAE/C,IAAI+B,GAAG,CAAClB,OAAO,KAAK,IAAI,EAAE;IACxBkB,GAAG,CAAClB,OAAO,GAAG,IAAIZ,QAAQ,CAAC+B,KAAK,CAACH,YAAY,EAAEC,MAAM,CAAC;EACxD;EAEA,OAAOC,GAAG,CAAClB,OAAO;AACpB","ignoreList":[]}
1
+ {"version":3,"names":["useRef","Animated","findNodeHandle","registerEventHandler","unregisterEventHandler","useEventHandlerRegistration","map","viewTagRef","onRegisterHandler","handler","ids","attachWorkletHandlers","viewTag","current","__DEV__","console","warn","push","Object","keys","handlerName","eventName","get","functionToCall","event","queueMicrotask","forEach","id","useAnimatedValue","initialValue","config","ref","Value"],"sources":["internal.ts"],"sourcesContent":["import { useRef } from \"react\";\nimport { Animated, findNodeHandle } from \"react-native\";\n\nimport { registerEventHandler, unregisterEventHandler } from \"./event-handler\";\n\ntype EventHandler = (event: never) => void;\ntype ComponentOrHandle = Parameters<typeof findNodeHandle>[0];\n\nexport function useEventHandlerRegistration<\n H extends Partial<Record<string, EventHandler>>,\n>(\n map: Map<keyof H, string>,\n viewTagRef: React.MutableRefObject<ComponentOrHandle>,\n) {\n const onRegisterHandler = (handler: H) => {\n const ids: (number | null)[] = [];\n const attachWorkletHandlers = () => {\n const viewTag = findNodeHandle(viewTagRef.current);\n\n if (__DEV__ && !viewTag) {\n console.warn(\n \"Can not attach worklet handlers for `react-native-keyboard-controller` because view tag can not be resolved. Be sure that `KeyboardProvider` is fully mounted before registering handlers. If you think it is a bug in library, please open an issue.\",\n );\n }\n\n ids.push(\n ...Object.keys(handler).map((handlerName) => {\n const eventName = map.get(handlerName as keyof H);\n const functionToCall = handler[handlerName as keyof H];\n\n if (eventName && viewTag) {\n return registerEventHandler(\n (event: Parameters<NonNullable<H[keyof H]>>[0]) => {\n \"worklet\";\n\n functionToCall?.(event);\n },\n eventName,\n viewTag,\n );\n }\n\n return null;\n }),\n );\n };\n\n if (viewTagRef.current) {\n attachWorkletHandlers();\n } else {\n // view may not be mounted yet - defer registration until call-stack becomes empty\n queueMicrotask(attachWorkletHandlers);\n }\n\n return () => {\n ids.forEach((id) => (id ? unregisterEventHandler(id) : null));\n };\n };\n\n return onRegisterHandler;\n}\n\n/**\n * TS variant of `useAnimatedValue` hook which is added in RN 0.71\n * A better alternative of storing animated values in refs, since\n * it doesn't recreate a new `Animated.Value` object on every re-render\n * and therefore consumes less memory. We can not use a variant from\n * RN, since this library supports earlier versions of RN.\n *\n * @see https://github.com/facebook/react-native/commit/e22217fe8b9455e32695f88ca835e11442b0a937\n */\nexport function useAnimatedValue(\n initialValue: number,\n config?: Animated.AnimatedConfig,\n): Animated.Value {\n const ref = useRef<Animated.Value | null>(null);\n\n if (ref.current === null) {\n ref.current = new Animated.Value(initialValue, config);\n }\n\n return ref.current;\n}\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,OAAO;AAC9B,SAASC,QAAQ,EAAEC,cAAc,QAAQ,cAAc;AAEvD,SAASC,oBAAoB,EAAEC,sBAAsB,QAAQ,iBAAiB;AAK9E,OAAO,SAASC,2BAA2BA,CAGzCC,GAAyB,EACzBC,UAAqD,EACrD;EACA,MAAMC,iBAAiB,GAAIC,OAAU,IAAK;IACxC,MAAMC,GAAsB,GAAG,EAAE;IACjC,MAAMC,qBAAqB,GAAGA,CAAA,KAAM;MAClC,MAAMC,OAAO,GAAGV,cAAc,CAACK,UAAU,CAACM,OAAO,CAAC;MAElD,IAAIC,OAAO,IAAI,CAACF,OAAO,EAAE;QACvBG,OAAO,CAACC,IAAI,CACV,uPACF,CAAC;MACH;MAEAN,GAAG,CAACO,IAAI,CACN,GAAGC,MAAM,CAACC,IAAI,CAACV,OAAO,CAAC,CAACH,GAAG,CAAEc,WAAW,IAAK;QAC3C,MAAMC,SAAS,GAAGf,GAAG,CAACgB,GAAG,CAACF,WAAsB,CAAC;QACjD,MAAMG,cAAc,GAAGd,OAAO,CAACW,WAAW,CAAY;QAEtD,IAAIC,SAAS,IAAIT,OAAO,EAAE;UACxB,OAAOT,oBAAoB,CACxBqB,KAA6C,IAAK;YACjD,SAAS;;YAETD,cAAc,aAAdA,cAAc,eAAdA,cAAc,CAAGC,KAAK,CAAC;UACzB,CAAC,EACDH,SAAS,EACTT,OACF,CAAC;QACH;QAEA,OAAO,IAAI;MACb,CAAC,CACH,CAAC;IACH,CAAC;IAED,IAAIL,UAAU,CAACM,OAAO,EAAE;MACtBF,qBAAqB,CAAC,CAAC;IACzB,CAAC,MAAM;MACL;MACAc,cAAc,CAACd,qBAAqB,CAAC;IACvC;IAEA,OAAO,MAAM;MACXD,GAAG,CAACgB,OAAO,CAAEC,EAAE,IAAMA,EAAE,GAAGvB,sBAAsB,CAACuB,EAAE,CAAC,GAAG,IAAK,CAAC;IAC/D,CAAC;EACH,CAAC;EAED,OAAOnB,iBAAiB;AAC1B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASoB,gBAAgBA,CAC9BC,YAAoB,EACpBC,MAAgC,EAChB;EAChB,MAAMC,GAAG,GAAG/B,MAAM,CAAwB,IAAI,CAAC;EAE/C,IAAI+B,GAAG,CAAClB,OAAO,KAAK,IAAI,EAAE;IACxBkB,GAAG,CAAClB,OAAO,GAAG,IAAIZ,QAAQ,CAAC+B,KAAK,CAACH,YAAY,EAAEC,MAAM,CAAC;EACxD;EAEA,OAAOC,GAAG,CAAClB,OAAO;AACpB","ignoreList":[]}
@@ -0,0 +1,39 @@
1
+ import { KeyboardControllerNative, KeyboardEvents } from "./bindings";
2
+ let isClosed = false;
3
+ let lastEvent = null;
4
+ KeyboardEvents.addListener("keyboardDidHide", e => {
5
+ isClosed = true;
6
+ lastEvent = e;
7
+ });
8
+ KeyboardEvents.addListener("keyboardDidShow", e => {
9
+ isClosed = false;
10
+ lastEvent = e;
11
+ });
12
+ const dismiss = async ({
13
+ keepFocus
14
+ } = {
15
+ keepFocus: false
16
+ }) => {
17
+ return new Promise(resolve => {
18
+ if (isClosed) {
19
+ resolve();
20
+ return;
21
+ }
22
+ const subscription = KeyboardEvents.addListener("keyboardDidHide", () => {
23
+ resolve(undefined);
24
+ subscription.remove();
25
+ });
26
+ KeyboardControllerNative.dismiss(keepFocus);
27
+ });
28
+ };
29
+ const isVisible = () => !isClosed;
30
+ const state = () => lastEvent;
31
+ export const KeyboardController = {
32
+ setDefaultMode: KeyboardControllerNative.setDefaultMode,
33
+ setInputMode: KeyboardControllerNative.setInputMode,
34
+ setFocusTo: KeyboardControllerNative.setFocusTo,
35
+ dismiss,
36
+ isVisible,
37
+ state
38
+ };
39
+ //# sourceMappingURL=module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["KeyboardControllerNative","KeyboardEvents","isClosed","lastEvent","addListener","e","dismiss","keepFocus","Promise","resolve","subscription","undefined","remove","isVisible","state","KeyboardController","setDefaultMode","setInputMode","setFocusTo"],"sources":["module.ts"],"sourcesContent":["import { KeyboardControllerNative, KeyboardEvents } from \"./bindings\";\n\nimport type {\n DismissOptions,\n KeyboardControllerModule,\n KeyboardEventData,\n} from \"./types\";\n\nlet isClosed = false;\nlet lastEvent: KeyboardEventData | null = null;\n\nKeyboardEvents.addListener(\"keyboardDidHide\", (e) => {\n isClosed = true;\n lastEvent = e;\n});\n\nKeyboardEvents.addListener(\"keyboardDidShow\", (e) => {\n isClosed = false;\n lastEvent = e;\n});\n\nconst dismiss = async (\n { keepFocus }: DismissOptions = { keepFocus: false },\n): Promise<void> => {\n return new Promise((resolve) => {\n if (isClosed) {\n resolve();\n\n return;\n }\n\n const subscription = KeyboardEvents.addListener(\"keyboardDidHide\", () => {\n resolve(undefined);\n subscription.remove();\n });\n\n KeyboardControllerNative.dismiss(keepFocus);\n });\n};\nconst isVisible = () => !isClosed;\nconst state = () => lastEvent;\n\nexport const KeyboardController: KeyboardControllerModule = {\n setDefaultMode: KeyboardControllerNative.setDefaultMode,\n setInputMode: KeyboardControllerNative.setInputMode,\n setFocusTo: KeyboardControllerNative.setFocusTo,\n dismiss,\n isVisible,\n state,\n};\n"],"mappings":"AAAA,SAASA,wBAAwB,EAAEC,cAAc,QAAQ,YAAY;AAQrE,IAAIC,QAAQ,GAAG,KAAK;AACpB,IAAIC,SAAmC,GAAG,IAAI;AAE9CF,cAAc,CAACG,WAAW,CAAC,iBAAiB,EAAGC,CAAC,IAAK;EACnDH,QAAQ,GAAG,IAAI;EACfC,SAAS,GAAGE,CAAC;AACf,CAAC,CAAC;AAEFJ,cAAc,CAACG,WAAW,CAAC,iBAAiB,EAAGC,CAAC,IAAK;EACnDH,QAAQ,GAAG,KAAK;EAChBC,SAAS,GAAGE,CAAC;AACf,CAAC,CAAC;AAEF,MAAMC,OAAO,GAAG,MAAAA,CACd;EAAEC;AAA0B,CAAC,GAAG;EAAEA,SAAS,EAAE;AAAM,CAAC,KAClC;EAClB,OAAO,IAAIC,OAAO,CAAEC,OAAO,IAAK;IAC9B,IAAIP,QAAQ,EAAE;MACZO,OAAO,CAAC,CAAC;MAET;IACF;IAEA,MAAMC,YAAY,GAAGT,cAAc,CAACG,WAAW,CAAC,iBAAiB,EAAE,MAAM;MACvEK,OAAO,CAACE,SAAS,CAAC;MAClBD,YAAY,CAACE,MAAM,CAAC,CAAC;IACvB,CAAC,CAAC;IAEFZ,wBAAwB,CAACM,OAAO,CAACC,SAAS,CAAC;EAC7C,CAAC,CAAC;AACJ,CAAC;AACD,MAAMM,SAAS,GAAGA,CAAA,KAAM,CAACX,QAAQ;AACjC,MAAMY,KAAK,GAAGA,CAAA,KAAMX,SAAS;AAE7B,OAAO,MAAMY,kBAA4C,GAAG;EAC1DC,cAAc,EAAEhB,wBAAwB,CAACgB,cAAc;EACvDC,YAAY,EAAEjB,wBAAwB,CAACiB,YAAY;EACnDC,UAAU,EAAElB,wBAAwB,CAACkB,UAAU;EAC/CZ,OAAO;EACPO,SAAS;EACTC;AACF,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["TurboModuleRegistry","get"],"sources":["NativeKeyboardController.ts"],"sourcesContent":["import { TurboModuleRegistry } from \"react-native\";\n\nimport type { TurboModule } from \"react-native\";\n\nexport interface Spec extends TurboModule {\n readonly getConstants: () => {};\n\n // methods\n setInputMode(mode: number): void;\n setDefaultMode(): void;\n dismiss(): void;\n setFocusTo(direction: string): void;\n\n // event emitter\n addListener: (eventName: string) => void;\n removeListeners: (count: number) => void;\n}\n\nexport default TurboModuleRegistry.get<Spec>(\"KeyboardController\");\n"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,cAAc;AAkBlD,eAAeA,mBAAmB,CAACC,GAAG,CAAO,oBAAoB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["TurboModuleRegistry","get"],"sources":["NativeKeyboardController.ts"],"sourcesContent":["import { TurboModuleRegistry } from \"react-native\";\n\nimport type { TurboModule } from \"react-native\";\n\nexport interface Spec extends TurboModule {\n readonly getConstants: () => {};\n\n // methods\n setInputMode(mode: number): void;\n setDefaultMode(): void;\n dismiss(keepFocus: boolean): void;\n setFocusTo(direction: string): void;\n\n // event emitter\n addListener: (eventName: string) => void;\n removeListeners: (count: number) => void;\n}\n\nexport default TurboModuleRegistry.get<Spec>(\"KeyboardController\");\n"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,cAAc;AAkBlD,eAAeA,mBAAmB,CAACC,GAAG,CAAO,oBAAoB,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { PropsWithChildren } from \"react\";\nimport type {\n EmitterSubscription,\n NativeSyntheticEvent,\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 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} & ViewProps;\nexport type OverKeyboardViewProps = PropsWithChildren<{\n visible: boolean;\n}>;\n\nexport type Direction = \"next\" | \"prev\" | \"current\";\nexport type KeyboardControllerModule = {\n // android only\n setDefaultMode: () => void;\n setInputMode: (mode: number) => void;\n // all platforms\n dismiss: () => 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};\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
+ {"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 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} & 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 | null;\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 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,6 +1,5 @@
1
- /// <reference types="react" />
2
- import type { FocusedInputEventsModule, KeyboardControllerModule, KeyboardControllerProps, KeyboardEventsModule, KeyboardGestureAreaProps, OverKeyboardViewProps, WindowDimensionsEventsModule } from "./types";
3
- export declare const KeyboardController: KeyboardControllerModule;
1
+ import type { FocusedInputEventsModule, KeyboardControllerNativeModule, KeyboardControllerProps, KeyboardEventsModule, KeyboardGestureAreaProps, OverKeyboardViewProps, WindowDimensionsEventsModule } from "./types";
2
+ export declare const KeyboardControllerNative: KeyboardControllerNativeModule;
4
3
  export declare const KeyboardEvents: KeyboardEventsModule;
5
4
  /**
6
5
  * This API is not documented, it's for internal usage only (for now), and is a subject to potential breaking changes in future.
@@ -8,6 +7,6 @@ export declare const KeyboardEvents: KeyboardEventsModule;
8
7
  */
9
8
  export declare const FocusedInputEvents: FocusedInputEventsModule;
10
9
  export declare const WindowDimensionsEvents: WindowDimensionsEventsModule;
11
- export declare const KeyboardControllerView: import("react").FC<KeyboardControllerProps>;
12
- export declare const KeyboardGestureArea: import("react").FC<KeyboardGestureAreaProps>;
13
- export declare const RCTOverKeyboardView: import("react").FC<OverKeyboardViewProps>;
10
+ export declare const KeyboardControllerView: React.FC<KeyboardControllerProps>;
11
+ export declare const KeyboardGestureArea: React.FC<KeyboardGestureAreaProps>;
12
+ export declare const RCTOverKeyboardView: React.FC<OverKeyboardViewProps>;
@@ -1,6 +1,5 @@
1
- /// <reference types="react" />
2
- import type { FocusedInputEventsModule, KeyboardControllerModule, KeyboardControllerProps, KeyboardEventsModule, KeyboardGestureAreaProps, OverKeyboardViewProps, WindowDimensionsEventsModule } from "./types";
3
- export declare const KeyboardController: KeyboardControllerModule;
1
+ import type { FocusedInputEventsModule, KeyboardControllerNativeModule, KeyboardControllerProps, KeyboardEventsModule, KeyboardGestureAreaProps, OverKeyboardViewProps, WindowDimensionsEventsModule } from "./types";
2
+ export declare const KeyboardControllerNative: KeyboardControllerNativeModule;
4
3
  export declare const KeyboardEvents: KeyboardEventsModule;
5
4
  /**
6
5
  * This API is not documented, it's for internal usage only (for now), and is a subject to potential breaking changes in future.
@@ -1,15 +1,7 @@
1
1
  import React from "react";
2
2
  import { View } from "react-native";
3
3
  import type { ViewProps } from "react-native";
4
- export type KeyboardAvoidingViewProps = {
5
- /**
6
- * Specify how to react to the presence of the keyboard.
7
- */
8
- behavior?: "height" | "position" | "padding";
9
- /**
10
- * Style of the content container when `behavior` is 'position'.
11
- */
12
- contentContainerStyle?: ViewProps["style"];
4
+ export type KeyboardAvoidingViewBaseProps = {
13
5
  /**
14
6
  * Controls whether this `KeyboardAvoidingView` instance should take effect.
15
7
  * This is useful when more than one is on the screen. Defaults to true.
@@ -21,30 +13,28 @@ export type KeyboardAvoidingViewProps = {
21
13
  */
22
14
  keyboardVerticalOffset?: number;
23
15
  } & ViewProps;
24
- /**
25
- * View that moves out of the way when the keyboard appears by automatically
26
- * adjusting its height, position, or bottom padding.
27
- */
28
- declare const KeyboardAvoidingView: React.ForwardRefExoticComponent<{
16
+ export type KeyboardAvoidingViewProps = KeyboardAvoidingViewBaseProps & ({
29
17
  /**
30
18
  * Specify how to react to the presence of the keyboard.
31
19
  */
32
- behavior?: "height" | "padding" | "position" | undefined;
20
+ behavior?: "position";
33
21
  /**
34
22
  * Style of the content container when `behavior` is 'position'.
35
23
  */
36
24
  contentContainerStyle?: ViewProps["style"];
25
+ } | {
37
26
  /**
38
- * Controls whether this `KeyboardAvoidingView` instance should take effect.
39
- * This is useful when more than one is on the screen. Defaults to true.
27
+ * Specify how to react to the presence of the keyboard.
40
28
  */
41
- enabled?: boolean | undefined;
29
+ behavior?: "height" | "padding";
42
30
  /**
43
- * Distance between the top of the user screen and the React Native view. This
44
- * may be non-zero in some cases. Defaults to 0.
31
+ * `contentContainerStyle` is not allowed for these behaviors.
45
32
  */
46
- keyboardVerticalOffset?: number | undefined;
47
- } & ViewProps & {
48
- children?: React.ReactNode;
49
- } & React.RefAttributes<View>>;
33
+ contentContainerStyle?: never;
34
+ });
35
+ /**
36
+ * View that moves out of the way when the keyboard appears by automatically
37
+ * adjusting its height, position, or bottom padding.
38
+ */
39
+ declare const KeyboardAvoidingView: React.ForwardRefExoticComponent<React.PropsWithChildren<KeyboardAvoidingViewProps> & React.RefAttributes<View>>;
50
40
  export default KeyboardAvoidingView;
@@ -14,16 +14,16 @@ export type KeyboardAwareScrollViewProps = {
14
14
  } & ScrollViewProps;
15
15
  declare const KeyboardAwareScrollView: React.ForwardRefExoticComponent<{
16
16
  /** The distance between keyboard and focused `TextInput` when keyboard is shown. Default is `0`. */
17
- bottomOffset?: number | undefined;
17
+ bottomOffset?: number;
18
18
  /** Prevents automatic scrolling of the `ScrollView` when the keyboard gets hidden, maintaining the current screen position. Default is `false`. */
19
- disableScrollOnKeyboardHide?: boolean | undefined;
19
+ disableScrollOnKeyboardHide?: boolean;
20
20
  /** Controls whether this `KeyboardAwareScrollView` instance should take effect. Default is `true` */
21
- enabled?: boolean | undefined;
21
+ enabled?: boolean;
22
22
  /** Adjusting the bottom spacing of KeyboardAwareScrollView. Default is `0` */
23
- extraKeyboardSpace?: number | undefined;
23
+ extraKeyboardSpace?: number;
24
24
  /** Custom component for `ScrollView`. Default is `ScrollView` */
25
- ScrollViewComponent?: React.ComponentType<ScrollViewProps> | undefined;
25
+ ScrollViewComponent?: React.ComponentType<ScrollViewProps>;
26
26
  } & ScrollViewProps & {
27
- children?: React.ReactNode;
27
+ children?: React.ReactNode | undefined;
28
28
  } & React.RefAttributes<ScrollView>>;
29
29
  export default KeyboardAwareScrollView;
@@ -1,2 +1,2 @@
1
- export declare const debounce: <F extends (...args: Parameters<F>) => ReturnType<F>>(worklet: F, wait?: number) => (...args: Parameters<F>) => void | ReturnType<F>;
1
+ export declare const debounce: <F extends (...args: Parameters<F>) => ReturnType<F>>(worklet: F, wait?: number) => (...args: Parameters<F>) => ReturnType<F> | void;
2
2
  export declare const scrollDistanceWithRespectToSnapPoints: (defaultScrollValue: number, snapPoints?: number[]) => number;
@@ -14,6 +14,8 @@ export type KeyboardStickyViewProps = {
14
14
  */
15
15
  opened?: number;
16
16
  };
17
+ /** Controls whether this `KeyboardStickyView` instance should take effect. Default is `true` */
18
+ enabled?: boolean;
17
19
  } & ViewProps;
18
20
  declare const KeyboardStickyView: React.ForwardRefExoticComponent<{
19
21
  /**
@@ -23,13 +25,15 @@ declare const KeyboardStickyView: React.ForwardRefExoticComponent<{
23
25
  /**
24
26
  * Adds additional `translateY` when keyboard is close. By default `0`.
25
27
  */
26
- closed?: number | undefined;
28
+ closed?: number;
27
29
  /**
28
30
  * Adds additional `translateY` when keyboard is open. By default `0`.
29
31
  */
30
- opened?: number | undefined;
31
- } | undefined;
32
+ opened?: number;
33
+ };
34
+ /** Controls whether this `KeyboardStickyView` instance should take effect. Default is `true` */
35
+ enabled?: boolean;
32
36
  } & ViewProps & {
33
- children?: React.ReactNode;
37
+ children?: React.ReactNode | undefined;
34
38
  } & React.RefAttributes<View>>;
35
39
  export default KeyboardStickyView;
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
2
  import type { KeyboardToolbarTheme } from "./types";
3
+ import type { PropsWithChildren } from "react";
3
4
  import type { GestureResponderEvent, ViewStyle } from "react-native";
4
5
  type ButtonProps = {
5
6
  disabled?: boolean;
@@ -11,5 +12,5 @@ type ButtonProps = {
11
12
  style?: ViewStyle;
12
13
  theme: KeyboardToolbarTheme;
13
14
  };
14
- declare const _default: ({ children, onPress, disabled, accessibilityLabel, accessibilityHint, testID, style, }: React.PropsWithChildren<ButtonProps>) => React.JSX.Element;
15
+ declare const _default: ({ children, onPress, disabled, accessibilityLabel, accessibilityHint, testID, style, }: PropsWithChildren<ButtonProps>) => React.JSX.Element;
15
16
  export default _default;
@@ -3,6 +3,7 @@ import Arrow from "./Arrow";
3
3
  import Button from "./Button";
4
4
  import { colors } from "./colors";
5
5
  import type { HEX, KeyboardToolbarTheme } from "./types";
6
+ import type { KeyboardStickyViewProps } from "../KeyboardStickyView";
6
7
  import type { ReactNode } from "react";
7
8
  import type { GestureResponderEvent, ViewProps } from "react-native";
8
9
  export type KeyboardToolbarProps = Omit<ViewProps, "style" | "testID" | "children"> & {
@@ -41,7 +42,7 @@ export type KeyboardToolbarProps = Omit<ViewProps, "style" | "testID" | "childre
41
42
  * A value for container opacity in hexadecimal format (e.g. `ff`). Default value is `ff`.
42
43
  */
43
44
  opacity?: HEX;
44
- };
45
+ } & Pick<KeyboardStickyViewProps, "offset" | "enabled">;
45
46
  /**
46
47
  * `KeyboardToolbar` is a component that is shown above the keyboard with `Prev`/`Next` and
47
48
  * `Done` buttons.
@@ -3,6 +3,7 @@ export * from "./animated";
3
3
  export * from "./context";
4
4
  export * from "./hooks";
5
5
  export * from "./constants";
6
+ export * from "./module";
6
7
  export * from "./types";
7
8
  export { KeyboardAvoidingView, KeyboardStickyView, KeyboardAwareScrollView, KeyboardToolbar, DefaultKeyboardToolbarTheme, } from "./components";
8
9
  export type { KeyboardAvoidingViewProps, KeyboardStickyViewProps, KeyboardAwareScrollViewProps, KeyboardToolbarProps, } from "./components";
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { Animated, findNodeHandle } from "react-native";
3
2
  type EventHandler = (event: never) => void;
4
3
  type ComponentOrHandle = Parameters<typeof findNodeHandle>[0];
@@ -0,0 +1,2 @@
1
+ import type { KeyboardControllerModule } from "./types";
2
+ export declare const KeyboardController: KeyboardControllerModule;
@@ -3,7 +3,7 @@ export interface Spec extends TurboModule {
3
3
  readonly getConstants: () => {};
4
4
  setInputMode(mode: number): void;
5
5
  setDefaultMode(): void;
6
- dismiss(): void;
6
+ dismiss(keepFocus: boolean): void;
7
7
  setFocusTo(direction: string): void;
8
8
  addListener: (eventName: string) => void;
9
9
  removeListeners: (count: number) => void;
@@ -1,5 +1,5 @@
1
1
  import type { PropsWithChildren } from "react";
2
- import type { EmitterSubscription, NativeSyntheticEvent, ViewProps } from "react-native";
2
+ import type { EmitterSubscription, NativeSyntheticEvent, TextInputProps, ViewProps } from "react-native";
3
3
  export type NativeEvent = {
4
4
  progress: number;
5
5
  height: number;
@@ -78,10 +78,21 @@ export type OverKeyboardViewProps = PropsWithChildren<{
78
78
  visible: boolean;
79
79
  }>;
80
80
  export type Direction = "next" | "prev" | "current";
81
+ export type DismissOptions = {
82
+ keepFocus: boolean;
83
+ };
81
84
  export type KeyboardControllerModule = {
82
85
  setDefaultMode: () => void;
83
86
  setInputMode: (mode: number) => void;
84
- dismiss: () => void;
87
+ dismiss: (options?: DismissOptions) => Promise<void>;
88
+ setFocusTo: (direction: Direction) => void;
89
+ isVisible: () => boolean;
90
+ state: () => KeyboardEventData | null;
91
+ };
92
+ export type KeyboardControllerNativeModule = {
93
+ setDefaultMode: () => void;
94
+ setInputMode: (mode: number) => void;
95
+ dismiss: (keepFocus: boolean) => void;
85
96
  setFocusTo: (direction: Direction) => void;
86
97
  addListener: (eventName: string) => void;
87
98
  removeListeners: (count: number) => void;
@@ -92,6 +103,8 @@ export type KeyboardEventData = {
92
103
  duration: number;
93
104
  timestamp: number;
94
105
  target: number;
106
+ type: NonNullable<TextInputProps["keyboardType"]>;
107
+ appearance: NonNullable<TextInputProps["keyboardAppearance"]>;
95
108
  };
96
109
  export type KeyboardEventsModule = {
97
110
  addListener: (name: KeyboardControllerEvents, cb: (e: KeyboardEventData) => void) => EmitterSubscription;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-keyboard-controller",
3
- "version": "1.14.4",
3
+ "version": "1.15.0",
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",
@@ -79,7 +79,8 @@
79
79
  },
80
80
  "devDependencies": {
81
81
  "@commitlint/config-conventional": "^11.0.0",
82
- "@react-native/eslint-config": "^0.75.3",
82
+ "@react-native/babel-preset": "0.76.2",
83
+ "@react-native/eslint-config": "0.76.2",
83
84
  "@release-it/conventional-changelog": "^2.0.0",
84
85
  "@testing-library/react-hooks": "^8.0.1",
85
86
  "@types/jest": "^29.2.1",
@@ -92,6 +93,7 @@
92
93
  "eslint-config-prettier": "^8.5.0",
93
94
  "eslint-import-resolver-typescript": "^3.6.1",
94
95
  "eslint-plugin-eslint-comments": "^3.2.0",
96
+ "eslint-plugin-ft-flow": "^3.0.11",
95
97
  "eslint-plugin-import": "^2.28.1",
96
98
  "eslint-plugin-jest": "^26.5.3",
97
99
  "eslint-plugin-prettier": "^4.2.1",
@@ -102,12 +104,12 @@
102
104
  "pod-install": "^0.1.0",
103
105
  "prettier": "^2.8.8",
104
106
  "react": "18.3.1",
105
- "react-native": "0.75.3",
107
+ "react-native": "0.76.2",
106
108
  "react-native-builder-bob": "^0.18.0",
107
109
  "react-native-reanimated": "3.16.1",
108
110
  "react-test-renderer": "18.2.0",
109
111
  "release-it": "^14.2.2",
110
- "typescript": "5.0.4"
112
+ "typescript": "5.6.3"
111
113
  },
112
114
  "peerDependencies": {
113
115
  "react": "*",
package/src/animated.tsx CHANGED
@@ -169,6 +169,11 @@ export const KeyboardProvider = ({
169
169
 
170
170
  updateSharedValues(event, ["android", "ios"]);
171
171
  },
172
+ onKeyboardMoveEnd: (event: NativeEvent) => {
173
+ "worklet";
174
+
175
+ updateSharedValues(event, ["android"]);
176
+ },
172
177
  },
173
178
  [],
174
179
  );
@@ -213,6 +218,7 @@ export const KeyboardProvider = ({
213
218
  onKeyboardMoveStart={OS === "ios" ? onKeyboardMove : undefined}
214
219
  onKeyboardMove={OS === "android" ? onKeyboardMove : undefined}
215
220
  onKeyboardMoveInteractive={onKeyboardMove}
221
+ onKeyboardMoveEnd={OS === "android" ? onKeyboardMove : undefined}
216
222
  onFocusedInputLayoutChangedReanimated={inputLayoutHandler}
217
223
  >
218
224
  {children}
@@ -2,7 +2,7 @@ import { NativeEventEmitter, Platform } from "react-native";
2
2
 
3
3
  import type {
4
4
  FocusedInputEventsModule,
5
- KeyboardControllerModule,
5
+ KeyboardControllerNativeModule,
6
6
  KeyboardControllerProps,
7
7
  KeyboardEventsModule,
8
8
  KeyboardGestureAreaProps,
@@ -19,7 +19,7 @@ const LINKING_ERROR =
19
19
  const RCTKeyboardController =
20
20
  require("./specs/NativeKeyboardController").default;
21
21
 
22
- export const KeyboardController = (
22
+ export const KeyboardControllerNative = (
23
23
  RCTKeyboardController
24
24
  ? RCTKeyboardController
25
25
  : new Proxy(
@@ -30,15 +30,16 @@ export const KeyboardController = (
30
30
  },
31
31
  },
32
32
  )
33
- ) as KeyboardControllerModule;
33
+ ) as KeyboardControllerNativeModule;
34
34
 
35
35
  const KEYBOARD_CONTROLLER_NAMESPACE = "KeyboardController::";
36
- const eventEmitter = new NativeEventEmitter(KeyboardController);
36
+ const eventEmitter = new NativeEventEmitter(KeyboardControllerNative);
37
37
 
38
38
  export const KeyboardEvents: KeyboardEventsModule = {
39
39
  addListener: (name, cb) =>
40
40
  eventEmitter.addListener(KEYBOARD_CONTROLLER_NAMESPACE + name, cb),
41
41
  };
42
+
42
43
  /**
43
44
  * This API is not documented, it's for internal usage only (for now), and is a subject to potential breaking changes in future.
44
45
  * Use it with cautious.
package/src/bindings.ts CHANGED
@@ -2,7 +2,7 @@ import { View } from "react-native";
2
2
 
3
3
  import type {
4
4
  FocusedInputEventsModule,
5
- KeyboardControllerModule,
5
+ KeyboardControllerNativeModule,
6
6
  KeyboardControllerProps,
7
7
  KeyboardEventsModule,
8
8
  KeyboardGestureAreaProps,
@@ -13,7 +13,7 @@ import type { EmitterSubscription } from "react-native";
13
13
 
14
14
  const NOOP = () => {};
15
15
 
16
- export const KeyboardController: KeyboardControllerModule = {
16
+ export const KeyboardControllerNative: KeyboardControllerNativeModule = {
17
17
  setDefaultMode: NOOP,
18
18
  setInputMode: NOOP,
19
19
  dismiss: NOOP,
@@ -14,17 +14,7 @@ import { useKeyboardAnimation } from "./hooks";
14
14
 
15
15
  import type { LayoutRectangle, ViewProps } from "react-native";
16
16
 
17
- export type KeyboardAvoidingViewProps = {
18
- /**
19
- * Specify how to react to the presence of the keyboard.
20
- */
21
- behavior?: "height" | "position" | "padding";
22
-
23
- /**
24
- * Style of the content container when `behavior` is 'position'.
25
- */
26
- contentContainerStyle?: ViewProps["style"];
27
-
17
+ export type KeyboardAvoidingViewBaseProps = {
28
18
  /**
29
19
  * Controls whether this `KeyboardAvoidingView` instance should take effect.
30
20
  * This is useful when more than one is on the screen. Defaults to true.
@@ -38,6 +28,32 @@ export type KeyboardAvoidingViewProps = {
38
28
  keyboardVerticalOffset?: number;
39
29
  } & ViewProps;
40
30
 
31
+ export type KeyboardAvoidingViewProps = KeyboardAvoidingViewBaseProps &
32
+ (
33
+ | {
34
+ /**
35
+ * Specify how to react to the presence of the keyboard.
36
+ */
37
+ behavior?: "position";
38
+
39
+ /**
40
+ * Style of the content container when `behavior` is 'position'.
41
+ */
42
+ contentContainerStyle?: ViewProps["style"];
43
+ }
44
+ | {
45
+ /**
46
+ * Specify how to react to the presence of the keyboard.
47
+ */
48
+ behavior?: "height" | "padding";
49
+
50
+ /**
51
+ * `contentContainerStyle` is not allowed for these behaviors.
52
+ */
53
+ contentContainerStyle?: never;
54
+ }
55
+ );
56
+
41
57
  const defaultLayout: LayoutRectangle = {
42
58
  x: 0,
43
59
  y: 0,
@@ -22,6 +22,9 @@ export type KeyboardStickyViewProps = {
22
22
  */
23
23
  opened?: number;
24
24
  };
25
+
26
+ /** Controls whether this `KeyboardStickyView` instance should take effect. Default is `true` */
27
+ enabled?: boolean;
25
28
  } & ViewProps;
26
29
 
27
30
  const KeyboardStickyView = forwardRef<
@@ -29,7 +32,13 @@ const KeyboardStickyView = forwardRef<
29
32
  React.PropsWithChildren<KeyboardStickyViewProps>
30
33
  >(
31
34
  (
32
- { children, offset: { closed = 0, opened = 0 } = {}, style, ...props },
35
+ {
36
+ children,
37
+ offset: { closed = 0, opened = 0 } = {},
38
+ style,
39
+ enabled = true,
40
+ ...props
41
+ },
33
42
  ref,
34
43
  ) => {
35
44
  const { height, progress } = useReanimatedKeyboardAnimation();
@@ -38,9 +47,9 @@ const KeyboardStickyView = forwardRef<
38
47
  const offset = interpolate(progress.value, [0, 1], [closed, opened]);
39
48
 
40
49
  return {
41
- transform: [{ translateY: height.value + offset }],
50
+ transform: [{ translateY: enabled ? height.value + offset : closed }],
42
51
  };
43
- }, [closed, opened]);
52
+ }, [closed, opened, enabled]);
44
53
 
45
54
  const styles = useMemo(
46
55
  () => [style, stickyViewStyle],