react-native-keyboard-controller 1.10.5 → 1.11.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.
- package/README.md +1 -0
- package/android/build.gradle +6 -0
- package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardControllerModule.kt +4 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/events/FocusedInputLayoutChangedEvent.kt +2 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/EditText.kt +22 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/ThemedReactContext.kt +9 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/{InteractiveKeyboardProvider.kt → interactive/InteractiveKeyboardProvider.kt} +1 -1
- package/android/src/main/java/com/reactnativekeyboardcontroller/{KeyboardAnimationController.kt → interactive/KeyboardAnimationController.kt} +1 -1
- package/android/src/main/java/com/reactnativekeyboardcontroller/{interpolators → interactive/interpolators}/Interpolator.kt +1 -1
- package/android/src/main/java/com/reactnativekeyboardcontroller/{interpolators → interactive/interpolators}/IosInterpolator.kt +1 -1
- package/android/src/main/java/com/reactnativekeyboardcontroller/{interpolators → interactive/interpolators}/LinearInterpolator.kt +1 -1
- package/android/src/main/java/com/reactnativekeyboardcontroller/listeners/FocusedInputObserver.kt +20 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/listeners/KeyboardAnimationCallback.kt +8 -14
- package/android/src/main/java/com/reactnativekeyboardcontroller/modules/KeyboardControllerModuleImpl.kt +15 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/traversal/FocusedInputHolder.kt +16 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/traversal/ViewHierarchyNavigator.kt +101 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/views/KeyboardGestureAreaReactViewGroup.kt +4 -4
- package/android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardControllerModule.kt +5 -0
- package/android/src/test/java/com/reactnativekeyboardcontroller/traversal/ViewHierarchyNavigatorTest.kt +188 -0
- package/ios/.swiftlint.yml +4 -0
- package/ios/Extensions.swift +29 -0
- package/ios/KeyboardController.xcodeproj/project.pbxproj +20 -0
- package/ios/KeyboardControllerModule.mm +18 -0
- package/ios/events/FocusedInputLayoutChangedEvent.m +3 -0
- package/ios/observers/FocusedInputObserver.swift +20 -4
- package/ios/observers/KeyboardMovementObserver.swift +5 -4
- package/ios/traversal/FocusedInputHolder.swift +32 -0
- package/ios/traversal/TextInput.swift +26 -0
- package/ios/traversal/ViewHierarchyNavigator.swift +116 -0
- package/ios/views/KeyboardControllerView.mm +10 -0
- package/ios/views/KeyboardControllerViewManager.swift +4 -1
- package/jest/index.js +20 -0
- package/lib/commonjs/bindings.js +12 -1
- package/lib/commonjs/bindings.js.map +1 -1
- package/lib/commonjs/bindings.native.js +11 -2
- package/lib/commonjs/bindings.native.js.map +1 -1
- package/lib/commonjs/components/KeyboardAwareScrollView/index.js +18 -6
- package/lib/commonjs/components/KeyboardAwareScrollView/index.js.map +1 -1
- package/lib/commonjs/components/KeyboardToolbar/Arrow.js +79 -0
- package/lib/commonjs/components/KeyboardToolbar/Arrow.js.map +1 -0
- package/lib/commonjs/components/KeyboardToolbar/Button.js +74 -0
- package/lib/commonjs/components/KeyboardToolbar/Button.js.map +1 -0
- package/lib/commonjs/components/KeyboardToolbar/colors.js +41 -0
- package/lib/commonjs/components/KeyboardToolbar/colors.js.map +1 -0
- package/lib/commonjs/components/KeyboardToolbar/index.js +136 -0
- package/lib/commonjs/components/KeyboardToolbar/index.js.map +1 -0
- package/lib/commonjs/components/hooks/useColorScheme.js +11 -0
- package/lib/commonjs/components/hooks/useColorScheme.js.map +1 -0
- package/lib/commonjs/components/hooks/useKeyboardInterpolation.js +3 -2
- package/lib/commonjs/components/hooks/useKeyboardInterpolation.js.map +1 -1
- package/lib/commonjs/components/index.js +21 -0
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/index.js +22 -13
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
- package/lib/commonjs/specs/NativeKeyboardController.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/bindings.js +10 -0
- package/lib/module/bindings.js.map +1 -1
- package/lib/module/bindings.native.js +9 -1
- package/lib/module/bindings.native.js.map +1 -1
- package/lib/module/components/KeyboardAwareScrollView/index.js +18 -6
- package/lib/module/components/KeyboardAwareScrollView/index.js.map +1 -1
- package/lib/module/components/KeyboardToolbar/Arrow.js +69 -0
- package/lib/module/components/KeyboardToolbar/Arrow.js.map +1 -0
- package/lib/module/components/KeyboardToolbar/Button.js +64 -0
- package/lib/module/components/KeyboardToolbar/Button.js.map +1 -0
- package/lib/module/components/KeyboardToolbar/colors.js +34 -0
- package/lib/module/components/KeyboardToolbar/colors.js.map +1 -0
- package/lib/module/components/KeyboardToolbar/index.js +121 -0
- package/lib/module/components/KeyboardToolbar/index.js.map +1 -0
- package/lib/module/components/hooks/useColorScheme.js +4 -0
- package/lib/module/components/hooks/useColorScheme.js.map +1 -0
- package/lib/module/components/hooks/useKeyboardInterpolation.js +3 -2
- package/lib/module/components/hooks/useKeyboardInterpolation.js.map +1 -1
- package/lib/module/components/index.js +1 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/index.js +3 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
- package/lib/module/specs/NativeKeyboardController.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/bindings.d.ts +6 -1
- package/lib/typescript/bindings.native.d.ts +6 -1
- package/lib/typescript/components/KeyboardToolbar/Arrow.d.ts +9 -0
- package/lib/typescript/components/KeyboardToolbar/Button.d.ts +15 -0
- package/lib/typescript/components/KeyboardToolbar/colors.d.ts +17 -0
- package/lib/typescript/components/KeyboardToolbar/index.d.ts +25 -0
- package/lib/typescript/components/hooks/useColorScheme.d.ts +2 -0
- package/lib/typescript/components/index.d.ts +1 -0
- package/lib/typescript/index.d.ts +1 -2
- package/lib/typescript/specs/KeyboardControllerViewNativeComponent.d.ts +1 -0
- package/lib/typescript/specs/NativeKeyboardController.d.ts +1 -0
- package/lib/typescript/types.d.ts +11 -0
- package/package.json +5 -1
- package/src/bindings.native.ts +11 -1
- package/src/bindings.ts +9 -0
- package/src/components/KeyboardAwareScrollView/index.tsx +22 -2
- package/src/components/KeyboardToolbar/Arrow.tsx +80 -0
- package/src/components/KeyboardToolbar/Button.tsx +98 -0
- package/src/components/KeyboardToolbar/colors.ts +51 -0
- package/src/components/KeyboardToolbar/index.tsx +154 -0
- package/src/components/hooks/useColorScheme.ts +5 -0
- package/src/components/hooks/useKeyboardInterpolation.ts +3 -2
- package/src/components/index.ts +5 -0
- package/src/index.ts +4 -1
- package/src/specs/KeyboardControllerViewNativeComponent.ts +1 -0
- package/src/specs/NativeKeyboardController.ts +1 -0
- package/src/types.ts +14 -0
- package/lib/commonjs/replicas.js +0 -125
- package/lib/commonjs/replicas.js.map +0 -1
- package/lib/module/replicas.js +0 -115
- package/lib/module/replicas.js.map +0 -1
- package/lib/typescript/replicas.d.ts +0 -38
- package/src/replicas.ts +0 -154
|
@@ -54,12 +54,14 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
|
|
|
54
54
|
const KeyboardAwareScrollView = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
55
55
|
let {
|
|
56
56
|
children,
|
|
57
|
+
onLayout,
|
|
57
58
|
bottomOffset = 0,
|
|
58
59
|
disableScrollOnKeyboardHide = false,
|
|
59
60
|
enabled = true,
|
|
60
61
|
...rest
|
|
61
62
|
} = _ref;
|
|
62
63
|
const scrollViewAnimatedRef = (0, _reactNativeReanimated.useAnimatedRef)();
|
|
64
|
+
const scrollViewTarget = (0, _reactNativeReanimated.useSharedValue)(null);
|
|
63
65
|
const scrollPosition = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
64
66
|
const position = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
65
67
|
const currentKeyboardFrameHeight = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
@@ -88,6 +90,10 @@ const KeyboardAwareScrollView = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref)
|
|
|
88
90
|
}
|
|
89
91
|
scrollViewAnimatedRef(assignedRef);
|
|
90
92
|
}, []);
|
|
93
|
+
const onScrollViewLayout = (0, _react.useCallback)(e => {
|
|
94
|
+
scrollViewTarget.value = e.nativeEvent.target;
|
|
95
|
+
onLayout === null || onLayout === void 0 ? void 0 : onLayout(e);
|
|
96
|
+
}, [onLayout]);
|
|
91
97
|
|
|
92
98
|
/**
|
|
93
99
|
* Function that will scroll a ScrollView as keyboard gets moving
|
|
@@ -95,14 +101,19 @@ const KeyboardAwareScrollView = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref)
|
|
|
95
101
|
const maybeScroll = (0, _react.useCallback)(function (e) {
|
|
96
102
|
"worklet";
|
|
97
103
|
|
|
98
|
-
var _layout$value, _layout$value2;
|
|
104
|
+
var _layout$value, _layout$value2, _layout$value3;
|
|
99
105
|
let animated = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
100
106
|
if (!enabled) {
|
|
101
107
|
return 0;
|
|
102
108
|
}
|
|
109
|
+
|
|
110
|
+
// input belongs to ScrollView
|
|
111
|
+
if (((_layout$value = layout.value) === null || _layout$value === void 0 ? void 0 : _layout$value.parentScrollViewTarget) !== scrollViewTarget.value) {
|
|
112
|
+
return 0;
|
|
113
|
+
}
|
|
103
114
|
const visibleRect = height - keyboardHeight.value;
|
|
104
|
-
const absoluteY = ((_layout$
|
|
105
|
-
const inputHeight = ((_layout$
|
|
115
|
+
const absoluteY = ((_layout$value2 = layout.value) === null || _layout$value2 === void 0 ? void 0 : _layout$value2.layout.absoluteY) || 0;
|
|
116
|
+
const inputHeight = ((_layout$value3 = layout.value) === null || _layout$value3 === void 0 ? void 0 : _layout$value3.layout.height) || 0;
|
|
106
117
|
const point = absoluteY + inputHeight;
|
|
107
118
|
if (visibleRect - point <= bottomOffset) {
|
|
108
119
|
const interpolatedScrollTo = (0, _reactNativeReanimated.interpolate)(e, [initialKeyboardSize.value, keyboardHeight.value], [0, keyboardHeight.value - (height - point) + bottomOffset]);
|
|
@@ -122,8 +133,8 @@ const KeyboardAwareScrollView = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref)
|
|
|
122
133
|
|
|
123
134
|
// if typing a text caused layout shift, then we need to ignore this handler
|
|
124
135
|
// because this event will be handled in `useAnimatedReaction` below
|
|
125
|
-
var _layout$
|
|
126
|
-
if (((_layout$
|
|
136
|
+
var _layout$value4, _input$value;
|
|
137
|
+
if (((_layout$value4 = layout.value) === null || _layout$value4 === void 0 ? void 0 : _layout$value4.layout.height) !== ((_input$value = input.value) === null || _input$value === void 0 ? void 0 : _input$value.layout.height)) {
|
|
127
138
|
return;
|
|
128
139
|
}
|
|
129
140
|
const prevScrollPosition = scrollPosition.value;
|
|
@@ -214,7 +225,8 @@ const KeyboardAwareScrollView = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref)
|
|
|
214
225
|
return /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.ScrollView, _extends({
|
|
215
226
|
ref: onRef
|
|
216
227
|
}, rest, {
|
|
217
|
-
// @ts-expect-error
|
|
228
|
+
// @ts-expect-error https://github.com/facebook/react-native/pull/42785
|
|
229
|
+
onLayout: onScrollViewLayout,
|
|
218
230
|
onScrollReanimated: onScroll,
|
|
219
231
|
scrollEventThrottle: 16
|
|
220
232
|
}), children, /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeReanimated","_reactNativeKeyboardController","_useSmoothKeyboardHandler","_utils","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","_extends","assign","bind","target","i","arguments","length","source","apply","KeyboardAwareScrollView","forwardRef","_ref","ref","children","bottomOffset","disableScrollOnKeyboardHide","enabled","rest","scrollViewAnimatedRef","useAnimatedRef","scrollPosition","useSharedValue","position","currentKeyboardFrameHeight","keyboardHeight","keyboardWillAppear","tag","initialKeyboardSize","scrollBeforeKeyboardMovement","input","useReanimatedFocusedInput","layout","height","useWindowDimensions","onScroll","useAnimatedScrollHandler","e","value","contentOffset","y","onRef","useCallback","assignedRef","current","maybeScroll","_layout$value","_layout$value2","animated","undefined","visibleRect","absoluteY","inputHeight","point","interpolatedScrollTo","interpolate","targetScrollY","Math","max","scrollTo","positionOnScreen","topOfScreen","onChangeText","_layout$value3","_input$value","prevScrollPosition","prevLayout","onChangeTextHandler","useMemo","debounce","useFocusedInputHandler","useSmoothKeyboardHandler","onStart","keyboardWillChangeSize","keyboardWillHide","focusWasChanged","onMove","onEnd","useAnimatedReaction","previous","view","useAnimatedStyle","paddingBottom","createElement","ScrollView","onScrollReanimated","scrollEventThrottle","View","style","_default","exports"],"sources":["index.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useMemo } from \"react\";\nimport { useWindowDimensions } from \"react-native\";\nimport Reanimated, {\n interpolate,\n scrollTo,\n useAnimatedReaction,\n useAnimatedRef,\n useAnimatedScrollHandler,\n useAnimatedStyle,\n useSharedValue,\n} from \"react-native-reanimated\";\n\nimport {\n useFocusedInputHandler,\n useReanimatedFocusedInput,\n} from \"react-native-keyboard-controller\";\n\nimport { useSmoothKeyboardHandler } from \"./useSmoothKeyboardHandler\";\nimport { debounce } from \"./utils\";\n\nimport type { ScrollView, ScrollViewProps } from \"react-native\";\nimport type { FocusedInputLayoutChangedEvent } from \"react-native-keyboard-controller\";\n\ntype KeyboardAwareScrollViewProps = {\n /** The distance between keyboard and focused `TextInput` when 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} & ScrollViewProps;\n\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 * +============================+ +============================+ +=====================================+\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 */\nconst KeyboardAwareScrollView = forwardRef<\n ScrollView,\n React.PropsWithChildren<KeyboardAwareScrollViewProps>\n>(\n (\n {\n children,\n bottomOffset = 0,\n disableScrollOnKeyboardHide = false,\n enabled = true,\n ...rest\n },\n ref,\n ) => {\n const scrollViewAnimatedRef = useAnimatedRef<Reanimated.ScrollView>();\n const scrollPosition = useSharedValue(0);\n const position = useSharedValue(0);\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 } = useReanimatedFocusedInput();\n const layout = useSharedValue<FocusedInputLayoutChangedEvent | null>(null);\n\n const { height } = useWindowDimensions();\n\n const onScroll = useAnimatedScrollHandler(\n {\n onScroll: (e) => {\n position.value = e.contentOffset.y;\n },\n },\n [],\n );\n\n const onRef = useCallback((assignedRef: Reanimated.ScrollView) => {\n if (typeof ref === \"function\") {\n ref(assignedRef);\n } else if (ref) {\n ref.current = assignedRef;\n }\n\n scrollViewAnimatedRef(assignedRef);\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 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 interpolatedScrollTo = interpolate(\n e,\n [initialKeyboardSize.value, keyboardHeight.value],\n [0, keyboardHeight.value - (height - point) + bottomOffset],\n );\n const targetScrollY =\n Math.max(interpolatedScrollTo, 0) + scrollPosition.value;\n scrollTo(scrollViewAnimatedRef, 0, targetScrollY, animated);\n\n return interpolatedScrollTo;\n }\n\n if (absoluteY < 0) {\n const positionOnScreen = visibleRect - inputHeight - bottomOffset;\n const topOfScreen = scrollPosition.value + absoluteY;\n\n scrollTo(\n scrollViewAnimatedRef,\n 0,\n topOfScreen - positionOnScreen,\n animated,\n );\n }\n\n return 0;\n },\n [bottomOffset, enabled],\n );\n\n const onChangeText = useCallback(() => {\n \"worklet\";\n\n // if typing a text caused layout shift, then we need to ignore this handler\n // because this event will be handled in `useAnimatedReaction` below\n if (layout.value?.layout.height !== input.value?.layout.height) {\n return;\n }\n\n const prevScrollPosition = scrollPosition.value;\n const prevLayout = layout.value;\n\n scrollPosition.value = position.value;\n layout.value = input.value;\n maybeScroll(keyboardHeight.value, true);\n scrollPosition.value = prevScrollPosition;\n layout.value = prevLayout;\n }, [maybeScroll]);\n\n const onChangeTextHandler = useMemo(\n () => debounce(onChangeText, 200),\n [onChangeText],\n );\n\n useFocusedInputHandler(\n {\n onChangeText: onChangeTextHandler,\n },\n [onChangeTextHandler],\n );\n\n useSmoothKeyboardHandler(\n enabled\n ? {\n onStart: (e) => {\n \"worklet\";\n\n const keyboardWillChangeSize =\n keyboardHeight.value !== e.height && e.height > 0;\n keyboardWillAppear.value =\n e.height > 0 && keyboardHeight.value === 0;\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\n // save position of focused text input when keyboard starts to move\n layout.value = input.value;\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 currentKeyboardFrameHeight.value = e.height;\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 }\n : {},\n [height, maybeScroll, disableScrollOnKeyboardHide, enabled],\n );\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 const prevLayout = layout.value;\n\n layout.value = input.value;\n scrollPosition.value += maybeScroll(keyboardHeight.value, true);\n layout.value = prevLayout;\n }\n },\n [],\n );\n\n const view = useAnimatedStyle(\n () => ({\n // animations become laggy 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 );\n\n return (\n <Reanimated.ScrollView\n ref={onRef}\n {...rest}\n // @ts-expect-error `onScrollReanimated` is a fake prop needed for reanimated to intercept scroll events\n onScrollReanimated={onScroll}\n scrollEventThrottle={16}\n >\n {children}\n <Reanimated.View style={view} />\n </Reanimated.ScrollView>\n );\n },\n);\n\nexport default KeyboardAwareScrollView;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAH,uBAAA,CAAAC,OAAA;AAUA,IAAAG,8BAAA,GAAAH,OAAA;AAKA,IAAAI,yBAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AA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","_reactNative","_reactNativeReanimated","_reactNativeKeyboardController","_useSmoothKeyboardHandler","_utils","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","_extends","assign","bind","target","i","arguments","length","source","apply","KeyboardAwareScrollView","forwardRef","_ref","ref","children","onLayout","bottomOffset","disableScrollOnKeyboardHide","enabled","rest","scrollViewAnimatedRef","useAnimatedRef","scrollViewTarget","useSharedValue","scrollPosition","position","currentKeyboardFrameHeight","keyboardHeight","keyboardWillAppear","tag","initialKeyboardSize","scrollBeforeKeyboardMovement","input","useReanimatedFocusedInput","layout","height","useWindowDimensions","onScroll","useAnimatedScrollHandler","e","value","contentOffset","y","onRef","useCallback","assignedRef","current","onScrollViewLayout","nativeEvent","maybeScroll","_layout$value","_layout$value2","_layout$value3","animated","undefined","parentScrollViewTarget","visibleRect","absoluteY","inputHeight","point","interpolatedScrollTo","interpolate","targetScrollY","Math","max","scrollTo","positionOnScreen","topOfScreen","onChangeText","_layout$value4","_input$value","prevScrollPosition","prevLayout","onChangeTextHandler","useMemo","debounce","useFocusedInputHandler","useSmoothKeyboardHandler","onStart","keyboardWillChangeSize","keyboardWillHide","focusWasChanged","onMove","onEnd","useAnimatedReaction","previous","view","useAnimatedStyle","paddingBottom","createElement","ScrollView","onScrollReanimated","scrollEventThrottle","View","style","_default","exports"],"sources":["index.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useMemo } from \"react\";\nimport { useWindowDimensions } from \"react-native\";\nimport Reanimated, {\n interpolate,\n scrollTo,\n useAnimatedReaction,\n useAnimatedRef,\n useAnimatedScrollHandler,\n useAnimatedStyle,\n useSharedValue,\n} from \"react-native-reanimated\";\n\nimport {\n useFocusedInputHandler,\n useReanimatedFocusedInput,\n} from \"react-native-keyboard-controller\";\n\nimport { useSmoothKeyboardHandler } from \"./useSmoothKeyboardHandler\";\nimport { debounce } from \"./utils\";\n\nimport type {\n LayoutChangeEvent,\n ScrollView,\n ScrollViewProps,\n} from \"react-native\";\nimport type { FocusedInputLayoutChangedEvent } from \"react-native-keyboard-controller\";\n\ntype KeyboardAwareScrollViewProps = {\n /** The distance between keyboard and focused `TextInput` when 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} & ScrollViewProps;\n\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 * +============================+ +============================+ +=====================================+\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 */\nconst KeyboardAwareScrollView = forwardRef<\n ScrollView,\n React.PropsWithChildren<KeyboardAwareScrollViewProps>\n>(\n (\n {\n children,\n onLayout,\n bottomOffset = 0,\n disableScrollOnKeyboardHide = false,\n enabled = true,\n ...rest\n },\n ref,\n ) => {\n const scrollViewAnimatedRef = useAnimatedRef<Reanimated.ScrollView>();\n const scrollViewTarget = useSharedValue<number | null>(null);\n const scrollPosition = useSharedValue(0);\n const position = useSharedValue(0);\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 } = useReanimatedFocusedInput();\n const layout = useSharedValue<FocusedInputLayoutChangedEvent | null>(null);\n\n const { height } = useWindowDimensions();\n\n const onScroll = useAnimatedScrollHandler(\n {\n onScroll: (e) => {\n position.value = e.contentOffset.y;\n },\n },\n [],\n );\n\n const onRef = useCallback((assignedRef: Reanimated.ScrollView) => {\n if (typeof ref === \"function\") {\n ref(assignedRef);\n } else if (ref) {\n ref.current = assignedRef;\n }\n\n scrollViewAnimatedRef(assignedRef);\n }, []);\n const onScrollViewLayout = useCallback(\n (e: LayoutChangeEvent & { nativeEvent: { target: number } }) => {\n scrollViewTarget.value = e.nativeEvent.target;\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 interpolatedScrollTo = interpolate(\n e,\n [initialKeyboardSize.value, keyboardHeight.value],\n [0, keyboardHeight.value - (height - point) + bottomOffset],\n );\n const targetScrollY =\n Math.max(interpolatedScrollTo, 0) + scrollPosition.value;\n scrollTo(scrollViewAnimatedRef, 0, targetScrollY, animated);\n\n return interpolatedScrollTo;\n }\n\n if (absoluteY < 0) {\n const positionOnScreen = visibleRect - inputHeight - bottomOffset;\n const topOfScreen = scrollPosition.value + absoluteY;\n\n scrollTo(\n scrollViewAnimatedRef,\n 0,\n topOfScreen - positionOnScreen,\n animated,\n );\n }\n\n return 0;\n },\n [bottomOffset, enabled],\n );\n\n const onChangeText = useCallback(() => {\n \"worklet\";\n\n // if typing a text caused layout shift, then we need to ignore this handler\n // because this event will be handled in `useAnimatedReaction` below\n if (layout.value?.layout.height !== input.value?.layout.height) {\n return;\n }\n\n const prevScrollPosition = scrollPosition.value;\n const prevLayout = layout.value;\n\n scrollPosition.value = position.value;\n layout.value = input.value;\n maybeScroll(keyboardHeight.value, true);\n scrollPosition.value = prevScrollPosition;\n layout.value = prevLayout;\n }, [maybeScroll]);\n\n const onChangeTextHandler = useMemo(\n () => debounce(onChangeText, 200),\n [onChangeText],\n );\n\n useFocusedInputHandler(\n {\n onChangeText: onChangeTextHandler,\n },\n [onChangeTextHandler],\n );\n\n useSmoothKeyboardHandler(\n enabled\n ? {\n onStart: (e) => {\n \"worklet\";\n\n const keyboardWillChangeSize =\n keyboardHeight.value !== e.height && e.height > 0;\n keyboardWillAppear.value =\n e.height > 0 && keyboardHeight.value === 0;\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\n // save position of focused text input when keyboard starts to move\n layout.value = input.value;\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 currentKeyboardFrameHeight.value = e.height;\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 }\n : {},\n [height, maybeScroll, disableScrollOnKeyboardHide, enabled],\n );\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 const prevLayout = layout.value;\n\n layout.value = input.value;\n scrollPosition.value += maybeScroll(keyboardHeight.value, true);\n layout.value = prevLayout;\n }\n },\n [],\n );\n\n const view = useAnimatedStyle(\n () => ({\n // animations become laggy 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 );\n\n return (\n <Reanimated.ScrollView\n ref={onRef}\n {...rest}\n // @ts-expect-error https://github.com/facebook/react-native/pull/42785\n onLayout={onScrollViewLayout}\n onScrollReanimated={onScroll}\n scrollEventThrottle={16}\n >\n {children}\n <Reanimated.View style={view} />\n </Reanimated.ScrollView>\n );\n },\n);\n\nexport default KeyboardAwareScrollView;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAH,uBAAA,CAAAC,OAAA;AAUA,IAAAG,8BAAA,GAAAH,OAAA;AAKA,IAAAI,yBAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAAmC,SAAAM,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAR,wBAAAY,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAX,GAAA,QAAAW,GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAd,GAAA,EAAAW,GAAA,SAAAI,IAAA,GAAAR,qBAAA,GAAAC,MAAA,C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,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEnD,MAAM,CAACC,MAAM,GAClD;MACA,MAAMqC,UAAU,GAAGtC,MAAM,CAACM,KAAK;MAE/BN,MAAM,CAACM,KAAK,GAAGR,KAAK,CAACQ,KAAK;MAC1BhB,cAAc,CAACgB,KAAK,IAAIS,WAAW,CAACtB,cAAc,CAACa,KAAK,EAAE,IAAI,CAAC;MAC/DN,MAAM,CAACM,KAAK,GAAGgC,UAAU;IAC3B;EACF,CAAC,EACD,EACF,CAAC;EAED,MAAMc,IAAI,GAAG,IAAAC,uCAAgB,EAC3B,OAAO;IACL;IACA;IACA;IACA;IACA;IACA;IACAC,aAAa,EAAE9D,0BAA0B,CAACc,KAAK,GAAG;EACpD,CAAC,CAAC,EACF,EACF,CAAC;EAED,oBACErE,MAAA,CAAAe,OAAA,CAAAuG,aAAA,CAAClH,sBAAA,CAAAW,OAAU,CAACwG,UAAU,EAAAzF,QAAA;IACpBY,GAAG,EAAE8B;EAAM,GACPxB,IAAI;IACR;IACAJ,QAAQ,EAAEgC,kBAAmB;IAC7B4C,kBAAkB,EAAEtD,QAAS;IAC7BuD,mBAAmB,EAAE;EAAG,IAEvB9E,QAAQ,eACT3C,MAAA,CAAAe,OAAA,CAAAuG,aAAA,CAAClH,sBAAA,CAAAW,OAAU,CAAC2G,IAAI;IAACC,KAAK,EAAER;EAAK,CAAE,CACV,CAAC;AAE5B,CACF,CAAC;AAAC,IAAAS,QAAA,GAEarF,uBAAuB;AAAAsF,OAAA,CAAA9G,OAAA,GAAA6G,QAAA"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _useColorScheme = _interopRequireDefault(require("../hooks/useColorScheme"));
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
12
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
13
|
+
const ArrowComponent = _ref => {
|
|
14
|
+
let {
|
|
15
|
+
type,
|
|
16
|
+
disabled,
|
|
17
|
+
theme
|
|
18
|
+
} = _ref;
|
|
19
|
+
const colorScheme = (0, _useColorScheme.default)();
|
|
20
|
+
const color = (0, _react.useMemo)(() => ({
|
|
21
|
+
backgroundColor: disabled ? theme[colorScheme].disabled : theme[colorScheme].primary
|
|
22
|
+
}), [disabled, theme, colorScheme]);
|
|
23
|
+
const left = (0, _react.useMemo)(() => [styles.arrowLeftLine, color], [color]);
|
|
24
|
+
const right = (0, _react.useMemo)(() => [styles.arrowRightLine, color], [color]);
|
|
25
|
+
return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
26
|
+
style: type === "next" ? styles.arrowDownContainer : styles.arrowUpContainer
|
|
27
|
+
}, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
28
|
+
style: styles.arrow
|
|
29
|
+
}, /*#__PURE__*/_react.default.createElement(_reactNative.Animated.View, {
|
|
30
|
+
style: left
|
|
31
|
+
}), /*#__PURE__*/_react.default.createElement(_reactNative.Animated.View, {
|
|
32
|
+
style: right
|
|
33
|
+
})));
|
|
34
|
+
};
|
|
35
|
+
const arrowLine = {
|
|
36
|
+
width: 13,
|
|
37
|
+
height: 2,
|
|
38
|
+
borderRadius: 1
|
|
39
|
+
};
|
|
40
|
+
const arrowUpContainer = {
|
|
41
|
+
marginHorizontal: 5,
|
|
42
|
+
width: 30,
|
|
43
|
+
height: 30,
|
|
44
|
+
justifyContent: "center",
|
|
45
|
+
alignItems: "center"
|
|
46
|
+
};
|
|
47
|
+
const styles = _reactNative.StyleSheet.create({
|
|
48
|
+
arrowUpContainer: arrowUpContainer,
|
|
49
|
+
arrowDownContainer: {
|
|
50
|
+
...arrowUpContainer,
|
|
51
|
+
transform: [{
|
|
52
|
+
rotate: "180deg"
|
|
53
|
+
}]
|
|
54
|
+
},
|
|
55
|
+
arrow: {
|
|
56
|
+
width: 20,
|
|
57
|
+
height: 20,
|
|
58
|
+
flexDirection: "row",
|
|
59
|
+
alignItems: "center",
|
|
60
|
+
justifyContent: "space-between"
|
|
61
|
+
},
|
|
62
|
+
arrowLeftLine: {
|
|
63
|
+
...arrowLine,
|
|
64
|
+
transform: [{
|
|
65
|
+
rotate: "-45deg"
|
|
66
|
+
}],
|
|
67
|
+
left: -0.5
|
|
68
|
+
},
|
|
69
|
+
arrowRightLine: {
|
|
70
|
+
...arrowLine,
|
|
71
|
+
transform: [{
|
|
72
|
+
rotate: "45deg"
|
|
73
|
+
}],
|
|
74
|
+
left: -5.5
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
var _default = ArrowComponent;
|
|
78
|
+
exports.default = _default;
|
|
79
|
+
//# sourceMappingURL=Arrow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_useColorScheme","_interopRequireDefault","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","ArrowComponent","_ref","type","disabled","theme","colorScheme","useColorScheme","color","useMemo","backgroundColor","primary","left","styles","arrowLeftLine","right","arrowRightLine","createElement","View","style","arrowDownContainer","arrowUpContainer","arrow","Animated","arrowLine","width","height","borderRadius","marginHorizontal","justifyContent","alignItems","StyleSheet","create","transform","rotate","flexDirection","_default","exports"],"sources":["Arrow.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport { Animated, StyleSheet, View } from \"react-native\";\n\nimport useColorScheme from \"../hooks/useColorScheme\";\n\nimport type { KeyboardToolbarTheme } from \"./colors\";\nimport type { ViewStyle } from \"react-native\";\n\ntype ArrowProps = {\n type: \"prev\" | \"next\";\n disabled?: boolean;\n theme: KeyboardToolbarTheme;\n};\n\nconst ArrowComponent: React.FC<ArrowProps> = ({ type, disabled, theme }) => {\n const colorScheme = useColorScheme();\n\n const color = useMemo(\n () => ({\n backgroundColor: disabled\n ? theme[colorScheme].disabled\n : theme[colorScheme].primary,\n }),\n [disabled, theme, colorScheme],\n );\n const left = useMemo(() => [styles.arrowLeftLine, color], [color]);\n const right = useMemo(() => [styles.arrowRightLine, color], [color]);\n\n return (\n <View\n style={\n type === \"next\" ? styles.arrowDownContainer : styles.arrowUpContainer\n }\n >\n <View style={styles.arrow}>\n <Animated.View style={left} />\n <Animated.View style={right} />\n </View>\n </View>\n );\n};\n\nconst arrowLine: ViewStyle = {\n width: 13,\n height: 2,\n borderRadius: 1,\n};\nconst arrowUpContainer: ViewStyle = {\n marginHorizontal: 5,\n width: 30,\n height: 30,\n justifyContent: \"center\",\n alignItems: \"center\",\n};\nconst styles = StyleSheet.create({\n arrowUpContainer: arrowUpContainer,\n arrowDownContainer: {\n ...arrowUpContainer,\n transform: [{ rotate: \"180deg\" }],\n },\n arrow: {\n width: 20,\n height: 20,\n flexDirection: \"row\",\n alignItems: \"center\",\n justifyContent: \"space-between\",\n },\n arrowLeftLine: {\n ...arrowLine,\n transform: [{ rotate: \"-45deg\" }],\n left: -0.5,\n },\n arrowRightLine: {\n ...arrowLine,\n transform: [{ rotate: \"45deg\" }],\n left: -5.5,\n },\n});\n\nexport default ArrowComponent;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,eAAA,GAAAC,sBAAA,CAAAH,OAAA;AAAqD,SAAAG,uBAAAC,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAT,wBAAAK,GAAA,EAAAI,WAAA,SAAAA,WAAA,IAAAJ,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAQ,KAAA,GAAAL,wBAAA,CAAAC,WAAA,OAAAI,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAT,GAAA,YAAAQ,KAAA,CAAAE,GAAA,CAAAV,GAAA,SAAAW,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAhB,GAAA,QAAAgB,GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAnB,GAAA,EAAAgB,GAAA,SAAAI,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,CAAC,CAAC;AAAC,IAAAwB,QAAA,GAEYnC,cAAc;AAAAoC,OAAA,CAAAxD,OAAA,GAAAuD,QAAA"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _useColorScheme = _interopRequireDefault(require("../hooks/useColorScheme"));
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
12
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
13
|
+
const ButtonIOS = _ref => {
|
|
14
|
+
let {
|
|
15
|
+
children,
|
|
16
|
+
onPress,
|
|
17
|
+
disabled,
|
|
18
|
+
accessibilityLabel,
|
|
19
|
+
accessibilityHint,
|
|
20
|
+
testID,
|
|
21
|
+
style
|
|
22
|
+
} = _ref;
|
|
23
|
+
// immediately switch to plain view to avoid animation flickering
|
|
24
|
+
// when fade out animation happens and view becomes disabled
|
|
25
|
+
const Container = disabled ? _reactNative.View : _reactNative.TouchableOpacity;
|
|
26
|
+
const accessibilityState = (0, _react.useMemo)(() => ({
|
|
27
|
+
disabled
|
|
28
|
+
}), [disabled]);
|
|
29
|
+
return /*#__PURE__*/_react.default.createElement(Container, {
|
|
30
|
+
accessibilityState: accessibilityState,
|
|
31
|
+
accessibilityRole: "button",
|
|
32
|
+
accessibilityLabel: accessibilityLabel,
|
|
33
|
+
accessibilityHint: accessibilityHint,
|
|
34
|
+
onPress: onPress,
|
|
35
|
+
style: style,
|
|
36
|
+
testID: testID
|
|
37
|
+
}, children);
|
|
38
|
+
};
|
|
39
|
+
const ButtonAndroid = _ref2 => {
|
|
40
|
+
let {
|
|
41
|
+
children,
|
|
42
|
+
onPress,
|
|
43
|
+
disabled,
|
|
44
|
+
accessibilityLabel,
|
|
45
|
+
accessibilityHint,
|
|
46
|
+
testID,
|
|
47
|
+
rippleRadius = 18,
|
|
48
|
+
style,
|
|
49
|
+
theme
|
|
50
|
+
} = _ref2;
|
|
51
|
+
const colorScheme = (0, _useColorScheme.default)();
|
|
52
|
+
const accessibilityState = (0, _react.useMemo)(() => ({
|
|
53
|
+
disabled
|
|
54
|
+
}), [disabled]);
|
|
55
|
+
const ripple = (0, _react.useMemo)(() => _reactNative.TouchableNativeFeedback.Ripple(theme[colorScheme].ripple, true, rippleRadius), [colorScheme, rippleRadius, theme]);
|
|
56
|
+
return /*#__PURE__*/_react.default.createElement(_reactNative.TouchableNativeFeedback, {
|
|
57
|
+
accessibilityState: accessibilityState,
|
|
58
|
+
accessibilityRole: "button",
|
|
59
|
+
accessibilityLabel: accessibilityLabel,
|
|
60
|
+
accessibilityHint: accessibilityHint,
|
|
61
|
+
onPress: onPress,
|
|
62
|
+
background: ripple,
|
|
63
|
+
testID: testID,
|
|
64
|
+
style: style
|
|
65
|
+
}, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
66
|
+
style: style
|
|
67
|
+
}, children));
|
|
68
|
+
};
|
|
69
|
+
var _default = _reactNative.Platform.select({
|
|
70
|
+
android: ButtonAndroid,
|
|
71
|
+
default: ButtonIOS
|
|
72
|
+
});
|
|
73
|
+
exports.default = _default;
|
|
74
|
+
//# sourceMappingURL=Button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_useColorScheme","_interopRequireDefault","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","ButtonIOS","_ref","children","onPress","disabled","accessibilityLabel","accessibilityHint","testID","style","Container","View","TouchableOpacity","accessibilityState","useMemo","createElement","accessibilityRole","ButtonAndroid","_ref2","rippleRadius","theme","colorScheme","useColorScheme","ripple","TouchableNativeFeedback","Ripple","background","_default","Platform","select","android","exports"],"sources":["Button.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport {\n Platform,\n TouchableNativeFeedback,\n TouchableOpacity,\n View,\n} from \"react-native\";\n\nimport useColorScheme from \"../hooks/useColorScheme\";\n\nimport type { KeyboardToolbarTheme } from \"./colors\";\nimport type { PropsWithChildren } from \"react\";\nimport type { ViewStyle } from \"react-native\";\n\ntype ButtonProps = {\n disabled?: boolean;\n onPress: () => void;\n accessibilityLabel: string;\n accessibilityHint: string;\n testID: string;\n rippleRadius?: number;\n style?: ViewStyle;\n theme: KeyboardToolbarTheme;\n};\n\nconst ButtonIOS = ({\n children,\n onPress,\n disabled,\n accessibilityLabel,\n accessibilityHint,\n testID,\n style,\n}: PropsWithChildren<ButtonProps>) => {\n // immediately switch to plain view to avoid animation flickering\n // when fade out animation happens and view becomes disabled\n const Container = disabled\n ? (View as unknown as typeof TouchableOpacity)\n : TouchableOpacity;\n const accessibilityState = useMemo(() => ({ disabled }), [disabled]);\n\n return (\n <Container\n accessibilityState={accessibilityState}\n accessibilityRole=\"button\"\n accessibilityLabel={accessibilityLabel}\n accessibilityHint={accessibilityHint}\n onPress={onPress}\n style={style}\n testID={testID}\n >\n {children}\n </Container>\n );\n};\nconst ButtonAndroid = ({\n children,\n onPress,\n disabled,\n accessibilityLabel,\n accessibilityHint,\n testID,\n rippleRadius = 18,\n style,\n theme,\n}: PropsWithChildren<ButtonProps>) => {\n const colorScheme = useColorScheme();\n const accessibilityState = useMemo(() => ({ disabled }), [disabled]);\n const ripple = useMemo(\n () =>\n TouchableNativeFeedback.Ripple(\n theme[colorScheme].ripple,\n true,\n rippleRadius,\n ),\n [colorScheme, rippleRadius, theme],\n );\n\n return (\n <TouchableNativeFeedback\n accessibilityState={accessibilityState}\n accessibilityRole=\"button\"\n accessibilityLabel={accessibilityLabel}\n accessibilityHint={accessibilityHint}\n onPress={onPress}\n background={ripple}\n testID={testID}\n style={style}\n >\n <View style={style}>{children}</View>\n </TouchableNativeFeedback>\n );\n};\n\nexport default Platform.select({\n android: ButtonAndroid,\n default: ButtonIOS,\n});\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAOA,IAAAE,eAAA,GAAAC,sBAAA,CAAAH,OAAA;AAAqD,SAAAG,uBAAAC,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAT,wBAAAK,GAAA,EAAAI,WAAA,SAAAA,WAAA,IAAAJ,GAAA,IAAAA,GAA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AAe,CACb,CAAC;AAE9B,CAAC;AAAC,IAAAwB,QAAA,GAEaC,qBAAQ,CAACC,MAAM,CAAC;EAC7BC,OAAO,EAAEb,aAAa;EACtBpC,OAAO,EAAEoB;AACX,CAAC,CAAC;AAAA8B,OAAA,CAAAlD,OAAA,GAAA8C,QAAA"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.colors = void 0;
|
|
7
|
+
var _reactNative = require("react-native");
|
|
8
|
+
const colors = {
|
|
9
|
+
light: {
|
|
10
|
+
primary: _reactNative.Platform.select({
|
|
11
|
+
ios: (0, _reactNative.PlatformColor)("link"),
|
|
12
|
+
default: "#2c2c2c"
|
|
13
|
+
}),
|
|
14
|
+
disabled: _reactNative.Platform.select({
|
|
15
|
+
ios: (0, _reactNative.PlatformColor)("systemGray4"),
|
|
16
|
+
default: "#B0BEC5"
|
|
17
|
+
}),
|
|
18
|
+
background: _reactNative.Platform.select({
|
|
19
|
+
ios: "#F8F8F8",
|
|
20
|
+
default: "#f3f3f4"
|
|
21
|
+
}),
|
|
22
|
+
ripple: "#bcbcbcbc"
|
|
23
|
+
},
|
|
24
|
+
dark: {
|
|
25
|
+
primary: _reactNative.Platform.select({
|
|
26
|
+
ios: (0, _reactNative.PlatformColor)("label"),
|
|
27
|
+
default: "#fafafa"
|
|
28
|
+
}),
|
|
29
|
+
disabled: _reactNative.Platform.select({
|
|
30
|
+
ios: (0, _reactNative.PlatformColor)("systemGray"),
|
|
31
|
+
default: "#707070"
|
|
32
|
+
}),
|
|
33
|
+
background: _reactNative.Platform.select({
|
|
34
|
+
ios: "#555756",
|
|
35
|
+
default: "#2C2C2E"
|
|
36
|
+
}),
|
|
37
|
+
ripple: "#F8F8F888"
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
exports.colors = colors;
|
|
41
|
+
//# sourceMappingURL=colors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","colors","light","primary","Platform","select","ios","PlatformColor","default","disabled","background","ripple","dark","exports"],"sources":["colors.ts"],"sourcesContent":["import { Platform, PlatformColor } from \"react-native\";\n\nimport type { ColorValue } from \"react-native\";\n\ntype Theme = {\n /** Color for arrow when it's enabled */\n primary: ColorValue;\n /** Color for arrow when it's disabled */\n disabled: ColorValue;\n /** Keyboard toolbar background color */\n background: ColorValue;\n /** Color for ripple effect (on button touch) on Android */\n ripple: ColorValue;\n};\nexport type KeyboardToolbarTheme = {\n light: Theme;\n dark: Theme;\n};\n\nexport const colors: KeyboardToolbarTheme = {\n light: {\n primary: Platform.select<ColorValue>({\n ios: PlatformColor(\"link\"),\n default: \"#2c2c2c\",\n }),\n disabled: Platform.select<ColorValue>({\n ios: PlatformColor(\"systemGray4\"),\n default: \"#B0BEC5\",\n }),\n background: Platform.select({\n ios: \"#F8F8F8\",\n default: \"#f3f3f4\",\n }),\n ripple: \"#bcbcbcbc\",\n },\n dark: {\n primary: Platform.select<ColorValue>({\n ios: PlatformColor(\"label\"),\n default: \"#fafafa\",\n }),\n disabled: Platform.select<ColorValue>({\n ios: PlatformColor(\"systemGray\"),\n default: \"#707070\",\n }),\n background: Platform.select({\n ios: \"#555756\",\n default: \"#2C2C2E\",\n }),\n ripple: \"#F8F8F888\",\n },\n};\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAmBO,MAAMC,MAA4B,GAAG;EAC1CC,KAAK,EAAE;IACLC,OAAO,EAAEC,qBAAQ,CAACC,MAAM,CAAa;MACnCC,GAAG,EAAE,IAAAC,0BAAa,EAAC,MAAM,CAAC;MAC1BC,OAAO,EAAE;IACX,CAAC,CAAC;IACFC,QAAQ,EAAEL,qBAAQ,CAACC,MAAM,CAAa;MACpCC,GAAG,EAAE,IAAAC,0BAAa,EAAC,aAAa,CAAC;MACjCC,OAAO,EAAE;IACX,CAAC,CAAC;IACFE,UAAU,EAAEN,qBAAQ,CAACC,MAAM,CAAC;MAC1BC,GAAG,EAAE,SAAS;MACdE,OAAO,EAAE;IACX,CAAC,CAAC;IACFG,MAAM,EAAE;EACV,CAAC;EACDC,IAAI,EAAE;IACJT,OAAO,EAAEC,qBAAQ,CAACC,MAAM,CAAa;MACnCC,GAAG,EAAE,IAAAC,0BAAa,EAAC,OAAO,CAAC;MAC3BC,OAAO,EAAE;IACX,CAAC,CAAC;IACFC,QAAQ,EAAEL,qBAAQ,CAACC,MAAM,CAAa;MACpCC,GAAG,EAAE,IAAAC,0BAAa,EAAC,YAAY,CAAC;MAChCC,OAAO,EAAE;IACX,CAAC,CAAC;IACFE,UAAU,EAAEN,qBAAQ,CAACC,MAAM,CAAC;MAC1BC,GAAG,EAAE,SAAS;MACdE,OAAO,EAAE;IACX,CAAC,CAAC;IACFG,MAAM,EAAE;EACV;AACF,CAAC;AAACE,OAAA,CAAAZ,MAAA,GAAAA,MAAA"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "DefaultKeyboardToolbarTheme", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _colors.colors;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
exports.default = void 0;
|
|
13
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
14
|
+
var _reactNative = require("react-native");
|
|
15
|
+
var _reactNativeKeyboardController = require("react-native-keyboard-controller");
|
|
16
|
+
var _bindings = require("../../bindings");
|
|
17
|
+
var _useColorScheme = _interopRequireDefault(require("../hooks/useColorScheme"));
|
|
18
|
+
var _Arrow = _interopRequireDefault(require("./Arrow"));
|
|
19
|
+
var _Button = _interopRequireDefault(require("./Button"));
|
|
20
|
+
var _colors = require("./colors");
|
|
21
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
23
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
24
|
+
const TEST_ID_KEYBOARD_TOOLBAR = "keyboard.toolbar";
|
|
25
|
+
const TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS = `${TEST_ID_KEYBOARD_TOOLBAR}.previous`;
|
|
26
|
+
const TEST_ID_KEYBOARD_TOOLBAR_NEXT = `${TEST_ID_KEYBOARD_TOOLBAR}.next`;
|
|
27
|
+
const TEST_ID_KEYBOARD_TOOLBAR_CONTENT = `${TEST_ID_KEYBOARD_TOOLBAR}.content`;
|
|
28
|
+
const TEST_ID_KEYBOARD_TOOLBAR_DONE = `${TEST_ID_KEYBOARD_TOOLBAR}.done`;
|
|
29
|
+
const KEYBOARD_TOOLBAR_HEIGHT = 42;
|
|
30
|
+
const offset = {
|
|
31
|
+
closed: KEYBOARD_TOOLBAR_HEIGHT
|
|
32
|
+
};
|
|
33
|
+
const dismissKeyboard = () => _bindings.KeyboardController.dismiss();
|
|
34
|
+
const goToNextField = () => _bindings.KeyboardController.setFocusTo("next");
|
|
35
|
+
const goToPrevField = () => _bindings.KeyboardController.setFocusTo("prev");
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* `KeyboardToolbar` is a component that is shown above the keyboard with `Prev`/`Next` and
|
|
39
|
+
* `Done` buttons.
|
|
40
|
+
*/
|
|
41
|
+
const KeyboardToolbar = _ref => {
|
|
42
|
+
let {
|
|
43
|
+
content,
|
|
44
|
+
theme = _colors.colors,
|
|
45
|
+
doneText,
|
|
46
|
+
button,
|
|
47
|
+
icon
|
|
48
|
+
} = _ref;
|
|
49
|
+
const colorScheme = (0, _useColorScheme.default)();
|
|
50
|
+
const [inputs, setInputs] = (0, _react.useState)({
|
|
51
|
+
current: 0,
|
|
52
|
+
count: 0
|
|
53
|
+
});
|
|
54
|
+
const isPrevDisabled = inputs.current === 0;
|
|
55
|
+
const isNextDisabled = inputs.current === inputs.count - 1;
|
|
56
|
+
(0, _react.useEffect)(() => {
|
|
57
|
+
const subscription = _reactNativeKeyboardController.FocusedInputEvents.addListener("focusDidSet", e => {
|
|
58
|
+
setInputs(e);
|
|
59
|
+
});
|
|
60
|
+
return subscription.remove;
|
|
61
|
+
}, []);
|
|
62
|
+
const doneStyle = (0, _react.useMemo)(() => [styles.doneButton, {
|
|
63
|
+
color: theme[colorScheme].primary
|
|
64
|
+
}], [colorScheme, theme]);
|
|
65
|
+
const toolbarStyle = (0, _react.useMemo)(() => [styles.toolbar, {
|
|
66
|
+
backgroundColor: theme[colorScheme].background
|
|
67
|
+
}], [colorScheme, theme]);
|
|
68
|
+
const ButtonContainer = button || _Button.default;
|
|
69
|
+
const IconContainer = icon || _Arrow.default;
|
|
70
|
+
return /*#__PURE__*/_react.default.createElement(_reactNativeKeyboardController.KeyboardStickyView, {
|
|
71
|
+
offset: offset
|
|
72
|
+
}, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
73
|
+
style: toolbarStyle,
|
|
74
|
+
testID: TEST_ID_KEYBOARD_TOOLBAR
|
|
75
|
+
}, /*#__PURE__*/_react.default.createElement(ButtonContainer, {
|
|
76
|
+
accessibilityLabel: "Previous",
|
|
77
|
+
accessibilityHint: "Will move focus to previous field",
|
|
78
|
+
disabled: isPrevDisabled,
|
|
79
|
+
onPress: goToPrevField,
|
|
80
|
+
testID: TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS,
|
|
81
|
+
theme: theme
|
|
82
|
+
}, /*#__PURE__*/_react.default.createElement(IconContainer, {
|
|
83
|
+
disabled: isPrevDisabled,
|
|
84
|
+
type: "prev",
|
|
85
|
+
theme: theme
|
|
86
|
+
})), /*#__PURE__*/_react.default.createElement(ButtonContainer, {
|
|
87
|
+
accessibilityLabel: "Next",
|
|
88
|
+
accessibilityHint: "Will move focus to next field",
|
|
89
|
+
disabled: isNextDisabled,
|
|
90
|
+
onPress: goToNextField,
|
|
91
|
+
testID: TEST_ID_KEYBOARD_TOOLBAR_NEXT,
|
|
92
|
+
theme: theme
|
|
93
|
+
}, /*#__PURE__*/_react.default.createElement(IconContainer, {
|
|
94
|
+
disabled: isNextDisabled,
|
|
95
|
+
type: "next",
|
|
96
|
+
theme: theme
|
|
97
|
+
})), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
98
|
+
style: styles.flex,
|
|
99
|
+
testID: TEST_ID_KEYBOARD_TOOLBAR_CONTENT
|
|
100
|
+
}, content), /*#__PURE__*/_react.default.createElement(ButtonContainer, {
|
|
101
|
+
accessibilityLabel: "Done",
|
|
102
|
+
accessibilityHint: "Will close the keyboard",
|
|
103
|
+
onPress: dismissKeyboard,
|
|
104
|
+
testID: TEST_ID_KEYBOARD_TOOLBAR_DONE,
|
|
105
|
+
rippleRadius: 28,
|
|
106
|
+
style: styles.doneButtonContainer,
|
|
107
|
+
theme: theme
|
|
108
|
+
}, /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
|
|
109
|
+
style: doneStyle,
|
|
110
|
+
maxFontSizeMultiplier: 1.3
|
|
111
|
+
}, doneText || "Done"))));
|
|
112
|
+
};
|
|
113
|
+
const styles = _reactNative.StyleSheet.create({
|
|
114
|
+
flex: {
|
|
115
|
+
flex: 1
|
|
116
|
+
},
|
|
117
|
+
toolbar: {
|
|
118
|
+
position: "absolute",
|
|
119
|
+
bottom: 0,
|
|
120
|
+
alignItems: "center",
|
|
121
|
+
width: "100%",
|
|
122
|
+
flexDirection: "row",
|
|
123
|
+
height: KEYBOARD_TOOLBAR_HEIGHT,
|
|
124
|
+
paddingHorizontal: 8
|
|
125
|
+
},
|
|
126
|
+
doneButton: {
|
|
127
|
+
fontWeight: "600",
|
|
128
|
+
fontSize: 15
|
|
129
|
+
},
|
|
130
|
+
doneButtonContainer: {
|
|
131
|
+
marginRight: 8
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
var _default = KeyboardToolbar;
|
|
135
|
+
exports.default = _default;
|
|
136
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeKeyboardController","_bindings","_useColorScheme","_interopRequireDefault","_Arrow","_Button","_colors","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","TEST_ID_KEYBOARD_TOOLBAR","TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS","TEST_ID_KEYBOARD_TOOLBAR_NEXT","TEST_ID_KEYBOARD_TOOLBAR_CONTENT","TEST_ID_KEYBOARD_TOOLBAR_DONE","KEYBOARD_TOOLBAR_HEIGHT","offset","closed","dismissKeyboard","KeyboardController","dismiss","goToNextField","setFocusTo","goToPrevField","KeyboardToolbar","_ref","content","theme","colors","doneText","button","icon","colorScheme","useColorScheme","inputs","setInputs","useState","current","count","isPrevDisabled","isNextDisabled","useEffect","subscription","FocusedInputEvents","addListener","e","remove","doneStyle","useMemo","styles","doneButton","color","primary","toolbarStyle","toolbar","backgroundColor","background","ButtonContainer","Button","IconContainer","Arrow","createElement","KeyboardStickyView","View","style","testID","accessibilityLabel","accessibilityHint","disabled","onPress","type","flex","rippleRadius","doneButtonContainer","Text","maxFontSizeMultiplier","StyleSheet","create","position","bottom","alignItems","width","flexDirection","height","paddingHorizontal","fontWeight","fontSize","marginRight","_default","exports"],"sources":["index.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useState } from \"react\";\nimport { StyleSheet, Text, View } from \"react-native\";\n\nimport {\n FocusedInputEvents,\n KeyboardStickyView,\n} from \"react-native-keyboard-controller\";\n\nimport { KeyboardController } from \"../../bindings\";\nimport useColorScheme from \"../hooks/useColorScheme\";\n\nimport Arrow from \"./Arrow\";\nimport Button from \"./Button\";\nimport { colors } from \"./colors\";\n\nimport type { KeyboardToolbarTheme } from \"./colors\";\nimport type { ReactNode } from \"react\";\n\nexport type KeyboardToolbarProps = {\n /** An element that is shown in the middle of the toolbar. */\n content?: JSX.Element | null;\n /** A set of dark/light colors consumed by toolbar component. */\n theme?: KeyboardToolbarTheme;\n /** Custom text for done button. */\n doneText?: ReactNode;\n /** Custom touchable component for toolbar (used for prev/next/done buttons). */\n button?: typeof Button;\n /** Custom icon component used to display next/prev buttons. */\n icon?: typeof Arrow;\n};\nconst TEST_ID_KEYBOARD_TOOLBAR = \"keyboard.toolbar\";\nconst TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS = `${TEST_ID_KEYBOARD_TOOLBAR}.previous`;\nconst TEST_ID_KEYBOARD_TOOLBAR_NEXT = `${TEST_ID_KEYBOARD_TOOLBAR}.next`;\nconst TEST_ID_KEYBOARD_TOOLBAR_CONTENT = `${TEST_ID_KEYBOARD_TOOLBAR}.content`;\nconst TEST_ID_KEYBOARD_TOOLBAR_DONE = `${TEST_ID_KEYBOARD_TOOLBAR}.done`;\n\nconst KEYBOARD_TOOLBAR_HEIGHT = 42;\nconst offset = { closed: KEYBOARD_TOOLBAR_HEIGHT };\n\nconst dismissKeyboard = () => KeyboardController.dismiss();\nconst goToNextField = () => KeyboardController.setFocusTo(\"next\");\nconst goToPrevField = () => KeyboardController.setFocusTo(\"prev\");\n\n/**\n * `KeyboardToolbar` is a component that is shown above the keyboard with `Prev`/`Next` and\n * `Done` buttons.\n */\nconst KeyboardToolbar: React.FC<KeyboardToolbarProps> = ({\n content,\n theme = colors,\n doneText,\n button,\n icon,\n}) => {\n const colorScheme = useColorScheme();\n const [inputs, setInputs] = useState({\n current: 0,\n count: 0,\n });\n const isPrevDisabled = inputs.current === 0;\n const isNextDisabled = inputs.current === inputs.count - 1;\n\n useEffect(() => {\n const subscription = FocusedInputEvents.addListener(\"focusDidSet\", (e) => {\n setInputs(e);\n });\n\n return subscription.remove;\n }, []);\n const doneStyle = useMemo(\n () => [styles.doneButton, { color: theme[colorScheme].primary }],\n [colorScheme, theme],\n );\n const toolbarStyle = useMemo(\n () => [\n styles.toolbar,\n {\n backgroundColor: theme[colorScheme].background,\n },\n ],\n [colorScheme, theme],\n );\n const ButtonContainer = button || Button;\n const IconContainer = icon || Arrow;\n\n return (\n <KeyboardStickyView offset={offset}>\n <View style={toolbarStyle} testID={TEST_ID_KEYBOARD_TOOLBAR}>\n <ButtonContainer\n accessibilityLabel=\"Previous\"\n accessibilityHint=\"Will move focus to previous field\"\n disabled={isPrevDisabled}\n onPress={goToPrevField}\n testID={TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS}\n theme={theme}\n >\n <IconContainer disabled={isPrevDisabled} type=\"prev\" theme={theme} />\n </ButtonContainer>\n <ButtonContainer\n accessibilityLabel=\"Next\"\n accessibilityHint=\"Will move focus to next field\"\n disabled={isNextDisabled}\n onPress={goToNextField}\n testID={TEST_ID_KEYBOARD_TOOLBAR_NEXT}\n theme={theme}\n >\n <IconContainer disabled={isNextDisabled} type=\"next\" theme={theme} />\n </ButtonContainer>\n\n <View style={styles.flex} testID={TEST_ID_KEYBOARD_TOOLBAR_CONTENT}>\n {content}\n </View>\n <ButtonContainer\n accessibilityLabel=\"Done\"\n accessibilityHint=\"Will close the keyboard\"\n onPress={dismissKeyboard}\n testID={TEST_ID_KEYBOARD_TOOLBAR_DONE}\n rippleRadius={28}\n style={styles.doneButtonContainer}\n theme={theme}\n >\n <Text style={doneStyle} maxFontSizeMultiplier={1.3}>\n {doneText || \"Done\"}\n </Text>\n </ButtonContainer>\n </View>\n </KeyboardStickyView>\n );\n};\n\nconst styles = StyleSheet.create({\n flex: {\n flex: 1,\n },\n toolbar: {\n position: \"absolute\",\n bottom: 0,\n alignItems: \"center\",\n width: \"100%\",\n flexDirection: \"row\",\n height: KEYBOARD_TOOLBAR_HEIGHT,\n paddingHorizontal: 8,\n },\n doneButton: {\n fontWeight: \"600\",\n fontSize: 15,\n },\n doneButtonContainer: {\n marginRight: 8,\n },\n});\n\nexport { colors as DefaultKeyboardToolbarTheme };\nexport default KeyboardToolbar;\n"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,8BAAA,GAAAF,OAAA;AAKA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,eAAA,GAAAC,sBAAA,CAAAL,OAAA;AAEA,IAAAM,MAAA,GAAAD,sBAAA,CAAAL,OAAA;AACA,IAAAO,OAAA,GAAAF,sBAAA,CAAAL,OAAA;AACA,IAAAQ,OAAA,GAAAR,OAAA;AAAkC,SAAAK,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAA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6
|
+
exports.default = void 0;
|
|
7
|
+
var _reactNative = require("react-native");
|
|
8
|
+
const useColorScheme = () => (0, _reactNative.useColorScheme)() || "light";
|
|
9
|
+
var _default = useColorScheme;
|
|
10
|
+
exports.default = _default;
|
|
11
|
+
//# sourceMappingURL=useColorScheme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","useColorScheme","useColorSchemeRN","_default","exports","default"],"sources":["useColorScheme.ts"],"sourcesContent":["import { useColorScheme as useColorSchemeRN } from \"react-native\";\n\nconst useColorScheme = () => useColorSchemeRN() || \"light\";\n\nexport default useColorScheme;\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,MAAMC,cAAc,GAAGA,CAAA,KAAM,IAAAC,2BAAgB,EAAC,CAAC,IAAI,OAAO;AAAC,IAAAC,QAAA,GAE5CF,cAAc;AAAAG,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
|
|
@@ -39,8 +39,9 @@ const useKeyboardInterpolation = () => {
|
|
|
39
39
|
if (_reactNative.Platform.OS === "ios") {
|
|
40
40
|
return (0, _reactNativeReanimated.interpolate)(keyboardPosition, [0, nextKeyboardHeight.value], output);
|
|
41
41
|
}
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
const interpolation = (0, _reactNativeReanimated.interpolate)(keyboardPosition, [prevKeyboardHeight.value, nextKeyboardHeight.value], shouldUseInternalInterpolation.value ? [lastInterpolation.value, output[1]] : output);
|
|
43
|
+
lastInterpolation.value = interpolation;
|
|
44
|
+
return interpolation;
|
|
44
45
|
};
|
|
45
46
|
(0, _reactNativeKeyboardController.useKeyboardHandler)({
|
|
46
47
|
onStart: e => {
|