react-native-keyboard-controller 1.17.1 → 1.17.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/README.md +24 -23
  2. package/lib/commonjs/animated.js +23 -7
  3. package/lib/commonjs/animated.js.map +1 -1
  4. package/lib/commonjs/bindings.js +19 -0
  5. package/lib/commonjs/bindings.js.map +1 -1
  6. package/lib/commonjs/components/KeyboardAvoidingView/index.js +11 -2
  7. package/lib/commonjs/components/KeyboardAvoidingView/index.js.map +1 -1
  8. package/lib/commonjs/components/KeyboardAwareScrollView/index.js +51 -36
  9. package/lib/commonjs/components/KeyboardAwareScrollView/index.js.map +1 -1
  10. package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +17 -1
  11. package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -1
  12. package/lib/commonjs/components/KeyboardStickyView/index.js +13 -0
  13. package/lib/commonjs/components/KeyboardStickyView/index.js.map +1 -1
  14. package/lib/commonjs/components/KeyboardToolbar/index.js +31 -22
  15. package/lib/commonjs/components/KeyboardToolbar/index.js.map +1 -1
  16. package/lib/commonjs/context.js +16 -0
  17. package/lib/commonjs/context.js.map +1 -1
  18. package/lib/commonjs/hooks/index.js +164 -0
  19. package/lib/commonjs/hooks/index.js.map +1 -1
  20. package/lib/commonjs/hooks/useKeyboardState/index.js +21 -0
  21. package/lib/commonjs/hooks/useKeyboardState/index.js.map +1 -1
  22. package/lib/commonjs/internal.js +21 -0
  23. package/lib/commonjs/internal.js.map +1 -1
  24. package/lib/commonjs/module.js +4 -0
  25. package/lib/commonjs/module.js.map +1 -1
  26. package/lib/commonjs/monkey-patch.android.js +0 -5
  27. package/lib/commonjs/monkey-patch.android.js.map +1 -1
  28. package/lib/commonjs/{types.js → types/hooks.js} +1 -1
  29. package/lib/commonjs/types/hooks.js.map +1 -0
  30. package/lib/commonjs/types/index.js +50 -0
  31. package/lib/commonjs/types/index.js.map +1 -0
  32. package/lib/commonjs/types/internal.js +6 -0
  33. package/lib/commonjs/types/internal.js.map +1 -0
  34. package/lib/commonjs/types/module.js +6 -0
  35. package/lib/commonjs/types/module.js.map +1 -0
  36. package/lib/commonjs/types/views.js +6 -0
  37. package/lib/commonjs/types/views.js.map +1 -0
  38. package/lib/commonjs/views/OverKeyboardView/index.js +18 -4
  39. package/lib/commonjs/views/OverKeyboardView/index.js.map +1 -1
  40. package/lib/module/animated.js +23 -7
  41. package/lib/module/animated.js.map +1 -1
  42. package/lib/module/bindings.js +19 -0
  43. package/lib/module/bindings.js.map +1 -1
  44. package/lib/module/components/KeyboardAvoidingView/index.js +11 -2
  45. package/lib/module/components/KeyboardAvoidingView/index.js.map +1 -1
  46. package/lib/module/components/KeyboardAwareScrollView/index.js +51 -36
  47. package/lib/module/components/KeyboardAwareScrollView/index.js.map +1 -1
  48. package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +17 -1
  49. package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -1
  50. package/lib/module/components/KeyboardStickyView/index.js +13 -0
  51. package/lib/module/components/KeyboardStickyView/index.js.map +1 -1
  52. package/lib/module/components/KeyboardToolbar/index.js +31 -22
  53. package/lib/module/components/KeyboardToolbar/index.js.map +1 -1
  54. package/lib/module/context.js +16 -0
  55. package/lib/module/context.js.map +1 -1
  56. package/lib/module/hooks/index.js +164 -0
  57. package/lib/module/hooks/index.js.map +1 -1
  58. package/lib/module/hooks/useKeyboardState/index.js +21 -0
  59. package/lib/module/hooks/useKeyboardState/index.js.map +1 -1
  60. package/lib/module/internal.js +21 -0
  61. package/lib/module/internal.js.map +1 -1
  62. package/lib/module/module.js +4 -0
  63. package/lib/module/module.js.map +1 -1
  64. package/lib/module/monkey-patch.android.js +0 -5
  65. package/lib/module/monkey-patch.android.js.map +1 -1
  66. package/lib/module/types/hooks.js +2 -0
  67. package/lib/module/types/hooks.js.map +1 -0
  68. package/lib/module/types/index.js +5 -0
  69. package/lib/module/types/index.js.map +1 -0
  70. package/lib/module/types/internal.js +2 -0
  71. package/lib/module/types/internal.js.map +1 -0
  72. package/lib/module/types/module.js +2 -0
  73. package/lib/module/types/module.js.map +1 -0
  74. package/lib/module/types/views.js +2 -0
  75. package/lib/module/types/views.js.map +1 -0
  76. package/lib/module/views/OverKeyboardView/index.js +18 -4
  77. package/lib/module/views/OverKeyboardView/index.js.map +1 -1
  78. package/lib/typescript/animated.d.ts +20 -6
  79. package/lib/typescript/bindings.d.ts +19 -0
  80. package/lib/typescript/components/KeyboardAvoidingView/index.d.ts +11 -2
  81. package/lib/typescript/components/KeyboardAwareScrollView/index.d.ts +23 -6
  82. package/lib/typescript/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.d.ts +17 -1
  83. package/lib/typescript/components/KeyboardStickyView/index.d.ts +15 -2
  84. package/lib/typescript/components/KeyboardToolbar/index.d.ts +13 -2
  85. package/lib/typescript/context.d.ts +32 -0
  86. package/lib/typescript/hooks/index.d.ts +157 -0
  87. package/lib/typescript/hooks/useKeyboardState/index.d.ts +20 -0
  88. package/lib/typescript/internal.d.ts +21 -0
  89. package/lib/typescript/module.d.ts +3 -0
  90. package/lib/typescript/{types.d.ts → types/hooks.d.ts} +72 -78
  91. package/lib/typescript/types/index.d.ts +4 -0
  92. package/lib/typescript/types/internal.d.ts +17 -0
  93. package/lib/typescript/types/module.d.ts +91 -0
  94. package/lib/typescript/types/views.d.ts +45 -0
  95. package/lib/typescript/views/OverKeyboardView/index.d.ts +14 -1
  96. package/package.json +2 -1
  97. package/src/animated.tsx +27 -12
  98. package/src/bindings.ts +19 -0
  99. package/src/components/KeyboardAvoidingView/index.tsx +11 -2
  100. package/src/components/KeyboardAwareScrollView/index.tsx +54 -39
  101. package/src/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.ts +17 -1
  102. package/src/components/KeyboardStickyView/index.tsx +14 -1
  103. package/src/components/KeyboardToolbar/index.tsx +31 -19
  104. package/src/context.ts +33 -0
  105. package/src/hooks/index.ts +157 -0
  106. package/src/hooks/useKeyboardState/index.ts +20 -0
  107. package/src/internal.ts +21 -0
  108. package/src/module.ts +3 -0
  109. package/src/monkey-patch.android.ts +3 -6
  110. package/src/{types.ts → types/hooks.ts} +72 -105
  111. package/src/types/index.ts +4 -0
  112. package/src/types/internal.ts +24 -0
  113. package/src/types/module.ts +105 -0
  114. package/src/types/views.ts +46 -0
  115. package/src/views/OverKeyboardView/index.tsx +15 -4
  116. package/lib/commonjs/types.js.map +0 -1
  117. package/lib/module/types.js +0 -2
  118. package/lib/module/types.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"names":["_react","require","_reactNative","_eventHandler","_findNodeHandle","useEventHandlerRegistration","map","viewTagRef","onRegisterHandler","handler","ids","attachWorkletHandlers","viewTag","findNodeHandle","current","__DEV__","console","warn","push","Object","keys","handlerName","eventName","get","functionToCall","registerEventHandler","event","queueMicrotask","forEach","id","unregisterEventHandler","useAnimatedValue","initialValue","config","ref","useRef","Animated","Value"],"sources":["internal.ts"],"sourcesContent":["import { useRef } from \"react\";\nimport { Animated } from \"react-native\";\n\nimport { registerEventHandler, unregisterEventHandler } from \"./event-handler\";\nimport { findNodeHandle } from \"./utils/findNodeHandle\";\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,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,aAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AAKO,SAASI,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,GAAG,IAAAC,8BAAc,EAACN,UAAU,CAACO,OAAO,CAAC;MAElD,IAAIC,OAAO,IAAI,CAACH,OAAO,EAAE;QACvBI,OAAO,CAACC,IAAI,CACV,uPACF,CAAC;MACH;MAEAP,GAAG,CAACQ,IAAI,CACN,GAAGC,MAAM,CAACC,IAAI,CAACX,OAAO,CAAC,CAACH,GAAG,CAAEe,WAAW,IAAK;QAC3C,MAAMC,SAAS,GAAGhB,GAAG,CAACiB,GAAG,CAACF,WAAsB,CAAC;QACjD,MAAMG,cAAc,GAAGf,OAAO,CAACY,WAAW,CAAY;QAEtD,IAAIC,SAAS,IAAIV,OAAO,EAAE;UACxB,OAAO,IAAAa,kCAAoB,EACxBC,KAA6C,IAAK;YACjD,SAAS;;YAETF,cAAc,aAAdA,cAAc,eAAdA,cAAc,CAAGE,KAAK,CAAC;UACzB,CAAC,EACDJ,SAAS,EACTV,OACF,CAAC;QACH;QAEA,OAAO,IAAI;MACb,CAAC,CACH,CAAC;IACH,CAAC;IAED,IAAIL,UAAU,CAACO,OAAO,EAAE;MACtBH,qBAAqB,CAAC,CAAC;IACzB,CAAC,MAAM;MACL;MACAgB,cAAc,CAAChB,qBAAqB,CAAC;IACvC;IAEA,OAAO,MAAM;MACXD,GAAG,CAACkB,OAAO,CAAEC,EAAE,IAAMA,EAAE,GAAG,IAAAC,oCAAsB,EAACD,EAAE,CAAC,GAAG,IAAK,CAAC;IAC/D,CAAC;EACH,CAAC;EAED,OAAOrB,iBAAiB;AAC1B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASuB,gBAAgBA,CAC9BC,YAAoB,EACpBC,MAAgC,EAChB;EAChB,MAAMC,GAAG,GAAG,IAAAC,aAAM,EAAwB,IAAI,CAAC;EAE/C,IAAID,GAAG,CAACpB,OAAO,KAAK,IAAI,EAAE;IACxBoB,GAAG,CAACpB,OAAO,GAAG,IAAIsB,qBAAQ,CAACC,KAAK,CAACL,YAAY,EAAEC,MAAM,CAAC;EACxD;EAEA,OAAOC,GAAG,CAACpB,OAAO;AACpB","ignoreList":[]}
