react-native-keyboard-controller 1.20.7 → 1.21.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/android/.settings/org.eclipse.buildship.core.prefs +2 -0
  2. package/android/src/base/java/com/reactnativekeyboardcontroller/KeyboardControllerPackage.kt +2 -0
  3. package/android/src/fabric/java/com/reactnativekeyboardcontroller/ClippingScrollViewDecoratorViewManager.kt +30 -0
  4. package/android/src/main/java/com/reactnativekeyboardcontroller/managers/ClippingScrollViewDecoratorViewManagerImpl.kt +13 -0
  5. package/android/src/main/java/com/reactnativekeyboardcontroller/views/ClippingScrollViewDecoratorView.kt +37 -0
  6. package/android/src/paper/java/com/reactnativekeyboardcontroller/ClippingScrollViewDecoratorViewManager.kt +24 -0
  7. package/ios/KeyboardController.xcodeproj/xcuserdata/kirylziusko.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
  8. package/ios/Tests/Tests.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  9. package/ios/Tests/Tests.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  10. package/ios/Tests/Tests.xcodeproj/project.xcworkspace/xcuserdata/kirylziusko.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  11. package/ios/Tests/Tests.xcodeproj/xcuserdata/kirylziusko.xcuserdatad/xcschemes/xcschememanagement.plist +32 -0
  12. package/ios/animations/KeyboardAnimation.swift +2 -2
  13. package/ios/animations/SpringAnimation.swift +1 -1
  14. package/ios/animations/TimingAnimation.swift +1 -3
  15. package/ios/delegates/KCTextInputCompositeDelegate.swift +2 -2
  16. package/ios/extensions/CGFloat.swift +1 -3
  17. package/ios/interactive/KeyboardAreaExtender.swift +2 -1
  18. package/ios/observers/FocusedInputObserver.swift +4 -2
  19. package/ios/observers/movement/KeyboardTrackingView.swift +4 -1
  20. package/ios/observers/movement/observer/KeyboardMovementObserver+Interactive.swift +4 -0
  21. package/ios/protocols/TextInput.swift +1 -1
  22. package/ios/swizzling/UIResponderSwizzle.swift +2 -4
  23. package/ios/traversal/FocusedInputHolder.swift +3 -3
  24. package/ios/traversal/KeyboardView.swift +1 -1
  25. package/ios/traversal/ViewHierarchyNavigator.swift +2 -2
  26. package/ios/views/KeyboardControllerViewManager.swift +5 -5
  27. package/lib/commonjs/bindings.js +7 -1
  28. package/lib/commonjs/bindings.js.map +1 -1
  29. package/lib/commonjs/bindings.native.js +4 -1
  30. package/lib/commonjs/bindings.native.js.map +1 -1
  31. package/lib/commonjs/components/KeyboardAwareScrollView/index.js +77 -22
  32. package/lib/commonjs/components/KeyboardAwareScrollView/index.js.map +1 -1
  33. package/lib/commonjs/components/ScrollViewWithBottomPadding/index.js +43 -0
  34. package/lib/commonjs/components/ScrollViewWithBottomPadding/index.js.map +1 -0
  35. package/lib/commonjs/components/ScrollViewWithBottomPadding/styles.js +14 -0
  36. package/lib/commonjs/components/ScrollViewWithBottomPadding/styles.js.map +1 -0
  37. package/lib/commonjs/components/hooks/useScrollState.js +43 -0
  38. package/lib/commonjs/components/hooks/useScrollState.js.map +1 -0
  39. package/lib/commonjs/specs/ClippingScrollViewDecoratorViewNativeComponent.js +12 -0
  40. package/lib/commonjs/specs/ClippingScrollViewDecoratorViewNativeComponent.js.map +1 -0
  41. package/lib/commonjs/types/views.js.map +1 -1
  42. package/lib/module/bindings.js +6 -0
  43. package/lib/module/bindings.js.map +1 -1
  44. package/lib/module/bindings.native.js +3 -0
  45. package/lib/module/bindings.native.js.map +1 -1
  46. package/lib/module/components/KeyboardAwareScrollView/index.js +78 -23
  47. package/lib/module/components/KeyboardAwareScrollView/index.js.map +1 -1
  48. package/lib/module/components/ScrollViewWithBottomPadding/index.js +35 -0
  49. package/lib/module/components/ScrollViewWithBottomPadding/index.js.map +1 -0
  50. package/lib/module/components/ScrollViewWithBottomPadding/styles.js +8 -0
  51. package/lib/module/components/ScrollViewWithBottomPadding/styles.js.map +1 -0
  52. package/lib/module/components/hooks/useScrollState.js +37 -0
  53. package/lib/module/components/hooks/useScrollState.js.map +1 -0
  54. package/lib/module/specs/ClippingScrollViewDecoratorViewNativeComponent.js +6 -0
  55. package/lib/module/specs/ClippingScrollViewDecoratorViewNativeComponent.js.map +1 -0
  56. package/lib/module/types/views.js.map +1 -1
  57. package/lib/typescript/bindings.d.ts +7 -1
  58. package/lib/typescript/bindings.native.d.ts +1 -0
  59. package/lib/typescript/components/KeyboardAwareScrollView/index.d.ts +3 -2
  60. package/lib/typescript/components/ScrollViewWithBottomPadding/index.d.ts +12 -0
  61. package/lib/typescript/components/ScrollViewWithBottomPadding/styles.d.ts +6 -0
  62. package/lib/typescript/components/hooks/useScrollState.d.ts +14 -0
  63. package/lib/typescript/specs/ClippingScrollViewDecoratorViewNativeComponent.d.ts +8 -0
  64. package/lib/typescript/types/views.d.ts +4 -0
  65. package/package.json +4 -3
  66. package/src/bindings.native.ts +5 -0
  67. package/src/bindings.ts +8 -0
  68. package/src/components/KeyboardAwareScrollView/index.tsx +111 -28
  69. package/src/components/ScrollViewWithBottomPadding/index.tsx +72 -0
  70. package/src/components/ScrollViewWithBottomPadding/styles.ts +9 -0
  71. package/src/components/hooks/useScrollState.ts +59 -0
  72. package/src/specs/ClippingScrollViewDecoratorViewNativeComponent.ts +17 -0
  73. package/src/types/views.ts +6 -0
@@ -1,9 +1,11 @@
1
1
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
2
  import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo } from "react";
3
- import Reanimated, { clamp, interpolate, runOnUI, scrollTo, useAnimatedReaction, useAnimatedRef, useAnimatedStyle, useScrollViewOffset, useSharedValue } from "react-native-reanimated";
3
+ import Reanimated, { clamp, interpolate, runOnUI, scrollTo, useAnimatedReaction, useAnimatedRef, useDerivedValue, useSharedValue } from "react-native-reanimated";
4
4
  import { useFocusedInputHandler, useReanimatedFocusedInput, useWindowDimensions } from "../../hooks";
5
5
  import { findNodeHandle } from "../../utils/findNodeHandle";
6
6
  import useCombinedRef from "../hooks/useCombinedRef";
7
+ import useScrollState from "../hooks/useScrollState";
8
+ import ScrollViewWithBottomPadding from "../ScrollViewWithBottomPadding";
7
9
  import { useSmoothKeyboardHandler } from "./useSmoothKeyboardHandler";
8
10
  import { debounce, scrollDistanceWithRespectToSnapPoints } from "./utils";
9
11
  // Everything begins from `onStart` handler. This handler is called every time,
