react-native-keyboard-controller 1.17.1 → 1.17.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/README.md +24 -23
  2. package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/ThemedReactContext.kt +20 -0
  3. package/android/src/main/java/com/reactnativekeyboardcontroller/listeners/KeyboardAnimationCallback.kt +4 -0
  4. package/ios/KeyboardControllerModule.mm +2 -0
  5. package/ios/views/KeyboardControllerView.mm +18 -0
  6. package/ios/views/KeyboardControllerViewManager.swift +19 -0
  7. package/lib/commonjs/animated.js +23 -7
  8. package/lib/commonjs/animated.js.map +1 -1
  9. package/lib/commonjs/bindings.js +19 -0
  10. package/lib/commonjs/bindings.js.map +1 -1
  11. package/lib/commonjs/components/KeyboardAvoidingView/index.js +14 -4
  12. package/lib/commonjs/components/KeyboardAvoidingView/index.js.map +1 -1
  13. package/lib/commonjs/components/KeyboardAwareScrollView/index.js +54 -36
  14. package/lib/commonjs/components/KeyboardAwareScrollView/index.js.map +1 -1
  15. package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +17 -1
  16. package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -1
  17. package/lib/commonjs/components/KeyboardStickyView/index.js +13 -0
  18. package/lib/commonjs/components/KeyboardStickyView/index.js.map +1 -1
  19. package/lib/commonjs/components/KeyboardToolbar/index.js +31 -22
  20. package/lib/commonjs/components/KeyboardToolbar/index.js.map +1 -1
  21. package/lib/commonjs/context.js +16 -0
  22. package/lib/commonjs/context.js.map +1 -1
  23. package/lib/commonjs/hooks/index.js +164 -0
  24. package/lib/commonjs/hooks/index.js.map +1 -1
  25. package/lib/commonjs/hooks/useKeyboardState/index.js +21 -0
  26. package/lib/commonjs/hooks/useKeyboardState/index.js.map +1 -1
  27. package/lib/commonjs/hooks/useWindowDimensions/index.js +29 -6
  28. package/lib/commonjs/hooks/useWindowDimensions/index.js.map +1 -1
  29. package/lib/commonjs/internal.js +21 -0
  30. package/lib/commonjs/internal.js.map +1 -1
  31. package/lib/commonjs/module.js +4 -0
  32. package/lib/commonjs/module.js.map +1 -1
  33. package/lib/commonjs/monkey-patch.android.js +0 -5
  34. package/lib/commonjs/monkey-patch.android.js.map +1 -1
  35. package/lib/commonjs/{types.js → types/hooks.js} +1 -1
  36. package/lib/commonjs/types/hooks.js.map +1 -0
  37. package/lib/commonjs/types/index.js +50 -0
  38. package/lib/commonjs/types/index.js.map +1 -0
  39. package/lib/commonjs/types/internal.js +6 -0
  40. package/lib/commonjs/types/internal.js.map +1 -0
  41. package/lib/commonjs/types/module.js +6 -0
  42. package/lib/commonjs/types/module.js.map +1 -0
  43. package/lib/commonjs/types/views.js +6 -0
  44. package/lib/commonjs/types/views.js.map +1 -0
  45. package/lib/commonjs/views/OverKeyboardView/index.js +18 -4
  46. package/lib/commonjs/views/OverKeyboardView/index.js.map +1 -1
  47. package/lib/module/animated.js +23 -7
  48. package/lib/module/animated.js.map +1 -1
  49. package/lib/module/bindings.js +19 -0
  50. package/lib/module/bindings.js.map +1 -1
  51. package/lib/module/components/KeyboardAvoidingView/index.js +14 -4
  52. package/lib/module/components/KeyboardAvoidingView/index.js.map +1 -1
  53. package/lib/module/components/KeyboardAwareScrollView/index.js +56 -38
  54. package/lib/module/components/KeyboardAwareScrollView/index.js.map +1 -1
  55. package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +17 -1
  56. package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -1
  57. package/lib/module/components/KeyboardStickyView/index.js +13 -0
  58. package/lib/module/components/KeyboardStickyView/index.js.map +1 -1
  59. package/lib/module/components/KeyboardToolbar/index.js +31 -22
  60. package/lib/module/components/KeyboardToolbar/index.js.map +1 -1
  61. package/lib/module/context.js +16 -0
  62. package/lib/module/context.js.map +1 -1
  63. package/lib/module/hooks/index.js +164 -0
  64. package/lib/module/hooks/index.js.map +1 -1
  65. package/lib/module/hooks/useKeyboardState/index.js +21 -0
  66. package/lib/module/hooks/useKeyboardState/index.js.map +1 -1
  67. package/lib/module/hooks/useWindowDimensions/index.js +28 -1
  68. package/lib/module/hooks/useWindowDimensions/index.js.map +1 -1
  69. package/lib/module/internal.js +21 -0
  70. package/lib/module/internal.js.map +1 -1
  71. package/lib/module/module.js +4 -0
  72. package/lib/module/module.js.map +1 -1
  73. package/lib/module/monkey-patch.android.js +0 -5
  74. package/lib/module/monkey-patch.android.js.map +1 -1
  75. package/lib/module/types/hooks.js +2 -0
  76. package/lib/module/types/hooks.js.map +1 -0
  77. package/lib/module/types/index.js +5 -0
  78. package/lib/module/types/index.js.map +1 -0
  79. package/lib/module/types/internal.js +2 -0
  80. package/lib/module/types/internal.js.map +1 -0
  81. package/lib/module/types/module.js +2 -0
  82. package/lib/module/types/module.js.map +1 -0
  83. package/lib/module/types/views.js +2 -0
  84. package/lib/module/types/views.js.map +1 -0
  85. package/lib/module/views/OverKeyboardView/index.js +18 -4
  86. package/lib/module/views/OverKeyboardView/index.js.map +1 -1
  87. package/lib/typescript/animated.d.ts +20 -6
  88. package/lib/typescript/bindings.d.ts +19 -0
  89. package/lib/typescript/components/KeyboardAvoidingView/index.d.ts +11 -2
  90. package/lib/typescript/components/KeyboardAwareScrollView/index.d.ts +23 -6
  91. package/lib/typescript/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.d.ts +17 -1
  92. package/lib/typescript/components/KeyboardStickyView/index.d.ts +15 -2
  93. package/lib/typescript/components/KeyboardToolbar/index.d.ts +13 -2
  94. package/lib/typescript/context.d.ts +32 -0
  95. package/lib/typescript/hooks/index.d.ts +157 -0
  96. package/lib/typescript/hooks/useKeyboardState/index.d.ts +20 -0
  97. package/lib/typescript/hooks/useWindowDimensions/index.d.ts +2 -1
  98. package/lib/typescript/internal.d.ts +21 -0
  99. package/lib/typescript/module.d.ts +3 -0
  100. package/lib/typescript/{types.d.ts → types/hooks.d.ts} +72 -78
  101. package/lib/typescript/types/index.d.ts +4 -0
  102. package/lib/typescript/types/internal.d.ts +17 -0
  103. package/lib/typescript/types/module.d.ts +91 -0
  104. package/lib/typescript/types/views.d.ts +45 -0
  105. package/lib/typescript/views/OverKeyboardView/index.d.ts +14 -1
  106. package/package.json +2 -1
  107. package/src/animated.tsx +27 -12
  108. package/src/bindings.ts +19 -0
  109. package/src/components/KeyboardAvoidingView/index.tsx +14 -4
  110. package/src/components/KeyboardAwareScrollView/index.tsx +60 -40
  111. package/src/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.ts +17 -1
  112. package/src/components/KeyboardStickyView/index.tsx +14 -1
  113. package/src/components/KeyboardToolbar/index.tsx +31 -19
  114. package/src/context.ts +33 -0
  115. package/src/hooks/index.ts +157 -0
  116. package/src/hooks/useKeyboardState/index.ts +20 -0
  117. package/src/hooks/useWindowDimensions/index.ts +41 -1
  118. package/src/internal.ts +21 -0
  119. package/src/module.ts +3 -0
  120. package/src/monkey-patch.android.ts +3 -6
  121. package/src/{types.ts → types/hooks.ts} +72 -105
  122. package/src/types/index.ts +4 -0
  123. package/src/types/internal.ts +24 -0
  124. package/src/types/module.ts +105 -0
  125. package/src/types/views.ts +46 -0
  126. package/src/views/OverKeyboardView/index.tsx +15 -4
  127. package/lib/commonjs/hooks/useWindowDimensions/index.android.js +0 -34
  128. package/lib/commonjs/hooks/useWindowDimensions/index.android.js.map +0 -1
  129. package/lib/commonjs/types.js.map +0 -1
  130. package/lib/module/hooks/useWindowDimensions/index.android.js +0 -27
  131. package/lib/module/hooks/useWindowDimensions/index.android.js.map +0 -1
  132. package/lib/module/types.js +0 -2
  133. package/lib/module/types.js.map +0 -1
  134. package/lib/typescript/hooks/useWindowDimensions/index.android.d.ts +0 -2
  135. package/src/hooks/useWindowDimensions/index.android.ts +0 -38