1
+ {"version":3,"names":["_react","require","_reactNative","_eventHandler","_findNodeHandle","useEventHandlerRegistration","map","viewTagRef","onRegisterHandler","handler","ids","attachWorkletHandlers","viewTag","findNodeHandle","current","__DEV__","console","warn","push","Object","keys","handlerName","eventName","get","functionToCall","registerEventHandler","event","queueMicrotask","forEach","id","unregisterEventHandler","useAnimatedValue","initialValue","config","ref","useRef","Animated","Value"],"sources":["internal.ts"],"sourcesContent":["import { useRef } from \"react\";\nimport { Animated } from \"react-native\";\n\nimport { registerEventHandler, unregisterEventHandler } from \"./event-handler\";\nimport { findNodeHandle } from \"./utils/findNodeHandle\";\n\ntype EventHandler = (event: never) => void;\ntype ComponentOrHandle = Parameters<typeof findNodeHandle>[0];\n\n/**\n * An internal hook that helps to register workletized event handlers.\n *\n * @param map - Map of event handlers and their names.\n * @param viewTagRef - Ref to the view that produces events.\n * @returns A function that registers supplied event handlers.\n * @example\n * ```ts\n * const setKeyboardHandlers = useEventHandlerRegistration<KeyboardHandler>(\n * keyboardEventsMap,\n * viewTagRef,\n * );\n * ```\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 * @param initialValue - Initial value of the animated value (numeric).\n * @param config - Additional {@link Animated.AnimatedConfig|configuration} for the animated value.\n * @returns Properly memoized {@link Animated.Value|Animated} value.\n * @see https://github.com/facebook/react-native/commit/e22217fe8b9455e32695f88ca835e11442b0a937\n * @example\n * ```ts\n * const progress = useAnimatedValue(0);\n * ```\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,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,aAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASI,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,GAAG,IAAAC,8BAAc,EAACN,UAAU,CAACO,OAAO,CAAC;MAElD,IAAIC,OAAO,IAAI,CAACH,OAAO,EAAE;QACvBI,OAAO,CAACC,IAAI,CACV,uPACF,CAAC;MACH;MAEAP,GAAG,CAACQ,IAAI,CACN,GAAGC,MAAM,CAACC,IAAI,CAACX,OAAO,CAAC,CAACH,GAAG,CAAEe,WAAW,IAAK;QAC3C,MAAMC,SAAS,GAAGhB,GAAG,CAACiB,GAAG,CAACF,WAAsB,CAAC;QACjD,MAAMG,cAAc,GAAGf,OAAO,CAACY,WAAW,CAAY;QAEtD,IAAIC,SAAS,IAAIV,OAAO,EAAE;UACxB,OAAO,IAAAa,kCAAoB,EACxBC,KAA6C,IAAK;YACjD,SAAS;;YAETF,cAAc,aAAdA,cAAc,eAAdA,cAAc,CAAGE,KAAK,CAAC;UACzB,CAAC,EACDJ,SAAS,EACTV,OACF,CAAC;QACH;QAEA,OAAO,IAAI;MACb,CAAC,CACH,CAAC;IACH,CAAC;IAED,IAAIL,UAAU,CAACO,OAAO,EAAE;MACtBH,qBAAqB,CAAC,CAAC;IACzB,CAAC,MAAM;MACL;MACAgB,cAAc,CAAChB,qBAAqB,CAAC;IACvC;IAEA,OAAO,MAAM;MACXD,GAAG,CAACkB,OAAO,CAAEC,EAAE,IAAMA,EAAE,GAAG,IAAAC,oCAAsB,EAACD,EAAE,CAAC,GAAG,IAAK,CAAC;IAC/D,CAAC;EACH,CAAC;EAED,OAAOrB,iBAAiB;AAC1B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASuB,gBAAgBA,CAC9BC,YAAoB,EACpBC,MAAgC,EAChB;EAChB,MAAMC,GAAG,GAAG,IAAAC,aAAM,EAAwB,IAAI,CAAC;EAE/C,IAAID,GAAG,CAACpB,OAAO,KAAK,IAAI,EAAE;IACxBoB,GAAG,CAACpB,OAAO,GAAG,IAAIsB,qBAAQ,CAACC,KAAK,CAACL,YAAY,EAAEC,MAAM,CAAC;EACxD;EAEA,OAAOC,GAAG,CAACpB,OAAO;AACpB","ignoreList":[]}
@@ -38,6 +38,10 @@ const dismiss = async options => {
38
38
  };
39
39
  const isVisible = () => !isClosed;
40
40
  const state = () => lastState;
41
+
42
+ /**
43
+ * KeyboardController module. Helps to perform imperative actions/checks with keyboard.
44
+ */
41
45
  const KeyboardController = exports.KeyboardController = {
42
46
  setDefaultMode: _bindings.KeyboardControllerNative.setDefaultMode,
43
47
  setInputMode: _bindings.KeyboardControllerNative.setInputMode,
@@ -1 +1 @@
1
- {"version":3,"names":["_bindings","require","isClosed","lastState","height","duration","timestamp","Date","getTime","target","type","appearance","KeyboardEvents","addListener","e","dismiss","options","keepFocus","Promise","resolve","subscription","undefined","remove","KeyboardControllerNative","isVisible","state","KeyboardController","exports","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 = true;\nlet lastState: KeyboardEventData = {\n height: 0,\n duration: 0,\n timestamp: new Date().getTime(),\n target: -1,\n type: \"default\",\n appearance: \"default\",\n};\n\nKeyboardEvents.addListener(\"keyboardDidHide\", (e) => {\n isClosed = true;\n lastState = e;\n});\n\nKeyboardEvents.addListener(\"keyboardDidShow\", (e) => {\n isClosed = false;\n lastState = e;\n});\n\nconst dismiss = async (options?: DismissOptions): Promise<void> => {\n const keepFocus = options?.keepFocus ?? false;\n\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 = () => lastState;\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,IAAAA,SAAA,GAAAC,OAAA;AAQA,IAAIC,QAAQ,GAAG,IAAI;AACnB,IAAIC,SAA4B,GAAG;EACjCC,MAAM,EAAE,CAAC;EACTC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;AACF,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_bindings","require","isClosed","lastState","height","duration","timestamp","Date","getTime","target","type","appearance","KeyboardEvents","addListener","e","dismiss","options","keepFocus","Promise","resolve","subscription","undefined","remove","KeyboardControllerNative","isVisible","state","KeyboardController","exports","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 = true;\nlet lastState: KeyboardEventData = {\n height: 0,\n duration: 0,\n timestamp: new Date().getTime(),\n target: -1,\n type: \"default\",\n appearance: \"default\",\n};\n\nKeyboardEvents.addListener(\"keyboardDidHide\", (e) => {\n isClosed = true;\n lastState = e;\n});\n\nKeyboardEvents.addListener(\"keyboardDidShow\", (e) => {\n isClosed = false;\n lastState = e;\n});\n\nconst dismiss = async (options?: DismissOptions): Promise<void> => {\n const keepFocus = options?.keepFocus ?? false;\n\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 = () => lastState;\n\n/**\n * KeyboardController module. Helps to perform imperative actions/checks with keyboard.\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,IAAAA,SAAA,GAAAC,OAAA;AAQA,IAAIC,QAAQ,GAAG,IAAI;AACnB,IAAIC,SAA4B,GAAG;EACjCC,MAAM,EAAE,CAAC;EACTC,QAAQ,EAAE,CAAC;EACXC,SAAS,EAAE,IAAIC,IAAI,CAAC,CAAC,C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edNativeAndroidManager = {
31
31
  setTranslucent: translucent => {
32
32
  RCTStatusBarManagerCompat.setTranslucent(translucent);
33
33
  },
34
- /**
35
- * - statusBarStyles can be:
36
- * - 'default'
37
- * - 'dark-content'
38
- */
39
34
  setStyle: statusBarStyle => {
40
35
  RCTStatusBarManagerCompat.setStyle(statusBarStyle);
41
36
  },
@@ -1 +1 @@
1
- {"version":3,"names":["NativeAndroidManager","_interopRequireWildcard","require","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","RCTStatusBarManagerCompat","OriginalNativeAndroidManager","ModifiedNativeAndroidManager","setColor","color","animated","setTranslucent","translucent","setStyle","statusBarStyle","setHidden","hidden","applyMonkeyPatch","assign","exports","revertMonkeyPatch"],"sources":["monkey-patch.android.ts"],"sourcesContent":["// @ts-expect-error because there is no corresponding type definition\nimport * as NativeAndroidManager from \"react-native/Libraries/Components/StatusBar/NativeStatusBarManagerAndroid\";\n\nconst RCTStatusBarManagerCompat =\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n require(\"./specs/NativeStatusBarManagerCompat\").default;\n\n// Copy original default manager to keep its original state and methods\nconst OriginalNativeAndroidManager = { ...NativeAndroidManager.default };\n\n// Create a new object that modifies the necessary methods\n// On Android < 11 RN uses legacy API which breaks EdgeToEdge mode in RN, so\n// in order to use library on all available platforms we have to monkey patch\n// default RN implementation and use modern `WindowInsetsControllerCompat`.\nconst ModifiedNativeAndroidManager = {\n ...NativeAndroidManager.default, // Spread original properties to keep existing functionality\n setColor: (color: number, animated: boolean): void => {\n RCTStatusBarManagerCompat.setColor(color, animated);\n },\n setTranslucent: (translucent: boolean): void => {\n RCTStatusBarManagerCompat.setTranslucent(translucent);\n },\n /**\n * - statusBarStyles can be:\n * - 'default'\n * - 'dark-content'\n */\n setStyle: (statusBarStyle?: string): void => {\n RCTStatusBarManagerCompat.setStyle(statusBarStyle);\n },\n setHidden: (hidden: boolean): void => {\n RCTStatusBarManagerCompat.setHidden(hidden);\n },\n};\n\n// Define a function to apply the monkey patch\nexport const applyMonkeyPatch = () => {\n Object.assign(NativeAndroidManager.default, ModifiedNativeAndroidManager);\n};\n\n// Define a function to revert changes back to the original state\nexport const revertMonkeyPatch = () => {\n Object.assign(NativeAndroidManager.default, OriginalNativeAndroidManager);\n};\n"],"mappings":";;;;;;AACA,IAAAA,oBAAA,GAAAC,uBAAA,CAAAC,OAAA;AAAkH,SAAAC,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAH,wBAAAG,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,CAAA,SAAAG,CAAA,GAAAP,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CAAA,UAAAG,CAAA,KAAAA,CAAA,CAAAV,GAAA,IAAAU,CAAA,CAAAC,GAAA,IAAAP,MAAA,CAAAC,cAAA,CAAAJ,CAAA,EAAAM,CAAA,EAAAG,CAAA,IAAAT,CAAA,CAAAM,CAAA,IAAAd,C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require","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","RCTStatusBarManagerCompat","OriginalNativeAndroidManager","ModifiedNativeAndroidManager","setColor","color","animated","setTranslucent","translucent","setStyle","statusBarStyle","setHidden","hidden","applyMonkeyPatch","assign","exports","revertMonkeyPatch"],"sources":["monkey-patch.android.ts"],"sourcesContent":["// @ts-expect-error because there is no corresponding type definition\nimport * as NativeAndroidManager from \"react-native/Libraries/Components/StatusBar/NativeStatusBarManagerAndroid\";\n\nconst RCTStatusBarManagerCompat =\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n require(\"./specs/NativeStatusBarManagerCompat\").default;\n\n// Copy original default manager to keep its original state and methods\nconst OriginalNativeAndroidManager = { ...NativeAndroidManager.default };\n\n// Create a new object that modifies the necessary methods\n// On Android < 11 RN uses legacy API which breaks EdgeToEdge mode in RN, so\n// in order to use library on all available platforms we have to monkey patch\n// default RN implementation and use modern `WindowInsetsControllerCompat`.\nconst ModifiedNativeAndroidManager = {\n ...NativeAndroidManager.default, // Spread original properties to keep existing functionality\n setColor: (color: number, animated: boolean): void => {\n RCTStatusBarManagerCompat.setColor(color, animated);\n },\n setTranslucent: (translucent: boolean): void => {\n RCTStatusBarManagerCompat.setTranslucent(translucent);\n },\n setStyle: (\n statusBarStyle?: \"default\" | \"dark-content\" | \"light-content\",\n ): void => {\n RCTStatusBarManagerCompat.setStyle(statusBarStyle);\n },\n setHidden: (hidden: boolean): void => {\n RCTStatusBarManagerCompat.setHidden(hidden);\n },\n};\n\n// Define a function to apply the monkey patch\nexport const applyMonkeyPatch = () => {\n Object.assign(NativeAndroidManager.default, ModifiedNativeAndroidManager);\n};\n\n// Define a function to revert changes back to the original state\nexport const revertMonkeyPatch = () => {\n Object.assign(NativeAndroidManager.default, OriginalNativeAndroidManager);\n};\n"],"mappings":";;;;;;AACA,IAAAA,oBAAA,GAAAC,uBAAA,CAAAC,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,CAAC;;AAExE;AACA;AACA;AACA;AACA,MAAMgB,4BAA4B,GAAG;EACnC,GAAGzB,oBAAoB,CAACS,OAAO;EAAE;EACjCiB,QAAQ,EAAEA,CAACC,KAAa,EAAEC,QAAiB,KAAW;IACpDL,yBAAyB,CAACG,QAAQ,CAACC,KAAK,EAAEC,QAAQ,CAAC;EACrD,CAAC;EACDC,cAAc,EAAGC,WAAoB,IAAW;IAC9CP,yBAAyB,CAACM,cAAc,CAACC,WAAW,CAAC;EACvD,CAAC;EACDC,QAAQ,EACNC,cAA6D,IACpD;IACTT,yBAAyB,CAACQ,QAAQ,CAACC,cAAc,CAAC;EACpD,CAAC;EACDC,SAAS,EAAGC,MAAe,IAAW;IACpCX,yBAAyB,CAACU,SAAS,CAACC,MAAM,CAAC;EAC7C;AACF,CAAC;;AAED;AACO,MAAMC,gBAAgB,GAAGA,CAAA,KAAM;EACpCpB,MAAM,CAACqB,MAAM,CAACpC,oBAAoB,CAACS,OAAO,EAAEgB,4BAA4B,CAAC;AAC3E,CAAC;;AAED;AAAAY,OAAA,CAAAF,gBAAA,GAAAA,gBAAA;AACO,MAAMG,iBAAiB,GAAGA,CAAA,KAAM;EACrCvB,MAAM,CAACqB,MAAM,CAACpC,oBAAoB,CAACS,OAAO,EAAEe,4BAA4B,CAAC;AAC3E,CAAC;AAACa,OAAA,CAAAC,iBAAA,GAAAA,iBAAA","ignoreList":[]}
@@ -3,4 +3,4 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- //# sourceMappingURL=types.js.map
6
+ //# sourceMappingURL=hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["hooks.ts"],"sourcesContent":["import type { NativeSyntheticEvent, ViewProps } from \"react-native\";\n\n// DirectEventHandler events declaration\nexport type NativeEvent = {\n /** A value between `0` and `1` indicating keyboard position, where `0` means keyboard is closed and `1` means keyboard is fully visible. */\n progress: number;\n /** Height of the keyboard. */\n height: number;\n /** Duration of the keyboard animation. */\n duration: number;\n /** Tag of the focused `TextInput`. */\n target: number;\n};\nexport type FocusedInputLayoutChangedEvent = {\n /** Tag of the focused `TextInput`. */\n target: number;\n /** Tag of the parent `ScrollView`. */\n parentScrollViewTarget: number;\n layout: {\n /** X coordinate of the focused `TextInput`. */\n x: number;\n /** Y coordinate of the focused `TextInput`. */\n y: number;\n /** Width of the focused `TextInput`. */\n width: number;\n /** Height of the focused `TextInput`. */\n height: number;\n /** X coordinate of the focused `TextInput` relative to the screen. */\n absoluteX: number;\n /** Y coordinate of the focused `TextInput` relative to the screen. */\n absoluteY: number;\n };\n};\nexport type FocusedInputTextChangedEvent = {\n /** Text that user typed in the focused `TextInput`. */\n text: string;\n};\nexport type FocusedInputSelectionChangedEvent = {\n /** Tag of the focused `TextInput`. */\n target: number;\n selection: {\n /** Start of the selection. Represents top-left point of rectangle. */\n start: {\n /** X coordinate of the selection start (relative to the `TextInput`). */\n x: number;\n /** Y coordinate of the selection start (relative to the `TextInput`). */\n y: number;\n /** The start of selection. */\n position: number;\n };\n /** End of the selection. Represents bottom-right point of rectangle. */\n end: {\n /** X coordinate of the selection end (relative to the `TextInput`). */\n x: number;\n /** Y coordinate of the selection end (relative to the `TextInput`). */\n y: number;\n /** The end of selection. */\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\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 /**\n * A callback that gets invoked when keyboard starts its movement.\n * The event contains DESTINATION values.\n *\n * @example\n * ```ts\n * onStart: (e) => {\n * \"worklet\";\n *\n * const willKeyboardAppear = e.progress === 1;\n * }\n * ```\n */\n onStart: (e: NativeEvent) => void;\n /**\n * A callback that gets involved every frame when keyboard changes its position.\n *\n * @example\n * ```ts\n * onMove: (e) => {\n * \"worklet\";\n *\n * const keyboardHeight = e.height;\n * }\n */\n onMove: (e: NativeEvent) => void;\n /**\n * A callback that gets invoked when keyboard finished its movement.\n *\n * @example\n * ```ts\n * onEnd: (e) => {\n * \"worklet\";\n *\n * const isKeyboardShown = e.progress === 1;\n * }\n * ```\n */\n onEnd: (e: NativeEvent) => void;\n /**\n * A callback that gets invoked every frame when keyboard changes its position due to interactive dismissal.\n *\n * @example\n * ```ts\n * onInteractive: (e) => {\n * \"worklet\";\n *\n * const keyboardHeight = e.height;\n * }\n */\n onInteractive: (e: NativeEvent) => void;\n}>;\nexport type KeyboardHandlers = Handlers<KeyboardHandler>;\nexport type FocusedInputHandler = Partial<{\n /** A callback that gets invoked every time when the text changes in focused input. */\n onChangeText: (e: FocusedInputTextChangedEvent) => void;\n /** A callback that gets invoked every time when the selection (cursor) coordinates change in focused input. */\n onSelectionChange: (e: FocusedInputSelectionChangedEvent) => void;\n}>;\nexport type FocusedInputHandlers = Handlers<FocusedInputHandler>;\n"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _hooks = require("./hooks");
7
+ Object.keys(_hooks).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _hooks[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _hooks[key];
14
+ }
15
+ });
16
+ });
17
+ var _views = require("./views");
18
+ Object.keys(_views).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _views[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _views[key];
25
+ }
26
+ });
27
+ });
28
+ var _module = require("./module");
29
+ Object.keys(_module).forEach(function (key) {
30
+ if (key === "default" || key === "__esModule") return;
31
+ if (key in exports && exports[key] === _module[key]) return;
32
+ Object.defineProperty(exports, key, {
33
+ enumerable: true,
34
+ get: function () {
35
+ return _module[key];
36
+ }
37
+ });
38
+ });
39
+ var _internal = require("./internal");
40
+ Object.keys(_internal).forEach(function (key) {
41
+ if (key === "default" || key === "__esModule") return;
42
+ if (key in exports && exports[key] === _internal[key]) return;
43
+ Object.defineProperty(exports, key, {
44
+ enumerable: true,
45
+ get: function () {
46
+ return _internal[key];
47
+ }
48
+ });
49
+ });
50
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_hooks","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_views","_module","_internal"],"sources":["index.ts"],"sourcesContent":["export * from \"./hooks\";\nexport * from \"./views\";\nexport * from \"./module\";\nexport * from \"./internal\";\n"],"mappings":";;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,MAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,MAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,M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js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["internal.ts"],"sourcesContent":["import type { EmitterSubscription } from \"react-native\";\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"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=module.js.map
@@ -0,0 +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 `default`, `dark` or `light`. */\n appearance: NonNullable<TextInputProps[\"keyboardAppearance\"]>;\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 * @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. @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 // 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 // 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":[]}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=views.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["views.ts"],"sourcesContent":["import type { PropsWithChildren } from \"react\";\nimport type { ViewProps } from \"react-native\";\n\nexport type KeyboardGestureAreaProps = {\n /**\n * Determines how the keyboard position will be controlled:\n * - `ios` - keyboard will be following finger only when finger touches keyboard\n * - `linear` - keyboard will be following finger position linearly.\n *\n * @platform android\n */\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 * @platform android\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 * @platform android\n */\n enableSwipeToDismiss?: boolean;\n /**\n * Extra distance to the keyboard.\n */\n offset?: number;\n /**\n * A corresponding `nativeID` value from the associated `TextInput` (a string that links the `KeyboardGestureArea` to one or more `TextInput` components).\n * This is **required on iOS** in order to apply the `offset` when the keyboard is shown. Only the currently focused `TextInput` with a matching `nativeID`\n * will receive offset behavior.\n *\n * @platform ios\n */\n textInputNativeID?: string;\n} & ViewProps;\nexport type OverKeyboardViewProps = PropsWithChildren<{\n /**\n * A boolean prop indicating whether the view is visible or not. If it's true then view is shown on the screen. If it's false then view is hidden.\n */\n visible: boolean;\n}>;\n"],"mappings":"","ignoreList":[]}
@@ -10,10 +10,24 @@ var _bindings = require("../../bindings");
10
10
  var _hooks = require("../../hooks");