@@ -75,7 +77,11 @@ const KeyboardAwareScrollView = /*#__PURE__*/forwardRef(({
75
77
  const onRef = useCombinedRef(scrollViewAnimatedRef, scrollViewRef);
76
78
  const scrollViewTarget = useSharedValue(null);
77
79
  const scrollPosition = useSharedValue(0);
78
- const position = useScrollViewOffset(scrollViewAnimatedRef);
80
+ const {
81
+ offset: position,
82
+ layout: scrollViewLayout,
83
+ size: scrollViewContentSize
84
+ } = useScrollState(scrollViewAnimatedRef);
79
85
  const currentKeyboardFrameHeight = useSharedValue(0);
80
86
  const keyboardHeight = useSharedValue(0);
81
87
  const keyboardWillAppear = useSharedValue(false);
@@ -88,6 +94,8 @@ const KeyboardAwareScrollView = /*#__PURE__*/forwardRef(({
88
94
  } = useReanimatedFocusedInput();
89
95
  const layout = useSharedValue(null);
90
96
  const lastSelection = useSharedValue(null);
97
+ const ghostViewSpace = useSharedValue(-1);
98
+ const pendingSelectionForFocus = useSharedValue(false);
91
99
  const {
92
100
  height
93
101
  } = useWindowDimensions();
@@ -129,6 +137,18 @@ const KeyboardAwareScrollView = /*#__PURE__*/forwardRef(({
129
137
  }
130
138
  return 0;
131
139
  }, [bottomOffset, enabled, height, snapToOffsets]);
140
+ const removeGhostPadding = useCallback(e => {
141
+ "worklet";
142
+
143
+ // new `ScrollViewWithBottomPadding` behavior: if we hide keyboard and we are in the end of `ScrollView`
144
+ // then we always need to scroll back, because we apply a padding that doesn't change layout, so we will
145
+ // not have auto scroll back in this case
146
+ if (!keyboardWillAppear.value && ghostViewSpace.value > 0) {
147
+ scrollTo(scrollViewAnimatedRef, 0, scrollPosition.value - interpolate(e, [initialKeyboardSize.value, keyboardHeight.value], [ghostViewSpace.value, 0]), false);
148
+ return true;
149
+ }
150
+ return false;
151
+ }, []);
132
152
  const performScrollWithPositionRestoration = useCallback(newPosition => {
133
153
  "worklet";
134
154
 
@@ -188,7 +208,17 @@ const KeyboardAwareScrollView = /*#__PURE__*/forwardRef(({
188
208
  const latestSelection = (_lastSelection$value3 = lastSelection.value) === null || _lastSelection$value3 === void 0 ? void 0 : _lastSelection$value3.selection;
189
209
  lastSelection.value = e;
190
210
  if (e.target !== lastTarget) {
191
- // ignore this event, because "focus changed" event handled in `useSmoothKeyboardHandler`
211
+ if (pendingSelectionForFocus.value) {
212
+ // selection arrived after onStart - complete the deferred setup
213
+ pendingSelectionForFocus.value = false;
214
+ updateLayoutFromSelection();
215
+
216
+ // if keyboard was already visible (focus change, no onMove expected),
217
+ // perform the deferred scroll now
218
+ if (!keyboardWillAppear.value && keyboardHeight.value > 0) {
219
+ position.value += maybeScroll(keyboardHeight.value, true);
220
+ }
221
+ }
192
222
  return;
193
223
  }
194
224
  // caret in the end + end coordinates has been changed -> we moved to a new line
@@ -201,7 +231,7 @@ const KeyboardAwareScrollView = /*#__PURE__*/forwardRef(({
201
231
  return scrollFromCurrentPosition();
202
232
  }
203
233
  onChangeTextHandler();
204
- }, [scrollFromCurrentPosition, onChangeTextHandler]);
234
+ }, [scrollFromCurrentPosition, onChangeTextHandler, updateLayoutFromSelection, maybeScroll]);
205
235
  useFocusedInputHandler({
206
236
  onSelectionChange: onSelectionChange
207
237
  }, [onSelectionChange]);
@@ -220,6 +250,7 @@ const KeyboardAwareScrollView = /*#__PURE__*/forwardRef(({
220
250
  // on back transition need to interpolate as [0, keyboardHeight]
221
251
  initialKeyboardSize.value = 0;
222
252
  scrollPosition.value = scrollBeforeKeyboardMovement.value;
253
+ pendingSelectionForFocus.value = false;
223
254
  }
224
255
  if (keyboardWillAppear.value || keyboardWillChangeSize || focusWasChanged) {
225
256
  // persist scroll value
@@ -230,23 +261,44 @@ const KeyboardAwareScrollView = /*#__PURE__*/forwardRef(({
230
261
 
231
262
  // focus was changed
232
263
  if (focusWasChanged) {
264
+ var _lastSelection$value4;
233
265
  tag.value = e.target;
234
- // save position of focused text input when keyboard starts to move
235
- updateLayoutFromSelection();
266
+ if (((_lastSelection$value4 = lastSelection.value) === null || _lastSelection$value4 === void 0 ? void 0 : _lastSelection$value4.target) === e.target) {
267
+ // selection arrived before onStart - use it to update layout
268
+ updateLayoutFromSelection();
269
+ pendingSelectionForFocus.value = false;
270
+ } else {
271
+ // selection hasn't arrived yet for the new target.
272
+ // use input layout as-is; will be refined when selection arrives.
273
+ if (input.value) {
274
+ layout.value = input.value;
275
+ }
276
+ pendingSelectionForFocus.value = true;
277
+ }
278
+
236
279
  // save current scroll position - when keyboard will hide we'll reuse
237
280
  // this value to achieve smooth hide effect
238
281
  scrollBeforeKeyboardMovement.value = position.value;
239
282
  }
240
283
  if (focusWasChanged && !keyboardWillAppear.value) {
241
- // update position on scroll value, so `onEnd` handler
242
- // will pick up correct values
243
- position.value += maybeScroll(e.height, true);
284
+ if (!pendingSelectionForFocus.value) {
285
+ // update position on scroll value, so `onEnd` handler
286
+ // will pick up correct values
287
+ position.value += maybeScroll(e.height, true);
288
+ }
289
+ }
290
+ ghostViewSpace.value = position.value + scrollViewLayout.value.height - scrollViewContentSize.value.height;
291
+ if (ghostViewSpace.value > 0) {
292
+ scrollPosition.value = position.value;
244
293
  }
245
294
  },
246
295
  onMove: e => {
247
296
  "worklet";
248
297
 
249
298
  syncKeyboardFrame(e);
299
+ if (removeGhostPadding(e.height)) {
300
+ return;
301
+ }
250
302
 
251
303
  // if the user has set disableScrollOnKeyboardHide, only auto-scroll when the keyboard opens
252
304
  if (!disableScrollOnKeyboardHide || keyboardWillAppear.value) {
@@ -256,11 +308,15 @@ const KeyboardAwareScrollView = /*#__PURE__*/forwardRef(({
256
308
  onEnd: e => {
257
309
  "worklet";
258
310
 
311
+ removeGhostPadding(e.height);
259
312
  keyboardHeight.value = e.height;
260
313
  scrollPosition.value = position.value;
314
+ if (e.height === 0) {
315
+ lastSelection.value = null;
316
+ }
261
317
  syncKeyboardFrame(e);
262
318
  }
263
- }, [maybeScroll, disableScrollOnKeyboardHide, syncKeyboardFrame]);
319
+ }, [maybeScroll, removeGhostPadding, disableScrollOnKeyboardHide, syncKeyboardFrame]);
264
320
  const synchronize = useCallback(async () => {
265
321
  await update();
266
322
  runOnUI(() => {
@@ -292,23 +348,22 @@ const KeyboardAwareScrollView = /*#__PURE__*/forwardRef(({
292
348
  scrollFromCurrentPosition();
293
349
  }
294
350
  }, []);
295
- const view = useAnimatedStyle(() => enabled ? {
296
- // animations become choppy when scrolling to the end of the `ScrollView` (when the last input is focused)
297
- // this happens because the layout recalculates on every frame. To avoid this we slightly increase padding
298
- // by `+1`. In this way we assure, that `scrollTo` will never scroll to the end, because it uses interpolation
299
- // from 0 to `keyboardHeight`, and here our padding is `keyboardHeight + 1`. It allows us not to re-run layout
300
- // re-calculation on every animation frame and it helps to achieve smooth animation.
301
- // see: https://github.com/kirillzyusko/react-native-keyboard-controller/pull/342
302
- paddingBottom: currentKeyboardFrameHeight.value + 1
303
- } : {}, [enabled]);
304
- return /*#__PURE__*/React.createElement(ScrollViewComponent, _extends({
351
+
352
+ // animations become choppy when scrolling to the end of the `ScrollView` (when the last input is focused)
353
+ // this happens because the layout recalculates on every frame. To avoid this we slightly increase padding
354
+ // by `+1`. In this way we assure, that `scrollTo` will never scroll to the end, because it uses interpolation
355
+ // from 0 to `keyboardHeight`, and here our padding is `keyboardHeight + 1`. It allows us not to re-run layout
356
+ // re-calculation on every animation frame and it helps to achieve smooth animation.
357
+ // see: https://github.com/kirillzyusko/react-native-keyboard-controller/pull/342
358
+ const padding = useDerivedValue(() => enabled ? currentKeyboardFrameHeight.value + 1 : 0, [enabled]);
359
+ return /*#__PURE__*/React.createElement(ScrollViewWithBottomPadding, _extends({
305
360
  ref: onRef
306
361
  }, rest, {
362
+ bottomPadding: padding,
307
363
  scrollEventThrottle: 16,
364
+ ScrollViewComponent: ScrollViewComponent,
308
365
  onLayout: onScrollViewLayout
309
- }), children, enabled && /*#__PURE__*/React.createElement(Reanimated.View, {
310
- style: view
311
- }));
366
+ }), children);
312
367
  });
313
368
  export default KeyboardAwareScrollView;
314
369
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","forwardRef","useCallback","useEffect","useImperativeHandle","useMemo","Reanimated","clamp","interpolate","runOnUI","scrollTo","useAnimatedReaction","useAnimatedRef","useAnimatedStyle","useScrollViewOffset","useSharedValue","useFocusedInputHandler","useReanimatedFocusedInput","useWindowDimensions","findNodeHandle","useCombinedRef","useSmoothKeyboardHandler","debounce","scrollDistanceWithRespectToSnapPoints","KeyboardAwareScrollView","children","onLayout","bottomOffset","disableScrollOnKeyboardHide","enabled","extraKeyboardSpace","ScrollViewComponent","ScrollView","snapToOffsets","rest","ref","scrollViewAnimatedRef","scrollViewRef","useRef","onRef","scrollViewTarget","scrollPosition","position","currentKeyboardFrameHeight","keyboardHeight","keyboardWillAppear","tag","initialKeyboardSize","scrollBeforeKeyboardMovement","input","update","layout","lastSelection","height","onScrollViewLayout","e","value","current","maybeScroll","animated","_layout$value","_layout$value2","_layout$value3","parentScrollViewTarget","visibleRect","absoluteY","inputHeight","point","relativeScrollTo","interpolatedScrollTo","targetScrollY","Math","max","positionOnScreen","topOfScreen","performScrollWithPositionRestoration","newPosition","prevScroll","syncKeyboardFrame","keyboardFrame","updateLayoutFromSelection","_lastSelection$value","_input$value","customHeight","selection","end","y","scrollFromCurrentPosition","prevLayout","onChangeText","onChangeTextHandler","onSelectionChange","_lastSelection$value2","_lastSelection$value3","lastTarget","target","latestSelection","start","onStart","keyboardWillChangeSize","keyboardWillHide","focusWasChanged","onMove","onEnd","synchronize","scrollView","existingMethods","assureFocusedInputVisible","previous","view","paddingBottom","createElement","_extends","scrollEventThrottle","View","style"],"sources":["index.tsx"],"sourcesContent":["import React, {\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n} from \"react\";\nimport Reanimated, {\n clamp,\n interpolate,\n runOnUI,\n scrollTo,\n useAnimatedReaction,\n useAnimatedRef,\n useAnimatedStyle,\n useScrollViewOffset,\n useSharedValue,\n} from \"react-native-reanimated\";\n\nimport {\n useFocusedInputHandler,\n useReanimatedFocusedInput,\n useWindowDimensions,\n} from \"../../hooks\";\nimport { findNodeHandle } from \"../../utils/findNodeHandle\";\nimport useCombinedRef from \"../hooks/useCombinedRef\";\n\nimport { useSmoothKeyboardHandler } from \"./useSmoothKeyboardHandler\";\nimport { debounce, scrollDistanceWithRespectToSnapPoints } from \"./utils\";\n\nimport type {\n LayoutChangeEvent,\n ScrollView,\n ScrollViewProps,\n} from \"react-native\";\nimport type {\n FocusedInputLayoutChangedEvent,\n FocusedInputSelectionChangedEvent,\n NativeEvent,\n} from \"react-native-keyboard-controller\";\n\nexport type KeyboardAwareScrollViewProps = {\n /** The distance between the keyboard and the caret inside a focused `TextInput` when the keyboard is shown. Default is `0`. */\n bottomOffset?: number;\n /** Prevents automatic scrolling of the `ScrollView` when the keyboard gets hidden, maintaining the current screen position. Default is `false`. */\n disableScrollOnKeyboardHide?: boolean;\n /** Controls whether this `KeyboardAwareScrollView` instance should take effect. Default is `true`. */\n enabled?: boolean;\n /** Adjusting the bottom spacing of KeyboardAwareScrollView. Default is `0`. */\n extraKeyboardSpace?: number;\n /** Custom component for `ScrollView`. Default is `ScrollView`. */\n ScrollViewComponent?: React.ComponentType<ScrollViewProps>;\n} & ScrollViewProps;\nexport type KeyboardAwareScrollViewRef = {\n assureFocusedInputVisible: () => void;\n} & ScrollView;\n\n// Everything begins from `onStart` handler. This handler is called every time,\n// when keyboard changes its size or when focused `TextInput` was changed. In\n// this handler we are calculating/memoizing values which later will be used\n// during layout movement. For that we calculate:\n// - layout of focused field (`layout`) - to understand whether there will be overlap\n// - initial keyboard size (`initialKeyboardSize`) - used in scroll interpolation\n// - future keyboard height (`keyboardHeight`) - used in scroll interpolation\n// - current scroll position (`scrollPosition`) - used to scroll from this point\n//\n// Once we've calculated all necessary variables - we can actually start to use them.\n// It happens in `onMove` handler - this function simply calls `maybeScroll` with\n// current keyboard frame height. This functions makes the smooth transition.\n//\n// When the transition has finished we go to `onEnd` handler. In this handler\n// we verify, that the current field is not overlapped within a keyboard frame.\n// For full `onStart`/`onMove`/`onEnd` flow it may look like a redundant thing,\n// however there could be some cases, when `onMove` is not called:\n// - on iOS when TextInput was changed - keyboard transition is instant\n// - on Android when TextInput was changed and keyboard size wasn't changed\n// So `onEnd` handler handle the case, when `onMove` wasn't triggered.\n//\n// ====================================================================================================================+\n// -----------------------------------------------------Flow chart-----------------------------------------------------+\n// ====================================================================================================================+\n//\n// +============================+ +============================+ +==================================+\n// + User Press on TextInput + => + Keyboard starts showing + => + As keyboard moves frame by frame + =>\n// + + + (run `onStart`) + + `onMove` is getting called +\n// +============================+ +============================+ +==================================+\n//\n// +============================+ +============================+ +=====================================+\n// + Keyboard is shown and we + => + User moved focus to + => + Only `onStart`/`onEnd` maybe called +\n// + call `onEnd` handler + + another `TextInput` + + (without involving `onMove`) +\n// +============================+ +============================+ +=====================================+\n//\n\n/**\n * A ScrollView component that automatically handles keyboard appearance and disappearance\n * by adjusting its content position to ensure the focused input remains visible.\n *\n * The component uses a sophisticated animation system to smoothly handle keyboard transitions\n * and maintain proper scroll position during keyboard interactions.\n *\n * @returns A ScrollView component that handles keyboard interactions.\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/components/keyboard-aware-scroll-view|Documentation} page for more details.\n * @example\n * ```tsx\n * <KeyboardAwareScrollView bottomOffset={20}>\n * <TextInput placeholder=\"Enter text\" />\n * <TextInput placeholder=\"Another input\" />\n * </KeyboardAwareScrollView>\n * ```\n */\nconst KeyboardAwareScrollView = forwardRef<\n KeyboardAwareScrollViewRef,\n React.PropsWithChildren<KeyboardAwareScrollViewProps>\n>(\n (\n {\n children,\n onLayout,\n bottomOffset = 0,\n disableScrollOnKeyboardHide = false,\n enabled = true,\n extraKeyboardSpace = 0,\n ScrollViewComponent = Reanimated.ScrollView,\n snapToOffsets,\n ...rest\n },\n ref,\n ) => {\n const scrollViewAnimatedRef = useAnimatedRef<Reanimated.ScrollView>();\n const scrollViewRef = React.useRef<ScrollView>(null);\n const onRef = useCombinedRef(scrollViewAnimatedRef, scrollViewRef);\n const scrollViewTarget = useSharedValue<number | null>(null);\n const scrollPosition = useSharedValue(0);\n const position = useScrollViewOffset(scrollViewAnimatedRef);\n const currentKeyboardFrameHeight = useSharedValue(0);\n const keyboardHeight = useSharedValue(0);\n const keyboardWillAppear = useSharedValue(false);\n const tag = useSharedValue(-1);\n const initialKeyboardSize = useSharedValue(0);\n const scrollBeforeKeyboardMovement = useSharedValue(0);\n const { input, update } = useReanimatedFocusedInput();\n const layout = useSharedValue<FocusedInputLayoutChangedEvent | null>(null);\n const lastSelection =\n useSharedValue<FocusedInputSelectionChangedEvent | null>(null);\n\n const { height } = useWindowDimensions();\n\n const onScrollViewLayout = useCallback(\n (e: LayoutChangeEvent) => {\n scrollViewTarget.value = findNodeHandle(scrollViewAnimatedRef.current);\n\n onLayout?.(e);\n },\n [onLayout],\n );\n\n /**\n * Function that will scroll a ScrollView as keyboard gets moving.\n */\n const maybeScroll = useCallback(\n (e: number, animated: boolean = false) => {\n \"worklet\";\n\n if (!enabled) {\n return 0;\n }\n\n // input belongs to ScrollView\n if (layout.value?.parentScrollViewTarget !== scrollViewTarget.value) {\n return 0;\n }\n\n const visibleRect = height - keyboardHeight.value;\n const absoluteY = layout.value?.layout.absoluteY || 0;\n const inputHeight = layout.value?.layout.height || 0;\n const point = absoluteY + inputHeight;\n\n if (visibleRect - point <= bottomOffset) {\n const relativeScrollTo =\n keyboardHeight.value - (height - point) + bottomOffset;\n const interpolatedScrollTo = interpolate(\n e,\n [initialKeyboardSize.value, keyboardHeight.value],\n [\n 0,\n scrollDistanceWithRespectToSnapPoints(\n relativeScrollTo + scrollPosition.value,\n snapToOffsets,\n ) - scrollPosition.value,\n ],\n );\n const targetScrollY =\n Math.max(interpolatedScrollTo, 0) + scrollPosition.value;\n\n scrollTo(scrollViewAnimatedRef, 0, targetScrollY, animated);\n\n return interpolatedScrollTo;\n }\n\n if (point < 0) {\n const positionOnScreen = visibleRect - bottomOffset;\n const topOfScreen = scrollPosition.value + point;\n\n scrollTo(\n scrollViewAnimatedRef,\n 0,\n topOfScreen - positionOnScreen,\n animated,\n );\n }\n\n return 0;\n },\n [bottomOffset, enabled, height, snapToOffsets],\n );\n const performScrollWithPositionRestoration = useCallback(\n (newPosition: number) => {\n \"worklet\";\n\n const prevScroll = scrollPosition.value;\n\n // eslint-disable-next-line react-compiler/react-compiler\n scrollPosition.value = newPosition;\n maybeScroll(keyboardHeight.value, true);\n scrollPosition.value = prevScroll;\n },\n [scrollPosition, keyboardHeight, maybeScroll],\n );\n const syncKeyboardFrame = useCallback(\n (e: NativeEvent) => {\n \"worklet\";\n\n const keyboardFrame = interpolate(\n e.height,\n [0, keyboardHeight.value],\n [0, keyboardHeight.value + extraKeyboardSpace],\n );\n\n currentKeyboardFrameHeight.value = keyboardFrame;\n },\n [extraKeyboardSpace],\n );\n\n const updateLayoutFromSelection = useCallback(() => {\n \"worklet\";\n\n const customHeight = lastSelection.value?.selection.end.y;\n\n if (!input.value?.layout || !customHeight) {\n return false;\n }\n\n layout.value = {\n ...input.value,\n layout: {\n ...input.value.layout,\n // when we have multiline input with limited amount of lines, then custom height can be very big\n // so we clamp it to max input height\n height: clamp(customHeight, 0, input.value.layout.height),\n },\n };\n\n return true;\n }, [input, lastSelection, layout]);\n const scrollFromCurrentPosition = useCallback(() => {\n \"worklet\";\n\n const prevLayout = layout.value;\n\n if (!updateLayoutFromSelection()) {\n return;\n }\n\n performScrollWithPositionRestoration(position.value);\n\n layout.value = prevLayout;\n }, [performScrollWithPositionRestoration]);\n const onChangeText = useCallback(() => {\n \"worklet\";\n scrollFromCurrentPosition();\n }, [scrollFromCurrentPosition]);\n const onChangeTextHandler = useMemo(\n () => debounce(onChangeText, 200),\n [onChangeText],\n );\n const onSelectionChange = useCallback(\n (e: FocusedInputSelectionChangedEvent) => {\n \"worklet\";\n\n const lastTarget = lastSelection.value?.target;\n const latestSelection = lastSelection.value?.selection;\n\n lastSelection.value = e;\n\n if (e.target !== lastTarget) {\n // ignore this event, because \"focus changed\" event handled in `useSmoothKeyboardHandler`\n return;\n }\n // caret in the end + end coordinates has been changed -> we moved to a new line\n // so input may grow\n if (\n e.selection.end.position === e.selection.start.position &&\n latestSelection?.end.y !== e.selection.end.y\n ) {\n return scrollFromCurrentPosition();\n }\n // selection has been changed\n if (e.selection.start.position !== e.selection.end.position) {\n return scrollFromCurrentPosition();\n }\n\n onChangeTextHandler();\n },\n [scrollFromCurrentPosition, onChangeTextHandler],\n );\n\n useFocusedInputHandler(\n {\n onSelectionChange: onSelectionChange,\n },\n [onSelectionChange],\n );\n\n useSmoothKeyboardHandler(\n {\n onStart: (e) => {\n \"worklet\";\n\n const keyboardWillChangeSize =\n keyboardHeight.value !== e.height && e.height > 0;\n\n keyboardWillAppear.value = e.height > 0 && keyboardHeight.value === 0;\n\n const keyboardWillHide = e.height === 0;\n const focusWasChanged =\n (tag.value !== e.target && e.target !== -1) ||\n keyboardWillChangeSize;\n\n if (keyboardWillChangeSize) {\n initialKeyboardSize.value = keyboardHeight.value;\n }\n\n if (keyboardWillHide) {\n // on back transition need to interpolate as [0, keyboardHeight]\n initialKeyboardSize.value = 0;\n scrollPosition.value = scrollBeforeKeyboardMovement.value;\n }\n\n if (\n keyboardWillAppear.value ||\n keyboardWillChangeSize ||\n focusWasChanged\n ) {\n // persist scroll value\n scrollPosition.value = position.value;\n // just persist height - later will be used in interpolation\n keyboardHeight.value = e.height;\n }\n\n // focus was changed\n if (focusWasChanged) {\n tag.value = e.target;\n // save position of focused text input when keyboard starts to move\n updateLayoutFromSelection();\n // save current scroll position - when keyboard will hide we'll reuse\n // this value to achieve smooth hide effect\n scrollBeforeKeyboardMovement.value = position.value;\n }\n\n if (focusWasChanged && !keyboardWillAppear.value) {\n // update position on scroll value, so `onEnd` handler\n // will pick up correct values\n position.value += maybeScroll(e.height, true);\n }\n },\n onMove: (e) => {\n \"worklet\";\n\n syncKeyboardFrame(e);\n\n // if the user has set disableScrollOnKeyboardHide, only auto-scroll when the keyboard opens\n if (!disableScrollOnKeyboardHide || keyboardWillAppear.value) {\n maybeScroll(e.height);\n }\n },\n onEnd: (e) => {\n \"worklet\";\n\n keyboardHeight.value = e.height;\n scrollPosition.value = position.value;\n\n syncKeyboardFrame(e);\n },\n },\n [maybeScroll, disableScrollOnKeyboardHide, syncKeyboardFrame],\n );\n\n const synchronize = useCallback(async () => {\n await update();\n\n runOnUI(() => {\n \"worklet\";\n\n scrollFromCurrentPosition();\n })();\n }, [update, scrollFromCurrentPosition]);\n\n useImperativeHandle(\n ref,\n () => {\n const scrollView = scrollViewRef.current;\n\n const existingMethods = scrollView ? { ...scrollView } : {};\n\n return {\n ...existingMethods,\n\n assureFocusedInputVisible: () => {\n synchronize();\n },\n } as KeyboardAwareScrollViewRef;\n },\n [synchronize],\n );\n\n useEffect(() => {\n synchronize();\n }, [bottomOffset]);\n\n useAnimatedReaction(\n () => input.value,\n (current, previous) => {\n if (\n current?.target === previous?.target &&\n current?.layout.height !== previous?.layout.height\n ) {\n // input has changed layout - let's check if we need to scroll\n // may happen when you paste text, then onSelectionChange will be\n // fired earlier than text actually changes its layout\n scrollFromCurrentPosition();\n }\n },\n [],\n );\n\n const view = useAnimatedStyle(\n () =>\n enabled\n ? {\n // animations become choppy when scrolling to the end of the `ScrollView` (when the last input is focused)\n // this happens because the layout recalculates on every frame. To avoid this we slightly increase padding\n // by `+1`. In this way we assure, that `scrollTo` will never scroll to the end, because it uses interpolation\n // from 0 to `keyboardHeight`, and here our padding is `keyboardHeight + 1`. It allows us not to re-run layout\n // re-calculation on every animation frame and it helps to achieve smooth animation.\n // see: https://github.com/kirillzyusko/react-native-keyboard-controller/pull/342\n paddingBottom: currentKeyboardFrameHeight.value + 1,\n }\n : {},\n [enabled],\n );\n\n return (\n <ScrollViewComponent\n ref={onRef}\n {...rest}\n scrollEventThrottle={16}\n onLayout={onScrollViewLayout}\n >\n {children}\n {enabled && <Reanimated.View style={view} />}\n </ScrollViewComponent>\n );\n },\n);\n\nexport default KeyboardAwareScrollView;\n"],"mappings":";AAAA,OAAOA,KAAK,IACVC,UAAU,EACVC,WAAW,EACXC,SAAS,EACTC,mBAAmB,EACnBC,OAAO,QACF,OAAO;AACd,OAAOC,UAAU,IACfC,KAAK,EACLC,WAAW,EACXC,OAAO,EACPC,QAAQ,EACRC,mBAAmB,EACnBC,cAAc,EACdC,gBAAgB,EAChBC,mBAAmB,EACnBC,cAAc,QACT,yBAAyB;AAEhC,SACEC,sBAAsB,EACtBC,yBAAyB,EACzBC,mBAAmB,QACd,aAAa;AACpB,SAASC,cAAc,QAAQ,4BAA4B;AAC3D,OAAOC,cAAc,MAAM,yBAAyB;AAEpD,SAASC,wBAAwB,QAAQ,4BAA4B;AACrE,SAASC,QAAQ,EAAEC,qCAAqC,QAAQ,SAAS;AA6BzE;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;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,uBAAuB,gBAAGvB,UAAU,CAIxC,CACE;EACEwB,QAAQ;EACRC,QAAQ;EACRC,YAAY,GAAG,CAAC;EAChBC,2BAA2B,GAAG,KAAK;EACnCC,OAAO,GAAG,IAAI;EACdC,k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AAO,uBAAPA,OAAO,CAAEN,MAAM,CAACE,MAAM,OAAKuD,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEzD,MAAM,CAACE,MAAM,GAClD;MACA;MACA;MACA;MACAkC,yBAAyB,CAAC,CAAC;IAC7B;EACF,CAAC,EACD,EACF,CAAC;EAED,MAAMsB,IAAI,GAAGhG,gBAAgB,CAC3B,MACEgB,OAAO,GACH;IACE;IACA;IACA;IACA;IACA;IACA;IACAiF,aAAa,EAAEnE,0BAA0B,CAACa,KAAK,GAAG;EACpD,CAAC,GACD,CAAC,CAAC,EACR,CAAC3B,OAAO,CACV,CAAC;EAED,oBACE7B,KAAA,CAAA+G,aAAA,CAAChF,mBAAmB,EAAAiF,QAAA;IAClB7E,GAAG,EAAEI;EAAM,GACPL,IAAI;IACR+E,mBAAmB,EAAE,EAAG;IACxBvF,QAAQ,EAAE4B;EAAmB,IAE5B7B,QAAQ,EACRI,OAAO,iBAAI7B,KAAA,CAAA+G,aAAA,CAACzG,UAAU,CAAC4G,IAAI;IAACC,KAAK,EAAEN;EAAK,CAAE,CACxB,CAAC;AAE1B,CACF,CAAC;AAED,eAAerF,uBAAuB","ignoreList":[]}
1
+ {"version":3,"names":["React","forwardRef","useCallback","useEffect","useImperativeHandle","useMemo","Reanimated","clamp","interpolate","runOnUI","scrollTo","useAnimatedReaction","useAnimatedRef","useDerivedValue","useSharedValue","useFocusedInputHandler","useReanimatedFocusedInput","useWindowDimensions","findNodeHandle","useCombinedRef","useScrollState","ScrollViewWithBottomPadding","useSmoothKeyboardHandler","debounce","scrollDistanceWithRespectToSnapPoints","KeyboardAwareScrollView","children","onLayout","bottomOffset","disableScrollOnKeyboardHide","enabled","extraKeyboardSpace","ScrollViewComponent","ScrollView","snapToOffsets","rest","ref","scrollViewAnimatedRef","scrollViewRef","useRef","onRef","scrollViewTarget","scrollPosition","offset","position","layout","scrollViewLayout","size","scrollViewContentSize","currentKeyboardFrameHeight","keyboardHeight","keyboardWillAppear","tag","initialKeyboardSize","scrollBeforeKeyboardMovement","input","update","lastSelection","ghostViewSpace","pendingSelectionForFocus","height","onScrollViewLayout","e","value","current","maybeScroll","animated","_layout$value","_layout$value2","_layout$value3","parentScrollViewTarget","visibleRect","absoluteY","inputHeight","point","relativeScrollTo","interpolatedScrollTo","targetScrollY","Math","max","positionOnScreen","topOfScreen","removeGhostPadding","performScrollWithPositionRestoration","newPosition","prevScroll","syncKeyboardFrame","keyboardFrame","updateLayoutFromSelection","_lastSelection$value","_input$value","customHeight","selection","end","y","scrollFromCurrentPosition","prevLayout","onChangeText","onChangeTextHandler","onSelectionChange","_lastSelection$value2","_lastSelection$value3","lastTarget","target","latestSelection","start","onStart","keyboardWillChangeSize","keyboardWillHide","focusWasChanged","_lastSelection$value4","onMove","onEnd","synchronize","scrollView","existingMethods","assureFocusedInputVisible","previous","padding","createElement","_extends","bottomPadding","scrollEventThrottle"],"sources":["index.tsx"],"sourcesContent":["import React, {\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n} from \"react\";\nimport Reanimated, {\n clamp,\n interpolate,\n runOnUI,\n scrollTo,\n useAnimatedReaction,\n useAnimatedRef,\n useDerivedValue,\n useSharedValue,\n} from \"react-native-reanimated\";\n\nimport {\n useFocusedInputHandler,\n useReanimatedFocusedInput,\n useWindowDimensions,\n} from \"../../hooks\";\nimport { findNodeHandle } from \"../../utils/findNodeHandle\";\nimport useCombinedRef from \"../hooks/useCombinedRef\";\nimport useScrollState from \"../hooks/useScrollState\";\nimport ScrollViewWithBottomPadding from \"../ScrollViewWithBottomPadding\";\n\nimport { useSmoothKeyboardHandler } from \"./useSmoothKeyboardHandler\";\nimport { debounce, scrollDistanceWithRespectToSnapPoints } from \"./utils\";\n\nimport type { AnimatedScrollViewComponent } from \"../ScrollViewWithBottomPadding\";\nimport type {\n LayoutChangeEvent,\n ScrollView,\n ScrollViewProps,\n} from \"react-native\";\nimport type {\n FocusedInputLayoutChangedEvent,\n FocusedInputSelectionChangedEvent,\n NativeEvent,\n} from \"react-native-keyboard-controller\";\n\nexport type KeyboardAwareScrollViewProps = {\n /** The distance between the keyboard and the caret inside a focused `TextInput` when the keyboard is shown. Default is `0`. */\n bottomOffset?: number;\n /** Prevents automatic scrolling of the `ScrollView` when the keyboard gets hidden, maintaining the current screen position. Default is `false`. */\n disableScrollOnKeyboardHide?: boolean;\n /** Controls whether this `KeyboardAwareScrollView` instance should take effect. Default is `true`. */\n enabled?: boolean;\n /** Adjusting the bottom spacing of KeyboardAwareScrollView. Default is `0`. */\n extraKeyboardSpace?: number;\n /** Custom component for `ScrollView`. Default is `ScrollView`. */\n ScrollViewComponent?: AnimatedScrollViewComponent;\n} & ScrollViewProps;\nexport type KeyboardAwareScrollViewRef = {\n assureFocusedInputVisible: () => void;\n} & ScrollView;\n\n// Everything begins from `onStart` handler. This handler is called every time,\n// when keyboard changes its size or when focused `TextInput` was changed. In\n// this handler we are calculating/memoizing values which later will be used\n// during layout movement. For that we calculate:\n// - layout of focused field (`layout`) - to understand whether there will be overlap\n// - initial keyboard size (`initialKeyboardSize`) - used in scroll interpolation\n// - future keyboard height (`keyboardHeight`) - used in scroll interpolation\n// - current scroll position (`scrollPosition`) - used to scroll from this point\n//\n// Once we've calculated all necessary variables - we can actually start to use them.\n// It happens in `onMove` handler - this function simply calls `maybeScroll` with\n// current keyboard frame height. This functions makes the smooth transition.\n//\n// When the transition has finished we go to `onEnd` handler. In this handler\n// we verify, that the current field is not overlapped within a keyboard frame.\n// For full `onStart`/`onMove`/`onEnd` flow it may look like a redundant thing,\n// however there could be some cases, when `onMove` is not called:\n// - on iOS when TextInput was changed - keyboard transition is instant\n// - on Android when TextInput was changed and keyboard size wasn't changed\n// So `onEnd` handler handle the case, when `onMove` wasn't triggered.\n//\n// ====================================================================================================================+\n// -----------------------------------------------------Flow chart-----------------------------------------------------+\n// ====================================================================================================================+\n//\n// +============================+ +============================+ +==================================+\n// + User Press on TextInput + => + Keyboard starts showing + => + As keyboard moves frame by frame + =>\n// + + + (run `onStart`) + + `onMove` is getting called +\n// +============================+ +============================+ +==================================+\n//\n// +============================+ +============================+ +=====================================+\n// + Keyboard is shown and we + => + User moved focus to + => + Only `onStart`/`onEnd` maybe called +\n// + call `onEnd` handler + + another `TextInput` + + (without involving `onMove`) +\n// +============================+ +============================+ +=====================================+\n//\n\n/**\n * A ScrollView component that automatically handles keyboard appearance and disappearance\n * by adjusting its content position to ensure the focused input remains visible.\n *\n * The component uses a sophisticated animation system to smoothly handle keyboard transitions\n * and maintain proper scroll position during keyboard interactions.\n *\n * @returns A ScrollView component that handles keyboard interactions.\n * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/components/keyboard-aware-scroll-view|Documentation} page for more details.\n * @example\n * ```tsx\n * <KeyboardAwareScrollView bottomOffset={20}>\n * <TextInput placeholder=\"Enter text\" />\n * <TextInput placeholder=\"Another input\" />\n * </KeyboardAwareScrollView>\n * ```\n */\nconst KeyboardAwareScrollView = forwardRef<\n KeyboardAwareScrollViewRef,\n React.PropsWithChildren<KeyboardAwareScrollViewProps>\n>(\n (\n {\n children,\n onLayout,\n bottomOffset = 0,\n disableScrollOnKeyboardHide = false,\n enabled = true,\n extraKeyboardSpace = 0,\n ScrollViewComponent = Reanimated.ScrollView,\n snapToOffsets,\n ...rest\n },\n ref,\n ) => {\n const scrollViewAnimatedRef = useAnimatedRef<Reanimated.ScrollView>();\n const scrollViewRef = React.useRef<ScrollView>(null);\n const onRef = useCombinedRef(scrollViewAnimatedRef, scrollViewRef);\n const scrollViewTarget = useSharedValue<number | null>(null);\n const scrollPosition = useSharedValue(0);\n const {\n offset: position,\n layout: scrollViewLayout,\n size: scrollViewContentSize,\n } = useScrollState(scrollViewAnimatedRef);\n const currentKeyboardFrameHeight = useSharedValue(0);\n const keyboardHeight = useSharedValue(0);\n const keyboardWillAppear = useSharedValue(false);\n const tag = useSharedValue(-1);\n const initialKeyboardSize = useSharedValue(0);\n const scrollBeforeKeyboardMovement = useSharedValue(0);\n const { input, update } = useReanimatedFocusedInput();\n const layout = useSharedValue<FocusedInputLayoutChangedEvent | null>(null);\n const lastSelection =\n useSharedValue<FocusedInputSelectionChangedEvent | null>(null);\n const ghostViewSpace = useSharedValue(-1);\n const pendingSelectionForFocus = useSharedValue(false);\n\n const { height } = useWindowDimensions();\n\n const onScrollViewLayout = useCallback(\n (e: LayoutChangeEvent) => {\n scrollViewTarget.value = findNodeHandle(scrollViewAnimatedRef.current);\n\n onLayout?.(e);\n },\n [onLayout],\n );\n\n /**\n * Function that will scroll a ScrollView as keyboard gets moving.\n */\n const maybeScroll = useCallback(\n (e: number, animated: boolean = false) => {\n \"worklet\";\n\n if (!enabled) {\n return 0;\n }\n\n // input belongs to ScrollView\n if (layout.value?.parentScrollViewTarget !== scrollViewTarget.value) {\n return 0;\n }\n\n const visibleRect = height - keyboardHeight.value;\n const absoluteY = layout.value?.layout.absoluteY || 0;\n const inputHeight = layout.value?.layout.height || 0;\n const point = absoluteY + inputHeight;\n\n if (visibleRect - point <= bottomOffset) {\n const relativeScrollTo =\n keyboardHeight.value - (height - point) + bottomOffset;\n const interpolatedScrollTo = interpolate(\n e,\n [initialKeyboardSize.value, keyboardHeight.value],\n [\n 0,\n scrollDistanceWithRespectToSnapPoints(\n relativeScrollTo + scrollPosition.value,\n snapToOffsets,\n ) - scrollPosition.value,\n ],\n );\n const targetScrollY =\n Math.max(interpolatedScrollTo, 0) + scrollPosition.value;\n\n scrollTo(scrollViewAnimatedRef, 0, targetScrollY, animated);\n\n return interpolatedScrollTo;\n }\n\n if (point < 0) {\n const positionOnScreen = visibleRect - bottomOffset;\n const topOfScreen = scrollPosition.value + point;\n\n scrollTo(\n scrollViewAnimatedRef,\n 0,\n topOfScreen - positionOnScreen,\n animated,\n );\n }\n\n return 0;\n },\n [bottomOffset, enabled, height, snapToOffsets],\n );\n const removeGhostPadding = useCallback((e: number) => {\n \"worklet\";\n\n // new `ScrollViewWithBottomPadding` behavior: if we hide keyboard and we are in the end of `ScrollView`\n // then we always need to scroll back, because we apply a padding that doesn't change layout, so we will\n // not have auto scroll back in this case\n if (!keyboardWillAppear.value && ghostViewSpace.value > 0) {\n scrollTo(\n scrollViewAnimatedRef,\n 0,\n scrollPosition.value -\n interpolate(\n e,\n [initialKeyboardSize.value, keyboardHeight.value],\n [ghostViewSpace.value, 0],\n ),\n false,\n );\n\n return true;\n }\n\n return false;\n }, []);\n const performScrollWithPositionRestoration = useCallback(\n (newPosition: number) => {\n \"worklet\";\n\n const prevScroll = scrollPosition.value;\n\n // eslint-disable-next-line react-compiler/react-compiler\n scrollPosition.value = newPosition;\n maybeScroll(keyboardHeight.value, true);\n scrollPosition.value = prevScroll;\n },\n [scrollPosition, keyboardHeight, maybeScroll],\n );\n const syncKeyboardFrame = useCallback(\n (e: NativeEvent) => {\n \"worklet\";\n\n const keyboardFrame = interpolate(\n e.height,\n [0, keyboardHeight.value],\n [0, keyboardHeight.value + extraKeyboardSpace],\n );\n\n currentKeyboardFrameHeight.value = keyboardFrame;\n },\n [extraKeyboardSpace],\n );\n\n const updateLayoutFromSelection = useCallback(() => {\n \"worklet\";\n\n const customHeight = lastSelection.value?.selection.end.y;\n\n if (!input.value?.layout || !customHeight) {\n return false;\n }\n\n layout.value = {\n ...input.value,\n layout: {\n ...input.value.layout,\n // when we have multiline input with limited amount of lines, then custom height can be very big\n // so we clamp it to max input height\n height: clamp(customHeight, 0, input.value.layout.height),\n },\n };\n\n return true;\n }, [input, lastSelection, layout]);\n const scrollFromCurrentPosition = useCallback(() => {\n \"worklet\";\n\n const prevLayout = layout.value;\n\n if (!updateLayoutFromSelection()) {\n return;\n }\n\n performScrollWithPositionRestoration(position.value);\n\n layout.value = prevLayout;\n }, [performScrollWithPositionRestoration]);\n const onChangeText = useCallback(() => {\n \"worklet\";\n scrollFromCurrentPosition();\n }, [scrollFromCurrentPosition]);\n const onChangeTextHandler = useMemo(\n () => debounce(onChangeText, 200),\n [onChangeText],\n );\n const onSelectionChange = useCallback(\n (e: FocusedInputSelectionChangedEvent) => {\n \"worklet\";\n\n const lastTarget = lastSelection.value?.target;\n const latestSelection = lastSelection.value?.selection;\n\n lastSelection.value = e;\n\n if (e.target !== lastTarget) {\n if (pendingSelectionForFocus.value) {\n // selection arrived after onStart - complete the deferred setup\n pendingSelectionForFocus.value = false;\n updateLayoutFromSelection();\n\n // if keyboard was already visible (focus change, no onMove expected),\n // perform the deferred scroll now\n if (!keyboardWillAppear.value && keyboardHeight.value > 0) {\n position.value += maybeScroll(keyboardHeight.value, true);\n }\n }\n\n return;\n }\n // caret in the end + end coordinates has been changed -> we moved to a new line\n // so input may grow\n if (\n e.selection.end.position === e.selection.start.position &&\n latestSelection?.end.y !== e.selection.end.y\n ) {\n return scrollFromCurrentPosition();\n }\n // selection has been changed\n if (e.selection.start.position !== e.selection.end.position) {\n return scrollFromCurrentPosition();\n }\n\n onChangeTextHandler();\n },\n [\n scrollFromCurrentPosition,\n onChangeTextHandler,\n updateLayoutFromSelection,\n maybeScroll,\n ],\n );\n\n useFocusedInputHandler(\n {\n onSelectionChange: onSelectionChange,\n },\n [onSelectionChange],\n );\n\n useSmoothKeyboardHandler(\n {\n onStart: (e) => {\n \"worklet\";\n\n const keyboardWillChangeSize =\n keyboardHeight.value !== e.height && e.height > 0;\n\n keyboardWillAppear.value = e.height > 0 && keyboardHeight.value === 0;\n\n const keyboardWillHide = e.height === 0;\n const focusWasChanged =\n (tag.value !== e.target && e.target !== -1) ||\n keyboardWillChangeSize;\n\n if (keyboardWillChangeSize) {\n initialKeyboardSize.value = keyboardHeight.value;\n }\n\n if (keyboardWillHide) {\n // on back transition need to interpolate as [0, keyboardHeight]\n initialKeyboardSize.value = 0;\n scrollPosition.value = scrollBeforeKeyboardMovement.value;\n pendingSelectionForFocus.value = false;\n }\n\n if (\n keyboardWillAppear.value ||\n keyboardWillChangeSize ||\n focusWasChanged\n ) {\n // persist scroll value\n scrollPosition.value = position.value;\n // just persist height - later will be used in interpolation\n keyboardHeight.value = e.height;\n }\n\n // focus was changed\n if (focusWasChanged) {\n tag.value = e.target;\n\n if (lastSelection.value?.target === e.target) {\n // selection arrived before onStart - use it to update layout\n updateLayoutFromSelection();\n pendingSelectionForFocus.value = false;\n } else {\n // selection hasn't arrived yet for the new target.\n // use input layout as-is; will be refined when selection arrives.\n if (input.value) {\n layout.value = input.value;\n }\n pendingSelectionForFocus.value = true;\n }\n\n // save current scroll position - when keyboard will hide we'll reuse\n // this value to achieve smooth hide effect\n scrollBeforeKeyboardMovement.value = position.value;\n }\n\n if (focusWasChanged && !keyboardWillAppear.value) {\n if (!pendingSelectionForFocus.value) {\n // update position on scroll value, so `onEnd` handler\n // will pick up correct values\n position.value += maybeScroll(e.height, true);\n }\n }\n\n ghostViewSpace.value =\n position.value +\n scrollViewLayout.value.height -\n scrollViewContentSize.value.height;\n\n if (ghostViewSpace.value > 0) {\n scrollPosition.value = position.value;\n }\n },\n onMove: (e) => {\n \"worklet\";\n\n syncKeyboardFrame(e);\n\n if (removeGhostPadding(e.height)) {\n return;\n }\n\n // if the user has set disableScrollOnKeyboardHide, only auto-scroll when the keyboard opens\n if (!disableScrollOnKeyboardHide || keyboardWillAppear.value) {\n maybeScroll(e.height);\n }\n },\n onEnd: (e) => {\n \"worklet\";\n\n removeGhostPadding(e.height);\n\n keyboardHeight.value = e.height;\n scrollPosition.value = position.value;\n\n if (e.height === 0) {\n lastSelection.value = null;\n }\n\n syncKeyboardFrame(e);\n },\n },\n [\n maybeScroll,\n removeGhostPadding,\n disableScrollOnKeyboardHide,\n syncKeyboardFrame,\n ],\n );\n\n const synchronize = useCallback(async () => {\n await update();\n\n runOnUI(() => {\n \"worklet\";\n\n scrollFromCurrentPosition();\n })();\n }, [update, scrollFromCurrentPosition]);\n\n useImperativeHandle(\n ref,\n () => {\n const scrollView = scrollViewRef.current;\n\n const existingMethods = scrollView ? { ...scrollView } : {};\n\n return {\n ...existingMethods,\n\n assureFocusedInputVisible: () => {\n synchronize();\n },\n } as KeyboardAwareScrollViewRef;\n },\n [synchronize],\n );\n\n useEffect(() => {\n synchronize();\n }, [bottomOffset]);\n\n useAnimatedReaction(\n () => input.value,\n (current, previous) => {\n if (\n current?.target === previous?.target &&\n current?.layout.height !== previous?.layout.height\n ) {\n // input has changed layout - let's check if we need to scroll\n // may happen when you paste text, then onSelectionChange will be\n // fired earlier than text actually changes its layout\n scrollFromCurrentPosition();\n }\n },\n [],\n );\n\n // animations become choppy when scrolling to the end of the `ScrollView` (when the last input is focused)\n // this happens because the layout recalculates on every frame. To avoid this we slightly increase padding\n // by `+1`. In this way we assure, that `scrollTo` will never scroll to the end, because it uses interpolation\n // from 0 to `keyboardHeight`, and here our padding is `keyboardHeight + 1`. It allows us not to re-run layout\n // re-calculation on every animation frame and it helps to achieve smooth animation.\n // see: https://github.com/kirillzyusko/react-native-keyboard-controller/pull/342\n const padding = useDerivedValue(\n () => (enabled ? currentKeyboardFrameHeight.value + 1 : 0),\n [enabled],\n );\n\n return (\n <ScrollViewWithBottomPadding\n ref={onRef}\n {...rest}\n bottomPadding={padding}\n scrollEventThrottle={16}\n ScrollViewComponent={ScrollViewComponent}\n onLayout={onScrollViewLayout}\n >\n {children}\n </ScrollViewWithBottomPadding>\n );\n },\n);\n\nexport default KeyboardAwareScrollView;\n"],"mappings":";AAAA,OAAOA,KAAK,IACVC,UAAU,EACVC,WAAW,EACXC,SAAS,EACTC,mBAAmB,EACnBC,OAAO,QACF,OAAO;AACd,OAAOC,UAAU,IACfC,KAAK,EACLC,WAAW,EACXC,OAAO,EACPC,QAAQ,EACRC,mBAAmB,EACnBC,cAAc,EACdC,eAAe,EACfC,cAAc,QACT,yBAAyB;AAEhC,SACEC,sBAAsB,EACtBC,yBAAyB,EACzBC,mBAAmB,QACd,aAAa;AACpB,SAASC,cAAc,QAAQ,4BAA4B;AAC3D,OAAOC,cAAc,MAAM,yBAAyB;AACpD,OAAOC,cAAc,MAAM,yBAAyB;AACpD,OAAOC,2BAA2B,MAAM,gCAAgC;AAExE,SAASC,wBAAwB,Q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PA,OAAO,CAAEnB,MAAM,CAACe,MAAM,OAAKyD,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAExE,MAAM,CAACe,MAAM,GAClD;MACA;MACA;MACA;MACAmC,yBAAyB,CAAC,CAAC;IAC7B;EACF,CAAC,EACD,EACF,CAAC;;EAED;EACA;EACA;EACA;EACA;EACA;EACA,MAAMuB,OAAO,GAAGzG,eAAe,CAC7B,MAAOiB,OAAO,GAAGmB,0BAA0B,CAACc,KAAK,GAAG,CAAC,GAAG,CAAE,EAC1D,CAACjC,OAAO,CACV,CAAC;EAED,oBACE9B,KAAA,CAAAuH,aAAA,CAAClG,2BAA2B,EAAAmG,QAAA;IAC1BpF,GAAG,EAAEI;EAAM,GACPL,IAAI;IACRsF,aAAa,EAAEH,OAAQ;IACvBI,mBAAmB,EAAE,EAAG;IACxB1F,mBAAmB,EAAEA,mBAAoB;IACzCL,QAAQ,EAAEkC;EAAmB,IAE5BnC,QAC0B,CAAC;AAElC,CACF,CAAC;AAED,eAAeD,uBAAuB","ignoreList":[]}
@@ -0,0 +1,35 @@
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
+ import React, { forwardRef } from "react";
3
+ import { Platform } from "react-native";
4
+ import Reanimated, { useAnimatedProps } from "react-native-reanimated";
5
+ import { ClippingScrollView } from "../../bindings";
6
+ import styles from "./styles";
7
+ const ReanimatedClippingScrollView = Platform.OS === "android" ? Reanimated.createAnimatedComponent(ClippingScrollView) : ClippingScrollView;
8
+ const ScrollViewWithBottomPadding = /*#__PURE__*/forwardRef(({
9
+ ScrollViewComponent,
10
+ bottomPadding,
11
+ contentInset,
12
+ children,
13
+ ...rest
14
+ }, ref) => {
15
+ const animatedProps = useAnimatedProps(() => ({
16
+ // iOS prop
17
+ contentInset: {
18
+ bottom: bottomPadding.value + ((contentInset === null || contentInset === void 0 ? void 0 : contentInset.bottom) || 0),
19
+ top: contentInset === null || contentInset === void 0 ? void 0 : contentInset.top,
20
+ right: contentInset === null || contentInset === void 0 ? void 0 : contentInset.right,
21
+ left: contentInset === null || contentInset === void 0 ? void 0 : contentInset.left
22
+ },
23
+ // Android prop
24
+ contentInsetBottom: bottomPadding.value
25
+ }), [contentInset === null || contentInset === void 0 ? void 0 : contentInset.bottom, contentInset === null || contentInset === void 0 ? void 0 : contentInset.top, contentInset === null || contentInset === void 0 ? void 0 : contentInset.right, contentInset === null || contentInset === void 0 ? void 0 : contentInset.left]);
26
+ return /*#__PURE__*/React.createElement(ReanimatedClippingScrollView, {
27
+ animatedProps: animatedProps,
28
+ style: styles.container
29
+ }, /*#__PURE__*/React.createElement(ScrollViewComponent, _extends({
30
+ ref: ref,
31
+ animatedProps: animatedProps
32
+ }, rest), children));
33
+ });
34
+ export default ScrollViewWithBottomPadding;
35
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","forwardRef","Platform","Reanimated","useAnimatedProps","ClippingScrollView","styles","ReanimatedClippingScrollView","OS","createAnimatedComponent","ScrollViewWithBottomPadding","ScrollViewComponent","bottomPadding","contentInset","children","rest","ref","animatedProps","bottom","value","top","right","left","contentInsetBottom","createElement","style","container","_extends"],"sources":["index.tsx"],"sourcesContent":["import React, { forwardRef } from \"react\";\nimport { Platform } from \"react-native\";\nimport Reanimated, { useAnimatedProps } from \"react-native-reanimated\";\n\nimport { ClippingScrollView } from \"../../bindings\";\n\nimport styles from \"./styles\";\n\nimport type { ScrollViewProps } from \"react-native\";\nimport type { SharedValue } from \"react-native-reanimated\";\n\nconst ReanimatedClippingScrollView =\n Platform.OS === \"android\"\n ? Reanimated.createAnimatedComponent(ClippingScrollView)\n : ClippingScrollView;\n\ntype AnimatedScrollViewProps = React.ComponentProps<\n typeof Reanimated.ScrollView\n>;\n\nexport type AnimatedScrollViewComponent = React.ForwardRefExoticComponent<\n AnimatedScrollViewProps & React.RefAttributes<Reanimated.ScrollView>\n>;\n\ntype ScrollViewWithBottomPaddingProps = {\n ScrollViewComponent: AnimatedScrollViewComponent;\n children?: React.ReactNode;\n bottomPadding: SharedValue<number>;\n} & ScrollViewProps;\n\nconst ScrollViewWithBottomPadding = forwardRef<\n Reanimated.ScrollView,\n ScrollViewWithBottomPaddingProps\n>(\n (\n { ScrollViewComponent, bottomPadding, contentInset, children, ...rest },\n ref,\n ) => {\n const animatedProps = useAnimatedProps(\n () => ({\n // iOS prop\n contentInset: {\n bottom: bottomPadding.value + (contentInset?.bottom || 0),\n top: contentInset?.top,\n right: contentInset?.right,\n left: contentInset?.left,\n },\n // Android prop\n contentInsetBottom: bottomPadding.value,\n }),\n [\n contentInset?.bottom,\n contentInset?.top,\n contentInset?.right,\n contentInset?.left,\n ],\n );\n\n return (\n <ReanimatedClippingScrollView\n animatedProps={animatedProps}\n style={styles.container}\n >\n <ScrollViewComponent ref={ref} animatedProps={animatedProps} {...rest}>\n {children}\n </ScrollViewComponent>\n </ReanimatedClippingScrollView>\n );\n },\n);\n\nexport default ScrollViewWithBottomPadding;\n"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;AACzC,SAASC,QAAQ,QAAQ,cAAc;AACvC,OAAOC,UAAU,IAAIC,gBAAgB,QAAQ,yBAAyB;AAEtE,SAASC,kBAAkB,QAAQ,gBAAgB;AAEnD,OAAOC,MAAM,MAAM,UAAU;AAK7B,MAAMC,4BAA4B,GAChCL,QAAQ,CAACM,EAAE,KAAK,SAAS,GACrBL,UAAU,CAACM,uBAAuB,CAACJ,kBAAkB,CAAC,GACtDA,kBAAkB;AAgBxB,MAAMK,2BAA2B,gBAAGT,UAAU,CAI5C,CACE;EAAEU,mBAAmB;EAAEC,aAAa;EAAEC,YAAY;EAAEC,QAAQ;EAAE,GAAGC;AAAK,CAAC,EACvEC,GAAG,KACA;EACH,MAAMC,aAAa,GAAGb,gBAAgB,CACpC,OAAO;IACL;IACAS,YAAY,EAAE;MACZK,MAAM,EAAEN,aAAa,CAACO,KAAK,IAAI,CAAAN,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAEK,MAAM,KAAI,CAAC,CAAC;MACzDE,GAAG,EAAEP,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAEO,GAAG;MACtBC,KAAK,EAAER,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAEQ,KAAK;MAC1BC,IAAI,EAAET,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAES;IACtB,CAAC;IACD;IACAC,kBAAkB,EAAEX,aAAa,CAACO;EACpC,CAAC,CAAC,EACF,CACEN,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAEK,MAAM,EACpBL,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAEO,GAAG,EACjBP,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAEQ,KAAK,EACnBR,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAES,IAAI,CAEtB,CAAC;EAED,oBACEtB,KAAA,CAAAwB,aAAA,CAACjB,4BAA4B;IAC3BU,aAAa,EAAEA,aAAc;IAC7BQ,KAAK,EAAEnB,MAAM,CAACoB;EAAU,gBAExB1B,KAAA,CAAAwB,aAAA,CAACb,mBAAmB,EAAAgB,QAAA;IAACX,GAAG,EAAEA,GAAI;IAACC,aAAa,EAAEA;EAAc,GAAKF,IAAI,GAClED,QACkB,CACO,CAAC;AAEnC,CACF,CAAC;AAED,eAAeJ,2BAA2B","ignoreList":[]}
@@ -0,0 +1,8 @@
1
+ import { StyleSheet } from "react-native";
2
+ const styles = StyleSheet.create({
3
+ container: {
4
+ flex: 1
5
+ }
6
+ });
7
+ export default styles;
8
+ //# sourceMappingURL=styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["StyleSheet","styles","create","container","flex"],"sources":["styles.ts"],"sourcesContent":["import { StyleSheet } from \"react-native\";\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n },\n});\n\nexport default styles;\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,cAAc;AAEzC,MAAMC,MAAM,GAAGD,UAAU,CAACE,MAAM,CAAC;EAC/BC,SAAS,EAAE;IACTC,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAEF,eAAeH,MAAM","ignoreList":[]}
@@ -0,0 +1,37 @@
1
+ import { useEffect } from "react";
2
+ import { useEvent, useSharedValue } from "react-native-reanimated";
3
+ import { useEventHandlerRegistration } from "../../internal";
4
+ const NATIVE_SCROLL_EVENT_NAMES = ["onScroll", "onScrollBeginDrag", "onScrollEndDrag", "onMomentumScrollBegin", "onMomentumScrollEnd"];
5
+ const useScrollState = ref => {
6
+ const offset = useSharedValue(0);
7
+ const layout = useSharedValue({
8
+ width: 0,
9
+ height: 0
10
+ });
11
+ const size = useSharedValue({
12
+ width: 0,
13
+ height: 0
14
+ });
15
+ const register = useEventHandlerRegistration(ref);
16
+ const eventHandler = useEvent(event => {
17
+ "worklet";
18
+
19
+ // eslint-disable-next-line react-compiler/react-compiler
20
+ offset.value = event.contentOffset.y;
21
+ layout.value = event.layoutMeasurement;
22
+ size.value = event.contentSize;
23
+ }, NATIVE_SCROLL_EVENT_NAMES);
24
+ useEffect(() => {
25
+ const cleanup = register(eventHandler);
26
+ return () => {
27
+ cleanup();
28
+ };
29
+ }, []);
30
+ return {
31
+ offset,
32
+ layout,
33
+ size
34
+ };
35
+ };
36
+ export default useScrollState;
37
+ //# sourceMappingURL=useScrollState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useEffect","useEvent","useSharedValue","useEventHandlerRegistration","NATIVE_SCROLL_EVENT_NAMES","useScrollState","ref","offset","layout","width","height","size","register","eventHandler","event","value","contentOffset","y","layoutMeasurement","contentSize","cleanup"],"sources":["useScrollState.ts"],"sourcesContent":["import { useEffect } from \"react\";\nimport { useEvent, useSharedValue } from \"react-native-reanimated\";\n\nimport { useEventHandlerRegistration } from \"../../internal\";\n\nimport type { AnimatedRef } from \"react-native-reanimated\";\nimport type Reanimated from \"react-native-reanimated\";\n\nconst NATIVE_SCROLL_EVENT_NAMES = [\n \"onScroll\",\n \"onScrollBeginDrag\",\n \"onScrollEndDrag\",\n \"onMomentumScrollBegin\",\n \"onMomentumScrollEnd\",\n];\n\ntype ScrollEvent = {\n contentOffset: {\n x: number;\n y: number;\n };\n layoutMeasurement: {\n width: number;\n height: number;\n };\n contentSize: {\n width: number;\n height: number;\n };\n};\n\nconst useScrollState = (ref: AnimatedRef<Reanimated.ScrollView>) => {\n const offset = useSharedValue(0);\n const layout = useSharedValue({ width: 0, height: 0 });\n const size = useSharedValue({ width: 0, height: 0 });\n\n const register = useEventHandlerRegistration(ref);\n\n const eventHandler = useEvent((event: ScrollEvent) => {\n \"worklet\";\n\n // eslint-disable-next-line react-compiler/react-compiler\n offset.value = event.contentOffset.y;\n layout.value = event.layoutMeasurement;\n size.value = event.contentSize;\n }, NATIVE_SCROLL_EVENT_NAMES);\n\n useEffect(() => {\n const cleanup = register(eventHandler);\n\n return () => {\n cleanup();\n };\n }, []);\n\n return { offset, layout, size };\n};\n\nexport default useScrollState;\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,OAAO;AACjC,SAASC,QAAQ,EAAEC,cAAc,QAAQ,yBAAyB;AAElE,SAASC,2BAA2B,QAAQ,gBAAgB;AAK5D,MAAMC,yBAAyB,GAAG,CAChC,UAAU,EACV,mBAAmB,EACnB,iBAAiB,EACjB,uBAAuB,EACvB,qBAAqB,CACtB;AAiBD,MAAMC,cAAc,GAAIC,GAAuC,IAAK;EAClE,MAAMC,MAAM,GAAGL,cAAc,CAAC,CAAC,CAAC;EAChC,MAAMM,MAAM,GAAGN,cAAc,CAAC;IAAEO,KAAK,EAAE,CAAC;IAAEC,MAAM,EAAE;EAAE,CAAC,CAAC;EACtD,MAAMC,IAAI,GAAGT,cAAc,CAAC;IAAEO,KAAK,EAAE,CAAC;IAAEC,MAAM,EAAE;EAAE,CAAC,CAAC;EAEpD,MAAME,QAAQ,GAAGT,2BAA2B,CAACG,GAAG,CAAC;EAEjD,MAAMO,YAAY,GAAGZ,QAAQ,CAAEa,KAAkB,IAAK;IACpD,SAAS;;IAET;IACAP,MAAM,CAACQ,KAAK,GAAGD,KAAK,CAACE,aAAa,CAACC,CAAC;IACpCT,MAAM,CAACO,KAAK,GAAGD,KAAK,CAACI,iBAAiB;IACtCP,IAAI,CAACI,KAAK,GAAGD,KAAK,CAACK,WAAW;EAChC,CAAC,EAAEf,yBAAyB,CAAC;EAE7BJ,SAAS,CAAC,MAAM;IACd,MAAMoB,OAAO,GAAGR,QAAQ,CAACC,YAAY,CAAC;IAEtC,OAAO,MAAM;MACXO,OAAO,CAAC,CAAC;IACX,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,OAAO;IAAEb,MAAM;IAAEC,MAAM;IAAEG;EAAK,CAAC;AACjC,CAAC;AAED,eAAeN,cAAc","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ import { codegenNativeComponent } from "react-native";
2
+ export default codegenNativeComponent("ClippingScrollViewDecoratorView", {
3
+ interfaceOnly: true,
4
+ excludedPlatforms: ["iOS"]
5
+ });
6
+ //# sourceMappingURL=ClippingScrollViewDecoratorViewNativeComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["codegenNativeComponent","interfaceOnly","excludedPlatforms"],"sources":["ClippingScrollViewDecoratorViewNativeComponent.ts"],"sourcesContent":["import { codegenNativeComponent } from \"react-native\";\n\nimport type { HostComponent } from \"react-native\";\nimport type { ViewProps } from \"react-native\";\nimport type { Double } from \"react-native/Libraries/Types/CodegenTypes\";\n\nexport interface NativeProps extends ViewProps {\n contentInsetBottom: Double;\n}\n\nexport default codegenNativeComponent<NativeProps>(\n \"ClippingScrollViewDecoratorView\",\n {\n interfaceOnly: true,\n excludedPlatforms: [\"iOS\"],\n },\n) as HostComponent<NativeProps>;\n"],"mappings":"AAAA,SAASA,sBAAsB,QAAQ,cAAc;AAUrD,eAAeA,sBAAsB,CACnC,iCAAiC,EACjC;EACEC,aAAa,EAAE,IAAI;EACnBC,iBAAiB,EAAE,CAAC,KAAK;AAC3B,CACF,CAAC","ignoreList":[]}
@@ -1 +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}>;\nexport type KeyboardBackgroundViewProps = PropsWithChildren<ViewProps>;\nexport type KeyboardExtenderProps = PropsWithChildren<{\n /** Controls whether this `KeyboardExtender` instance should take an effect. Default is `true`. */\n enabled?: boolean;\n}>;\n"],"mappings":"","ignoreList":[]}
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}>;\nexport type KeyboardBackgroundViewProps = PropsWithChildren<ViewProps>;\nexport type KeyboardExtenderProps = PropsWithChildren<{\n /** Controls whether this `KeyboardExtender` instance should take an effect. Default is `true`. */\n enabled?: boolean;\n}>;\nexport type ClippingScrollViewProps = PropsWithChildren<\n ViewProps & {\n /** An additional space that gets applied to the bottom of the `ScrollView` (inside a scrollable content). Default is `0`. */\n contentInsetBottom?: number;\n }\n>;\n"],"mappings":"","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import type { FocusedInputEventsModule, KeyboardBackgroundViewProps, KeyboardControllerNativeModule, KeyboardControllerProps, KeyboardEventsModule, KeyboardExtenderProps, KeyboardGestureAreaProps, OverKeyboardViewProps, WindowDimensionsEventsModule } from "./types";
1
+ import type { ClippingScrollViewProps, FocusedInputEventsModule, KeyboardBackgroundViewProps, KeyboardControllerNativeModule, KeyboardControllerProps, KeyboardEventsModule, KeyboardExtenderProps, KeyboardGestureAreaProps, OverKeyboardViewProps, WindowDimensionsEventsModule } from "./types";
2
2
  export declare const KeyboardControllerNative: KeyboardControllerNativeModule;
3
3
  /**
4
4
  * An event emitter that provides a way to subscribe to next keyboard events:
@@ -45,3 +45,9 @@ export declare const KeyboardBackgroundView: React.FC<KeyboardBackgroundViewProp
45
45
  * @see {@link https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-extender|Documentation} page for more details.
46
46
  */
47
47
  export declare const RCTKeyboardExtender: React.FC<KeyboardExtenderProps>;
48
+ /**
49
+ * A decorator that will clip the content of the `ScrollView`. It helps to simulate `contentInset` behavior on Android.
50
+ * Supports only `bottom` property (`paddingBottom` is not supported property of `ScrollView.style`).
51
+ * Using this component we can modify bottom inset without having a fake view.
52
+ */
53
+ export declare const ClippingScrollView: React.FC<ClippingScrollViewProps>;
@@ -13,3 +13,4 @@ export declare const KeyboardGestureArea: React.FC<KeyboardGestureAreaProps>;
13
13
  export declare const RCTOverKeyboardView: React.FC<OverKeyboardViewProps>;
14
14
  export declare const KeyboardBackgroundView: React.FC<KeyboardBackgroundViewProps>;
15
15
  export declare const RCTKeyboardExtender: React.FC<KeyboardExtenderProps>;
16
+ export declare const ClippingScrollView: React.FC<KeyboardBackgroundViewProps>;
@@ -1,4 +1,5 @@
1
1
  import React from "react";
2
+ import type { AnimatedScrollViewComponent } from "../ScrollViewWithBottomPadding";
2
3
  import type { ScrollView, ScrollViewProps } from "react-native";
3
4
  export type KeyboardAwareScrollViewProps = {
4
5
  /** The distance between the keyboard and the caret inside a focused `TextInput` when the keyboard is shown. Default is `0`. */
@@ -10,7 +11,7 @@ export type KeyboardAwareScrollViewProps = {
10
11
  /** Adjusting the bottom spacing of KeyboardAwareScrollView. Default is `0`. */
11
12
  extraKeyboardSpace?: number;
12
13
  /** Custom component for `ScrollView`. Default is `ScrollView`. */
13
- ScrollViewComponent?: React.ComponentType<ScrollViewProps>;
14
+ ScrollViewComponent?: AnimatedScrollViewComponent;
14
15
  } & ScrollViewProps;
15
16
  export type KeyboardAwareScrollViewRef = {
16
17
  assureFocusedInputVisible: () => void;
@@ -42,7 +43,7 @@ declare const KeyboardAwareScrollView: React.ForwardRefExoticComponent<{
42
43
  /** Adjusting the bottom spacing of KeyboardAwareScrollView. Default is `0`. */
43
44
  extraKeyboardSpace?: number;
44
45
  /** Custom component for `ScrollView`. Default is `ScrollView`. */
45
- ScrollViewComponent?: React.ComponentType<ScrollViewProps>;
46
+ ScrollViewComponent?: AnimatedScrollViewComponent;
46
47
  } & ScrollViewProps & {
47
48
  children?: React.ReactNode | undefined;
48
49
  } & React.RefAttributes<KeyboardAwareScrollViewRef>>;
@@ -0,0 +1,12 @@
1
+ import React from "react";
2
+ import Reanimated from "react-native-reanimated";
3
+ import type { ScrollViewProps } from "react-native";
4
+ import type { SharedValue } from "react-native-reanimated";
5
+ type AnimatedScrollViewProps = React.ComponentProps<typeof Reanimated.ScrollView>;
6
+ export type AnimatedScrollViewComponent = React.ForwardRefExoticComponent<AnimatedScrollViewProps & React.RefAttributes<Reanimated.ScrollView>>;
7
+ declare const ScrollViewWithBottomPadding: React.ForwardRefExoticComponent<{
8
+ ScrollViewComponent: AnimatedScrollViewComponent;
9
+ children?: React.ReactNode;
10
+ bottomPadding: SharedValue<number>;
11
+ } & ScrollViewProps & React.RefAttributes<Reanimated.ScrollView>>;
12
+ export default ScrollViewWithBottomPadding;
@@ -0,0 +1,6 @@
1
+ declare const styles: {
2
+ container: {
3
+ flex: number;
4
+ };
5
+ };
6
+ export default styles;
@@ -0,0 +1,14 @@
1
+ import type { AnimatedRef } from "react-native-reanimated";
2
+ import type Reanimated from "react-native-reanimated";
3
+ declare const useScrollState: (ref: AnimatedRef<Reanimated.ScrollView>) => {
4
+ offset: import("react-native-reanimated").SharedValue<number>;
5
+ layout: import("react-native-reanimated").SharedValue<{
6
+ width: number;
7
+ height: number;
8
+ }>;
9
+ size: import("react-native-reanimated").SharedValue<{
10
+ width: number;
11
+ height: number;
12
+ }>;
13
+ };
14
+ export default useScrollState;
@@ -0,0 +1,8 @@
1
+ import type { HostComponent } from "react-native";
2
+ import type { ViewProps } from "react-native";
3
+ import type { Double } from "react-native/Libraries/Types/CodegenTypes";
4
+ export interface NativeProps extends ViewProps {
5
+ contentInsetBottom: Double;
6
+ }
7
+ declare const _default: HostComponent<NativeProps>;
8
+ export default _default;
@@ -48,3 +48,7 @@ export type KeyboardExtenderProps = PropsWithChildren<{
48
48
  /** Controls whether this `KeyboardExtender` instance should take an effect. Default is `true`. */
49
49
  enabled?: boolean;
50
50
  }>;
51
+ export type ClippingScrollViewProps = PropsWithChildren<ViewProps & {
52
+ /** An additional space that gets applied to the bottom of the `ScrollView` (inside a scrollable content). Default is `0`. */
53
+ contentInsetBottom?: number;
54
+ }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-keyboard-controller",
3
- "version": "1.20.7",
3
+ "version": "1.21.0-beta.0",
4
4
  "description": "Keyboard manager which works in identical way on both iOS and Android",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -41,7 +41,7 @@
41
41
  "typescript": "tsc --noEmit --project tsconfig.build.json",
42
42
  "lint": "eslint --quiet \"**/*.{js,ts,tsx}\"",
43
43
  "lint-clang": "find ios/ -iname *.h -o -iname *.m -o -iname *.mm | grep -v -e Pods -e build | xargs clang-format -i -n --Werror",
44
- "prepare": "bob build > /dev/null 2>&1",
44
+ "prepare": "bob build",
45
45
  "release": "release-it",
46
46
  "example": "yarn --cwd example",
47
47
  "pods": "cd example && pod-install --quiet",
@@ -187,5 +187,6 @@
187
187
  "KeyboardExtender": "KeyboardExtender"
188
188
  }
189
189
  }
190
- }
190
+ },
191
+ "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
191
192
  }