@@ -48,24 +48,100 @@ Object.keys(_useKeyboardState).forEach(function (key) {
48
48
  }
49
49
  });
50
50
  });
51
+ /**
52
+ * Hook that sets the Android soft input mode to adjust resize on mount and
53
+ * restores default mode on unmount. This ensures the keyboard behavior is consistent
54
+ * on all Android versions.
55
+ *
56
+ * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#setinputmode-|Documentation} page for more details.
57
+ * @example
58
+ * ```tsx
59
+ * function MyComponent() {
60
+ * useResizeMode();
61
+ * return <View />;
62
+ * }
63
+ * ```
64
+ */
51
65
  const useResizeMode = () => {
52
66
  (0, _react.useEffect)(() => {
53
67
  _module.KeyboardController.setInputMode(_constants.AndroidSoftInputModes.SOFT_INPUT_ADJUST_RESIZE);
54
68
  return () => _module.KeyboardController.setDefaultMode();
55
69
  }, []);
56
70
  };
71
+
72
+ /**
73
+ * Hook that provides animated (`height`/`progress`) values for tracking keyboard movement.
74
+ * Automatically sets the resize mode for Android.
75
+ *
76
+ * @returns Object {@link AnimatedContext|containing} animated values for keyboard movement.
77
+ * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/hooks/keyboard/use-keyboard-animation|Documentation} page for more details.
78
+ * @example
79
+ * ```tsx
80
+ * function MyComponent() {
81
+ * const { height, progress } = useKeyboardAnimation();
82
+ * return <Animated.View style={{ transform: [{ translateY: height }] }} />;
83
+ * }
84
+ * ```
85
+ */
57
86
  exports.useResizeMode = useResizeMode;
58
87
  const useKeyboardAnimation = () => {
59
88
  useResizeMode();
60
89
  const context = (0, _context.useKeyboardContext)();
61
90
  return context.animated;
62
91
  };
92
+
93
+ /**
94
+ * Hook that provides reanimated (`height`/`progress`) values for tracking keyboard movement.
95
+ * Automatically sets the resize mode for Android.
96
+ *
97
+ * @returns Object {@link ReanimatedContext|containing} reanimated values for keyboard movement.
98
+ * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/hooks/keyboard/use-reanimated-keyboard-animation|Documentation} page for more details.
99
+ * @example
100
+ * ```tsx
101
+ * function MyComponent() {
102
+ * const { height, progress } = useReanimatedKeyboardAnimation();
103
+ * return <Reanimated.View style={{ transform: [{ translateY: height }] }} />;
104
+ * }
105
+ * ```
106
+ */
63
107
  exports.useKeyboardAnimation = useKeyboardAnimation;
64
108
  const useReanimatedKeyboardAnimation = () => {
65
109
  useResizeMode();
66
110
  const context = (0, _context.useKeyboardContext)();
67
111
  return context.reanimated;
68
112
  };
113
+
114
+ /**
115
+ * An alternative to {@link useKeyboardHandler} that doesn't set resize mode on mount. If your
116
+ * app already uses `adjustResize`, then you can use this hook instead of `useKeyboardHandler`.
117
+ *
118
+ * @param handler - Object containing keyboard event handlers.
119
+ * @param [deps] - Dependencies array for the effect.
120
+ * @example
121
+ * ```tsx
122
+ * function MyComponent() {
123
+ * const height = useSharedValue(0);
124
+ * const progress = useSharedValue(0);
125
+ *
126
+ * useGenericKeyboardHandler({
127
+ * onMove: (e) => {
128
+ * "worklet";
129
+ *
130
+ * height.value = e.height;
131
+ * progress.value = e.progress;
132
+ * },
133
+ * onEnd: (e) => {
134
+ * "worklet";
135
+ *
136
+ * height.value = e.height;
137
+ * progress.value = e.progress;
138
+ * },
139
+ * }, []);
140
+ *
141
+ * return <Reanimated.View style={{ height: height }] }} />;
142
+ * }
143
+ * ```
144
+ */
69
145
  exports.useReanimatedKeyboardAnimation = useReanimatedKeyboardAnimation;
