react-native-keyboard-controller 1.9.5 → 1.10.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 -1
- package/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardControllerModule.kt +4 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/events/FocusedInputTextChangedEvent.kt +20 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/EditText.kt +36 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/WindowInsetsAnimationCompat.kt +7 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/listeners/FocusedInputObserver.kt +17 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/listeners/KeyboardAnimationCallback.kt +12 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/managers/KeyboardControllerViewManagerImpl.kt +2 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/modules/KeyboardControllerModuleImpl.kt +13 -0
- package/android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardControllerModule.kt +5 -0
- package/ios/KeyboardController.xcodeproj/project.pbxproj +10 -0
- package/ios/KeyboardControllerModule.mm +14 -0
- package/ios/events/FocusedInputTextChangedEvent.h +16 -0
- package/ios/events/FocusedInputTextChangedEvent.m +72 -0
- package/ios/observers/FocusedInputObserver.swift +29 -14
- package/ios/observers/TextChangeObserver.swift +41 -0
- package/ios/views/KeyboardControllerView.mm +53 -31
- package/ios/views/KeyboardControllerViewManager.mm +1 -0
- package/ios/views/KeyboardControllerViewManager.swift +21 -10
- package/jest/index.js +2 -0
- package/lib/commonjs/animated.js +20 -14
- package/lib/commonjs/animated.js.map +1 -1
- package/lib/commonjs/bindings.js +1 -0
- package/lib/commonjs/bindings.js.map +1 -1
- package/lib/commonjs/components/KeyboardAvoidingView/index.js +7 -4
- package/lib/commonjs/components/KeyboardAvoidingView/index.js.map +1 -1
- package/lib/commonjs/components/KeyboardAwareScrollView/index.js +199 -0
- package/lib/commonjs/components/KeyboardAwareScrollView/index.js.map +1 -0
- package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +100 -0
- package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -0
- package/lib/commonjs/components/KeyboardAwareScrollView/utils.js +28 -0
- package/lib/commonjs/components/KeyboardAwareScrollView/utils.js.map +1 -0
- package/lib/commonjs/components/KeyboardStickyView/index.js +0 -1
- package/lib/commonjs/components/KeyboardStickyView/index.js.map +1 -1
- package/lib/commonjs/components/index.js +7 -0
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/context.js +2 -1
- package/lib/commonjs/context.js.map +1 -1
- package/lib/commonjs/hooks.js +17 -2
- package/lib/commonjs/hooks.js.map +1 -1
- package/lib/commonjs/index.js +8 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/internal.js +2 -5
- package/lib/commonjs/internal.js.map +1 -1
- package/lib/commonjs/reanimated.js +5 -3
- package/lib/commonjs/reanimated.js.map +1 -1
- package/lib/commonjs/reanimated.native.js +20 -3
- package/lib/commonjs/reanimated.native.js.map +1 -1
- package/lib/commonjs/replicas.js +3 -1
- package/lib/commonjs/replicas.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/animated.js +21 -15
- package/lib/module/animated.js.map +1 -1
- package/lib/module/bindings.js +1 -0
- package/lib/module/bindings.js.map +1 -1
- package/lib/module/components/KeyboardAvoidingView/index.js +8 -5
- package/lib/module/components/KeyboardAvoidingView/index.js.map +1 -1
- package/lib/module/components/KeyboardAwareScrollView/index.js +190 -0
- package/lib/module/components/KeyboardAwareScrollView/index.js.map +1 -0
- package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +93 -0
- package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -0
- package/lib/module/components/KeyboardAwareScrollView/utils.js +21 -0
- package/lib/module/components/KeyboardAwareScrollView/utils.js.map +1 -0
- package/lib/module/components/KeyboardStickyView/index.js +0 -1
- package/lib/module/components/KeyboardStickyView/index.js.map +1 -1
- package/lib/module/components/index.js +1 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/context.js +2 -1
- package/lib/module/context.js.map +1 -1
- package/lib/module/hooks.js +16 -2
- package/lib/module/hooks.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/internal.js +2 -5
- package/lib/module/internal.js.map +1 -1
- package/lib/module/reanimated.js +2 -1
- package/lib/module/reanimated.js.map +1 -1
- package/lib/module/reanimated.native.js +17 -1
- package/lib/module/reanimated.native.js.map +1 -1
- package/lib/module/replicas.js +5 -3
- package/lib/module/replicas.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/components/KeyboardAwareScrollView/index.d.ts +45 -0
- package/lib/typescript/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.d.ts +6 -0
- package/lib/typescript/components/KeyboardAwareScrollView/utils.d.ts +1 -0
- package/lib/typescript/components/index.d.ts +1 -0
- package/lib/typescript/context.d.ts +3 -2
- package/lib/typescript/hooks.d.ts +2 -1
- package/lib/typescript/index.d.ts +1 -1
- package/lib/typescript/internal.d.ts +8 -5
- package/lib/typescript/reanimated.d.ts +3 -2
- package/lib/typescript/reanimated.native.d.ts +3 -2
- package/lib/typescript/specs/KeyboardControllerViewNativeComponent.d.ts +4 -0
- package/lib/typescript/specs/NativeKeyboardController.d.ts +1 -0
- package/lib/typescript/types.d.ts +15 -2
- package/package.json +5 -2
- package/react-native-keyboard-controller.podspec +1 -1
- package/src/animated.tsx +27 -10
- package/src/bindings.ts +1 -0
- package/src/components/KeyboardAvoidingView/index.tsx +7 -5
- package/src/components/KeyboardAwareScrollView/index.tsx +262 -0
- package/src/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.ts +123 -0
- package/src/components/KeyboardAwareScrollView/utils.ts +26 -0
- package/src/components/KeyboardStickyView/index.tsx +1 -6
- package/src/components/index.ts +1 -0
- package/src/context.ts +9 -3
- package/src/hooks.ts +20 -3
- package/src/index.ts +5 -1
- package/src/internal.ts +17 -8
- package/src/reanimated.native.ts +27 -2
- package/src/reanimated.ts +8 -2
- package/src/replicas.ts +4 -3
- package/src/specs/KeyboardControllerViewNativeComponent.ts +7 -0
- package/src/specs/NativeKeyboardController.ts +1 -0
- package/src/types.ts +28 -2
|
@@ -16,10 +16,14 @@ class KeyboardControllerView: UIView {
|
|
|
16
16
|
private var eventDispatcher: RCTEventDispatcherProtocol
|
|
17
17
|
private var bridge: RCTBridge
|
|
18
18
|
// react callbacks
|
|
19
|
+
/// keyboard
|
|
19
20
|
@objc var onKeyboardMoveStart: RCTDirectEventBlock?
|
|
20
21
|
@objc var onKeyboardMove: RCTDirectEventBlock?
|
|
21
22
|
@objc var onKeyboardMoveEnd: RCTDirectEventBlock?
|
|
22
23
|
@objc var onKeyboardMoveInteractive: RCTDirectEventBlock?
|
|
24
|
+
/// focused input
|
|
25
|
+
@objc var onFocusedInputLayoutChanged: RCTDirectEventBlock?
|
|
26
|
+
@objc var onFocusedInputTextChanged: RCTDirectEventBlock?
|
|
23
27
|
// react props
|
|
24
28
|
@objc var enabled: ObjCBool = true {
|
|
25
29
|
didSet {
|
|
@@ -35,7 +39,7 @@ class KeyboardControllerView: UIView {
|
|
|
35
39
|
self.bridge = bridge
|
|
36
40
|
eventDispatcher = bridge.eventDispatcher()
|
|
37
41
|
super.init(frame: frame)
|
|
38
|
-
inputObserver = FocusedInputObserver(
|
|
42
|
+
inputObserver = FocusedInputObserver(onLayoutChangedHandler: onLayoutChanged, onTextChangedHandler: onTextChanged)
|
|
39
43
|
keyboardObserver = KeyboardMovementObserver(handler: onEvent, onNotify: onNotify)
|
|
40
44
|
}
|
|
41
45
|
|
|
@@ -58,19 +62,21 @@ class KeyboardControllerView: UIView {
|
|
|
58
62
|
}
|
|
59
63
|
}
|
|
60
64
|
|
|
61
|
-
func
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return
|
|
65
|
-
}
|
|
65
|
+
func onLayoutChanged(event: NSObject) {
|
|
66
|
+
guard isJSThreadReady() else { return }
|
|
67
|
+
|
|
66
68
|
eventDispatcher.send(FocusedInputLayoutChangedEvent(reactTag: reactTag, event: event))
|
|
67
69
|
}
|
|
68
70
|
|
|
71
|
+
func onTextChanged(text: String) {
|
|
72
|
+
guard isJSThreadReady() else { return }
|
|
73
|
+
|
|
74
|
+
eventDispatcher.send(FocusedInputTextChangedEvent(reactTag: reactTag, text: text))
|
|
75
|
+
}
|
|
76
|
+
|
|
69
77
|
func onEvent(event: NSString, height: NSNumber, progress: NSNumber, duration: NSNumber, target: NSNumber) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
return
|
|
73
|
-
}
|
|
78
|
+
guard isJSThreadReady() else { return }
|
|
79
|
+
|
|
74
80
|
eventDispatcher.send(
|
|
75
81
|
KeyboardMoveEvent(
|
|
76
82
|
reactTag: reactTag,
|
|
@@ -96,4 +102,9 @@ class KeyboardControllerView: UIView {
|
|
|
96
102
|
inputObserver?.unmount()
|
|
97
103
|
keyboardObserver?.unmount()
|
|
98
104
|
}
|
|
105
|
+
|
|
106
|
+
private func isJSThreadReady() -> Bool {
|
|
107
|
+
// we don't want to send event to JS before the JS thread is ready
|
|
108
|
+
return bridge.value(forKey: "_jsThread") != nil
|
|
109
|
+
}
|
|
99
110
|
}
|
package/jest/index.js
CHANGED
|
@@ -34,10 +34,12 @@ const mock = {
|
|
|
34
34
|
useGenericKeyboardHandler: jest.fn(),
|
|
35
35
|
useKeyboardHandler: jest.fn(),
|
|
36
36
|
useReanimatedFocusedInput: jest.fn().mockReturnValue(focusedInput),
|
|
37
|
+
useFocusedInputHandler: jest.fn(),
|
|
37
38
|
// modules
|
|
38
39
|
KeyboardController: {
|
|
39
40
|
setInputMode: jest.fn(),
|
|
40
41
|
setDefaultMode: jest.fn(),
|
|
42
|
+
dismiss: jest.fn(),
|
|
41
43
|
},
|
|
42
44
|
KeyboardEvents: {
|
|
43
45
|
addListener: jest.fn(() => ({ remove: jest.fn() })),
|
package/lib/commonjs/animated.js
CHANGED
|
@@ -31,6 +31,7 @@ const KeyboardProvider = _ref => {
|
|
|
31
31
|
navigationBarTranslucent,
|
|
32
32
|
enabled: initiallyEnabled = true
|
|
33
33
|
} = _ref;
|
|
34
|
+
// state
|
|
34
35
|
const [enabled, setEnabled] = (0, _react.useState)(initiallyEnabled);
|
|
35
36
|
// animated values
|
|
36
37
|
const progress = (0, _internal.useAnimatedValue)(0);
|
|
@@ -39,10 +40,8 @@ const KeyboardProvider = _ref => {
|
|
|
39
40
|
const progressSV = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
40
41
|
const heightSV = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
41
42
|
const layout = (0, _reactNativeReanimated.useSharedValue)(null);
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
broadcast
|
|
45
|
-
} = (0, _internal.useSharedHandlers)();
|
|
43
|
+
const [setKeyboardHandlers, broadcastKeyboardEvents] = (0, _internal.useSharedHandlers)();
|
|
44
|
+
const [setInputHandlers, broadcastInputEvents] = (0, _internal.useSharedHandlers)();
|
|
46
45
|
// memo
|
|
47
46
|
const context = (0, _react.useMemo)(() => ({
|
|
48
47
|
enabled,
|
|
@@ -55,7 +54,8 @@ const KeyboardProvider = _ref => {
|
|
|
55
54
|
height: heightSV
|
|
56
55
|
},
|
|
57
56
|
layout,
|
|
58
|
-
|
|
57
|
+
setKeyboardHandlers,
|
|
58
|
+
setInputHandlers,
|
|
59
59
|
setEnabled
|
|
60
60
|
}), [enabled]);
|
|
61
61
|
const style = (0, _react.useMemo)(() => [styles.hidden, {
|
|
@@ -86,28 +86,28 @@ const KeyboardProvider = _ref => {
|
|
|
86
86
|
onKeyboardMoveStart: event => {
|
|
87
87
|
'worklet';
|
|
88
88
|
|
|
89
|
-
|
|
89
|
+
broadcastKeyboardEvents('onStart', event);
|
|
90
90
|
updateSharedValues(event, ['ios']);
|
|
91
91
|
},
|
|
92
92
|
onKeyboardMove: event => {
|
|
93
93
|
'worklet';
|
|
94
94
|
|
|
95
|
-
|
|
95
|
+
broadcastKeyboardEvents('onMove', event);
|
|
96
96
|
updateSharedValues(event, ['android']);
|
|
97
97
|
},
|
|
98
98
|
onKeyboardMoveEnd: event => {
|
|
99
99
|
'worklet';
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
broadcastKeyboardEvents('onEnd', event);
|
|
102
102
|
},
|
|
103
103
|
onKeyboardMoveInteractive: event => {
|
|
104
104
|
'worklet';
|
|
105
105
|
|
|
106
106
|
updateSharedValues(event, ['android', 'ios']);
|
|
107
|
-
|
|
107
|
+
broadcastKeyboardEvents('onInteractive', event);
|
|
108
108
|
}
|
|
109
109
|
}, []);
|
|
110
|
-
const
|
|
110
|
+
const inputLayoutHandler = (0, _reanimated.useFocusedInputLayoutHandler)({
|
|
111
111
|
onFocusedInputLayoutChanged: e => {
|
|
112
112
|
'worklet';
|
|
113
113
|
|
|
@@ -118,6 +118,13 @@ const KeyboardProvider = _ref => {
|
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
}, []);
|
|
121
|
+
const inputTextHandler = (0, _reanimated.useFocusedInputTextHandler)({
|
|
122
|
+
onFocusedInputTextChanged: e => {
|
|
123
|
+
'worklet';
|
|
124
|
+
|
|
125
|
+
broadcastInputEvents('onChangeText', e);
|
|
126
|
+
}
|
|
127
|
+
}, []);
|
|
121
128
|
// effects
|
|
122
129
|
(0, _react.useEffect)(() => {
|
|
123
130
|
if (enabled) {
|
|
@@ -134,11 +141,10 @@ const KeyboardProvider = _ref => {
|
|
|
134
141
|
onKeyboardMoveStart: _reactNative.Platform.OS === 'ios' ? onKeyboardMove : undefined,
|
|
135
142
|
onKeyboardMove: _reactNative.Platform.OS === 'android' ? onKeyboardMove : undefined,
|
|
136
143
|
onKeyboardMoveInteractive: onKeyboardMove,
|
|
137
|
-
onFocusedInputLayoutChangedReanimated:
|
|
144
|
+
onFocusedInputLayoutChangedReanimated: inputLayoutHandler,
|
|
145
|
+
onFocusedInputTextChangedReanimated: inputTextHandler,
|
|
138
146
|
navigationBarTranslucent: navigationBarTranslucent,
|
|
139
|
-
statusBarTranslucent: statusBarTranslucent
|
|
140
|
-
// @ts-expect-error https://github.com/software-mansion/react-native-reanimated/pull/4923
|
|
141
|
-
,
|
|
147
|
+
statusBarTranslucent: statusBarTranslucent,
|
|
142
148
|
style: styles.container
|
|
143
149
|
}, children), /*#__PURE__*/_react.default.createElement(_reactNative.Animated.View, {
|
|
144
150
|
// we are using this small hack, because if the component (where
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["KeyboardControllerViewAnimated","Reanimated","createAnimatedComponent","Animated","KeyboardControllerView","styles","StyleSheet","create","container","flex","hidden","display","position","KeyboardProvider","children","statusBarTranslucent","navigationBarTranslucent","enabled","initiallyEnabled","setEnabled","useState","progress","useAnimatedValue","height","progressSV","useSharedValue","heightSV","layout","setHandlers","broadcast","useSharedHandlers","context","useMemo","animated","multiply","reanimated","style","transform","translateX","translateY","onKeyboardMove","event","nativeEvent","useNativeDriver","updateSharedValues","platforms","includes","Platform","OS","value","keyboardHandler","useAnimatedKeyboardHandler","onKeyboardMoveStart","onKeyboardMoveEnd","onKeyboardMoveInteractive","inputHandler","useFocusedInputHandler","onFocusedInputLayoutChanged","e","target","useEffect","applyMonkeyPatch","revertMonkeyPatch","undefined"],"sources":["animated.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useState } from 'react';\nimport { Animated, Platform, StyleSheet } from 'react-native';\nimport Reanimated, { useSharedValue } from 'react-native-reanimated';\n\nimport { KeyboardControllerView } from './bindings';\nimport { KeyboardContext } from './context';\nimport { useAnimatedValue, useSharedHandlers } from './internal';\nimport { applyMonkeyPatch, revertMonkeyPatch } from './monkey-patch';\nimport {\n useAnimatedKeyboardHandler,\n useFocusedInputHandler,\n} from './reanimated';\n\nimport type { KeyboardAnimationContext } from './context';\nimport type {\n FocusedInputLayoutChangedEvent,\n KeyboardControllerProps,\n KeyboardHandler,\n NativeEvent,\n} from './types';\nimport type { ViewStyle } from 'react-native';\n\nconst KeyboardControllerViewAnimated = Reanimated.createAnimatedComponent(\n Animated.createAnimatedComponent(\n KeyboardControllerView\n ) as React.FC<KeyboardControllerProps>\n);\n\ntype Styles = {\n container: ViewStyle;\n hidden: ViewStyle;\n};\n\nconst styles = StyleSheet.create<Styles>({\n container: {\n flex: 1,\n },\n hidden: {\n display: 'none',\n position: 'absolute',\n },\n});\n\ntype KeyboardProviderProps = {\n children: React.ReactNode;\n /**\n * Set the value to `true`, if you use translucent status bar on Android.\n * If you already control status bar translucency via `react-native-screens`\n * or `StatusBar` component from `react-native`, you can ignore it.\n * Defaults to `false`.\n *\n * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/14\n * @platform android\n */\n statusBarTranslucent?: boolean;\n /**\n * Set the value to `true`, if you use translucent navigation bar on Android.\n * Defaults to `false`.\n *\n * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/119\n * @platform android\n */\n navigationBarTranslucent?: boolean;\n /**\n * A boolean prop indicating whether the module is enabled. It indicate only initial state,\n * i. e. if you try to change this prop after component mount it will not have any effect.\n * To change the property in runtime use `useKeyboardController` hook and `setEnabled` method.\n * Defaults to `true`.\n */\n enabled?: boolean;\n};\n\nexport const KeyboardProvider = ({\n children,\n statusBarTranslucent,\n navigationBarTranslucent,\n enabled: initiallyEnabled = true,\n}: KeyboardProviderProps) => {\n const [enabled, setEnabled] = useState(initiallyEnabled);\n // animated values\n const progress = useAnimatedValue(0);\n const height = useAnimatedValue(0);\n // shared values\n const progressSV = useSharedValue(0);\n const heightSV = useSharedValue(0);\n const layout = useSharedValue<FocusedInputLayoutChangedEvent | null>(null);\n const { setHandlers, broadcast } = useSharedHandlers<KeyboardHandler>();\n // memo\n const context = useMemo<KeyboardAnimationContext>(\n () => ({\n enabled,\n animated: { progress: progress, height: Animated.multiply(height, -1) },\n reanimated: { progress: progressSV, height: heightSV },\n layout,\n setHandlers,\n setEnabled,\n }),\n [enabled]\n );\n const style = useMemo(\n () => [\n styles.hidden,\n { transform: [{ translateX: height }, { translateY: progress }] },\n ],\n []\n );\n const onKeyboardMove = useMemo(\n () =>\n Animated.event(\n [\n {\n nativeEvent: {\n progress,\n height,\n },\n },\n ],\n { useNativeDriver: true }\n ),\n []\n );\n // handlers\n const updateSharedValues = (event: NativeEvent, platforms: string[]) => {\n 'worklet';\n\n if (platforms.includes(Platform.OS)) {\n progressSV.value = event.progress;\n heightSV.value = -event.height;\n }\n };\n const keyboardHandler = useAnimatedKeyboardHandler(\n {\n onKeyboardMoveStart: (event: NativeEvent) => {\n 'worklet';\n\n broadcast('onStart', event);\n updateSharedValues(event, ['ios']);\n },\n onKeyboardMove: (event: NativeEvent) => {\n 'worklet';\n\n broadcast('onMove', event);\n updateSharedValues(event, ['android']);\n },\n onKeyboardMoveEnd: (event: NativeEvent) => {\n 'worklet';\n\n broadcast('onEnd', event);\n },\n onKeyboardMoveInteractive: (event: NativeEvent) => {\n 'worklet';\n\n updateSharedValues(event, ['android', 'ios']);\n broadcast('onInteractive', event);\n },\n },\n []\n );\n const inputHandler = useFocusedInputHandler(\n {\n onFocusedInputLayoutChanged: (e) => {\n 'worklet';\n\n if (e.target !== -1) {\n layout.value = e;\n } else {\n layout.value = null;\n }\n },\n },\n []\n );\n // effects\n useEffect(() => {\n if (enabled) {\n applyMonkeyPatch();\n } else {\n revertMonkeyPatch();\n }\n }, [enabled]);\n\n return (\n <KeyboardContext.Provider value={context}>\n <KeyboardControllerViewAnimated\n enabled={enabled}\n onKeyboardMoveReanimated={keyboardHandler}\n onKeyboardMoveStart={Platform.OS === 'ios' ? onKeyboardMove : undefined}\n onKeyboardMove={Platform.OS === 'android' ? onKeyboardMove : undefined}\n onKeyboardMoveInteractive={onKeyboardMove}\n onFocusedInputLayoutChangedReanimated={inputHandler}\n navigationBarTranslucent={navigationBarTranslucent}\n statusBarTranslucent={statusBarTranslucent}\n // @ts-expect-error https://github.com/software-mansion/react-native-reanimated/pull/4923\n style={styles.container}\n >\n {children}\n </KeyboardControllerViewAnimated>\n <Animated.View\n // we are using this small hack, because if the component (where\n // animated value has been used) is unmounted, then animation will\n // stop receiving events (seems like it's react-native optimization).\n // So we need to keep a reference to the animated value, to keep it's\n // always mounted (keep a reference to an animated value).\n //\n // To test why it's needed, try to open screen which consumes Animated.Value\n // then close it and open it again (for example 'Animated transition').\n style={style}\n />\n </KeyboardContext.Provider>\n );\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAGsB;AAAA;AAWtB,MAAMA,8BAA8B,GAAGC,8BAAU,CAACC,uBAAuB,CACvEC,qBAAQ,CAACD,uBAAuB,CAC9BE,gCAAsB,CACvB,CACF;AAOD,MAAMC,MAAM,GAAGC,uBAAU,CAACC,MAAM,CAAS;EACvCC,SAAS,EAAE;IACTC,IAAI,EAAE;EACR,CAAC;EACDC,MAAM,EAAE;IACNC,OAAO,EAAE,MAAM;IACfC,QAAQ,EAAE;EACZ;AACF,CAAC,CAAC;AA+BK,MAAMC,gBAAgB,GAAG,QAKH;EAAA,IALI;IAC/BC,QAAQ;IACRC,oBAAoB;IACpBC,wBAAwB;IACxBC,OAAO,EAAEC,gBAAgB,GAAG;EACP,CAAC;EACtB,MAAM,CAACD,OAAO,EAAEE,UAAU,CAAC,GAAG,IAAAC,eAAQ,EAACF,gBAAgB,CAAC;EACxD;EACA,MAAMG,QAAQ,GAAG,IAAAC,0BAAgB,EAAC,CAAC,CAAC;EACpC,MAAMC,MAAM,GAAG,IAAAD,0BAAgB,EAAC,CAAC,CAAC;EAClC;EACA,MAAME,UAAU,GAAG,IAAAC,qCAAc,EAAC,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AAQ,gBACvC,6BAAC,8BAA8B;IAC7B,OAAO,EAAEd,OAAQ;IACjB,wBAAwB,EAAEiC,eAAgB;IAC1C,mBAAmB,EAAEH,qBAAQ,CAACC,EAAE,KAAK,KAAK,GAAGR,cAAc,GAAGuB,SAAU;IACxE,cAAc,EAAEhB,qBAAQ,CAACC,EAAE,KAAK,SAAS,GAAGR,cAAc,GAAGuB,SAAU;IACvE,yBAAyB,EAAEvB,cAAe;IAC1C,qCAAqC,EAAEe,YAAa;IACpD,wBAAwB,EAAEvC,wBAAyB;IACnD,oBAAoB,EAAED;IACtB;IAAA;IACA,KAAK,EAAEV,MAAM,CAACG;EAAU,GAEvBM,QAAQ,CACsB,eACjC,6BAAC,qBAAQ,CAAC,IAAI;IACZ;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,KAAK,EAAEsB;EAAM,EACb,CACuB;AAE/B,CAAC;AAAC"}
|
|
1
|
+
{"version":3,"names":["KeyboardControllerViewAnimated","Reanimated","createAnimatedComponent","Animated","KeyboardControllerView","styles","StyleSheet","create","container","flex","hidden","display","position","KeyboardProvider","children","statusBarTranslucent","navigationBarTranslucent","enabled","initiallyEnabled","setEnabled","useState","progress","useAnimatedValue","height","progressSV","useSharedValue","heightSV","layout","setKeyboardHandlers","broadcastKeyboardEvents","useSharedHandlers","setInputHandlers","broadcastInputEvents","context","useMemo","animated","multiply","reanimated","style","transform","translateX","translateY","onKeyboardMove","event","nativeEvent","useNativeDriver","updateSharedValues","platforms","includes","Platform","OS","value","keyboardHandler","useAnimatedKeyboardHandler","onKeyboardMoveStart","onKeyboardMoveEnd","onKeyboardMoveInteractive","inputLayoutHandler","useFocusedInputLayoutHandler","onFocusedInputLayoutChanged","e","target","inputTextHandler","useFocusedInputTextHandler","onFocusedInputTextChanged","useEffect","applyMonkeyPatch","revertMonkeyPatch","undefined"],"sources":["animated.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useState } from 'react';\nimport { Animated, Platform, StyleSheet } from 'react-native';\nimport Reanimated, { useSharedValue } from 'react-native-reanimated';\n\nimport { KeyboardControllerView } from './bindings';\nimport { KeyboardContext } from './context';\nimport { useAnimatedValue, useSharedHandlers } from './internal';\nimport { applyMonkeyPatch, revertMonkeyPatch } from './monkey-patch';\nimport {\n useAnimatedKeyboardHandler,\n useFocusedInputLayoutHandler,\n useFocusedInputTextHandler,\n} from './reanimated';\n\nimport type { KeyboardAnimationContext } from './context';\nimport type {\n FocusedInputHandler,\n FocusedInputLayoutChangedEvent,\n KeyboardControllerProps,\n KeyboardHandler,\n NativeEvent,\n} from './types';\nimport type { ViewStyle } from 'react-native';\n\nconst KeyboardControllerViewAnimated = Reanimated.createAnimatedComponent(\n Animated.createAnimatedComponent(\n KeyboardControllerView\n ) as React.FC<KeyboardControllerProps>\n);\n\ntype Styles = {\n container: ViewStyle;\n hidden: ViewStyle;\n};\n\nconst styles = StyleSheet.create<Styles>({\n container: {\n flex: 1,\n },\n hidden: {\n display: 'none',\n position: 'absolute',\n },\n});\n\ntype KeyboardProviderProps = {\n children: React.ReactNode;\n /**\n * Set the value to `true`, if you use translucent status bar on Android.\n * If you already control status bar translucency via `react-native-screens`\n * or `StatusBar` component from `react-native`, you can ignore it.\n * Defaults to `false`.\n *\n * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/14\n * @platform android\n */\n statusBarTranslucent?: boolean;\n /**\n * Set the value to `true`, if you use translucent navigation bar on Android.\n * Defaults to `false`.\n *\n * @see https://github.com/kirillzyusko/react-native-keyboard-controller/issues/119\n * @platform android\n */\n navigationBarTranslucent?: boolean;\n /**\n * A boolean prop indicating whether the module is enabled. It indicate only initial state,\n * i. e. if you try to change this prop after component mount it will not have any effect.\n * To change the property in runtime use `useKeyboardController` hook and `setEnabled` method.\n * Defaults to `true`.\n */\n enabled?: boolean;\n};\n\nexport const KeyboardProvider = ({\n children,\n statusBarTranslucent,\n navigationBarTranslucent,\n enabled: initiallyEnabled = true,\n}: KeyboardProviderProps) => {\n // state\n const [enabled, setEnabled] = useState(initiallyEnabled);\n // animated values\n const progress = useAnimatedValue(0);\n const height = useAnimatedValue(0);\n // shared values\n const progressSV = useSharedValue(0);\n const heightSV = useSharedValue(0);\n const layout = useSharedValue<FocusedInputLayoutChangedEvent | null>(null);\n const [setKeyboardHandlers, broadcastKeyboardEvents] =\n useSharedHandlers<KeyboardHandler>();\n const [setInputHandlers, broadcastInputEvents] =\n useSharedHandlers<FocusedInputHandler>();\n // memo\n const context = useMemo<KeyboardAnimationContext>(\n () => ({\n enabled,\n animated: { progress: progress, height: Animated.multiply(height, -1) },\n reanimated: { progress: progressSV, height: heightSV },\n layout,\n setKeyboardHandlers,\n setInputHandlers,\n setEnabled,\n }),\n [enabled]\n );\n const style = useMemo(\n () => [\n styles.hidden,\n { transform: [{ translateX: height }, { translateY: progress }] },\n ],\n []\n );\n const onKeyboardMove = useMemo(\n () =>\n Animated.event(\n [\n {\n nativeEvent: {\n progress,\n height,\n },\n },\n ],\n { useNativeDriver: true }\n ),\n []\n );\n // handlers\n const updateSharedValues = (event: NativeEvent, platforms: string[]) => {\n 'worklet';\n\n if (platforms.includes(Platform.OS)) {\n progressSV.value = event.progress;\n heightSV.value = -event.height;\n }\n };\n const keyboardHandler = useAnimatedKeyboardHandler(\n {\n onKeyboardMoveStart: (event: NativeEvent) => {\n 'worklet';\n\n broadcastKeyboardEvents('onStart', event);\n updateSharedValues(event, ['ios']);\n },\n onKeyboardMove: (event: NativeEvent) => {\n 'worklet';\n\n broadcastKeyboardEvents('onMove', event);\n updateSharedValues(event, ['android']);\n },\n onKeyboardMoveEnd: (event: NativeEvent) => {\n 'worklet';\n\n broadcastKeyboardEvents('onEnd', event);\n },\n onKeyboardMoveInteractive: (event: NativeEvent) => {\n 'worklet';\n\n updateSharedValues(event, ['android', 'ios']);\n broadcastKeyboardEvents('onInteractive', event);\n },\n },\n []\n );\n const inputLayoutHandler = useFocusedInputLayoutHandler(\n {\n onFocusedInputLayoutChanged: (e) => {\n 'worklet';\n\n if (e.target !== -1) {\n layout.value = e;\n } else {\n layout.value = null;\n }\n },\n },\n []\n );\n const inputTextHandler = useFocusedInputTextHandler(\n {\n onFocusedInputTextChanged: (e) => {\n 'worklet';\n\n broadcastInputEvents('onChangeText', e);\n },\n },\n []\n );\n // effects\n useEffect(() => {\n if (enabled) {\n applyMonkeyPatch();\n } else {\n revertMonkeyPatch();\n }\n }, [enabled]);\n\n return (\n <KeyboardContext.Provider value={context}>\n <KeyboardControllerViewAnimated\n enabled={enabled}\n onKeyboardMoveReanimated={keyboardHandler}\n onKeyboardMoveStart={Platform.OS === 'ios' ? onKeyboardMove : undefined}\n onKeyboardMove={Platform.OS === 'android' ? onKeyboardMove : undefined}\n onKeyboardMoveInteractive={onKeyboardMove}\n onFocusedInputLayoutChangedReanimated={inputLayoutHandler}\n onFocusedInputTextChangedReanimated={inputTextHandler}\n navigationBarTranslucent={navigationBarTranslucent}\n statusBarTranslucent={statusBarTranslucent}\n style={styles.container}\n >\n {children}\n </KeyboardControllerViewAnimated>\n <Animated.View\n // we are using this small hack, because if the component (where\n // animated value has been used) is unmounted, then animation will\n // stop receiving events (seems like it's react-native optimization).\n // So we need to keep a reference to the animated value, to keep it's\n // always mounted (keep a reference to an animated value).\n //\n // To test why it's needed, try to open screen which consumes Animated.Value\n // then close it and open it again (for example 'Animated transition').\n style={style}\n />\n </KeyboardContext.Provider>\n );\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAIsB;AAAA;AAYtB,MAAMA,8BAA8B,GAAGC,8BAAU,CAACC,uBAAuB,CACvEC,qBAAQ,CAACD,uBAAuB,CAC9BE,gCAAsB,CACvB,CACF;AAOD,MAAMC,MAAM,GAAGC,uBAAU,CAACC,MAAM,CAAS;EACvCC,SAAS,EAAE;IACTC,IAAI,EAAE;EACR,CAAC;EACDC,MAAM,EAAE;IACNC,OAAO,EAAE,MAAM;IACfC,QAAQ,EAAE;EACZ;AACF,CAAC,CAAC;AA+BK,MAAMC,gB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,EACb,CACuB;AAE/B,CAAC;AAAC"}
|
package/lib/commonjs/bindings.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NOOP","KeyboardController","setDefaultMode","setInputMode","addListener","removeListeners","KeyboardEvents","remove","KeyboardControllerView","View","KeyboardGestureArea"],"sources":["bindings.ts"],"sourcesContent":["import { View } from 'react-native';\n\nimport type {\n KeyboardControllerModule,\n KeyboardControllerProps,\n KeyboardEventsModule,\n KeyboardGestureAreaProps,\n} from './types';\nimport type { EmitterSubscription } from 'react-native';\n\nconst NOOP = () => {};\nexport const KeyboardController: KeyboardControllerModule = {\n setDefaultMode: NOOP,\n setInputMode: NOOP,\n addListener: NOOP,\n removeListeners: NOOP,\n};\nexport const KeyboardEvents: KeyboardEventsModule = {\n addListener: () => ({ remove: NOOP } as EmitterSubscription),\n};\nexport const KeyboardControllerView =\n View as unknown as React.FC<KeyboardControllerProps>;\nexport const KeyboardGestureArea =\n View as unknown as React.FC<KeyboardGestureAreaProps>;\n"],"mappings":";;;;;;AAAA;AAUA,MAAMA,IAAI,GAAG,MAAM,CAAC,CAAC;AACd,MAAMC,kBAA4C,GAAG;EAC1DC,cAAc,EAAEF,IAAI;EACpBG,YAAY,EAAEH,IAAI;EAClBI,
|
|
1
|
+
{"version":3,"names":["NOOP","KeyboardController","setDefaultMode","setInputMode","dismiss","addListener","removeListeners","KeyboardEvents","remove","KeyboardControllerView","View","KeyboardGestureArea"],"sources":["bindings.ts"],"sourcesContent":["import { View } from 'react-native';\n\nimport type {\n KeyboardControllerModule,\n KeyboardControllerProps,\n KeyboardEventsModule,\n KeyboardGestureAreaProps,\n} from './types';\nimport type { EmitterSubscription } from 'react-native';\n\nconst NOOP = () => {};\nexport const KeyboardController: KeyboardControllerModule = {\n setDefaultMode: NOOP,\n setInputMode: NOOP,\n dismiss: NOOP,\n addListener: NOOP,\n removeListeners: NOOP,\n};\nexport const KeyboardEvents: KeyboardEventsModule = {\n addListener: () => ({ remove: NOOP } as EmitterSubscription),\n};\nexport const KeyboardControllerView =\n View as unknown as React.FC<KeyboardControllerProps>;\nexport const KeyboardGestureArea =\n View as unknown as React.FC<KeyboardGestureAreaProps>;\n"],"mappings":";;;;;;AAAA;AAUA,MAAMA,IAAI,GAAG,MAAM,CAAC,CAAC;AACd,MAAMC,kBAA4C,GAAG;EAC1DC,cAAc,EAAEF,IAAI;EACpBG,YAAY,EAAEH,IAAI;EAClBI,OAAO,EAAEJ,IAAI;EACbK,WAAW,EAAEL,IAAI;EACjBM,eAAe,EAAEN;AACnB,CAAC;AAAC;AACK,MAAMO,cAAoC,GAAG;EAClDF,WAAW,EAAE,OAAO;IAAEG,MAAM,EAAER;EAAK,CAAC;AACtC,CAAC;AAAC;AACK,MAAMS,sBAAsB,GACjCC,iBAAoD;AAAC;AAChD,MAAMC,mBAAmB,GAC9BD,iBAAqD;AAAC"}
|
|
@@ -39,15 +39,19 @@ const KeyboardAvoidingView = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) =>
|
|
|
39
39
|
const {
|
|
40
40
|
height: screenHeight
|
|
41
41
|
} = (0, _reactNative.useWindowDimensions)();
|
|
42
|
-
const relativeKeyboardHeight = (0,
|
|
42
|
+
const relativeKeyboardHeight = (0, _react.useCallback)(() => {
|
|
43
|
+
'worklet';
|
|
44
|
+
|
|
43
45
|
const keyboardY = screenHeight - keyboard.heightWhenOpened.value - keyboardVerticalOffset;
|
|
44
46
|
return Math.max(frame.value.y + frame.value.height - keyboardY, 0);
|
|
45
47
|
}, [screenHeight, keyboardVerticalOffset]);
|
|
46
|
-
const onLayoutWorklet = (0,
|
|
48
|
+
const onLayoutWorklet = (0, _react.useCallback)(layout => {
|
|
49
|
+
'worklet';
|
|
50
|
+
|
|
47
51
|
if (keyboard.isClosed.value) {
|
|
48
52
|
initialFrame.value = layout;
|
|
49
53
|
}
|
|
50
|
-
});
|
|
54
|
+
}, []);
|
|
51
55
|
const onLayout = (0, _react.useCallback)(e => {
|
|
52
56
|
(0, _reactNativeReanimated.runOnUI)(onLayoutWorklet)(e.nativeEvent.layout);
|
|
53
57
|
onLayoutProps === null || onLayoutProps === void 0 ? void 0 : onLayoutProps(e);
|
|
@@ -89,7 +93,6 @@ const KeyboardAvoidingView = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) =>
|
|
|
89
93
|
}, children));
|
|
90
94
|
}
|
|
91
95
|
return /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, _extends({
|
|
92
|
-
// @ts-expect-error because `ref` from reanimated is not compatible with react-native
|
|
93
96
|
ref: ref,
|
|
94
97
|
onLayout: onLayout,
|
|
95
98
|
style: combinedStyles
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["defaultLayout","x","y","width","height","KeyboardAvoidingView","forwardRef","ref","behavior","children","contentContainerStyle","enabled","keyboardVerticalOffset","style","onLayout","onLayoutProps","props","initialFrame","useSharedValue","frame","useDerivedValue","value","keyboard","useKeyboardAnimation","screenHeight","useWindowDimensions","relativeKeyboardHeight","
|
|
1
|
+
{"version":3,"names":["defaultLayout","x","y","width","height","KeyboardAvoidingView","forwardRef","ref","behavior","children","contentContainerStyle","enabled","keyboardVerticalOffset","style","onLayout","onLayoutProps","props","initialFrame","useSharedValue","frame","useDerivedValue","value","keyboard","useKeyboardAnimation","screenHeight","useWindowDimensions","relativeKeyboardHeight","useCallback","keyboardY","heightWhenOpened","Math","max","onLayoutWorklet","layout","isClosed","e","runOnUI","nativeEvent","animatedStyle","useAnimatedStyle","bottom","interpolate","progress","bottomHeight","flex","paddingBottom","isPositionBehavior","containerStyle","combinedStyles","useMemo"],"sources":["index.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useMemo } from 'react';\nimport { View, useWindowDimensions } from 'react-native';\nimport Reanimated, {\n interpolate,\n runOnUI,\n useAnimatedStyle,\n useDerivedValue,\n useSharedValue,\n} from 'react-native-reanimated';\n\nimport { useKeyboardAnimation } from './hooks';\n\nimport type { LayoutRectangle, ViewProps } from 'react-native';\n\ntype Props = {\n /**\n * Specify how to react to the presence of the keyboard.\n */\n behavior?: 'height' | 'position' | 'padding';\n\n /**\n * Style of the content container when `behavior` is 'position'.\n */\n contentContainerStyle?: ViewProps['style'];\n\n /**\n * Controls whether this `KeyboardAvoidingView` instance should take effect.\n * This is useful when more than one is on the screen. Defaults to true.\n */\n enabled?: boolean;\n\n /**\n * Distance between the top of the user screen and the React Native view. This\n * may be non-zero in some cases. Defaults to 0.\n */\n keyboardVerticalOffset?: number;\n} & ViewProps;\n\nconst defaultLayout: LayoutRectangle = {\n x: 0,\n y: 0,\n width: 0,\n height: 0,\n};\n\n/**\n * View that moves out of the way when the keyboard appears by automatically\n * adjusting its height, position, or bottom padding.\n */\nconst KeyboardAvoidingView = forwardRef<View, React.PropsWithChildren<Props>>(\n (\n {\n behavior,\n children,\n contentContainerStyle,\n enabled = true,\n keyboardVerticalOffset = 0,\n style,\n onLayout: onLayoutProps,\n ...props\n },\n ref\n ) => {\n const initialFrame = useSharedValue<LayoutRectangle | null>(null);\n const frame = useDerivedValue(() => initialFrame.value || defaultLayout);\n\n const keyboard = useKeyboardAnimation();\n const { height: screenHeight } = useWindowDimensions();\n\n const relativeKeyboardHeight = useCallback(() => {\n 'worklet';\n\n const keyboardY =\n screenHeight - keyboard.heightWhenOpened.value - keyboardVerticalOffset;\n\n return Math.max(frame.value.y + frame.value.height - keyboardY, 0);\n }, [screenHeight, keyboardVerticalOffset]);\n\n const onLayoutWorklet = useCallback((layout: LayoutRectangle) => {\n 'worklet';\n\n if (keyboard.isClosed.value) {\n initialFrame.value = layout;\n }\n }, []);\n const onLayout = useCallback<NonNullable<ViewProps['onLayout']>>(\n (e) => {\n runOnUI(onLayoutWorklet)(e.nativeEvent.layout);\n onLayoutProps?.(e);\n },\n [onLayoutProps]\n );\n\n const animatedStyle = useAnimatedStyle(() => {\n const bottom = interpolate(\n keyboard.progress.value,\n [0, 1],\n [0, relativeKeyboardHeight()]\n );\n const bottomHeight = enabled ? bottom : 0;\n\n switch (behavior) {\n case 'height':\n if (!keyboard.isClosed.value) {\n return {\n height: frame.value.height - bottomHeight,\n flex: 0,\n };\n }\n\n return {};\n\n case 'position':\n return { bottom: bottomHeight };\n\n case 'padding':\n return { paddingBottom: bottomHeight };\n\n default:\n return {};\n }\n }, [behavior, enabled, relativeKeyboardHeight]);\n const isPositionBehavior = behavior === 'position';\n const containerStyle = isPositionBehavior ? contentContainerStyle : style;\n const combinedStyles = useMemo(\n () => [containerStyle, animatedStyle],\n [containerStyle, animatedStyle]\n );\n\n if (isPositionBehavior) {\n return (\n <View ref={ref} style={style} onLayout={onLayout} {...props}>\n <Reanimated.View style={combinedStyles}>{children}</Reanimated.View>\n </View>\n );\n }\n\n return (\n <Reanimated.View\n ref={ref}\n onLayout={onLayout}\n style={combinedStyles}\n {...props}\n >\n {children}\n </Reanimated.View>\n );\n }\n);\n\nexport default KeyboardAvoidingView;\n"],"mappings":";;;;;;AAAA;AACA;AACA;AAQA;AAA+C;AAAA;AAAA;AA4B/C,MAAMA,aAA8B,GAAG;EACrCC,CAAC,EAAE,CAAC;EACJC,CAAC,EAAE,CAAC;EACJC,KAAK,EAAE,CAAC;EACRC,MAAM,EAAE;AACV,CAAC;;AAED;AACA;AACA;AACA;AACA,MAAMC,oBAAoB,gBAAG,IAAAC,iBAAU,EACrC,OAWEC,GAAG,KACA;EAAA,IAXH;IACEC,QAAQ;IACRC,QAAQ;IACRC,qBAAqB;IACrBC,OAAO,GAAG,IAAI;IACdC,sBAAsB,GAAG,CAAC;IAC1BC,KAAK;IACLC,QAAQ,EAAEC,aAAa;IACvB,GAAGC;EACL,CAAC;EAGD,MAAMC,YAAY,GAAG,IAAAC,qCAAc,EAAyB,IAAI,CAAC;EACjE,MAAMC,KAAK,GAAG,IAAAC,sCAAe,EAAC,MAAMH,YAAY,CAACI,KAAK,IAAIrB,aAAa,CAAC;EAExE,MAAMsB,QAAQ,GAAG,IAAAC,2BAAoB,GAAE;EACvC,MAAM;IAAEnB,MAAM,E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= _interopRequireWildcard(require("react"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
|
|
10
|
+
var _reactNativeKeyboardController = require("react-native-keyboard-controller");
|
|
11
|
+
var _useSmoothKeyboardHandler = require("./useSmoothKeyboardHandler");
|
|
12
|
+
var _utils = require("./utils");
|
|
13
|
+
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); }
|
|
14
|
+
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; }
|
|
15
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
16
|
+
/**
|
|
17
|
+
* Everything begins from `onStart` handler. This handler is called every time,
|
|
18
|
+
* when keyboard changes its size or when focused `TextInput` was changed. In
|
|
19
|
+
* this handler we are calculating/memoizing values which later will be used
|
|
20
|
+
* during layout movement. For that we calculate:
|
|
21
|
+
* - layout of focused field (`layout`) - to understand whether there will be overlap
|
|
22
|
+
* - initial keyboard size (`initialKeyboardSize`) - used in scroll interpolation
|
|
23
|
+
* - future keyboard height (`keyboardHeight`) - used in scroll interpolation
|
|
24
|
+
* - current scroll position (`scrollPosition`) - used to scroll from this point
|
|
25
|
+
*
|
|
26
|
+
* Once we've calculated all necessary variables - we can actually start to use them.
|
|
27
|
+
* It happens in `onMove` handler - this function simply calls `maybeScroll` with
|
|
28
|
+
* current keyboard frame height. This functions makes the smooth transition.
|
|
29
|
+
*
|
|
30
|
+
* When the transition has finished we go to `onEnd` handler. In this handler
|
|
31
|
+
* we verify, that the current field is not overlapped within a keyboard frame.
|
|
32
|
+
* For full `onStart`/`onMove`/`onEnd` flow it may look like a redundant thing,
|
|
33
|
+
* however there could be some cases, when `onMove` is not called:
|
|
34
|
+
* - on iOS when TextInput was changed - keyboard transition is instant
|
|
35
|
+
* - on Android when TextInput was changed and keyboard size wasn't changed
|
|
36
|
+
* So `onEnd` handler handle the case, when `onMove` wasn't triggered.
|
|
37
|
+
*
|
|
38
|
+
* ====================================================================================================================+
|
|
39
|
+
* -----------------------------------------------------Flow chart-----------------------------------------------------+
|
|
40
|
+
* ====================================================================================================================+
|
|
41
|
+
*
|
|
42
|
+
* +============================+ +============================+ +==================================+
|
|
43
|
+
* + User Press on TextInput + => + Keyboard starts showing + => + As keyboard moves frame by frame + =>
|
|
44
|
+
* + + + (run `onStart`) + + `onMove` is getting called +
|
|
45
|
+
* +============================+ +============================+ +==================================+
|
|
46
|
+
*
|
|
47
|
+
*
|
|
48
|
+
* +============================+ +============================+ +=====================================+
|
|
49
|
+
* + Keyboard is shown and we + => + User moved focus to + => + Only `onStart`/`onEnd` maybe called +
|
|
50
|
+
* + call `onEnd` handler + + another `TextInput` + + (without involving `onMove`) +
|
|
51
|
+
* +============================+ +============================+ +=====================================+
|
|
52
|
+
*
|
|
53
|
+
*/
|
|
54
|
+
const KeyboardAwareScrollView = _ref => {
|
|
55
|
+
let {
|
|
56
|
+
children,
|
|
57
|
+
bottomOffset = 0,
|
|
58
|
+
...rest
|
|
59
|
+
} = _ref;
|
|
60
|
+
const scrollViewAnimatedRef = (0, _reactNativeReanimated.useAnimatedRef)();
|
|
61
|
+
const scrollPosition = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
62
|
+
const position = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
63
|
+
const keyboardHeight = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
64
|
+
const tag = (0, _reactNativeReanimated.useSharedValue)(-1);
|
|
65
|
+
const initialKeyboardSize = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
66
|
+
const scrollBeforeKeyboardMovement = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
67
|
+
const {
|
|
68
|
+
input
|
|
69
|
+
} = (0, _reactNativeKeyboardController.useReanimatedFocusedInput)();
|
|
70
|
+
const layout = (0, _reactNativeReanimated.useSharedValue)(null);
|
|
71
|
+
const {
|
|
72
|
+
height
|
|
73
|
+
} = (0, _reactNative.useWindowDimensions)();
|
|
74
|
+
const onScroll = (0, _reactNativeReanimated.useAnimatedScrollHandler)({
|
|
75
|
+
onScroll: e => {
|
|
76
|
+
position.value = e.contentOffset.y;
|
|
77
|
+
}
|
|
78
|
+
}, []);
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Function that will scroll a ScrollView as keyboard gets moving
|
|
82
|
+
*/
|
|
83
|
+
const maybeScroll = (0, _react.useCallback)(function (e) {
|
|
84
|
+
'worklet';
|
|
85
|
+
|
|
86
|
+
var _layout$value, _layout$value2;
|
|
87
|
+
let animated = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
88
|
+
const visibleRect = height - keyboardHeight.value;
|
|
89
|
+
const absoluteY = ((_layout$value = layout.value) === null || _layout$value === void 0 ? void 0 : _layout$value.layout.absoluteY) || 0;
|
|
90
|
+
const inputHeight = ((_layout$value2 = layout.value) === null || _layout$value2 === void 0 ? void 0 : _layout$value2.layout.height) || 0;
|
|
91
|
+
const point = absoluteY + inputHeight;
|
|
92
|
+
if (visibleRect - point <= bottomOffset) {
|
|
93
|
+
const interpolatedScrollTo = (0, _reactNativeReanimated.interpolate)(e, [initialKeyboardSize.value, keyboardHeight.value], [0, keyboardHeight.value - (height - point) + bottomOffset]);
|
|
94
|
+
const targetScrollY = Math.max(interpolatedScrollTo, 0) + scrollPosition.value;
|
|
95
|
+
(0, _reactNativeReanimated.scrollTo)(scrollViewAnimatedRef, 0, targetScrollY, animated);
|
|
96
|
+
return interpolatedScrollTo;
|
|
97
|
+
}
|
|
98
|
+
if (absoluteY < 0) {
|
|
99
|
+
const positionOnScreen = visibleRect - inputHeight - bottomOffset;
|
|
100
|
+
const topOfScreen = scrollPosition.value + absoluteY;
|
|
101
|
+
(0, _reactNativeReanimated.scrollTo)(scrollViewAnimatedRef, 0, topOfScreen - positionOnScreen, animated);
|
|
102
|
+
}
|
|
103
|
+
return 0;
|
|
104
|
+
}, [bottomOffset]);
|
|
105
|
+
const onChangeText = (0, _react.useCallback)(() => {
|
|
106
|
+
'worklet';
|
|
107
|
+
|
|
108
|
+
// if typing a text caused layout shift, then we need to ignore this handler
|
|
109
|
+
// because this event will be handled in `useAnimatedReaction` below
|
|
110
|
+
var _layout$value3, _input$value;
|
|
111
|
+
if (((_layout$value3 = layout.value) === null || _layout$value3 === void 0 ? void 0 : _layout$value3.layout.height) !== ((_input$value = input.value) === null || _input$value === void 0 ? void 0 : _input$value.layout.height)) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
const prevScrollPosition = scrollPosition.value;
|
|
115
|
+
const prevLayout = layout.value;
|
|
116
|
+
scrollPosition.value = position.value;
|
|
117
|
+
layout.value = input.value;
|
|
118
|
+
maybeScroll(keyboardHeight.value, true);
|
|
119
|
+
scrollPosition.value = prevScrollPosition;
|
|
120
|
+
layout.value = prevLayout;
|
|
121
|
+
}, [maybeScroll]);
|
|
122
|
+
const onChangeTextHandler = (0, _react.useMemo)(() => (0, _utils.debounce)(onChangeText, 200), [onChangeText]);
|
|
123
|
+
(0, _reactNativeKeyboardController.useFocusedInputHandler)({
|
|
124
|
+
onChangeText: onChangeTextHandler
|
|
125
|
+
}, [onChangeTextHandler]);
|
|
126
|
+
(0, _useSmoothKeyboardHandler.useSmoothKeyboardHandler)({
|
|
127
|
+
onStart: e => {
|
|
128
|
+
'worklet';
|
|
129
|
+
|
|
130
|
+
const keyboardWillChangeSize = keyboardHeight.value !== e.height && e.height > 0;
|
|
131
|
+
const keyboardWillAppear = e.height > 0 && keyboardHeight.value === 0;
|
|
132
|
+
const keyboardWillHide = e.height === 0;
|
|
133
|
+
const focusWasChanged = tag.value !== e.target && e.target !== -1 || keyboardWillChangeSize;
|
|
134
|
+
if (keyboardWillChangeSize) {
|
|
135
|
+
initialKeyboardSize.value = keyboardHeight.value;
|
|
136
|
+
}
|
|
137
|
+
if (keyboardWillHide) {
|
|
138
|
+
// on back transition need to interpolate as [0, keyboardHeight]
|
|
139
|
+
initialKeyboardSize.value = 0;
|
|
140
|
+
scrollPosition.value = scrollBeforeKeyboardMovement.value;
|
|
141
|
+
}
|
|
142
|
+
if (keyboardWillAppear || keyboardWillChangeSize || focusWasChanged) {
|
|
143
|
+
// persist scroll value
|
|
144
|
+
scrollPosition.value = position.value;
|
|
145
|
+
// just persist height - later will be used in interpolation
|
|
146
|
+
keyboardHeight.value = e.height;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// focus was changed
|
|
150
|
+
if (focusWasChanged) {
|
|
151
|
+
tag.value = e.target;
|
|
152
|
+
|
|
153
|
+
// save position of focused text input when keyboard starts to move
|
|
154
|
+
layout.value = input.value;
|
|
155
|
+
// save current scroll position - when keyboard will hide we'll reuse
|
|
156
|
+
// this value to achieve smooth hide effect
|
|
157
|
+
scrollBeforeKeyboardMovement.value = position.value;
|
|
158
|
+
}
|
|
159
|
+
if (focusWasChanged && !keyboardWillAppear) {
|
|
160
|
+
// update position on scroll value, so `onEnd` handler
|
|
161
|
+
// will pick up correct values
|
|
162
|
+
position.value += maybeScroll(e.height, true);
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
onMove: e => {
|
|
166
|
+
'worklet';
|
|
167
|
+
|
|
168
|
+
maybeScroll(e.height);
|
|
169
|
+
},
|
|
170
|
+
onEnd: e => {
|
|
171
|
+
'worklet';
|
|
172
|
+
|
|
173
|
+
keyboardHeight.value = e.height;
|
|
174
|
+
scrollPosition.value = position.value;
|
|
175
|
+
}
|
|
176
|
+
}, [height, maybeScroll]);
|
|
177
|
+
(0, _reactNativeReanimated.useAnimatedReaction)(() => input.value, (current, previous) => {
|
|
178
|
+
if ((current === null || current === void 0 ? void 0 : current.target) === (previous === null || previous === void 0 ? void 0 : previous.target) && (current === null || current === void 0 ? void 0 : current.layout.height) !== (previous === null || previous === void 0 ? void 0 : previous.layout.height)) {
|
|
179
|
+
const prevLayout = layout.value;
|
|
180
|
+
layout.value = input.value;
|
|
181
|
+
scrollPosition.value += maybeScroll(keyboardHeight.value, true);
|
|
182
|
+
layout.value = prevLayout;
|
|
183
|
+
}
|
|
184
|
+
}, []);
|
|
185
|
+
const view = (0, _reactNativeReanimated.useAnimatedStyle)(() => ({
|
|
186
|
+
paddingBottom: keyboardHeight.value
|
|
187
|
+
}), []);
|
|
188
|
+
return /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.ScrollView, _extends({
|
|
189
|
+
ref: scrollViewAnimatedRef
|
|
190
|
+
}, rest, {
|
|
191
|
+
onScroll: onScroll,
|
|
192
|
+
scrollEventThrottle: 16
|
|
193
|
+
}), /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, {
|
|
194
|
+
style: view
|
|
195
|
+
}, children));
|
|
196
|
+
};
|
|
197
|
+
var _default = KeyboardAwareScrollView;
|
|
198
|
+
exports.default = _default;
|
|
199
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["KeyboardAwareScrollView","children","bottomOffset","rest","scrollViewAnimatedRef","useAnimatedRef","scrollPosition","useSharedValue","position","keyboardHeight","tag","initialKeyboardSize","scrollBeforeKeyboardMovement","input","useReanimatedFocusedInput","layout","height","useWindowDimensions","onScroll","useAnimatedScrollHandler","e","value","contentOffset","y","maybeScroll","useCallback","animated","visibleRect","absoluteY","inputHeight","point","interpolatedScrollTo","interpolate","targetScrollY","Math","max","scrollTo","positionOnScreen","topOfScreen","onChangeText","prevScrollPosition","prevLayout","onChangeTextHandler","useMemo","debounce","useFocusedInputHandler","useSmoothKeyboardHandler","onStart","keyboardWillChangeSize","keyboardWillAppear","keyboardWillHide","focusWasChanged","target","onMove","onEnd","useAnimatedReaction","current","previous","view","useAnimatedStyle","paddingBottom"],"sources":["index.tsx"],"sourcesContent":["import React, { 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 { FC } from 'react';\nimport type { ScrollViewProps } from 'react-native';\nimport type { FocusedInputLayoutChangedEvent } from 'react-native-keyboard-controller';\n\ntype KeyboardAwareScrollViewProps = {\n bottomOffset?: number;\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: FC<KeyboardAwareScrollViewProps> = ({\n children,\n bottomOffset = 0,\n ...rest\n}) => {\n const scrollViewAnimatedRef = useAnimatedRef<Reanimated.ScrollView>();\n const scrollPosition = useSharedValue(0);\n const position = useSharedValue(0);\n const keyboardHeight = useSharedValue(0);\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 /**\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 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]\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 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 {\n onStart: (e) => {\n 'worklet';\n\n const keyboardWillChangeSize =\n keyboardHeight.value !== e.height && e.height > 0;\n const keyboardWillAppear = e.height > 0 && keyboardHeight.value === 0;\n const keyboardWillHide = e.height === 0;\n const focusWasChanged =\n (tag.value !== e.target && e.target !== -1) || 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 (keyboardWillAppear || keyboardWillChangeSize || focusWasChanged) {\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) {\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 maybeScroll(e.height);\n },\n onEnd: (e) => {\n 'worklet';\n\n keyboardHeight.value = e.height;\n scrollPosition.value = position.value;\n },\n },\n [height, maybeScroll]\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 paddingBottom: keyboardHeight.value,\n }),\n []\n );\n\n return (\n <Reanimated.ScrollView\n ref={scrollViewAnimatedRef}\n {...rest}\n onScroll={onScroll}\n scrollEventThrottle={16}\n >\n <Reanimated.View style={view}>{children}</Reanimated.View>\n </Reanimated.ScrollView>\n );\n};\n\nexport default KeyboardAwareScrollView;\n"],"mappings":";;;;;;AAAA;AACA;AACA;AAUA;AAKA;AACA;AAAmC;AAAA;AAAA;AAUnC;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;AACA;AACA;AACA;AACA,MAAMA,uBAAyD,GAAG,QAI5D;EAAA,IAJ6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