11
11
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
12
12
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
13
- const OverKeyboardView = ({
14
- children,
15
- visible
16
- }) => {
13
+ /**
14
+ * A view component that renders its children over the keyboard without closing the keyboard.
15
+ * Acts similar to modal, but doesn't close the keyboard when it's visible.
16
+ *
17
+ * @param props - Component props.
18
+ * @returns A view component that renders over the keyboard.
19
+ * @example
20
+ * ```tsx
21
+ * <OverKeyboardView visible={true}>
22
+ * <Text>This will appear over the keyboard</Text>
23
+ * </OverKeyboardView>
24
+ * ```
25
+ */
26
+ const OverKeyboardView = props => {
27
+ const {
28
+ children,
29
+ visible
30
+ } = props;
17
31
  const {
18
32
  height,
19
33
  width
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_bindings","_hooks","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","OverKeyboardView","children","visible","height","width","useWindowDimensions","inner","useMemo","style","styles","absolute","Platform","OS","undefined","stretch","createElement","RCTOverKeyboardView","View","collapsable","StyleSheet","create","position","top","bottom","left","right","_default","exports"],"sources":["index.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport { Platform, StyleSheet, View } from \"react-native\";\n\nimport { RCTOverKeyboardView } from \"../../bindings\";\nimport { useWindowDimensions } from \"../../hooks\";\n\nimport type { OverKeyboardViewProps } from \"../../types\";\nimport type { PropsWithChildren } from \"react\";\n\nconst OverKeyboardView = ({\n children,\n visible,\n}: PropsWithChildren<OverKeyboardViewProps>) => {\n const { height, width } = useWindowDimensions();\n const inner = useMemo(() => ({ height, width }), [height, width]);\n const style = useMemo(\n () => [\n styles.absolute,\n // On iOS - stretch view to full window dimensions to make yoga work\n Platform.OS === \"ios\" ? inner : undefined,\n // On Android - we are laid out by ShadowNode, so just stretch to full container\n Platform.OS === \"android\" ? styles.stretch : undefined,\n ],\n [inner],\n );\n\n return (\n <RCTOverKeyboardView visible={visible}>\n {/* `OverKeyboardView` should always have a single child */}\n <View collapsable={false} style={style}>\n {/* Match RN behavior and trigger mount/unmount when visibility changes */}\n {visible && children}\n </View>\n </RCTOverKeyboardView>\n );\n};\n\nconst styles = StyleSheet.create({\n absolute: {\n position: \"absolute\",\n },\n stretch: {\n top: 0,\n bottom: 0,\n left: 0,\n right: 0,\n },\n});\n\nexport default OverKeyboardView;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAAkD,SAAAI,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAN,wBAAAM,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,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;IAACd,OAAO,EAAEA;EAAQ,gBAEpC5B,MAAA,CAAAY,OAAA,CAAA6B,aAAA,CAACtC,YAAA,CAAAwC,IAAI;IAACC,WAAW,EAAE,KAAM;IAACV,KAAK,EAAEA;EAAM,GAEpCN,OAAO,IAAID,QACR,CACa,CAAC;AAE1B,CAAC;AAED,MAAMQ,MAAM,GAAGU,uBAAU,CAACC,MAAM,CAAC;EAC/BV,QAAQ,EAAE;IACRW,QAAQ,EAAE;EACZ,CAAC;EACDP,OAAO,EAAE;IACPQ,GAAG,EAAE,CAAC;IACNC,MAAM,EAAE,CAAC;IACTC,IAAI,EAAE,CAAC;IACPC,KAAK,EAAE;EACT;AACF,CAAC,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAzC,OAAA,GAEYc,gBAAgB","ignoreList":[]}
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_bindings","_hooks","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","OverKeyboardView","props","children","visible","height","width","useWindowDimensions","inner","useMemo","style","styles","absolute","Platform","OS","undefined","stretch","createElement","RCTOverKeyboardView","View","collapsable","StyleSheet","create","position","top","bottom","left","right","_default","exports"],"sources":["index.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport { Platform, StyleSheet, View } from \"react-native\";\n\nimport { RCTOverKeyboardView } from \"../../bindings\";\nimport { useWindowDimensions } from \"../../hooks\";\n\nimport type { OverKeyboardViewProps } from \"../../types\";\nimport type { PropsWithChildren } from \"react\";\n\n/**\n * A view component that renders its children over the keyboard without closing the keyboard.\n * Acts similar to modal, but doesn't close the keyboard when it's visible.\n *\n * @param props - Component props.\n * @returns A view component that renders over the keyboard.\n * @example\n * ```tsx\n * <OverKeyboardView visible={true}>\n * <Text>This will appear over the keyboard</Text>\n * </OverKeyboardView>\n * ```\n */\nconst OverKeyboardView = (props: PropsWithChildren<OverKeyboardViewProps>) => {\n const { children, visible } = props;\n const { height, width } = useWindowDimensions();\n const inner = useMemo(() => ({ height, width }), [height, width]);\n const style = useMemo(\n () => [\n styles.absolute,\n // On iOS - stretch view to full window dimensions to make yoga work\n Platform.OS === \"ios\" ? inner : undefined,\n // On Android - we are laid out by ShadowNode, so just stretch to full container\n Platform.OS === \"android\" ? styles.stretch : undefined,\n ],\n [inner],\n );\n\n return (\n <RCTOverKeyboardView visible={visible}>\n {/* `OverKeyboardView` should always have a single child */}\n <View collapsable={false} style={style}>\n {/* Match RN behavior and trigger mount/unmount when visibility changes */}\n {visible && children}\n </View>\n </RCTOverKeyboardView>\n );\n};\n\nconst styles = StyleSheet.create({\n absolute: {\n position: \"absolute\",\n },\n stretch: {\n top: 0,\n bottom: 0,\n left: 0,\n right: 0,\n },\n});\n\nexport default OverKeyboardView;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAAkD,SAAAI,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAN,wBAAAM,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,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,CAAAuC,mBAAmB;IAACd,OAAO,EAAEA;EAAQ,gBAEpC7B,MAAA,CAAAY,OAAA,CAAA8B,aAAA,CAACvC,YAAA,CAAAyC,IAAI;IAACC,WAAW,EAAE,KAAM;IAACV,KAAK,EAAEA;EAAM,GAEpCN,OAAO,IAAID,QACR,CACa,CAAC;AAE1B,CAAC;AAED,MAAMQ,MAAM,GAAGU,uBAAU,CAACC,MAAM,CAAC;EAC/BV,QAAQ,EAAE;IACRW,QAAQ,EAAE;EACZ,CAAC;EACDP,OAAO,EAAE;IACPQ,GAAG,EAAE,CAAC;IACNC,MAAM,EAAE,CAAC;IACTC,IAAI,EAAE,CAAC;IACPC,KAAK,EAAE;EACT;AACF,CAAC,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA1C,OAAA,GAEYc,gBAAgB","ignoreList":[]}
@@ -23,13 +23,29 @@ const styles = StyleSheet.create({
23
23
  // capture `Platform.OS` in separate variable to avoid deep workletization of entire RN package
24
24
  // see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/393 and https://github.com/kirillzyusko/react-native-keyboard-controller/issues/294 for more details
25
25
  const OS = Platform.OS;
26
- export const KeyboardProvider = ({
27
- children,
28
- statusBarTranslucent,
29
- navigationBarTranslucent,
30
- preserveEdgeToEdge,
31
- enabled: initiallyEnabled = true
32
- }) => {
26
+
27
+ /**
28
+ * A component that wrap your app. Under the hood it works with {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller-view|KeyboardControllerView} to receive events during keyboard movements,
29
+ * maps these events to `Animated`/`Reanimated` values and store them in context.
30
+ *
31
+ * @param props - Provider props, such as `statusBarTranslucent`, `navigationBarTranslucent`, etc.
32
+ * @returns A component that should be mounted in root of your App layout.
33
+ * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-provider|Documentation} page for more details.
34
+ * @example
35
+ * ```tsx
36
+ * <KeyboardProvider>
37
+ * <NavigationContainer />
38
+ * </KeyboardProvider>
39
+ * ```
40
+ */
41
+ export const KeyboardProvider = props => {
42
+ const {
43
+ children,
44
+ statusBarTranslucent,
45
+ navigationBarTranslucent,
46
+ preserveEdgeToEdge,
47
+ enabled: initiallyEnabled = true
48
+ } = props;
33
49
  // ref
34
50
  const viewTagRef = useRef(null);
35
51
  // state
@@ -1 +1 @@
1
- {"version":3,"names":["React","useLayoutEffect","useMemo","useRef","useState","Animated","Platform","StyleSheet","controlEdgeToEdgeValues","isEdgeToEdge","Reanimated","useSharedValue","KeyboardControllerView","KeyboardContext","focusedInputEventsMap","keyboardEventsMap","useAnimatedValue","useEventHandlerRegistration","applyMonkeyPatch","revertMonkeyPatch","useAnimatedKeyboardHandler","useFocusedInputLayoutHandler","IS_EDGE_TO_EDGE","KeyboardControllerViewAnimated","createAnimatedComponent","styles","create","container","flex","hidden","display","position","OS","KeyboardProvider","children","statusBarTranslucent","navigationBarTranslucent","preserveEdgeToEdge","enabled","initiallyEnabled","viewTagRef","setEnabled","progress","height","progressSV","heightSV","layout","setKeyboardHandlers","setInputHandlers","context","animated","multiply","reanimated","style","transform","translateX","translateY","onKeyboardMove","event","nativeEvent","useNativeDriver","updateSharedValues","platforms","includes","value","keyboardHandler","onKeyboardMoveStart","onKeyboardMoveInteractive","onKeyboardMoveEnd","inputLayoutHandler","onFocusedInputLayoutChanged","e","target","__DEV__","createElement","Provider","ref","onKeyboardMoveReanimated","undefined","onFocusedInputLayoutChangedReanimated","View"],"sources":["animated.tsx"],"sourcesContent":["/* eslint react/jsx-sort-props: off */\nimport React, { useLayoutEffect, useMemo, useRef, useState } from \"react\";\nimport { Animated, Platform, StyleSheet } from \"react-native\";\nimport {\n controlEdgeToEdgeValues,\n isEdgeToEdge,\n} from \"react-native-is-edge-to-edge\";\nimport Reanimated, { useSharedValue } from \"react-native-reanimated\";\n\nimport { KeyboardControllerView } from \"./bindings\";\nimport { KeyboardContext } from \"./context\";\nimport { focusedInputEventsMap, keyboardEventsMap } from \"./event-mappings\";\nimport { useAnimatedValue, useEventHandlerRegistration } from \"./internal\";\nimport { applyMonkeyPatch, revertMonkeyPatch } from \"./monkey-patch\";\nimport {\n useAnimatedKeyboardHandler,\n useFocusedInputLayoutHandler,\n} from \"./reanimated\";\n\nimport type { KeyboardAnimationContext } from \"./context\";\nimport type {\n FocusedInputHandler,\n FocusedInputLayoutChangedEvent,\n KeyboardControllerProps,\n KeyboardHandler,\n NativeEvent,\n} from \"./types\";\nimport type { ViewStyle } from \"react-native\";\n\nconst IS_EDGE_TO_EDGE = isEdgeToEdge();\n\nconst KeyboardControllerViewAnimated = Reanimated.createAnimatedComponent(\n Animated.createAnimatedComponent(KeyboardControllerView),\n);\n\ntype Styles = {\n container: ViewStyle;\n hidden: ViewStyle;\n};\n\nconst styles = StyleSheet.create<Styles>({\n container: {\n flex: 1,\n },\n hidden: {\n display: \"none\",\n position: \"absolute\",\n },\n});\n\ntype KeyboardProviderProps = {\n children: React.ReactNode;\n /**\n * Set the value to `true`, if you use translucent status bar on Android.\n * If you already control status bar translucency via `react-native-screens`\n * or `StatusBar` component from `react-native`, you can ignore it.\n * Defaults to `false`.\n *\n * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/14\n * @platform android\n */\n statusBarTranslucent?: boolean;\n /**\n * Set the value to `true`, if you use translucent navigation bar on Android.\n * Defaults to `false`.\n *\n * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/119\n * @platform android\n */\n navigationBarTranslucent?: boolean;\n /**\n * A boolean property indicating whether to keep edge-to-edge mode always enabled (even when you disable the module).\n * Defaults to `false`.\n *\n * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/592\n * @platform android\n */\n preserveEdgeToEdge?: boolean;\n /**\n * A boolean prop indicating whether the module is enabled. It indicate only initial state,\n * i. e. if you try to change this prop after component mount it will not have any effect.\n * To change the property in runtime use `useKeyboardController` hook and `setEnabled` method.\n * Defaults to `true`.\n */\n enabled?: boolean;\n};\n\n// capture `Platform.OS` in separate variable to avoid deep workletization of entire RN package\n// see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/393 and https://github.com/kirillzyusko/react-native-keyboard-controller/issues/294 for more details\nconst OS = Platform.OS;\n\nexport const KeyboardProvider = ({\n children,\n statusBarTranslucent,\n navigationBarTranslucent,\n preserveEdgeToEdge,\n enabled: initiallyEnabled = true,\n}: KeyboardProviderProps) => {\n // ref\n const viewTagRef = useRef<React.Component<KeyboardControllerProps>>(null);\n // state\n const [enabled, setEnabled] = useState(initiallyEnabled);\n // animated values\n const progress = useAnimatedValue(0);\n const height = useAnimatedValue(0);\n // shared values\n const progressSV = useSharedValue(0);\n const heightSV = useSharedValue(0);\n const layout = useSharedValue<FocusedInputLayoutChangedEvent | null>(null);\n const setKeyboardHandlers = useEventHandlerRegistration<KeyboardHandler>(\n keyboardEventsMap,\n viewTagRef,\n );\n const setInputHandlers = useEventHandlerRegistration<FocusedInputHandler>(\n focusedInputEventsMap,\n viewTagRef,\n );\n // memo\n const context = useMemo<KeyboardAnimationContext>(\n () => ({\n enabled,\n animated: { progress: progress, height: Animated.multiply(height, -1) },\n reanimated: { progress: progressSV, height: heightSV },\n layout,\n setKeyboardHandlers,\n setInputHandlers,\n setEnabled,\n }),\n [enabled],\n );\n const style = useMemo(\n () => [\n styles.hidden,\n { transform: [{ translateX: height }, { translateY: progress }] },\n ],\n [],\n );\n const onKeyboardMove = useMemo(\n () =>\n Animated.event(\n [\n {\n nativeEvent: {\n progress,\n height,\n },\n },\n ],\n // Setting useNativeDriver to true on web triggers a warning due to the absence of a native driver for web. Therefore, it is set to false.\n { useNativeDriver: Platform.OS !== \"web\" },\n ),\n [],\n );\n // handlers\n const updateSharedValues = (event: NativeEvent, platforms: string[]) => {\n \"worklet\";\n\n if (platforms.includes(OS)) {\n // eslint-disable-next-line react-compiler/react-compiler\n progressSV.value = event.progress;\n heightSV.value = -event.height;\n }\n };\n const keyboardHandler = useAnimatedKeyboardHandler(\n {\n onKeyboardMoveStart: (event: NativeEvent) => {\n \"worklet\";\n\n updateSharedValues(event, [\"ios\"]);\n },\n onKeyboardMove: (event: NativeEvent) => {\n \"worklet\";\n\n updateSharedValues(event, [\"android\"]);\n },\n onKeyboardMoveInteractive: (event: NativeEvent) => {\n \"worklet\";\n\n updateSharedValues(event, [\"android\", \"ios\"]);\n },\n onKeyboardMoveEnd: (event: NativeEvent) => {\n \"worklet\";\n\n updateSharedValues(event, [\"android\"]);\n },\n },\n [],\n );\n const inputLayoutHandler = useFocusedInputLayoutHandler(\n {\n onFocusedInputLayoutChanged: (e) => {\n \"worklet\";\n\n if (e.target !== -1) {\n layout.value = e;\n } else {\n layout.value = null;\n }\n },\n },\n [],\n );\n\n // layout effects\n useLayoutEffect(() => {\n if (enabled) {\n applyMonkeyPatch();\n } else {\n revertMonkeyPatch();\n }\n }, [enabled]);\n\n if (__DEV__) {\n controlEdgeToEdgeValues({\n statusBarTranslucent,\n navigationBarTranslucent,\n preserveEdgeToEdge,\n });\n }\n\n return (\n <KeyboardContext.Provider value={context}>\n <KeyboardControllerViewAnimated\n ref={viewTagRef}\n enabled={enabled}\n navigationBarTranslucent={IS_EDGE_TO_EDGE || navigationBarTranslucent}\n statusBarTranslucent={IS_EDGE_TO_EDGE || statusBarTranslucent}\n preserveEdgeToEdge={IS_EDGE_TO_EDGE || preserveEdgeToEdge}\n style={styles.container}\n // on*Reanimated prop must precede animated handlers to work correctly\n onKeyboardMoveReanimated={keyboardHandler}\n onKeyboardMoveStart={OS === \"ios\" ? onKeyboardMove : undefined}\n onKeyboardMove={OS === \"android\" ? onKeyboardMove : undefined}\n onKeyboardMoveInteractive={onKeyboardMove}\n onKeyboardMoveEnd={OS === \"android\" ? onKeyboardMove : undefined}\n onFocusedInputLayoutChangedReanimated={inputLayoutHandler}\n >\n {children}\n </KeyboardControllerViewAnimated>\n <Animated.View\n // we are using this small hack, because if the component (where\n // animated value has been used) is unmounted, then animation will\n // stop receiving events (seems like it's react-native optimization).\n // So we need to keep a reference to the animated value, to keep it's\n // always mounted (keep a reference to an animated value).\n //\n // To test why it's needed, try to open screen which consumes Animated.Value\n // then close it and open it again (for example 'Animated transition').\n style={style}\n />\n </KeyboardContext.Provider>\n );\n};\n"],"mappings":"AAAA;AACA,OAAOA,KAAK,IAAIC,eAAe,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AACzE,SAASC,QAAQ,EAAEC,QAAQ,EAAEC,UAAU,QAAQ,cAAc;AAC7D,SACEC,uBAAuB,EACvBC,YAAY,QACP,8BAA8B;AACrC,OAAOC,UAAU,IAAIC,cAAc,QAAQ,yBAAyB;AAEpE,SAASC,sBAAsB,QAAQ,YAAY;AACnD,SAASC,eAAe,QAAQ,WAAW;AAC3C,SAASC,qBAAqB,EAAEC,iBAAiB,QAAQ,kBAAkB;AAC3E,SAASC,gBAAgB,EAAEC,2BAA2B,QAAQ,YAAY;AAC1E,SAASC,gBAAgB,EAAEC,iBAAiB,QAAQ,gBAAgB;AACpE,SACEC,0BAA0B,EAC1BC,4BAA4B,QACvB,cAAc;AAYrB,MAAMC,eAAe,GAAGb,YAAY,CAAC,CAAC;AAEtC,MAAMc,8BAA8B,GAAGb,UAAU,CAACc,uBAAuB,CACvEnB,QAAQ,CAACmB,uBAAuB,CAACZ,sBAAsB,CACzD,CAAC;AAOD,MAAMa,MAAM,GAAGlB,UAAU,CAACmB,MAAM,CAAS;EACvCC,SAAS,EAAE;IACTC,IAAI,EAAE;EACR,CAAC;EACDC,MAAM,EAAE;IACNC,OAAO,EAAE,MAAM;IACfC,QAAQ,EAAE;EACZ;AACF,CAAC,CAAC;AAuCF;AACA;AACA,MAAMC,EAAE,GAAG1B,QAAQ,CAAC0B,EAAE;AAEtB,OAAO,MAAMC,gBAAgB,GAAGA,CAAC;EAC/BC,QAAQ;EACRC,oBAAoB;EACpBC,wBAAwB;EACxBC,kBAAkB;EAClBC,OAAO,EAAEC,gBAAgB,GAAG;AACP,CAAC,KAAK;EAC3B;EACA,MAAMC,UAAU,GAAGrC,MAAM,CAA2C,IAA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IAAIqC,OAAO,EAAE;MACXpB,gBAAgB,CAAC,CAAC;IACpB,CAAC,MAAM;MACLC,iBAAiB,CAAC,CAAC;IACrB;EACF,CAAC,EAAE,CAACmB,OAAO,CAAC,CAAC;EAEb,IAAImC,OAAO,EAAE;IACXjE,uBAAuB,CAAC;MACtB2B,oBAAoB;MACpBC,wBAAwB;MACxBC;IACF,CAAC,CAAC;EACJ;EAEA,oBACErC,KAAA,CAAA0E,aAAA,CAAC7D,eAAe,CAAC8D,QAAQ;IAACX,KAAK,EAAEf;EAAQ,gBACvCjD,KAAA,CAAA0E,aAAA,CAACnD,8BAA8B;IAC7BqD,GAAG,EAAEpC,UAAW;IAChBF,OAAO,EAAEA,OAAQ;IACjBF,wBAAwB,EAAEd,eAAe,IAAIc,wBAAyB;IACtED,oBAAoB,EAAEb,eAAe,IAAIa,oBAAqB;IAC9DE,kBAAkB,EAAEf,eAAe,IAAIe,kBAAmB;IAC1DgB,KAAK,EAAE5B,MAAM,CAACE;IACd;IAAA;IACAkD,wBAAwB,EAAEZ,eAAgB;IAC1CC,mBAAmB,EAAElC,EAAE,KAAK,KAAK,GAAGyB,cAAc,GAAGqB,SAAU;IAC/DrB,cAAc,EAAEzB,EAAE,KAAK,SAAS,GAAGyB,cAAc,GAAGqB,SAAU;IAC9DX,yBAAyB,EAAEV,cAAe;IAC1CW,iBAAiB,EAAEpC,EAAE,KAAK,SAAS,GAAGyB,cAAc,GAAGqB,SAAU;IACjEC,qCAAqC,EAAEV;EAAmB,GAEzDnC,QAC6B,CAAC,eACjClC,KAAA,CAAA0E,aAAA,CAACrE,QAAQ,CAAC2E,IAAI;IACZ;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA3B,KAAK,EAAEA;EAAM,CACd,CACuB,CAAC;AAE/B,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["React","useLayoutEffect","useMemo","useRef","useState","Animated","Platform","StyleSheet","controlEdgeToEdgeValues","isEdgeToEdge","Reanimated","useSharedValue","KeyboardControllerView","KeyboardContext","focusedInputEventsMap","keyboardEventsMap","useAnimatedValue","useEventHandlerRegistration","applyMonkeyPatch","revertMonkeyPatch","useAnimatedKeyboardHandler","useFocusedInputLayoutHandler","IS_EDGE_TO_EDGE","KeyboardControllerViewAnimated","createAnimatedComponent","styles","create","container","flex","hidden","display","position","OS","KeyboardProvider","props","children","statusBarTranslucent","navigationBarTranslucent","preserveEdgeToEdge","enabled","initiallyEnabled","viewTagRef","setEnabled","progress","height","progressSV","heightSV","layout","setKeyboardHandlers","setInputHandlers","context","animated","multiply","reanimated","style","transform","translateX","translateY","onKeyboardMove","event","nativeEvent","useNativeDriver","updateSharedValues","platforms","includes","value","keyboardHandler","onKeyboardMoveStart","onKeyboardMoveInteractive","onKeyboardMoveEnd","inputLayoutHandler","onFocusedInputLayoutChanged","e","target","__DEV__","createElement","Provider","ref","onKeyboardMoveReanimated","undefined","onFocusedInputLayoutChangedReanimated","View"],"sources":["animated.tsx"],"sourcesContent":["/* eslint react/jsx-sort-props: off */\nimport React, { useLayoutEffect, useMemo, useRef, useState } from \"react\";\nimport { Animated, Platform, StyleSheet } from \"react-native\";\nimport {\n controlEdgeToEdgeValues,\n isEdgeToEdge,\n} from \"react-native-is-edge-to-edge\";\nimport Reanimated, { useSharedValue } from \"react-native-reanimated\";\n\nimport { KeyboardControllerView } from \"./bindings\";\nimport { KeyboardContext } from \"./context\";\nimport { focusedInputEventsMap, keyboardEventsMap } from \"./event-mappings\";\nimport { useAnimatedValue, useEventHandlerRegistration } from \"./internal\";\nimport { applyMonkeyPatch, revertMonkeyPatch } from \"./monkey-patch\";\nimport {\n useAnimatedKeyboardHandler,\n useFocusedInputLayoutHandler,\n} from \"./reanimated\";\n\nimport type { KeyboardAnimationContext } from \"./context\";\nimport type {\n FocusedInputHandler,\n FocusedInputLayoutChangedEvent,\n KeyboardControllerProps,\n KeyboardHandler,\n NativeEvent,\n} from \"./types\";\nimport type { ViewStyle } from \"react-native\";\n\nconst IS_EDGE_TO_EDGE = isEdgeToEdge();\n\nconst KeyboardControllerViewAnimated = Reanimated.createAnimatedComponent(\n Animated.createAnimatedComponent(KeyboardControllerView),\n);\n\ntype Styles = {\n container: ViewStyle;\n hidden: ViewStyle;\n};\n\nconst styles = StyleSheet.create<Styles>({\n container: {\n flex: 1,\n },\n hidden: {\n display: \"none\",\n position: \"absolute\",\n },\n});\n\ntype KeyboardProviderProps = {\n children: React.ReactNode;\n /**\n * Set the value to `true`, if you use translucent status bar on Android.\n * If you already control status bar translucency via `react-native-screens`\n * or `StatusBar` component from `react-native`, you can ignore it.\n * Defaults to `false`.\n *\n * @platform android\n * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/14\n */\n statusBarTranslucent?: boolean;\n /**\n * Set the value to `true`, if you use translucent navigation bar on Android.\n * Defaults to `false`.\n *\n * @platform android\n * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/119\n */\n navigationBarTranslucent?: boolean;\n /**\n * A boolean property indicating whether to keep edge-to-edge mode always enabled (even when you disable the module).\n * Defaults to `false`.\n *\n * @platform android\n * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/592\n */\n preserveEdgeToEdge?: boolean;\n /**\n * A boolean prop indicating whether the module is enabled. It indicate only initial state\n * (if you try to change this prop after component mount it will not have any effect).\n * To change the property in runtime use `useKeyboardController` hook and `setEnabled` method.\n * Defaults to `true`.\n */\n enabled?: boolean;\n};\n\n// capture `Platform.OS` in separate variable to avoid deep workletization of entire RN package\n// see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/393 and https://github.com/kirillzyusko/react-native-keyboard-controller/issues/294 for more details\nconst OS = Platform.OS;\n\n/**\n * A component that wrap your app. Under the hood it works with {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller-view|KeyboardControllerView} to receive events during keyboard movements,\n * maps these events to `Animated`/`Reanimated` values and store them in context.\n *\n * @param props - Provider props, such as `statusBarTranslucent`, `navigationBarTranslucent`, etc.\n * @returns A component that should be mounted in root of your App layout.\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-provider|Documentation} page for more details.\n * @example\n * ```tsx\n * <KeyboardProvider>\n * <NavigationContainer />\n * </KeyboardProvider>\n * ```\n */\nexport const KeyboardProvider = (props: KeyboardProviderProps) => {\n const {\n children,\n statusBarTranslucent,\n navigationBarTranslucent,\n preserveEdgeToEdge,\n enabled: initiallyEnabled = true,\n } = props;\n // ref\n const viewTagRef = useRef<React.Component<KeyboardControllerProps>>(null);\n // state\n const [enabled, setEnabled] = useState(initiallyEnabled);\n // animated values\n const progress = useAnimatedValue(0);\n const height = useAnimatedValue(0);\n // shared values\n const progressSV = useSharedValue(0);\n const heightSV = useSharedValue(0);\n const layout = useSharedValue<FocusedInputLayoutChangedEvent | null>(null);\n const setKeyboardHandlers = useEventHandlerRegistration<KeyboardHandler>(\n keyboardEventsMap,\n viewTagRef,\n );\n const setInputHandlers = useEventHandlerRegistration<FocusedInputHandler>(\n focusedInputEventsMap,\n viewTagRef,\n );\n // memo\n const context = useMemo<KeyboardAnimationContext>(\n () => ({\n enabled,\n animated: { progress: progress, height: Animated.multiply(height, -1) },\n reanimated: { progress: progressSV, height: heightSV },\n layout,\n setKeyboardHandlers,\n setInputHandlers,\n setEnabled,\n }),\n [enabled],\n );\n const style = useMemo(\n () => [\n styles.hidden,\n { transform: [{ translateX: height }, { translateY: progress }] },\n ],\n [],\n );\n const onKeyboardMove = useMemo(\n () =>\n Animated.event(\n [\n {\n nativeEvent: {\n progress,\n height,\n },\n },\n ],\n // Setting useNativeDriver to true on web triggers a warning due to the absence of a native driver for web. Therefore, it is set to false.\n { useNativeDriver: Platform.OS !== \"web\" },\n ),\n [],\n );\n // handlers\n const updateSharedValues = (event: NativeEvent, platforms: string[]) => {\n \"worklet\";\n\n if (platforms.includes(OS)) {\n // eslint-disable-next-line react-compiler/react-compiler\n progressSV.value = event.progress;\n heightSV.value = -event.height;\n }\n };\n const keyboardHandler = useAnimatedKeyboardHandler(\n {\n onKeyboardMoveStart: (event: NativeEvent) => {\n \"worklet\";\n\n updateSharedValues(event, [\"ios\"]);\n },\n onKeyboardMove: (event: NativeEvent) => {\n \"worklet\";\n\n updateSharedValues(event, [\"android\"]);\n },\n onKeyboardMoveInteractive: (event: NativeEvent) => {\n \"worklet\";\n\n updateSharedValues(event, [\"android\", \"ios\"]);\n },\n onKeyboardMoveEnd: (event: NativeEvent) => {\n \"worklet\";\n\n updateSharedValues(event, [\"android\"]);\n },\n },\n [],\n );\n const inputLayoutHandler = useFocusedInputLayoutHandler(\n {\n onFocusedInputLayoutChanged: (e) => {\n \"worklet\";\n\n if (e.target !== -1) {\n layout.value = e;\n } else {\n layout.value = null;\n }\n },\n },\n [],\n );\n\n // layout effects\n useLayoutEffect(() => {\n if (enabled) {\n applyMonkeyPatch();\n } else {\n revertMonkeyPatch();\n }\n }, [enabled]);\n\n if (__DEV__) {\n controlEdgeToEdgeValues({\n statusBarTranslucent,\n navigationBarTranslucent,\n preserveEdgeToEdge,\n });\n }\n\n return (\n <KeyboardContext.Provider value={context}>\n <KeyboardControllerViewAnimated\n ref={viewTagRef}\n enabled={enabled}\n navigationBarTranslucent={IS_EDGE_TO_EDGE || navigationBarTranslucent}\n statusBarTranslucent={IS_EDGE_TO_EDGE || statusBarTranslucent}\n preserveEdgeToEdge={IS_EDGE_TO_EDGE || preserveEdgeToEdge}\n style={styles.container}\n // on*Reanimated prop must precede animated handlers to work correctly\n onKeyboardMoveReanimated={keyboardHandler}\n onKeyboardMoveStart={OS === \"ios\" ? onKeyboardMove : undefined}\n onKeyboardMove={OS === \"android\" ? onKeyboardMove : undefined}\n onKeyboardMoveInteractive={onKeyboardMove}\n onKeyboardMoveEnd={OS === \"android\" ? onKeyboardMove : undefined}\n onFocusedInputLayoutChangedReanimated={inputLayoutHandler}\n >\n {children}\n </KeyboardControllerViewAnimated>\n <Animated.View\n // we are using this small hack, because if the component (where\n // animated value has been used) is unmounted, then animation will\n // stop receiving events (seems like it's react-native optimization).\n // So we need to keep a reference to the animated value, to keep it's\n // always mounted (keep a reference to an animated value).\n //\n // To test why it's needed, try to open screen which consumes Animated.Value\n // then close it and open it again (for example 'Animated transition').\n style={style}\n />\n </KeyboardContext.Provider>\n );\n};\n"],"mappings":"AAAA;AACA,OAAOA,KAAK,IAAIC,eAAe,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AACzE,SAASC,QAAQ,EAAEC,QAAQ,EAAEC,UAAU,QAAQ,cAAc;AAC7D,SACEC,uBAAuB,EACvBC,YAAY,QACP,8BAA8B;AACrC,OAAOC,UAAU,IAAIC,cAAc,QAAQ,yBAAyB;AAEpE,SAASC,sBAAsB,QAAQ,YAAY;AACnD,SAASC,eAAe,QAAQ,WAAW;AAC3C,SAASC,qBAAqB,EAAEC,iBAAiB,QAAQ,kBAAkB;AAC3E,SAASC,gBAAgB,EAAEC,2BAA2B,QAAQ,YAAY;AAC1E,SAASC,gBAAgB,EAAEC,iBAAiB,QAAQ,gBAAgB;AACpE,SACEC,0BAA0B,EAC1BC,4BAA4B,QACvB,cAAc;AAYrB,MAAMC,eAAe,GAAGb,YAAY,CAAC,CAAC;AAEtC,MAAMc,8BAA8B,GAAGb,UAAU,CAACc,uBAAuB,CACvEnB,QAAQ,CAACmB,uBAAuB,CAACZ,sBAAsB,CACzD,CAAC;AAOD,MAAMa,MAAM,GAAGlB,UAAU,CAACmB,MAAM,CAAS;EACvCC,SAAS,EAAE;IACTC,IAAI,EAAE;EACR,CAAC;EACDC,MAAM,EAAE;IACNC,OAAO,EAAE,MAAM;IACfC,QAAQ,EAAE;EACZ;AACF,CAAC,CAAC;AAuCF;AACA;AACA,MAAMC,EAAE,GAAG1B,QAAQ,CAAC0B,EAAE;;AAEtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,GAAIC,KAA4B,IAAK;EAChE,MAAM;IACJC,QAAQ;IACRC,oBAAo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,CAAC;AAE/B,CAAC","ignoreList":[]}
@@ -8,6 +8,15 @@ export const KeyboardControllerNative = {
8
8
  addListener: NOOP,
9
9
  removeListeners: NOOP
10
10
  };
11
+ /**
12
+ * An event emitter that provides a way to subscribe to next keyboard events:
13
+ * - `keyboardWillShow`;
14
+ * - `keyboardDidShow`;
15
+ * - `keyboardWillHide`;
16
+ * - `keyboardDidHide`.
17
+ *
18
+ * Use `addListener` function to add your event listener for a specific keyboard event.
19
+ */
11
20
  export const KeyboardEvents = {
12
21
  addListener: () => ({
13
22
  remove: NOOP
@@ -27,7 +36,17 @@ export const WindowDimensionsEvents = {
27
36
  remove: NOOP
28
37
  })
29
38
  };
39
+ /**
40
+ * A view that sends events whenever keyboard or focused events are happening.
41
+ *
42
+ * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller-view|Documentation} page for more details.
43
+ */
30
44
  export const KeyboardControllerView = View;
45
+ /**
46
+ * A view that defines a region on the screen, where gestures will control the keyboard position.
47
+ *
48
+ * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-gesture-area|Documentation} page for more details.
49
+ */
31
50
  export const KeyboardGestureArea = View;
32
51
  export const RCTOverKeyboardView = View;
33
52
  //# sourceMappingURL=bindings.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["View","NOOP","KeyboardControllerNative","setDefaultMode","setInputMode","dismiss","setFocusTo","addListener","removeListeners","KeyboardEvents","remove","FocusedInputEvents","WindowDimensionsEvents","KeyboardControllerView","KeyboardGestureArea","RCTOverKeyboardView"],"sources":["bindings.ts"],"sourcesContent":["import { View } from \"react-native\";\n\nimport type {\n FocusedInputEventsModule,\n KeyboardControllerNativeModule,\n KeyboardControllerProps,\n KeyboardEventsModule,\n KeyboardGestureAreaProps,\n OverKeyboardViewProps,\n WindowDimensionsEventsModule,\n} from \"./types\";\nimport type { EmitterSubscription } from \"react-native\";\n\nconst NOOP = () => {};\n\nexport const KeyboardControllerNative: KeyboardControllerNativeModule = {\n setDefaultMode: NOOP,\n setInputMode: NOOP,\n dismiss: NOOP,\n setFocusTo: NOOP,\n addListener: NOOP,\n removeListeners: NOOP,\n};\nexport const KeyboardEvents: KeyboardEventsModule = {\n addListener: () => ({ remove: NOOP } as EmitterSubscription),\n};\n/**\n * This API is not documented, it's for internal usage only (for now), and is a subject to potential breaking changes in future.\n * Use it with cautious.\n */\nexport const FocusedInputEvents: FocusedInputEventsModule = {\n addListener: () => ({ remove: NOOP } as EmitterSubscription),\n};\nexport const WindowDimensionsEvents: WindowDimensionsEventsModule = {\n addListener: () => ({ remove: NOOP } as EmitterSubscription),\n};\nexport const KeyboardControllerView =\n View as unknown as React.FC<KeyboardControllerProps>;\nexport const KeyboardGestureArea =\n View as unknown as React.FC<KeyboardGestureAreaProps>;\nexport const RCTOverKeyboardView =\n View as unknown as React.FC<OverKeyboardViewProps>;\n"],"mappings":"AAAA,SAASA,IAAI,QAAQ,cAAc;AAanC,MAAMC,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AAErB,OAAO,MAAMC,wBAAwD,GAAG;EACtEC,cAAc,EAAEF,IAAI;EACpBG,YAAY,EAAEH,IAAI;EAClBI,OAAO,EAAEJ,IAAI;EACbK,UAAU,EAAEL,IAAI;EAChBM,WAAW,EAAEN,IAAI;EACjBO,eAAe,EAAEP;AACnB,CAAC;AACD,OAAO,MAAMQ,cAAoC,GAAG;EAClDF,WAAW,EAAEA,CAAA,MAAO;IAAEG,MAAM,EAAET;EAAK,CAAC;AACtC,CAAC;AACD;AACA;AACA;AACA;AACA,OAAO,MAAMU,kBAA4C,GAAG;EAC1DJ,WAAW,EAAEA,CAAA,MAAO;IAAEG,MAAM,EAAET;EAAK,CAAC;AACtC,CAAC;AACD,OAAO,MAAMW,sBAAoD,GAAG;EAClEL,WAAW,EAAEA,CAAA,MAAO;IAAEG,MAAM,EAAET;EAAK,CAAC;AACtC,CAAC;AACD,OAAO,MAAMY,sBAAsB,GACjCb,IAAoD;AACtD,OAAO,MAAMc,mBAAmB,GAC9Bd,IAAqD;AACvD,OAAO,MAAMe,mBAAmB,GAC9Bf,IAAkD","ignoreList":[]}
1
+ {"version":3,"names":["View","NOOP","KeyboardControllerNative","setDefaultMode","setInputMode","dismiss","setFocusTo","addListener","removeListeners","KeyboardEvents","remove","FocusedInputEvents","WindowDimensionsEvents","KeyboardControllerView","KeyboardGestureArea","RCTOverKeyboardView"],"sources":["bindings.ts"],"sourcesContent":["import { View } from \"react-native\";\n\nimport type {\n FocusedInputEventsModule,\n KeyboardControllerNativeModule,\n KeyboardControllerProps,\n KeyboardEventsModule,\n KeyboardGestureAreaProps,\n OverKeyboardViewProps,\n WindowDimensionsEventsModule,\n} from \"./types\";\nimport type { EmitterSubscription } from \"react-native\";\n\nconst NOOP = () => {};\n\nexport const KeyboardControllerNative: KeyboardControllerNativeModule = {\n setDefaultMode: NOOP,\n setInputMode: NOOP,\n dismiss: NOOP,\n setFocusTo: NOOP,\n addListener: NOOP,\n removeListeners: NOOP,\n};\n/**\n * An event emitter that provides a way to subscribe to next keyboard events:\n * - `keyboardWillShow`;\n * - `keyboardDidShow`;\n * - `keyboardWillHide`;\n * - `keyboardDidHide`.\n *\n * Use `addListener` function to add your event listener for a specific keyboard event.\n */\nexport const KeyboardEvents: KeyboardEventsModule = {\n addListener: () => ({ remove: NOOP } as EmitterSubscription),\n};\n/**\n * This API is not documented, it's for internal usage only (for now), and is a subject to potential breaking changes in future.\n * Use it with cautious.\n */\nexport const FocusedInputEvents: FocusedInputEventsModule = {\n addListener: () => ({ remove: NOOP } as EmitterSubscription),\n};\nexport const WindowDimensionsEvents: WindowDimensionsEventsModule = {\n addListener: () => ({ remove: NOOP } as EmitterSubscription),\n};\n/**\n * A view that sends events whenever keyboard or focused events are happening.\n *\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller-view|Documentation} page for more details.\n */\nexport const KeyboardControllerView =\n View as unknown as React.FC<KeyboardControllerProps>;\n/**\n * A view that defines a region on the screen, where gestures will control the keyboard position.\n *\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-gesture-area|Documentation} page for more details.\n */\nexport const KeyboardGestureArea =\n View as unknown as React.FC<KeyboardGestureAreaProps>;\nexport const RCTOverKeyboardView =\n View as unknown as React.FC<OverKeyboardViewProps>;\n"],"mappings":"AAAA,SAASA,IAAI,QAAQ,cAAc;AAanC,MAAMC,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AAErB,OAAO,MAAMC,wBAAwD,GAAG;EACtEC,cAAc,EAAEF,IAAI;EACpBG,YAAY,EAAEH,IAAI;EAClBI,OAAO,EAAEJ,IAAI;EACbK,UAAU,EAAEL,IAAI;EAChBM,WAAW,EAAEN,IAAI;EACjBO,eAAe,EAAEP;AACnB,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMQ,cAAoC,GAAG;EAClDF,WAAW,EAAEA,CAAA,MAAO;IAAEG,MAAM,EAAET;EAAK,CAAC;AACtC,CAAC;AACD;AACA;AACA;AACA;AACA,OAAO,MAAMU,kBAA4C,GAAG;EAC1DJ,WAAW,EAAEA,CAAA,MAAO;IAAEG,MAAM,EAAET;EAAK,CAAC;AACtC,CAAC;AACD,OAAO,MAAMW,sBAAoD,GAAG;EAClEL,WAAW,EAAEA,CAAA,MAAO;IAAEG,MAAM,EAAET;EAAK,CAAC;AACtC,CAAC;AACD;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMY,sBAAsB,GACjCb,IAAoD;AACtD;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMc,mBAAmB,GAC9Bd,IAAqD;AACvD,OAAO,MAAMe,mBAAmB,GAC9Bf,IAAkD","ignoreList":[]}
@@ -12,8 +12,17 @@ const defaultLayout = {
12
12
  };
13
13
 
14
14
  /**
15
- * View that moves out of the way when the keyboard appears by automatically
16
- * adjusting its height, position, or bottom padding.
15
+ * A View component that automatically adjusts its height, position, or bottom padding
16
+ * when the keyboard appears to ensure that the content remains visible.
17
+ *
18
+ * @returns A View component that adjusts to keyboard visibility.
19
+ * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/components/keyboard-avoiding-view|Documentation} page for more details.
20
+ * @example
21
+ * ```tsx
22
+ * <KeyboardAvoidingView behavior="padding">
23
+ * <TextInput />
24
+ * </KeyboardAvoidingView>
25
+ * ```
17
26
  */
18
27
  const KeyboardAvoidingView = /*#__PURE__*/forwardRef(({
19
28
  behavior,
@@ -1 +1 @@
1
- {"version":3,"names":["React","forwardRef","useCallback","useMemo","View","Reanimated","interpolate","runOnUI","useAnimatedStyle","useDerivedValue","useSharedValue","useWindowDimensions","useKeyboardAnimation","useTranslateAnimation","defaultLayout","x","y","width","height","KeyboardAvoidingView","behavior","children","contentContainerStyle","enabled","keyboardVerticalOffset","style","onLayout","onLayoutProps","props","ref","initialFrame","frame","value","translate","padding","keyboard","screenHeight","relativeKeyboardHeight","keyboardY","heightWhenOpened","Math","max","interpolateToRelativeKeyboardHeight","onLayoutWorklet","layout","isClosed","e","nativeEvent","animatedStyle","bottom","progress","translateY","paddingBottom","bottomHeight","flex","paddingTop","transform","isPositionBehavior","containerStyle","combinedStyles","createElement","_extends"],"sources":["index.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useMemo } from \"react\";\nimport { View } from \"react-native\";\nimport Reanimated, {\n interpolate,\n runOnUI,\n useAnimatedStyle,\n useDerivedValue,\n useSharedValue,\n} from \"react-native-reanimated\";\n\nimport { useWindowDimensions } from \"../../hooks\";\n\nimport { useKeyboardAnimation, useTranslateAnimation } from \"./hooks\";\n\nimport type { LayoutRectangle, ViewProps } from \"react-native\";\n\nexport type KeyboardAvoidingViewBaseProps = {\n /**\n * Controls whether this `KeyboardAvoidingView` instance should take effect.\n * This is useful when more than one is on the screen. Defaults to true.\n */\n enabled?: boolean;\n\n /**\n * Distance between the top of the user screen and the React Native view. This\n * may be non-zero in some cases. Defaults to 0.\n */\n keyboardVerticalOffset?: number;\n} & ViewProps;\n\nexport type KeyboardAvoidingViewProps = KeyboardAvoidingViewBaseProps &\n (\n | {\n /**\n * Specify how to react to the presence of the keyboard.\n */\n behavior?: \"position\";\n\n /**\n * Style of the content container when `behavior` is 'position'.\n */\n contentContainerStyle?: ViewProps[\"style\"];\n }\n | {\n /**\n * Specify how to react to the presence of the keyboard.\n */\n behavior?: \"height\" | \"padding\" | \"translate-with-padding\";\n\n /**\n * `contentContainerStyle` is not allowed for these behaviors.\n */\n contentContainerStyle?: never;\n }\n );\n\nconst defaultLayout: LayoutRectangle = {\n x: 0,\n y: 0,\n width: 0,\n height: 0,\n};\n\n/**\n * View that moves out of the way when the keyboard appears by automatically\n * adjusting its height, position, or bottom padding.\n */\nconst KeyboardAvoidingView = forwardRef<\n View,\n React.PropsWithChildren<KeyboardAvoidingViewProps>\n>(\n (\n {\n behavior,\n children,\n contentContainerStyle,\n enabled = true,\n keyboardVerticalOffset = 0,\n style,\n onLayout: onLayoutProps,\n ...props\n },\n ref,\n ) => {\n const initialFrame = useSharedValue<LayoutRectangle | null>(null);\n const frame = useDerivedValue(() => initialFrame.value || defaultLayout);\n\n const { translate, padding } = useTranslateAnimation();\n const keyboard = useKeyboardAnimation();\n const { height: screenHeight } = useWindowDimensions();\n\n const relativeKeyboardHeight = useCallback(() => {\n \"worklet\";\n\n const keyboardY =\n screenHeight - keyboard.heightWhenOpened.value - keyboardVerticalOffset;\n\n return Math.max(frame.value.y + frame.value.height - keyboardY, 0);\n }, [screenHeight, keyboardVerticalOffset]);\n const interpolateToRelativeKeyboardHeight = useCallback(\n (value: number) => {\n \"worklet\";\n\n return interpolate(value, [0, 1], [0, relativeKeyboardHeight()]);\n },\n [relativeKeyboardHeight],\n );\n\n const onLayoutWorklet = useCallback(\n (layout: LayoutRectangle) => {\n \"worklet\";\n\n if (\n keyboard.isClosed.value ||\n initialFrame.value === null ||\n behavior !== \"height\"\n ) {\n // eslint-disable-next-line react-compiler/react-compiler\n initialFrame.value = layout;\n }\n },\n [behavior],\n );\n const onLayout = useCallback<NonNullable<ViewProps[\"onLayout\"]>>(\n (e) => {\n runOnUI(onLayoutWorklet)(e.nativeEvent.layout);\n onLayoutProps?.(e);\n },\n [onLayoutProps],\n );\n\n const animatedStyle = useAnimatedStyle(() => {\n const bottom = interpolateToRelativeKeyboardHeight(\n keyboard.progress.value,\n );\n const translateY = interpolateToRelativeKeyboardHeight(translate.value);\n const paddingBottom = interpolateToRelativeKeyboardHeight(padding.value);\n const bottomHeight = enabled ? bottom : 0;\n\n switch (behavior) {\n case \"height\":\n if (!keyboard.isClosed.value) {\n return {\n height: frame.value.height - bottomHeight,\n flex: 0,\n };\n }\n\n return {};\n\n case \"position\":\n return { bottom: bottomHeight };\n\n case \"padding\":\n return { paddingBottom: bottomHeight };\n\n case \"translate-with-padding\":\n return {\n paddingTop: paddingBottom,\n transform: [{ translateY: -translateY }],\n };\n\n default:\n return {};\n }\n }, [behavior, enabled, interpolateToRelativeKeyboardHeight]);\n const isPositionBehavior = behavior === \"position\";\n const containerStyle = isPositionBehavior ? contentContainerStyle : style;\n const combinedStyles = useMemo(\n () => [containerStyle, animatedStyle],\n [containerStyle, animatedStyle],\n );\n\n if (isPositionBehavior) {\n return (\n <View ref={ref} style={style} onLayout={onLayout} {...props}>\n <Reanimated.View style={combinedStyles}>{children}</Reanimated.View>\n </View>\n );\n }\n\n return (\n <Reanimated.View\n ref={ref}\n style={combinedStyles}\n onLayout={onLayout}\n {...props}\n >\n {children}\n </Reanimated.View>\n );\n },\n);\n\nexport default KeyboardAvoidingView;\n"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,UAAU,EAAEC,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAC/D,SAASC,IAAI,QAAQ,cAAc;AACnC,OAAOC,UAAU,IACfC,WAAW,EACXC,OAAO,EACPC,gBAAgB,EAChBC,eAAe,EACfC,cAAc,QACT,yBAAyB;AAEhC,SAASC,mBAAmB,QAAQ,aAAa;AAEjD,SAASC,oBAAo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CAAC;MAEjC,KAAK,SAAS;QACZ,OAAO;UAAED,aAAa,EAAEC;QAAa,CAAC;MAExC,KAAK,wBAAwB;QAC3B,OAAO;UACLE,UAAU,EAAEH,aAAa;UACzBI,SAAS,EAAE,CAAC;YAAEL,UAAU,EAAE,CAACA;UAAW,CAAC;QACzC,CAAC;MAEH;QACE,OAAO,CAAC,CAAC;IACb;EACF,CAAC,EAAE,CAAC/B,QAAQ,EAAEG,OAAO,EAAEmB,mCAAmC,CAAC,CAAC;EAC5D,MAAMe,kBAAkB,GAAGrC,QAAQ,KAAK,UAAU;EAClD,MAAMsC,cAAc,GAAGD,kBAAkB,GAAGnC,qBAAqB,GAAGG,KAAK;EACzE,MAAMkC,cAAc,GAAGxD,OAAO,CAC5B,MAAM,CAACuD,cAAc,EAAEV,aAAa,CAAC,EACrC,CAACU,cAAc,EAAEV,aAAa,CAChC,CAAC;EAED,IAAIS,kBAAkB,EAAE;IACtB,oBACEzD,KAAA,CAAA4D,aAAA,CAACxD,IAAI,EAAAyD,QAAA;MAAChC,GAAG,EAAEA,GAAI;MAACJ,KAAK,EAAEA,KAAM;MAACC,QAAQ,EAAEA;IAAS,GAAKE,KAAK,gBACzD5B,KAAA,CAAA4D,aAAA,CAACvD,UAAU,CAACD,IAAI;MAACqB,KAAK,EAAEkC;IAAe,GAAEtC,QAA0B,CAC/D,CAAC;EAEX;EAEA,oBACErB,KAAA,CAAA4D,aAAA,CAACvD,UAAU,CAACD,IAAI,EAAAyD,QAAA;IACdhC,GAAG,EAAEA,GAAI;IACTJ,KAAK,EAAEkC,cAAe;IACtBjC,QAAQ,EAAEA;EAAS,GACfE,KAAK,GAERP,QACc,CAAC;AAEtB,CACF,CAAC;AAED,eAAeF,oBAAoB","ignoreList":[]}
1
+ {"version":3,"names":["React","forwardRef","useCallback","useMemo","View","Reanimated","interpolate","runOnUI","useAnimatedStyle","useDerivedValue","useSharedValue","useWindowDimensions","useKeyboardAnimation","useTranslateAnimation","defaultLayout","x","y","width","height","KeyboardAvoidingView","behavior","children","contentContainerStyle","enabled","keyboardVerticalOffset","style","onLayout","onLayoutProps","props","ref","initialFrame","frame","value","translate","padding","keyboard","screenHeight","relativeKeyboardHeight","keyboardY","heightWhenOpened","Math","max","interpolateToRelativeKeyboardHeight","onLayoutWorklet","layout","isClosed","e","nativeEvent","animatedStyle","bottom","progress","translateY","paddingBottom","bottomHeight","flex","paddingTop","transform","isPositionBehavior","containerStyle","combinedStyles","createElement","_extends"],"sources":["index.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useMemo } from \"react\";\nimport { View } from \"react-native\";\nimport Reanimated, {\n interpolate,\n runOnUI,\n useAnimatedStyle,\n useDerivedValue,\n useSharedValue,\n} from \"react-native-reanimated\";\n\nimport { useWindowDimensions } from \"../../hooks\";\n\nimport { useKeyboardAnimation, useTranslateAnimation } from \"./hooks\";\n\nimport type { LayoutRectangle, ViewProps } from \"react-native\";\n\nexport type KeyboardAvoidingViewBaseProps = {\n /**\n * Controls whether this `KeyboardAvoidingView` instance should take effect.\n * This is useful when more than one is on the screen. Defaults to true.\n */\n enabled?: boolean;\n\n /**\n * Distance between the top of the user screen and the React Native view. This\n * may be non-zero in some cases. Defaults to 0.\n */\n keyboardVerticalOffset?: number;\n} & ViewProps;\n\nexport type KeyboardAvoidingViewProps = KeyboardAvoidingViewBaseProps &\n (\n | {\n /**\n * Specify how to react to the presence of the keyboard.\n */\n behavior?: \"position\";\n\n /**\n * Style of the content container when `behavior` is 'position'.\n */\n contentContainerStyle?: ViewProps[\"style\"];\n }\n | {\n /**\n * Specify how to react to the presence of the keyboard.\n */\n behavior?: \"height\" | \"padding\" | \"translate-with-padding\";\n\n /**\n * `contentContainerStyle` is not allowed for these behaviors.\n */\n contentContainerStyle?: never;\n }\n );\n\nconst defaultLayout: LayoutRectangle = {\n x: 0,\n y: 0,\n width: 0,\n height: 0,\n};\n\n/**\n * A View component that automatically adjusts its height, position, or bottom padding\n * when the keyboard appears to ensure that the content remains visible.\n *\n * @returns A View component that adjusts to keyboard visibility.\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/components/keyboard-avoiding-view|Documentation} page for more details.\n * @example\n * ```tsx\n * <KeyboardAvoidingView behavior=\"padding\">\n * <TextInput />\n * </KeyboardAvoidingView>\n * ```\n */\nconst KeyboardAvoidingView = forwardRef<\n View,\n React.PropsWithChildren<KeyboardAvoidingViewProps>\n>(\n (\n {\n behavior,\n children,\n contentContainerStyle,\n enabled = true,\n keyboardVerticalOffset = 0,\n style,\n onLayout: onLayoutProps,\n ...props\n },\n ref,\n ) => {\n const initialFrame = useSharedValue<LayoutRectangle | null>(null);\n const frame = useDerivedValue(() => initialFrame.value || defaultLayout);\n\n const { translate, padding } = useTranslateAnimation();\n const keyboard = useKeyboardAnimation();\n const { height: screenHeight } = useWindowDimensions();\n\n const relativeKeyboardHeight = useCallback(() => {\n \"worklet\";\n\n const keyboardY =\n screenHeight - keyboard.heightWhenOpened.value - keyboardVerticalOffset;\n\n return Math.max(frame.value.y + frame.value.height - keyboardY, 0);\n }, [screenHeight, keyboardVerticalOffset]);\n const interpolateToRelativeKeyboardHeight = useCallback(\n (value: number) => {\n \"worklet\";\n\n return interpolate(value, [0, 1], [0, relativeKeyboardHeight()]);\n },\n [relativeKeyboardHeight],\n );\n\n const onLayoutWorklet = useCallback(\n (layout: LayoutRectangle) => {\n \"worklet\";\n\n if (\n keyboard.isClosed.value ||\n initialFrame.value === null ||\n behavior !== \"height\"\n ) {\n // eslint-disable-next-line react-compiler/react-compiler\n initialFrame.value = layout;\n }\n },\n [behavior],\n );\n const onLayout = useCallback<NonNullable<ViewProps[\"onLayout\"]>>(\n (e) => {\n runOnUI(onLayoutWorklet)(e.nativeEvent.layout);\n onLayoutProps?.(e);\n },\n [onLayoutProps],\n );\n\n const animatedStyle = useAnimatedStyle(() => {\n const bottom = interpolateToRelativeKeyboardHeight(\n keyboard.progress.value,\n );\n const translateY = interpolateToRelativeKeyboardHeight(translate.value);\n const paddingBottom = interpolateToRelativeKeyboardHeight(padding.value);\n const bottomHeight = enabled ? bottom : 0;\n\n switch (behavior) {\n case \"height\":\n if (!keyboard.isClosed.value) {\n return {\n height: frame.value.height - bottomHeight,\n flex: 0,\n };\n }\n\n return {};\n\n case \"position\":\n return { bottom: bottomHeight };\n\n case \"padding\":\n return { paddingBottom: bottomHeight };\n\n case \"translate-with-padding\":\n return {\n paddingTop: paddingBottom,\n transform: [{ translateY: -translateY }],\n };\n\n default:\n return {};\n }\n }, [behavior, enabled, interpolateToRelativeKeyboardHeight]);\n const isPositionBehavior = behavior === \"position\";\n const containerStyle = isPositionBehavior ? contentContainerStyle : style;\n const combinedStyles = useMemo(\n () => [containerStyle, animatedStyle],\n [containerStyle, animatedStyle],\n );\n\n if (isPositionBehavior) {\n return (\n <View ref={ref} style={style} onLayout={onLayout} {...props}>\n <Reanimated.View style={combinedStyles}>{children}</Reanimated.View>\n </View>\n );\n }\n\n return (\n <Reanimated.View\n ref={ref}\n style={combinedStyles}\n onLayout={onLayout}\n {...props}\n >\n {children}\n </Reanimated.View>\n );\n },\n);\n\nexport default KeyboardAvoidingView;\n"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,UAAU,EAAEC,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAC/D,SAASC,IAAI,QAAQ,cAAc;AACnC,OAAOC,UAAU,IACfC,WAAW,EACXC,OAAO,EACPC,gBAAgB,EAChBC,eAAe,EACfC,cAAc,QACT,yBAAyB;AAEhC,SAASC,mBAAmB,QAAQ,aAAa;AAEjD,SAASC,oBAAoB,EAAEC,qBAAqB,QAAQ,SAAS;AA4CrE,MAAMC,aAA8B,GAAG;EACrCC,CAAC,EAAE,CAAC;EACJC,CAAC,EAAE,CAAC;EACJC,KAAK,EAAE,CAAC;EACRC,MAAM,EAAE;AACV,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,oBAAoB,gBAAGlB,UAAU,CAIrC,C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