70
146
  function useGenericKeyboardHandler(handler, deps) {
71
147
  const context = (0, _context.useKeyboardContext)();
@@ -74,10 +150,66 @@ function useGenericKeyboardHandler(handler, deps) {
74
150
  return () => cleanup();
75
151
  }, deps);
76
152
  }
153
+
154
+ /**
155
+ * Hook that gives an access to each aspect of keyboard movement with workletized `onStart`/`onMove`/`onInteractive`/`onEnd` handlers.
156
+ *
157
+ * @param handler - Object containing keyboard event handlers.
158
+ * @param [deps] - Dependencies array for the effect.
159
+ * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/hooks/keyboard/use-keyboard-handler|Documentation} page for more details.
160
+ * @example
161
+ * ```tsx
162
+ * function MyComponent() {
163
+ * const height = useSharedValue(0);
164
+ * const progress = useSharedValue(0);
165
+ *
166
+ * useKeyboardHandler({
167
+ * onMove: (e) => {
168
+ * "worklet";
169
+ *
170
+ * height.value = e.height;
171
+ * progress.value = e.progress;
172
+ * },
173
+ * onEnd: (e) => {
174
+ * "worklet";
175
+ *
176
+ * height.value = e.height;
177
+ * progress.value = e.progress;
178
+ * },
179
+ * }, []);
180
+ *
181
+ * return <Reanimated.View style={{ height: height }] }} />;
182
+ * }
183
+ * ```
184
+ */
77
185
  function useKeyboardHandler(handler, deps) {
78
186
  useResizeMode();
79
187
  useGenericKeyboardHandler(handler, deps);
80
188
  }
189
+
190
+ /**
191
+ * Hook for controlling keyboard controller module.
192
+ * Allows to disable/enable it and check the actual state (whether it's enabled or not).
193
+ * When disabled it fallbacks to default android keyboard handling and stops tracking all
194
+ * the events that are exposed from this library.
195
+ *
196
+ * @property {Function} setEnabled - Function to enable/disable keyboard handling.
197
+ * @property {boolean} enabled - Current enabled state.
198
+ * @returns Object containing keyboard control functions and state.
199
+ * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/hooks/module/use-keyboard-controller|Documentation} page for more details.
200
+ * @example
201
+ * ```tsx
202
+ * function MyComponent() {
203
+ * const { setEnabled, enabled } = useKeyboardController();
204
+ * return (
205
+ * <Button
206
+ * title={enabled ? 'Disable' : 'Enable'}
207
+ * onPress={() => setEnabled(!enabled)}
208
+ * />
209
+ * );
210
+ * }
211
+ * ```
212
+ */
81
213
  function useKeyboardController() {
82
214
  const context = (0, _context.useKeyboardContext)();
83
215
  return {
@@ -85,12 +217,44 @@ function useKeyboardController() {
85
217
  enabled: context.enabled
86
218
  };
87
219
  }
220
+
221
+ /**
222
+ * Hook that provides access to the layout of the currently focused input.
223
+ *
224
+ * @returns Object containing reanimated values for focused input.
225
+ * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/hooks/input/use-reanimated-focused-input|Documentation} page for more details.
226
+ * @example
227
+ * ```tsx
228
+ * function MyComponent() {
229
+ * const { input } = useReanimatedFocusedInput();
230
+ * return <Reanimated.View style={{ height: input.value?.layout.height }} />;
231
+ * }
232
+ * ```
233
+ */
88
234
  function useReanimatedFocusedInput() {
89
235
  const context = (0, _context.useKeyboardContext)();
90
236
  return {
91
237
  input: context.layout
92
238
  };
93
239
  }
240
+
241
+ /**
242
+ * Hook for handling focused input events, such as changes of selection, text etc.
243
+ *
244
+ * @param handler - Object containing focused input event handlers.
245
+ * @param [deps] - Dependencies array for the effect.
246
+ * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/hooks/input/use-focused-input-handler|Documentation} page for more details.
247
+ * @example
248
+ * ```tsx
249
+ * function MyComponent() {
250
+ * useFocusedInputHandler({
251
+ * onChangeText: (e) => console.log('Text changed:', e.text),
252
+ * onSelectionChange: (e) => console.log('Selection changed:', e.selection)
253
+ * });
254
+ * return <View />;
255
+ * }
256
+ * ```
257
+ */
94
258
  function useFocusedInputHandler(handler, deps) {
95
259
  const context = (0, _context.useKeyboardContext)();
96
260
  (0, _react.useLayoutEffect)(() => {
@@ -1 +1 @@
1
- {"version":3,"names":["_react","require","_constants","_context","_module","_useWindowDimensions","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_useKeyboardState","useResizeMode","useEffect","KeyboardController","setInputMode","AndroidSoftInputModes","SOFT_INPUT_ADJUST_RESIZE","setDefaultMode","useKeyboardAnimation","context","useKeyboardContext","animated","useReanimatedKeyboardAnimation","reanimated","useGenericKeyboardHandler","handler","deps","useLayoutEffect","cleanup","setKeyboardHandlers","useKeyboardHandler","useKeyboardController","setEnabled","enabled","useReanimatedFocusedInput","input","layout","useFocusedInputHandler","setInputHandlers"],"sources":["index.ts"],"sourcesContent":["import { useEffect, useLayoutEffect } from \"react\";\n\nimport { AndroidSoftInputModes } from \"../constants\";\nimport { useKeyboardContext } from \"../context\";\nimport { KeyboardController } from \"../module\";\n\nimport type { AnimatedContext, ReanimatedContext } from \"../context\";\nimport type { FocusedInputHandler, KeyboardHandler } from \"../types\";\nimport type { DependencyList } from \"react\";\n\nexport const useResizeMode = () => {\n useEffect(() => {\n KeyboardController.setInputMode(\n AndroidSoftInputModes.SOFT_INPUT_ADJUST_RESIZE,\n );\n\n return () => KeyboardController.setDefaultMode();\n }, []);\n};\n\nexport const useKeyboardAnimation = (): AnimatedContext => {\n useResizeMode();\n const context = useKeyboardContext();\n\n return context.animated;\n};\n\nexport const useReanimatedKeyboardAnimation = (): ReanimatedContext => {\n useResizeMode();\n const context = useKeyboardContext();\n\n return context.reanimated;\n};\n\nexport function useGenericKeyboardHandler(\n handler: KeyboardHandler,\n deps?: DependencyList,\n) {\n const context = useKeyboardContext();\n\n useLayoutEffect(() => {\n const cleanup = context.setKeyboardHandlers(handler);\n\n return () => cleanup();\n }, deps);\n}\n\nexport function useKeyboardHandler(\n handler: KeyboardHandler,\n deps?: DependencyList,\n) {\n useResizeMode();\n useGenericKeyboardHandler(handler, deps);\n}\n\nexport function useKeyboardController() {\n const context = useKeyboardContext();\n\n return { setEnabled: context.setEnabled, enabled: context.enabled };\n}\n\nexport function useReanimatedFocusedInput() {\n const context = useKeyboardContext();\n\n return { input: context.layout };\n}\n\nexport function useFocusedInputHandler(\n handler: FocusedInputHandler,\n deps?: DependencyList,\n) {\n const context = useKeyboardContext();\n\n useLayoutEffect(() => {\n const cleanup = context.setInputHandlers(handler);\n\n return () => cleanup();\n }, deps);\n}\n\nexport * from \"./useWindowDimensions\";\nexport * from \"./useKeyboardState\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AA4EA,IAAAI,oBAAA,GAAAJ,OAAA;AAAAK,MAAA,CAAAC,IAAA,CAAAF,oBAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,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ACV","ignoreList":[]}
1
+ {"version":3,"names":["_react","require","_constants","_context","_module","_useWindowDimensions","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_useKeyboardState","useResizeMode","useEffect","KeyboardController","setInputMode","AndroidSoftInputModes","SOFT_INPUT_ADJUST_RESIZE","setDefaultMode","useKeyboardAnimation","context","useKeyboardContext","animated","useReanimatedKeyboardAnimation","reanimated","useGenericKeyboardHandler","handler","deps","useLayoutEffect","cleanup","setKeyboardHandlers","useKeyboardHandler","useKeyboardController","setEnabled","enabled","useReanimatedFocusedInput","input","layout","useFocusedInputHandler","setInputHandlers"],"sources":["index.ts"],"sourcesContent":["import { useEffect, useLayoutEffect } from \"react\";\n\nimport { AndroidSoftInputModes } from \"../constants\";\nimport { useKeyboardContext } from \"../context\";\nimport { KeyboardController } from \"../module\";\n\nimport type { AnimatedContext, ReanimatedContext } from \"../context\";\nimport type { FocusedInputHandler, KeyboardHandler } from \"../types\";\nimport type { DependencyList } from \"react\";\n\n/**\n * Hook that sets the Android soft input mode to adjust resize on mount and\n * restores default mode on unmount. This ensures the keyboard behavior is consistent\n * on all Android versions.\n *\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-controller#setinputmode-|Documentation} page for more details.\n * @example\n * ```tsx\n * function MyComponent() {\n * useResizeMode();\n * return <View />;\n * }\n * ```\n */\nexport const useResizeMode = () => {\n useEffect(() => {\n KeyboardController.setInputMode(\n AndroidSoftInputModes.SOFT_INPUT_ADJUST_RESIZE,\n );\n\n return () => KeyboardController.setDefaultMode();\n }, []);\n};\n\n/**\n * Hook that provides animated (`height`/`progress`) values for tracking keyboard movement.\n * Automatically sets the resize mode for Android.\n *\n * @returns Object {@link AnimatedContext|containing} animated values for keyboard movement.\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/hooks/keyboard/use-keyboard-animation|Documentation} page for more details.\n * @example\n * ```tsx\n * function MyComponent() {\n * const { height, progress } = useKeyboardAnimation();\n * return <Animated.View style={{ transform: [{ translateY: height }] }} />;\n * }\n * ```\n */\nexport const useKeyboardAnimation = (): AnimatedContext => {\n useResizeMode();\n const context = useKeyboardContext();\n\n return context.animated;\n};\n\n/**\n * Hook that provides reanimated (`height`/`progress`) values for tracking keyboard movement.\n * Automatically sets the resize mode for Android.\n *\n * @returns Object {@link ReanimatedContext|containing} reanimated values for keyboard movement.\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/hooks/keyboard/use-reanimated-keyboard-animation|Documentation} page for more details.\n * @example\n * ```tsx\n * function MyComponent() {\n * const { height, progress } = useReanimatedKeyboardAnimation();\n * return <Reanimated.View style={{ transform: [{ translateY: height }] }} />;\n * }\n * ```\n */\nexport const useReanimatedKeyboardAnimation = (): ReanimatedContext => {\n useResizeMode();\n const context = useKeyboardContext();\n\n return context.reanimated;\n};\n\n/**\n * An alternative to {@link useKeyboardHandler} that doesn't set resize mode on mount. If your\n * app already uses `adjustResize`, then you can use this hook instead of `useKeyboardHandler`.\n *\n * @param handler - Object containing keyboard event handlers.\n * @param [deps] - Dependencies array for the effect.\n * @example\n * ```tsx\n * function MyComponent() {\n * const height = useSharedValue(0);\n * const progress = useSharedValue(0);\n *\n * useGenericKeyboardHandler({\n * onMove: (e) => {\n * \"worklet\";\n *\n * height.value = e.height;\n * progress.value = e.progress;\n * },\n * onEnd: (e) => {\n * \"worklet\";\n *\n * height.value = e.height;\n * progress.value = e.progress;\n * },\n * }, []);\n *\n * return <Reanimated.View style={{ height: height }] }} />;\n * }\n * ```\n */\nexport function useGenericKeyboardHandler(\n handler: KeyboardHandler,\n deps?: DependencyList,\n) {\n const context = useKeyboardContext();\n\n useLayoutEffect(() => {\n const cleanup = context.setKeyboardHandlers(handler);\n\n return () => cleanup();\n }, deps);\n}\n\n/**\n * Hook that gives an access to each aspect of keyboard movement with workletized `onStart`/`onMove`/`onInteractive`/`onEnd` handlers.\n *\n * @param handler - Object containing keyboard event handlers.\n * @param [deps] - Dependencies array for the effect.\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/hooks/keyboard/use-keyboard-handler|Documentation} page for more details.\n * @example\n * ```tsx\n * function MyComponent() {\n * const height = useSharedValue(0);\n * const progress = useSharedValue(0);\n *\n * useKeyboardHandler({\n * onMove: (e) => {\n * \"worklet\";\n *\n * height.value = e.height;\n * progress.value = e.progress;\n * },\n * onEnd: (e) => {\n * \"worklet\";\n *\n * height.value = e.height;\n * progress.value = e.progress;\n * },\n * }, []);\n *\n * return <Reanimated.View style={{ height: height }] }} />;\n * }\n * ```\n */\nexport function useKeyboardHandler(\n handler: KeyboardHandler,\n deps?: DependencyList,\n) {\n useResizeMode();\n useGenericKeyboardHandler(handler, deps);\n}\n\n/**\n * Hook for controlling keyboard controller module.\n * Allows to disable/enable it and check the actual state (whether it's enabled or not).\n * When disabled it fallbacks to default android keyboard handling and stops tracking all\n * the events that are exposed from this library.\n *\n * @property {Function} setEnabled - Function to enable/disable keyboard handling.\n * @property {boolean} enabled - Current enabled state.\n * @returns Object containing keyboard control functions and state.\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/hooks/module/use-keyboard-controller|Documentation} page for more details.\n * @example\n * ```tsx\n * function MyComponent() {\n * const { setEnabled, enabled } = useKeyboardController();\n * return (\n * <Button\n * title={enabled ? 'Disable' : 'Enable'}\n * onPress={() => setEnabled(!enabled)}\n * />\n * );\n * }\n * ```\n */\nexport function useKeyboardController() {\n const context = useKeyboardContext();\n\n return { setEnabled: context.setEnabled, enabled: context.enabled };\n}\n\n/**\n * Hook that provides access to the layout of the currently focused input.\n *\n * @returns Object containing reanimated values for focused input.\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/hooks/input/use-reanimated-focused-input|Documentation} page for more details.\n * @example\n * ```tsx\n * function MyComponent() {\n * const { input } = useReanimatedFocusedInput();\n * return <Reanimated.View style={{ height: input.value?.layout.height }} />;\n * }\n * ```\n */\nexport function useReanimatedFocusedInput() {\n const context = useKeyboardContext();\n\n return { input: context.layout };\n}\n\n/**\n * Hook for handling focused input events, such as changes of selection, text etc.\n *\n * @param handler - Object containing focused input event handlers.\n * @param [deps] - Dependencies array for the effect.\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/hooks/input/use-focused-input-handler|Documentation} page for more details.\n * @example\n * ```tsx\n * function MyComponent() {\n * useFocusedInputHandler({\n * onChangeText: (e) => console.log('Text changed:', e.text),\n * onSelectionChange: (e) => console.log('Selection changed:', e.selection)\n * });\n * return <View />;\n * }\n * ```\n */\nexport function useFocusedInputHandler(\n handler: FocusedInputHandler,\n deps?: DependencyList,\n) {\n const context = useKeyboardContext();\n\n useLayoutEffect(() => {\n const cleanup = context.setInputHandlers(handler);\n\n return () => cleanup();\n }, deps);\n}\n\nexport * from \"./useWindowDimensions\";\nexport * from \"./useKeyboardState\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AAyOA,IAAAI,oBAAA,GAAAJ,OAAA;AAAAK,MAAA,CAAAC,IAAA,CAAAF,oBAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,oBAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,oBAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,iBAAA,GAAAjB,OAAA;AAAAK,MAAA,CAAAC,IAAA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AAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AA9BAjB,OAAA,CAAAgB,8BAAA,GAAAA,8BAAA;AA+BO,SAASE,yBAAyBA,CACvCC,OAAwB,EACxBC,IAAqB,EACrB;EACA,MAAMP,OAAO,GAAG,IAAAC,2BAAkB,EAAC,CAAC;EAEpC,IAAAO,sBAAe,EAAC,MAAM;IACpB,MAAMC,OAAO,GAAGT,OAAO,CAACU,mBAAmB,CAACJ,OAAO,CAAC;IAEpD,OAAO,MAAMG,OAAO,CAAC,CAAC;EACxB,CAAC,EAAEF,IAAI,CAAC;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASI,kBAAkBA,CAChCL,OAAwB,EACxBC,IAAqB,EACrB;EACAf,aAAa,CAAC,CAAC;EACfa,yBAAyB,CAACC,OAAO,EAAEC,IAAI,CAAC;AAC1C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASK,qBAAqBA,CAAA,EAAG;EACtC,MAAMZ,OAAO,GAAG,IAAAC,2BAAkB,EAAC,CAAC;EAEpC,OAAO;IAAEY,UAAU,EAAEb,OAAO,CAACa,UAAU;IAAEC,OAAO,EAAEd,OAAO,CAACc;EAAQ,CAAC;AACrE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,yBAAyBA,CAAA,EAAG;EAC1C,MAAMf,OAAO,GAAG,IAAAC,2BAAkB,EAAC,CAAC;EAEpC,OAAO;IAAEe,KAAK,EAAEhB,OAAO,CAACiB;EAAO,CAAC;AAClC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,sBAAsBA,CACpCZ,OAA4B,EAC5BC,IAAqB,EACrB;EACA,MAAMP,OAAO,GAAG,IAAAC,2BAAkB,EAAC,CAAC;EAEpC,IAAAO,sBAAe,EAAC,MAAM;IACpB,MAAMC,OAAO,GAAGT,OAAO,CAACmB,gBAAgB,CAACb,OAAO,CAAC;IAEjD,OAAO,MAAMG,OAAO,CAAC,CAAC;EACxB,CAAC,EAAEF,IAAI,CAAC;AACV","ignoreList":[]}
@@ -12,6 +12,27 @@ const getLatestState = () => ({
12
12
  ..._module.KeyboardController.state(),
13
13
  isVisible: _module.KeyboardController.isVisible()
14
14
  });
15
+
16
+ /**
17
+ * React Hook that represents the current keyboard state on iOS and Android.
18
+ * It tracks keyboard visibility, height, appearance, type and other properties.
19
+ * This hook subscribes to keyboard events and updates the state reactively.
20
+ *
21
+ * @returns Object {@link KeyboardState|containing} keyboard state information.
22
+ * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/hooks/keyboard/use-keyboard-state|Documentation} page for more details.
23
+ * @example
24
+ * ```tsx
25
+ * function MyComponent() {
26
+ * const { isVisible, height } = useKeyboardState();
27
+ * return (
28
+ * <View>
29
+ * <Text>Keyboard is {isVisible ? 'visible' : 'hidden'}</Text>
30
+ * <Text>Keyboard height: {height}</Text>
31
+ * </View>
32
+ * );
33
+ * }
34
+ * ```
35
+ */
15
36
  const useKeyboardState = () => {
16
37
  const [state, setState] = (0, _react.useState)(getLatestState);
17
38
  (0, _react.useEffect)(() => {
@@ -1 +1 @@
1
- {"version":3,"names":["_react","require","_bindings","_module","EVENTS","getLatestState","KeyboardController","state","isVisible","useKeyboardState","setState","useState","useEffect","subscriptions","map","event","KeyboardEvents","addListener","forEach","subscription","remove","exports"],"sources":["index.ts"],"sourcesContent":["import { useEffect, useState } from \"react\";\n\nimport { KeyboardEvents } from \"../../bindings\";\nimport { KeyboardController } from \"../../module\";\n\nimport type { KeyboardState } from \"../../types\";\n\nconst EVENTS = [\"keyboardDidShow\", \"keyboardDidHide\"] as const;\n\nconst getLatestState = () => ({\n ...KeyboardController.state(),\n isVisible: KeyboardController.isVisible(),\n});\n\nexport const useKeyboardState = (): KeyboardState => {\n const [state, setState] = useState(getLatestState);\n\n useEffect(() => {\n const subscriptions = EVENTS.map((event) =>\n KeyboardEvents.addListener(event, () =>\n // state will be updated by global listener first,\n // so we simply read it and don't derive data from the event\n setState(getLatestState),\n ),\n );\n\n // we might have missed an update between reading a value in render and\n // `addListener` in this handler, so we set it here. If there was\n // no change, React will filter out this update as a no-op.\n setState(getLatestState);\n\n return () => {\n subscriptions.forEach((subscription) => subscription.remove());\n };\n }, []);\n\n return state;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAIA,MAAMG,MAAM,GAAG,CAAC,iBAAiB,EAAE,iBAAiB,CAAU;AAE9D,MAAMC,cAAc,GAAGA,CAAA,MAAO;EAC5B,GAAGC,0BAAkB,CAACC,KAAK,CAAC,CAAC;EAC7BC,SAAS,EAAEF,0BAAkB,CAACE,SAAS,CAAC;AAC1C,CAAC,CAAC;AAEK,MAAMC,gBAAgB,GAAGA,CAAA,KAAqB;EACnD,MAAM,CAACF,KAAK,EAAEG,QAAQ,CAAC,GAAG,IAAAC,eAAQ,EAACN,cAAc,CAAC;EAElD,IAAAO,gBAAS,EAAC,MAAM;IACd,MAAMC,aAAa,GAAGT,MAAM,CAACU,GAAG,CAAEC,KAAK,IACrCC,wBAAc,CAACC,WAAW,CAACF,KAAK,EAAE;IAChC;IACA;IACAL,QAAQ,CAACL,cAAc,CACzB,CACF,CAAC;;IAED;IACA;IACA;IACAK,QAAQ,CAACL,cAAc,CAAC;IAExB,OAAO,MAAM;MACXQ,aAAa,CAACK,OAAO,CAAEC,YAAY,IAAKA,YAAY,CAACC,MAAM,CAAC,CAAC,CAAC;IAChE,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOb,KAAK;AACd,CAAC;AAACc,OAAA,CAAAZ,gBAAA,GAAAA,gBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_react","require","_bindings","_module","EVENTS","getLatestState","KeyboardController","state","isVisible","useKeyboardState","setState","useState","useEffect","subscriptions","map","event","KeyboardEvents","addListener","forEach","subscription","remove","exports"],"sources":["index.ts"],"sourcesContent":["import { useEffect, useState } from \"react\";\n\nimport { KeyboardEvents } from \"../../bindings\";\nimport { KeyboardController } from \"../../module\";\n\nimport type { KeyboardState } from \"../../types\";\n\nconst EVENTS = [\"keyboardDidShow\", \"keyboardDidHide\"] as const;\n\nconst getLatestState = () => ({\n ...KeyboardController.state(),\n isVisible: KeyboardController.isVisible(),\n});\n\n/**\n * React Hook that represents the current keyboard state on iOS and Android.\n * It tracks keyboard visibility, height, appearance, type and other properties.\n * This hook subscribes to keyboard events and updates the state reactively.\n *\n * @returns Object {@link KeyboardState|containing} keyboard state information.\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/hooks/keyboard/use-keyboard-state|Documentation} page for more details.\n * @example\n * ```tsx\n * function MyComponent() {\n * const { isVisible, height } = useKeyboardState();\n * return (\n * <View>\n * <Text>Keyboard is {isVisible ? 'visible' : 'hidden'}</Text>\n * <Text>Keyboard height: {height}</Text>\n * </View>\n * );\n * }\n * ```\n */\nexport const useKeyboardState = (): KeyboardState => {\n const [state, setState] = useState(getLatestState);\n\n useEffect(() => {\n const subscriptions = EVENTS.map((event) =>\n KeyboardEvents.addListener(event, () =>\n // state will be updated by global listener first,\n // so we simply read it and don't derive data from the event\n setState(getLatestState),\n ),\n );\n\n // we might have missed an update between reading a value in render and\n // `addListener` in this handler, so we set it here. If there was\n // no change, React will filter out this update as a no-op.\n setState(getLatestState);\n\n return () => {\n subscriptions.forEach((subscription) => subscription.remove());\n };\n }, []);\n\n return state;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAIA,MAAMG,MAAM,GAAG,CAAC,iBAAiB,EAAE,iBAAiB,CAAU;AAE9D,MAAMC,cAAc,GAAGA,CAAA,MAAO;EAC5B,GAAGC,0BAAkB,CAACC,KAAK,CAAC,CAAC;EAC7BC,SAAS,EAAEF,0BAAkB,CAACE,SAAS,CAAC;AAC1C,CAAC,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,gBAAgB,GAAGA,CAAA,KAAqB;EACnD,MAAM,CAACF,KAAK,EAAEG,QAAQ,CAAC,GAAG,IAAAC,eAAQ,EAACN,cAAc,CAAC;EAElD,IAAAO,gBAAS,EAAC,MAAM;IACd,MAAMC,aAAa,GAAGT,MAAM,CAACU,GAAG,CAAEC,KAAK,IACrCC,wBAAc,CAACC,WAAW,CAACF,KAAK,EAAE;IAChC;IACA;IACAL,QAAQ,CAACL,cAAc,CACzB,CACF,CAAC;;IAED;IACA;IACA;IACAK,QAAQ,CAACL,cAAc,CAAC;IAExB,OAAO,MAAM;MACXQ,aAAa,CAACK,OAAO,CAAEC,YAAY,IAAKA,YAAY,CAACC,MAAM,CAAC,CAAC,CAAC;IAChE,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOb,KAAK;AACd,CAAC;AAACc,OAAA,CAAAZ,gBAAA,GAAAA,gBAAA","ignoreList":[]}
@@ -3,11 +3,34 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "useWindowDimensions", {
7
- enumerable: true,
8
- get: function () {
9
- return _reactNative.useWindowDimensions;
10
- }
11
- });
6
+ exports.useWindowDimensions = void 0;
7
+ var _react = require("react");
12
8
  var _reactNative = require("react-native");
9
+ var _bindings = require("../../bindings");
10
+ const screen = _reactNative.Dimensions.get("screen");
11
+ let initialDimensions = {
12
+ width: screen.width,
13
+ height: screen.height
14
+ };
15
+ _bindings.WindowDimensionsEvents.addListener("windowDidResize", e => {
16
+ initialDimensions = e;
17
+ });
18
+ const useWindowDimensions = () => {
19
+ const [dimensions, setDimensions] = (0, _react.useState)(initialDimensions);
20
+ (0, _react.useEffect)(() => {
21
+ const subscription = _bindings.WindowDimensionsEvents.addListener("windowDidResize", e => {
22
+ setDimensions(e);
23
+ });
24
+
25
+ // we might have missed an update between reading a value in render and
26
+ // `addListener` in this handler, so we set it here. If there was
27
+ // no change, React will filter out this update as a no-op.
28
+ setDimensions(initialDimensions);
29
+ return () => {
30
+ subscription.remove();
31
+ };
32
+ }, []);
33
+ return dimensions;
34
+ };
35
+ exports.useWindowDimensions = useWindowDimensions;
13
36
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require"],"sources":["index.ts"],"sourcesContent":["export { useWindowDimensions } from \"react-native\";\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA","ignoreList":[]}
1
+ {"version":3,"names":["_react","require","_reactNative","_bindings","screen","Dimensions","get","initialDimensions","width","height","WindowDimensionsEvents","addListener","e","useWindowDimensions","dimensions","setDimensions","useState","useEffect","subscription","remove","exports"],"sources":["index.ts"],"sourcesContent":["import { useEffect, useState } from \"react\";\nimport { Dimensions } from \"react-native\";\n\nimport { WindowDimensionsEvents } from \"../../bindings\";\n\nimport type { WindowDimensionsEventData } from \"../../types\";\n\nconst screen = Dimensions.get(\"screen\");\n\nlet initialDimensions: WindowDimensionsEventData = {\n width: screen.width,\n height: screen.height,\n};\n\nWindowDimensionsEvents.addListener(\"windowDidResize\", (e) => {\n initialDimensions = e;\n});\n\nexport const useWindowDimensions = () => {\n const [dimensions, setDimensions] = useState(initialDimensions);\n\n useEffect(() => {\n const subscription = WindowDimensionsEvents.addListener(\n \"windowDidResize\",\n (e) => {\n setDimensions(e);\n },\n );\n\n // we might have missed an update between reading a value in render and\n // `addListener` in this handler, so we set it here. If there was\n // no change, React will filter out this update as a no-op.\n setDimensions(initialDimensions);\n\n return () => {\n subscription.remove();\n };\n }, []);\n\n return dimensions;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,SAAA,GAAAF,OAAA;AAIA,MAAMG,MAAM,GAAGC,uBAAU,CAACC,GAAG,CAAC,QAAQ,CAAC;AAEvC,IAAIC,iBAA4C,GAAG;EACjDC,KAAK,EAAEJ,MAAM,CAACI,KAAK;EACnBC,MAAM,EAAEL,MAAM,CAACK;AACjB,CAAC;AAEDC,gCAAsB,CAACC,WAAW,CAAC,iBAAiB,EAAGC,CAAC,IAAK;EAC3DL,iBAAiB,GAAGK,CAAC;AACvB,CAAC,CAAC;AAEK,MAAMC,mBAAmB,GAAGA,CAAA,KAAM;EACvC,MAAM,CAACC,UAAU,EAAEC,aAAa,CAAC,GAAG,IAAAC,eAAQ,EAACT,iBAAiB,CAAC;EAE/D,IAAAU,gBAAS,EAAC,MAAM;IACd,MAAMC,YAAY,GAAGR,gCAAsB,CAACC,WAAW,CACrD,iBAAiB,EAChBC,CAAC,IAAK;MACLG,aAAa,CAACH,CAAC,CAAC;IAClB,CACF,CAAC;;IAED;IACA;IACA;IACAG,aAAa,CAACR,iBAAiB,CAAC;IAEhC,OAAO,MAAM;MACXW,YAAY,CAACC,MAAM,CAAC,CAAC;IACvB,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOL,UAAU;AACnB,CAAC;AAACM,OAAA,CAAAP,mBAAA,GAAAA,mBAAA","ignoreList":[]}
@@ -9,6 +9,20 @@ var _react = require("react");
9
9
  var _reactNative = require("react-native");
10
10
  var _eventHandler = require("./event-handler");
11
11
  var _findNodeHandle = require("./utils/findNodeHandle");
12
+ /**
13
+ * An internal hook that helps to register workletized event handlers.
14
+ *
15
+ * @param map - Map of event handlers and their names.
16
+ * @param viewTagRef - Ref to the view that produces events.
17
+ * @returns A function that registers supplied event handlers.
18
+ * @example
19
+ * ```ts
20
+ * const setKeyboardHandlers = useEventHandlerRegistration<KeyboardHandler>(
21
+ * keyboardEventsMap,
22
+ * viewTagRef,
23
+ * );
24
+ * ```
25
+ */
12
26
  function useEventHandlerRegistration(map, viewTagRef) {
13
27
  const onRegisterHandler = handler => {
14
28
  const ids = [];
@@ -50,7 +64,14 @@ function useEventHandlerRegistration(map, viewTagRef) {
50
64
  * and therefore consumes less memory. We can not use a variant from
51
65
  * RN, since this library supports earlier versions of RN.
52
66
  *
67
+ * @param initialValue - Initial value of the animated value (numeric).
68
+ * @param config - Additional {@link Animated.AnimatedConfig|configuration} for the animated value.
69
+ * @returns Properly memoized {@link Animated.Value|Animated} value.
53
70
  * @see https://github.com/facebook/react-native/commit/e22217fe8b9455e32695f88ca835e11442b0a937
71
+ * @example
72
+ * ```ts
73
+ * const progress = useAnimatedValue(0);
74
+ * ```
54
75
  */
55
76
  function useAnimatedValue(initialValue, config) {
56
77
  const ref = (0, _react.useRef)(null);
@@ -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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O,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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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,QAAQ,EAAE,CAAC;EACXC,SAAS,EAAE,IAAIC,IAAI,CAAC,CAAC,CAACC,OAAO,CAAC,CAAC;EAC/BC,MAAM,EAAE,CAAC,CAAC;EACVC,IAAI,EAAE,SAAS;EACfC,UAAU,EAAE;AACd,CAAC;AAEDC,wBAAc,CAACC,WAAW,CAAC,iBAAiB,EAAGC,CAAC,IAAK;EACnDZ,QAAQ,GAAG,IAAI;EACfC,SAAS,GAAGW,CAAC;AACf,CAAC,CAAC;AAEFF,wBAAc,CAACC,WAAW,CAAC,iBAAiB,EAAGC,CAAC,IAAK;EACnDZ,QAAQ,GAAG,KAAK;EAChBC,SAAS,GAAGW,CAAC;AACf,CAAC,CAAC;AAEF,MAAMC,OAAO,GAAG,MAAOC,OAAwB,IAAoB;EACjE,MAAMC,SAAS,GAAG,CAAAD,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEC,SAAS,KAAI,KAAK;EAE7C,OAAO,IAAIC,OAAO,CAAEC,OAAO,IAAK;IAC9B,IAAIjB,QAAQ,EAAE;MACZiB,OAAO,CAAC,CAAC;MAET;IACF;IAEA,MAAMC,YAAY,GAAGR,wBAAc,CAACC,WAAW,CAAC,iBAAiB,EAAE,MAAM;MACvEM,OAAO,CAACE,SAAS,CAAC;MAClBD,YAAY,CAACE,MAAM,CAAC,CAAC;IACvB,CAAC,CAAC;IAEFC,kCAAwB,CAACR,OAAO,CAACE,SAAS,CAAC;EAC7C,CAAC,CAAC;AACJ,CAAC;AACD,MAAMO,SAAS,GAAGA,CAAA,KAAM,CAACtB,QAAQ;AACjC,MAAMuB,KAAK,GAAGA,CAAA,KAAMtB,SAAS;AAEtB,MAAMuB,kBAA4C,GAAAC,OAAA,CAAAD,kBAAA,GAAG;EAC1DE,cAAc,EAAEL,kCAAwB,CAACK,cAAc;EACvDC,YAAY,EAAEN,kCAAwB,CAACM,YAAY;EACnDC,UAAU,EAAEP,kCAAwB,CAACO,UAAU;EAC/Cf,OAAO;EACPS,SAAS;EACTC;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,CAACC,OAAO,CAAC,CAAC;EAC/BC,MAAM,EAAE,CAAC,CAAC;EACVC,IAAI,EAAE,SAAS;EACfC,UAAU,EAAE;AACd,CAAC;AAEDC,wBAAc,CAACC,WAAW,CAAC,iBAAiB,EAAGC,CAAC,IAAK;EACnDZ,QAAQ,GAAG,IAAI;EACfC,SAAS,GAAGW,CAAC;AACf,CAAC,CAAC;AAEFF,wBAAc,CAACC,WAAW,CAAC,iBAAiB,EAAGC,CAAC,IAAK;EACnDZ,QAAQ,GAAG,KAAK;EAChBC,SAAS,GAAGW,CAAC;AACf,CAAC,CAAC;AAEF,MAAMC,OAAO,GAAG,MAAOC,OAAwB,IAAoB;EACjE,MAAMC,SAAS,GAAG,CAAAD,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEC,SAAS,KAAI,KAAK;EAE7C,OAAO,IAAIC,OAAO,CAAEC,OAAO,IAAK;IAC9B,IAAIjB,QAAQ,EAAE;MACZiB,OAAO,CAAC,CAAC;MAET;IACF;IAEA,MAAMC,YAAY,GAAGR,wBAAc,CAACC,WAAW,CAAC,iBAAiB,EAAE,MAAM;MACvEM,OAAO,CAACE,SAAS,CAAC;MAClBD,YAAY,CAACE,MAAM,CAAC,CAAC;IACvB,CAAC,CAAC;IAEFC,kCAAwB,CAACR,OAAO,CAACE,SAAS,CAAC;EAC7C,CAAC,CAAC;AACJ,CAAC;AACD,MAAMO,SAAS,GAAGA,CAAA,KAAM,CAACtB,QAAQ;AACjC,MAAMuB,KAAK,GAAGA,CAAA,KAAMtB,SAAS;;AAE7B;AACA;AACA;AACO,MAAMuB,kBAA4C,GAAAC,OAAA,CAAAD,kBAAA,GAAG;EAC1DE,cAAc,EAAEL,kCAAwB,CAACK,cAAc;EACvDC,YAAY,EAAEN,kCAAwB,CAACM,YAAY;EACnDC,UAAU,EAAEP,kCAAwB,CAACO,UAAU;EAC/Cf,OAAO;EACPS,SAAS;EACTC;AACF,CAAC","ignoreList":[]}
@@ -31,11 +31,6 @@ const ModifiedNativeAndroidManager = {
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,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;;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":[]}
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 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,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,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AACa,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"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,SAAA,EAAAR,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAO,SAAA,CAAAP,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAG,SAAA,CAAAP,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=internal.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":[]}