react-native-keyboard-controller 1.12.6 → 1.13.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/android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardGestureAreaViewManager.kt +5 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/ReactContext.kt +13 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/extensions/ThemedReactContext.kt +0 -10
- package/android/src/main/java/com/reactnativekeyboardcontroller/interactive/interpolators/Interpolator.kt +2 -1
- package/android/src/main/java/com/reactnativekeyboardcontroller/interactive/interpolators/IosInterpolator.kt +2 -1
- package/android/src/main/java/com/reactnativekeyboardcontroller/interactive/interpolators/LinearInterpolator.kt +1 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/listeners/FocusedInputObserver.kt +15 -8
- package/android/src/main/java/com/reactnativekeyboardcontroller/listeners/KeyboardAnimationCallback.kt +71 -59
- package/android/src/main/java/com/reactnativekeyboardcontroller/managers/KeyboardGestureAreaViewManagerImpl.kt +4 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/modal/ModalAttachedWatcher.kt +80 -0
- package/android/src/main/java/com/reactnativekeyboardcontroller/modules/StatusBarManagerCompatModuleImpl.kt +6 -12
- package/android/src/main/java/com/reactnativekeyboardcontroller/views/EdgeToEdgeReactViewGroup.kt +31 -4
- package/android/src/main/java/com/reactnativekeyboardcontroller/views/KeyboardGestureAreaReactViewGroup.kt +7 -0
- package/android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardGestureAreaViewManager.kt +5 -0
- package/ios/core/KeyboardAnimation.swift +1 -1
- package/ios/core/TimingAnimation.swift +108 -0
- package/ios/extensions/UIApplication.swift +29 -0
- package/ios/extensions/UIView.swift +10 -0
- package/ios/observers/FocusedInputObserver.swift +2 -0
- package/ios/observers/KeyboardMovementObserver.swift +19 -10
- package/ios/traversal/ViewHierarchyNavigator.swift +1 -1
- package/ios/views/KeyboardControllerView.mm +30 -39
- package/lib/commonjs/animated.js +16 -30
- package/lib/commonjs/animated.js.map +1 -1
- package/lib/commonjs/bindings.js.map +1 -1
- package/lib/commonjs/bindings.native.js.map +1 -1
- package/lib/commonjs/components/KeyboardAvoidingView/hooks.js +3 -14
- package/lib/commonjs/components/KeyboardAvoidingView/hooks.js.map +1 -1
- package/lib/commonjs/components/KeyboardAvoidingView/index.js +5 -4
- package/lib/commonjs/components/KeyboardAvoidingView/index.js.map +1 -1
- package/lib/commonjs/components/KeyboardAwareScrollView/index.js +42 -16
- package/lib/commonjs/components/KeyboardAwareScrollView/index.js.map +1 -1
- package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +1 -0
- package/lib/commonjs/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -1
- package/lib/commonjs/components/KeyboardAwareScrollView/utils.js.map +1 -1
- package/lib/commonjs/components/KeyboardStickyView/index.js +2 -2
- package/lib/commonjs/components/KeyboardStickyView/index.js.map +1 -1
- package/lib/commonjs/components/KeyboardToolbar/Arrow.js +2 -2
- package/lib/commonjs/components/KeyboardToolbar/Arrow.js.map +1 -1
- package/lib/commonjs/components/KeyboardToolbar/Button.js +12 -12
- package/lib/commonjs/components/KeyboardToolbar/Button.js.map +1 -1
- package/lib/commonjs/components/KeyboardToolbar/index.js +33 -27
- package/lib/commonjs/components/KeyboardToolbar/index.js.map +1 -1
- package/lib/commonjs/components/index.js +2 -2
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/context.js +3 -2
- package/lib/commonjs/context.js.map +1 -1
- package/lib/commonjs/event-handler.js +19 -0
- package/lib/commonjs/event-handler.js.map +1 -0
- package/lib/commonjs/event-handler.web.js +10 -0
- package/lib/commonjs/event-handler.web.js.map +1 -0
- package/lib/commonjs/event-mappings.js +9 -0
- package/lib/commonjs/event-mappings.js.map +1 -0
- package/lib/commonjs/hooks/index.js +8 -21
- package/lib/commonjs/hooks/index.js.map +1 -1
- package/lib/commonjs/hooks/useSyncEffect/index.js +37 -0
- package/lib/commonjs/hooks/useSyncEffect/index.js.map +1 -0
- package/lib/commonjs/internal.js +20 -43
- package/lib/commonjs/internal.js.map +1 -1
- package/lib/commonjs/monkey-patch.android.js +1 -1
- package/lib/commonjs/monkey-patch.android.js.map +1 -1
- package/lib/commonjs/monkey-patch.js.map +1 -1
- package/lib/commonjs/reanimated.js +1 -3
- package/lib/commonjs/reanimated.js.map +1 -1
- package/lib/commonjs/reanimated.native.js +1 -35
- package/lib/commonjs/reanimated.native.js.map +1 -1
- package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js +1 -1
- package/lib/commonjs/specs/KeyboardControllerViewNativeComponent.js.map +1 -1
- package/lib/commonjs/specs/KeyboardGestureAreaNativeComponent.js +1 -1
- package/lib/commonjs/specs/KeyboardGestureAreaNativeComponent.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/animated.js +17 -32
- package/lib/module/animated.js.map +1 -1
- package/lib/module/bindings.js.map +1 -1
- package/lib/module/bindings.native.js.map +1 -1
- package/lib/module/components/KeyboardAvoidingView/hooks.js +3 -14
- package/lib/module/components/KeyboardAvoidingView/hooks.js.map +1 -1
- package/lib/module/components/KeyboardAvoidingView/index.js +4 -3
- package/lib/module/components/KeyboardAvoidingView/index.js.map +1 -1
- package/lib/module/components/KeyboardAwareScrollView/index.js +41 -15
- package/lib/module/components/KeyboardAwareScrollView/index.js.map +1 -1
- package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js +1 -0
- package/lib/module/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.js.map +1 -1
- package/lib/module/components/KeyboardAwareScrollView/utils.js.map +1 -1
- package/lib/module/components/KeyboardStickyView/index.js +1 -1
- package/lib/module/components/KeyboardToolbar/Button.js +10 -10
- package/lib/module/components/KeyboardToolbar/Button.js.map +1 -1
- package/lib/module/components/KeyboardToolbar/index.js +31 -25
- package/lib/module/components/KeyboardToolbar/index.js.map +1 -1
- package/lib/module/context.js +3 -2
- package/lib/module/context.js.map +1 -1
- package/lib/module/event-handler.js +13 -0
- package/lib/module/event-handler.js.map +1 -0
- package/lib/module/event-handler.web.js +5 -0
- package/lib/module/event-handler.web.js.map +1 -0
- package/lib/module/event-mappings.js +3 -0
- package/lib/module/event-mappings.js.map +1 -0
- package/lib/module/hooks/index.js +7 -21
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/hooks/useSyncEffect/index.js +31 -0
- package/lib/module/hooks/useSyncEffect/index.js.map +1 -0
- package/lib/module/internal.js +21 -44
- package/lib/module/internal.js.map +1 -1
- package/lib/module/monkey-patch.js.map +1 -1
- package/lib/module/reanimated.js +0 -2
- package/lib/module/reanimated.js.map +1 -1
- package/lib/module/reanimated.native.js +0 -32
- package/lib/module/reanimated.native.js.map +1 -1
- package/lib/module/specs/KeyboardGestureAreaNativeComponent.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/components/KeyboardToolbar/Button.d.ts +2 -2
- package/lib/typescript/components/KeyboardToolbar/index.d.ts +4 -3
- package/lib/typescript/context.d.ts +3 -3
- package/lib/typescript/event-handler.d.ts +3 -0
- package/lib/typescript/event-mappings.d.ts +2 -0
- package/lib/typescript/hooks/index.d.ts +1 -1
- package/lib/typescript/hooks/useSyncEffect/index.d.ts +14 -0
- package/lib/typescript/internal.d.ts +5 -19
- package/lib/typescript/reanimated.d.ts +1 -3
- package/lib/typescript/reanimated.native.d.ts +1 -3
- package/lib/typescript/specs/KeyboardGestureAreaNativeComponent.d.ts +2 -1
- package/lib/typescript/types.d.ts +6 -0
- package/package.json +14 -7
- package/src/animated.tsx +21 -43
- package/src/bindings.native.ts +1 -0
- package/src/bindings.ts +1 -0
- package/src/components/KeyboardAvoidingView/hooks.ts +3 -13
- package/src/components/KeyboardAvoidingView/index.tsx +2 -1
- package/src/components/KeyboardAwareScrollView/index.tsx +51 -13
- package/src/components/KeyboardAwareScrollView/useSmoothKeyboardHandler.ts +2 -0
- package/src/components/KeyboardAwareScrollView/utils.ts +1 -0
- package/src/components/KeyboardToolbar/Button.tsx +11 -11
- package/src/components/KeyboardToolbar/index.tsx +45 -25
- package/src/context.ts +8 -6
- package/src/event-handler.js +15 -0
- package/src/event-handler.ts +8 -0
- package/src/event-handler.web.js +5 -0
- package/src/event-mappings.ts +14 -0
- package/src/hooks/index.ts +9 -16
- package/src/hooks/useSyncEffect/index.ts +36 -0
- package/src/internal.ts +34 -53
- package/src/monkey-patch.ts +1 -0
- package/src/reanimated.native.ts +0 -50
- package/src/reanimated.ts +1 -12
- package/src/specs/KeyboardGestureAreaNativeComponent.ts +5 -1
- package/src/types.ts +6 -0
- package/lib/commonjs/utils.js +0 -9
- package/lib/commonjs/utils.js.map +0 -1
- package/lib/module/utils.js +0 -2
- package/lib/module/utils.js.map +0 -1
- package/lib/typescript/utils.d.ts +0 -1
- package/src/utils.ts +0 -1
|
@@ -18,9 +18,9 @@ var _useColorScheme = _interopRequireDefault(require("../hooks/useColorScheme"))
|
|
|
18
18
|
var _Arrow = _interopRequireDefault(require("./Arrow"));
|
|
19
19
|
var _Button = _interopRequireDefault(require("./Button"));
|
|
20
20
|
var _colors = require("./colors");
|
|
21
|
-
function _interopRequireDefault(
|
|
21
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
22
22
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
23
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u &&
|
|
23
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
24
24
|
const TEST_ID_KEYBOARD_TOOLBAR = "keyboard.toolbar";
|
|
25
25
|
const TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS = `${TEST_ID_KEYBOARD_TOOLBAR}.previous`;
|
|
26
26
|
const TEST_ID_KEYBOARD_TOOLBAR_NEXT = `${TEST_ID_KEYBOARD_TOOLBAR}.next`;
|
|
@@ -73,17 +73,23 @@ const KeyboardToolbar = ({
|
|
|
73
73
|
}], [colorScheme, opacity, theme]);
|
|
74
74
|
const ButtonContainer = button || _Button.default;
|
|
75
75
|
const IconContainer = icon || _Arrow.default;
|
|
76
|
-
const onPressNext = (0, _react.useCallback)(
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
const onPressNext = (0, _react.useCallback)(event => {
|
|
77
|
+
onNextCallback === null || onNextCallback === void 0 || onNextCallback(event);
|
|
78
|
+
if (!event.isDefaultPrevented()) {
|
|
79
|
+
goToNextField();
|
|
80
|
+
}
|
|
79
81
|
}, [onNextCallback]);
|
|
80
|
-
const onPressPrev = (0, _react.useCallback)(
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
const onPressPrev = (0, _react.useCallback)(event => {
|
|
83
|
+
onPrevCallback === null || onPrevCallback === void 0 || onPrevCallback(event);
|
|
84
|
+
if (!event.isDefaultPrevented()) {
|
|
85
|
+
goToPrevField();
|
|
86
|
+
}
|
|
83
87
|
}, [onPrevCallback]);
|
|
84
|
-
const onPressDone = (0, _react.useCallback)(
|
|
85
|
-
|
|
86
|
-
|
|
88
|
+
const onPressDone = (0, _react.useCallback)(event => {
|
|
89
|
+
onDoneCallback === null || onDoneCallback === void 0 || onDoneCallback(event);
|
|
90
|
+
if (!event.isDefaultPrevented()) {
|
|
91
|
+
dismissKeyboard();
|
|
92
|
+
}
|
|
87
93
|
}, [onDoneCallback]);
|
|
88
94
|
return /*#__PURE__*/_react.default.createElement(_reactNativeKeyboardController.KeyboardStickyView, {
|
|
89
95
|
offset: offset
|
|
@@ -91,41 +97,41 @@ const KeyboardToolbar = ({
|
|
|
91
97
|
style: toolbarStyle,
|
|
92
98
|
testID: TEST_ID_KEYBOARD_TOOLBAR
|
|
93
99
|
}, blur, showArrows && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(ButtonContainer, {
|
|
100
|
+
accessibilityHint: "Moves focus to the previous field",
|
|
94
101
|
accessibilityLabel: "Previous",
|
|
95
|
-
accessibilityHint: "Will move focus to previous field",
|
|
96
102
|
disabled: isPrevDisabled,
|
|
97
|
-
onPress: onPressPrev,
|
|
98
103
|
testID: TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS,
|
|
99
|
-
theme: theme
|
|
104
|
+
theme: theme,
|
|
105
|
+
onPress: onPressPrev
|
|
100
106
|
}, /*#__PURE__*/_react.default.createElement(IconContainer, {
|
|
101
107
|
disabled: isPrevDisabled,
|
|
102
|
-
|
|
103
|
-
|
|
108
|
+
theme: theme,
|
|
109
|
+
type: "prev"
|
|
104
110
|
})), /*#__PURE__*/_react.default.createElement(ButtonContainer, {
|
|
111
|
+
accessibilityHint: "Moves focus to the next field",
|
|
105
112
|
accessibilityLabel: "Next",
|
|
106
|
-
accessibilityHint: "Will move focus to next field",
|
|
107
113
|
disabled: isNextDisabled,
|
|
108
|
-
onPress: onPressNext,
|
|
109
114
|
testID: TEST_ID_KEYBOARD_TOOLBAR_NEXT,
|
|
110
|
-
theme: theme
|
|
115
|
+
theme: theme,
|
|
116
|
+
onPress: onPressNext
|
|
111
117
|
}, /*#__PURE__*/_react.default.createElement(IconContainer, {
|
|
112
118
|
disabled: isNextDisabled,
|
|
113
|
-
|
|
114
|
-
|
|
119
|
+
theme: theme,
|
|
120
|
+
type: "next"
|
|
115
121
|
}))), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
116
122
|
style: styles.flex,
|
|
117
123
|
testID: TEST_ID_KEYBOARD_TOOLBAR_CONTENT
|
|
118
124
|
}, content), /*#__PURE__*/_react.default.createElement(ButtonContainer, {
|
|
125
|
+
accessibilityHint: "Closes the keyboard",
|
|
119
126
|
accessibilityLabel: "Done",
|
|
120
|
-
accessibilityHint: "Will close the keyboard",
|
|
121
|
-
onPress: onPressDone,
|
|
122
|
-
testID: TEST_ID_KEYBOARD_TOOLBAR_DONE,
|
|
123
127
|
rippleRadius: 28,
|
|
124
128
|
style: styles.doneButtonContainer,
|
|
125
|
-
|
|
129
|
+
testID: TEST_ID_KEYBOARD_TOOLBAR_DONE,
|
|
130
|
+
theme: theme,
|
|
131
|
+
onPress: onPressDone
|
|
126
132
|
}, /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
|
|
127
|
-
|
|
128
|
-
|
|
133
|
+
maxFontSizeMultiplier: 1.3,
|
|
134
|
+
style: doneStyle
|
|
129
135
|
}, doneText || "Done"))));
|
|
130
136
|
};
|
|
131
137
|
const styles = _reactNative.StyleSheet.create({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeKeyboardController","_bindings","_useColorScheme","_interopRequireDefault","_Arrow","_Button","_colors","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","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","DEFAULT_OPACITY","offset","closed","dismissKeyboard","KeyboardController","dismiss","goToNextField","setFocusTo","goToPrevField","KeyboardToolbar","content","theme","colors","doneText","button","icon","showArrows","onNextCallback","onPrevCallback","onDoneCallback","blur","opacity","colorScheme","useColorScheme","inputs","setInputs","useState","current","count","isPrevDisabled","isNextDisabled","useEffect","subscription","FocusedInputEvents","addListener","remove","doneStyle","useMemo","styles","doneButton","color","primary","toolbarStyle","toolbar","backgroundColor","background","ButtonContainer","Button","IconContainer","Arrow","onPressNext","useCallback","onPressPrev","onPressDone","createElement","KeyboardStickyView","View","style","testID","Fragment","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, { useCallback, 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 { HEX, KeyboardToolbarTheme } from \"./types\";\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 /**\n * Whether to show next and previous buttons. Can be useful to set it to `false` if you have only one input\n * and want to show only `Done` button. Default to `true`.\n */\n showArrows?: boolean;\n /**\n * A callback that is called when the user presses the next button along with the default action.\n */\n onNextCallback?: () => void;\n /**\n * A callback that is called when the user presses the previous button along with the default action.\n */\n onPrevCallback?: () => void;\n /**\n * A callback that is called when the user presses the done button along with the default action.\n */\n onDoneCallback?: () => void;\n /**\n * A component that applies blur effect to the toolbar.\n */\n blur?: JSX.Element | null;\n /**\n * A value for container opacity in hexadecimal format (e.g. `ff`). Default value is `ff`.\n */\n opacity?: HEX;\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 DEFAULT_OPACITY: HEX = \"FF\";\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 showArrows = true,\n onNextCallback,\n onPrevCallback,\n onDoneCallback,\n blur = null,\n opacity = DEFAULT_OPACITY,\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}${opacity}`,\n },\n ],\n [colorScheme, opacity, theme],\n );\n const ButtonContainer = button || Button;\n const IconContainer = icon || Arrow;\n\n const onPressNext = useCallback(() => {\n goToNextField();\n onNextCallback?.();\n }, [onNextCallback]);\n const onPressPrev = useCallback(() => {\n goToPrevField();\n onPrevCallback?.();\n }, [onPrevCallback]);\n const onPressDone = useCallback(() => {\n dismissKeyboard();\n onDoneCallback?.();\n }, [onDoneCallback]);\n\n return (\n <KeyboardStickyView offset={offset}>\n <View style={toolbarStyle} testID={TEST_ID_KEYBOARD_TOOLBAR}>\n {blur}\n {showArrows && (\n <>\n <ButtonContainer\n accessibilityLabel=\"Previous\"\n accessibilityHint=\"Will move focus to previous field\"\n disabled={isPrevDisabled}\n onPress={onPressPrev}\n testID={TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS}\n theme={theme}\n >\n <IconContainer\n disabled={isPrevDisabled}\n type=\"prev\"\n theme={theme}\n />\n </ButtonContainer>\n <ButtonContainer\n accessibilityLabel=\"Next\"\n accessibilityHint=\"Will move focus to next field\"\n disabled={isNextDisabled}\n onPress={onPressNext}\n testID={TEST_ID_KEYBOARD_TOOLBAR_NEXT}\n theme={theme}\n >\n <IconContainer\n disabled={isNextDisabled}\n type=\"next\"\n theme={theme}\n />\n </ButtonContainer>\n </>\n )}\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={onPressDone}\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,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAd,wBAAAc,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAH,UAAA,SAAAG,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAF,OAAA,EAAAE,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAC,GAAA,CAAAJ,CAAA,UAAAG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U;IACpBC,MAAM,EAAE,CAAC;IACTC,UAAU,EAAE,QAAQ;IACpBC,KAAK,EAAE,MAAM;IACbC,aAAa,EAAE,KAAK;IACpBC,MAAM,EAAE9E,uBAAuB;IAC/B+E,iBAAiB,EAAE;EACrB,CAAC;EACDvC,UAAU,EAAE;IACVwC,UAAU,EAAE,KAAK;IACjBC,QAAQ,EAAE;EACZ,CAAC;EACDb,mBAAmB,EAAE;IACnBc,WAAW,EAAE;EACf;AACF,CAAC,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA7G,OAAA,GAGYmC,eAAe","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeKeyboardController","_bindings","_useColorScheme","_interopRequireDefault","_Arrow","_Button","_colors","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","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","DEFAULT_OPACITY","offset","closed","dismissKeyboard","KeyboardController","dismiss","goToNextField","setFocusTo","goToPrevField","KeyboardToolbar","content","theme","colors","doneText","button","icon","showArrows","onNextCallback","onPrevCallback","onDoneCallback","blur","opacity","colorScheme","useColorScheme","inputs","setInputs","useState","current","count","isPrevDisabled","isNextDisabled","useEffect","subscription","FocusedInputEvents","addListener","remove","doneStyle","useMemo","styles","doneButton","color","primary","toolbarStyle","toolbar","backgroundColor","background","ButtonContainer","Button","IconContainer","Arrow","onPressNext","useCallback","event","isDefaultPrevented","onPressPrev","onPressDone","createElement","KeyboardStickyView","View","style","testID","Fragment","accessibilityHint","accessibilityLabel","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, { useCallback, 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 { HEX, KeyboardToolbarTheme } from \"./types\";\nimport type { ReactNode } from \"react\";\nimport type { GestureResponderEvent } from \"react-native\";\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 /**\n * Whether to show next and previous buttons. Can be useful to set it to `false` if you have only one input\n * and want to show only `Done` button. Default to `true`.\n */\n showArrows?: boolean;\n /**\n * A callback that is called when the user presses the next button along with the default action.\n */\n onNextCallback?: (event: GestureResponderEvent) => void;\n /**\n * A callback that is called when the user presses the previous button along with the default action.\n */\n onPrevCallback?: (event: GestureResponderEvent) => void;\n /**\n * A callback that is called when the user presses the done button along with the default action.\n */\n onDoneCallback?: (event: GestureResponderEvent) => void;\n /**\n * A component that applies blur effect to the toolbar.\n */\n blur?: JSX.Element | null;\n /**\n * A value for container opacity in hexadecimal format (e.g. `ff`). Default value is `ff`.\n */\n opacity?: HEX;\n};\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 DEFAULT_OPACITY: HEX = \"FF\";\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 showArrows = true,\n onNextCallback,\n onPrevCallback,\n onDoneCallback,\n blur = null,\n opacity = DEFAULT_OPACITY,\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}${opacity}`,\n },\n ],\n [colorScheme, opacity, theme],\n );\n const ButtonContainer = button || Button;\n const IconContainer = icon || Arrow;\n\n const onPressNext = useCallback(\n (event: GestureResponderEvent) => {\n onNextCallback?.(event);\n\n if (!event.isDefaultPrevented()) {\n goToNextField();\n }\n },\n [onNextCallback],\n );\n const onPressPrev = useCallback(\n (event: GestureResponderEvent) => {\n onPrevCallback?.(event);\n\n if (!event.isDefaultPrevented()) {\n goToPrevField();\n }\n },\n [onPrevCallback],\n );\n const onPressDone = useCallback(\n (event: GestureResponderEvent) => {\n onDoneCallback?.(event);\n\n if (!event.isDefaultPrevented()) {\n dismissKeyboard();\n }\n },\n [onDoneCallback],\n );\n\n return (\n <KeyboardStickyView offset={offset}>\n <View style={toolbarStyle} testID={TEST_ID_KEYBOARD_TOOLBAR}>\n {blur}\n {showArrows && (\n <>\n <ButtonContainer\n accessibilityHint=\"Moves focus to the previous field\"\n accessibilityLabel=\"Previous\"\n disabled={isPrevDisabled}\n testID={TEST_ID_KEYBOARD_TOOLBAR_PREVIOUS}\n theme={theme}\n onPress={onPressPrev}\n >\n <IconContainer\n disabled={isPrevDisabled}\n theme={theme}\n type=\"prev\"\n />\n </ButtonContainer>\n <ButtonContainer\n accessibilityHint=\"Moves focus to the next field\"\n accessibilityLabel=\"Next\"\n disabled={isNextDisabled}\n testID={TEST_ID_KEYBOARD_TOOLBAR_NEXT}\n theme={theme}\n onPress={onPressNext}\n >\n <IconContainer\n disabled={isNextDisabled}\n theme={theme}\n type=\"next\"\n />\n </ButtonContainer>\n </>\n )}\n\n <View style={styles.flex} testID={TEST_ID_KEYBOARD_TOOLBAR_CONTENT}>\n {content}\n </View>\n <ButtonContainer\n accessibilityHint=\"Closes the keyboard\"\n accessibilityLabel=\"Done\"\n rippleRadius={28}\n style={styles.doneButtonContainer}\n testID={TEST_ID_KEYBOARD_TOOLBAR_DONE}\n theme={theme}\n onPress={onPressDone}\n >\n <Text maxFontSizeMultiplier={1.3} style={doneStyle}>\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,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,yBAAAH,CAAA,6BAAAI,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAD,wBAAA,YAAAA,CAAAH,CAAA,WAAAA,CAAA,GAAAM,CAAA,GAAAD,CAAA,KAAAL,CAAA;AAAA,SAAAV,wBAAAU,CAAA,EAAAK,CAAA,SAAAA,CAAA,IAAAL,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAE,OAAA,EAAAF,CAAA,QAAAM,CAAA,GAAAH,wBAAA,CAAAE,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAC,GAAA,CAAAP,CAAA,UAAAM,CAAA,CAAAE,GAAA,CAAAR,CAAA,OAAAS,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAf,CAAA,oBAAAe,CAAA,OAAA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AC;EACDxB,OAAO,EAAE;IACP+B,QAAQ,EAAE,UAAU;IACpBC,MAAM,EAAE,CAAC;IACTC,UAAU,EAAE,QAAQ;IACpBC,KAAK,EAAE,MAAM;IACbC,aAAa,EAAE,KAAK;IACpBC,MAAM,EAAEhF,uBAAuB;IAC/BiF,iBAAiB,EAAE;EACrB,CAAC;EACDzC,UAAU,EAAE;IACV0C,UAAU,EAAE,KAAK;IACjBC,QAAQ,EAAE;EACZ,CAAC;EACDb,mBAAmB,EAAE;IACnBc,WAAW,EAAE;EACf;AACF,CAAC,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA7G,OAAA,GAGYiC,eAAe","ignoreList":[]}
|
|
@@ -38,6 +38,6 @@ var _KeyboardStickyView = _interopRequireDefault(require("./KeyboardStickyView")
|
|
|
38
38
|
var _KeyboardAwareScrollView = _interopRequireDefault(require("./KeyboardAwareScrollView"));
|
|
39
39
|
var _KeyboardToolbar = _interopRequireWildcard(require("./KeyboardToolbar"));
|
|
40
40
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
41
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u &&
|
|
42
|
-
function _interopRequireDefault(
|
|
41
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
42
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
43
43
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_KeyboardAvoidingView","_interopRequireDefault","require","_KeyboardStickyView","_KeyboardAwareScrollView","_KeyboardToolbar","_interopRequireWildcard","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","
|
|
1
|
+
{"version":3,"names":["_KeyboardAvoidingView","_interopRequireDefault","require","_KeyboardStickyView","_KeyboardAwareScrollView","_KeyboardToolbar","_interopRequireWildcard","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set"],"sources":["index.ts"],"sourcesContent":["export { default as KeyboardAvoidingView } from \"./KeyboardAvoidingView\";\nexport { default as KeyboardStickyView } from \"./KeyboardStickyView\";\nexport { default as KeyboardAwareScrollView } from \"./KeyboardAwareScrollView\";\nexport {\n default as KeyboardToolbar,\n DefaultKeyboardToolbarTheme,\n} from \"./KeyboardToolbar\";\nexport type { KeyboardAvoidingViewProps } from \"./KeyboardAvoidingView\";\nexport type { KeyboardStickyViewProps } from \"./KeyboardStickyView\";\nexport type { KeyboardAwareScrollViewProps } from \"./KeyboardAwareScrollView\";\nexport type { KeyboardToolbarProps } from \"./KeyboardToolbar\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,qBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,wBAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,gBAAA,GAAAC,uBAAA,CAAAJ,OAAA;AAG2B,SAAAK,yB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KeyboardContext = exports.KeyboardContext = void 0;
|
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _reactNative = require("react-native");
|
|
9
9
|
const NOOP = () => {};
|
|
10
|
+
const NESTED_NOOP = () => NOOP;
|
|
10
11
|
const withSharedValue = value => ({
|
|
11
12
|
value,
|
|
12
13
|
addListener: NOOP,
|
|
@@ -26,8 +27,8 @@ const defaultContext = {
|
|
|
26
27
|
height: DEFAULT_SHARED_VALUE
|
|
27
28
|
},
|
|
28
29
|
layout: DEFAULT_LAYOUT,
|
|
29
|
-
setKeyboardHandlers:
|
|
30
|
-
setInputHandlers:
|
|
30
|
+
setKeyboardHandlers: NESTED_NOOP,
|
|
31
|
+
setInputHandlers: NESTED_NOOP,
|
|
31
32
|
setEnabled: NOOP
|
|
32
33
|
};
|
|
33
34
|
const KeyboardContext = exports.KeyboardContext = /*#__PURE__*/(0, _react.createContext)(defaultContext);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_reactNative","NOOP","withSharedValue","value","addListener","removeListener","modify","DEFAULT_SHARED_VALUE","DEFAULT_LAYOUT","defaultContext","enabled","animated","progress","Animated","Value","height","reanimated","layout","setKeyboardHandlers","setInputHandlers","setEnabled","KeyboardContext","exports","createContext","useKeyboardContext","context","useContext","__DEV__","console","warn"],"sources":["context.ts"],"sourcesContent":["import { createContext, useContext } from \"react\";\nimport { Animated } from \"react-native\";\n\nimport type {\n
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","NOOP","NESTED_NOOP","withSharedValue","value","addListener","removeListener","modify","DEFAULT_SHARED_VALUE","DEFAULT_LAYOUT","defaultContext","enabled","animated","progress","Animated","Value","height","reanimated","layout","setKeyboardHandlers","setInputHandlers","setEnabled","KeyboardContext","exports","createContext","useKeyboardContext","context","useContext","__DEV__","console","warn"],"sources":["context.ts"],"sourcesContent":["import { createContext, useContext } from \"react\";\nimport { Animated } from \"react-native\";\n\nimport type {\n FocusedInputHandler,\n FocusedInputLayoutChangedEvent,\n KeyboardHandler,\n} from \"./types\";\nimport type React from \"react\";\nimport type { SharedValue } from \"react-native-reanimated\";\n\nexport type AnimatedContext = {\n progress: Animated.Value;\n height: Animated.AnimatedMultiplication<number>;\n};\nexport type ReanimatedContext = {\n progress: SharedValue<number>;\n height: SharedValue<number>;\n};\nexport type KeyboardAnimationContext = {\n enabled: boolean;\n animated: AnimatedContext;\n reanimated: ReanimatedContext;\n layout: SharedValue<FocusedInputLayoutChangedEvent | null>;\n setKeyboardHandlers: (handlers: KeyboardHandler) => () => void;\n setInputHandlers: (handlers: FocusedInputHandler) => () => void;\n setEnabled: React.Dispatch<React.SetStateAction<boolean>>;\n};\nconst NOOP = () => {};\nconst NESTED_NOOP = () => NOOP;\nconst withSharedValue = <T>(value: T): SharedValue<T> => ({\n value,\n addListener: NOOP,\n removeListener: NOOP,\n modify: NOOP,\n});\nconst DEFAULT_SHARED_VALUE = withSharedValue(0);\nconst DEFAULT_LAYOUT = withSharedValue<FocusedInputLayoutChangedEvent | null>(\n null,\n);\nconst defaultContext: KeyboardAnimationContext = {\n enabled: true,\n animated: {\n progress: new Animated.Value(0),\n height: new Animated.Value(0),\n },\n reanimated: {\n progress: DEFAULT_SHARED_VALUE,\n height: DEFAULT_SHARED_VALUE,\n },\n layout: DEFAULT_LAYOUT,\n setKeyboardHandlers: NESTED_NOOP,\n setInputHandlers: NESTED_NOOP,\n setEnabled: NOOP,\n};\n\nexport const KeyboardContext = createContext(defaultContext);\nexport const useKeyboardContext = () => {\n const context = useContext(KeyboardContext);\n\n if (__DEV__ && context === defaultContext) {\n console.warn(\n \"Couldn't find real values for `KeyboardContext`. Please make sure you're inside of `KeyboardProvider` - otherwise functionality of `react-native-keyboard-controller` will not work.\",\n );\n }\n\n return context;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AA2BA,MAAME,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AACrB,MAAMC,WAAW,GAAGA,CAAA,KAAMD,IAAI;AAC9B,MAAME,eAAe,GAAOC,KAAQ,KAAsB;EACxDA,KAAK;EACLC,WAAW,EAAEJ,IAAI;EACjBK,cAAc,EAAEL,IAAI;EACpBM,MAAM,EAAEN;AACV,CAAC,CAAC;AACF,MAAMO,oBAAoB,GAAGL,eAAe,CAAC,CAAC,CAAC;AAC/C,MAAMM,cAAc,GAAGN,eAAe,CACpC,IACF,CAAC;AACD,MAAMO,cAAwC,GAAG;EAC/CC,OAAO,EAAE,IAAI;EACbC,QAAQ,EAAE;IACRC,QAAQ,EAAE,IAAIC,qBAAQ,CAACC,KAAK,CAAC,CAAC,CAAC;IAC/BC,MAAM,EAAE,IAAIF,qBAAQ,CAACC,KAAK,CAAC,CAAC;EAC9B,CAAC;EACDE,UAAU,EAAE;IACVJ,QAAQ,EAAEL,oBAAoB;IAC9BQ,MAAM,EAAER;EACV,CAAC;EACDU,MAAM,EAAET,cAAc;EACtBU,mBAAmB,EAAEjB,WAAW;EAChCkB,gBAAgB,EAAElB,WAAW;EAC7BmB,UAAU,EAAEpB;AACd,CAAC;AAEM,MAAMqB,eAAe,GAAAC,OAAA,CAAAD,eAAA,gBAAG,IAAAE,oBAAa,EAACd,cAAc,CAAC;AACrD,MAAMe,kBAAkB,GAAGA,CAAA,KAAM;EACtC,MAAMC,OAAO,GAAG,IAAAC,iBAAU,EAACL,eAAe,CAAC;EAE3C,IAAIM,OAAO,IAAIF,OAAO,KAAKhB,cAAc,EAAE;IACzCmB,OAAO,CAACC,IAAI,CACV,sLACF,CAAC;EACH;EAEA,OAAOJ,OAAO;AAChB,CAAC;AAACH,OAAA,CAAAE,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.unregisterEventHandler = exports.registerEventHandler = void 0;
|
|
7
|
+
let REACore = null;
|
|
8
|
+
try {
|
|
9
|
+
REACore = require("react-native-reanimated/src/core");
|
|
10
|
+
} catch (e1) {
|
|
11
|
+
try {
|
|
12
|
+
REACore = require("react-native-reanimated/src/reanimated2/core");
|
|
13
|
+
} catch (e2) {
|
|
14
|
+
console.warn("Failed to load REACore from both paths");
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const registerEventHandler = exports.registerEventHandler = REACore.registerEventHandler;
|
|
18
|
+
const unregisterEventHandler = exports.unregisterEventHandler = REACore.unregisterEventHandler;
|
|
19
|
+
//# sourceMappingURL=event-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["REACore","require","e1","e2","console","warn","registerEventHandler","exports","unregisterEventHandler"],"sources":["event-handler.js"],"sourcesContent":["let REACore = null;\n\ntry {\n REACore = require(\"react-native-reanimated/src/core\");\n} catch (e1) {\n try {\n REACore = require(\"react-native-reanimated/src/reanimated2/core\");\n } catch (e2) {\n console.warn(\"Failed to load REACore from both paths\");\n }\n}\nconst registerEventHandler = REACore.registerEventHandler;\nconst unregisterEventHandler = REACore.unregisterEventHandler;\n\nexport { registerEventHandler, unregisterEventHandler };\n"],"mappings":";;;;;;AAAA,IAAIA,OAAO,GAAG,IAAI;AAElB,IAAI;EACFA,OAAO,GAAGC,OAAO,CAAC,kCAAkC,CAAC;AACvD,CAAC,CAAC,OAAOC,EAAE,EAAE;EACX,IAAI;IACFF,OAAO,GAAGC,OAAO,CAAC,8CAA8C,CAAC;EACnE,CAAC,CAAC,OAAOE,EAAE,EAAE;IACXC,OAAO,CAACC,IAAI,CAAC,wCAAwC,CAAC;EACxD;AACF;AACA,MAAMC,oBAAoB,GAAAC,OAAA,CAAAD,oBAAA,GAAGN,OAAO,CAACM,oBAAoB;AACzD,MAAME,sBAAsB,GAAAD,OAAA,CAAAC,sBAAA,GAAGR,OAAO,CAACQ,sBAAsB","ignoreList":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.unregisterEventHandler = exports.registerEventHandler = void 0;
|
|
7
|
+
const NOOP = () => {};
|
|
8
|
+
const registerEventHandler = exports.registerEventHandler = NOOP;
|
|
9
|
+
const unregisterEventHandler = exports.unregisterEventHandler = NOOP;
|
|
10
|
+
//# sourceMappingURL=event-handler.web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["NOOP","registerEventHandler","exports","unregisterEventHandler"],"sources":["event-handler.web.js"],"sourcesContent":["const NOOP = () => {};\nconst registerEventHandler = NOOP;\nconst unregisterEventHandler = NOOP;\n\nexport { registerEventHandler, unregisterEventHandler };\n"],"mappings":";;;;;;AAAA,MAAMA,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AACrB,MAAMC,oBAAoB,GAAAC,OAAA,CAAAD,oBAAA,GAAGD,IAAI;AACjC,MAAMG,sBAAsB,GAAAD,OAAA,CAAAC,sBAAA,GAAGH,IAAI","ignoreList":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.keyboardEventsMap = exports.focusedInputEventsMap = void 0;
|
|
7
|
+
const keyboardEventsMap = exports.keyboardEventsMap = new Map([["onStart", "onKeyboardMoveStart"], ["onMove", "onKeyboardMove"], ["onEnd", "onKeyboardMoveEnd"], ["onInteractive", "onKeyboardMoveInteractive"]]);
|
|
8
|
+
const focusedInputEventsMap = exports.focusedInputEventsMap = new Map([["onChangeText", "onFocusedInputTextChanged"], ["onSelectionChange", "onFocusedInputSelectionChanged"]]);
|
|
9
|
+
//# sourceMappingURL=event-mappings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["keyboardEventsMap","exports","Map","focusedInputEventsMap"],"sources":["event-mappings.ts"],"sourcesContent":["import type { FocusedInputHandler, KeyboardHandler } from \"./types\";\n\nexport const keyboardEventsMap = new Map<keyof KeyboardHandler, string>([\n [\"onStart\", \"onKeyboardMoveStart\"],\n [\"onMove\", \"onKeyboardMove\"],\n [\"onEnd\", \"onKeyboardMoveEnd\"],\n [\"onInteractive\", \"onKeyboardMoveInteractive\"],\n]);\nexport const focusedInputEventsMap = new Map<keyof FocusedInputHandler, string>(\n [\n [\"onChangeText\", \"onFocusedInputTextChanged\"],\n [\"onSelectionChange\", \"onFocusedInputSelectionChanged\"],\n ],\n);\n"],"mappings":";;;;;;AAEO,MAAMA,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA,GAAG,IAAIE,GAAG,CAAgC,CACtE,CAAC,SAAS,EAAE,qBAAqB,CAAC,EAClC,CAAC,QAAQ,EAAE,gBAAgB,CAAC,EAC5B,CAAC,OAAO,EAAE,mBAAmB,CAAC,EAC9B,CAAC,eAAe,EAAE,2BAA2B,CAAC,CAC/C,CAAC;AACK,MAAMC,qBAAqB,GAAAF,OAAA,CAAAE,qBAAA,GAAG,IAAID,GAAG,CAC1C,CACE,CAAC,cAAc,EAAE,2BAA2B,CAAC,EAC7C,CAAC,mBAAmB,EAAE,gCAAgC,CAAC,CAE3D,CAAC","ignoreList":[]}
|
|
@@ -24,7 +24,7 @@ var _react = require("react");
|
|
|
24
24
|
var _bindings = require("../bindings");
|
|
25
25
|
var _constants = require("../constants");
|
|
26
26
|
var _context = require("../context");
|
|
27
|
-
var
|
|
27
|
+
var _useSyncEffect = _interopRequireDefault(require("./useSyncEffect"));
|
|
28
28
|
var _useWindowDimensions = require("./useWindowDimensions");
|
|
29
29
|
Object.keys(_useWindowDimensions).forEach(function (key) {
|
|
30
30
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -37,6 +37,7 @@ Object.keys(_useWindowDimensions).forEach(function (key) {
|
|
|
37
37
|
}
|
|
38
38
|
});
|
|
39
39
|
});
|
|
40
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
40
41
|
const useResizeMode = () => {
|
|
41
42
|
(0, _react.useEffect)(() => {
|
|
42
43
|
_bindings.KeyboardController.setInputMode(_constants.AndroidSoftInputModes.SOFT_INPUT_ADJUST_RESIZE);
|
|
@@ -58,16 +59,9 @@ const useReanimatedKeyboardAnimation = () => {
|
|
|
58
59
|
exports.useReanimatedKeyboardAnimation = useReanimatedKeyboardAnimation;
|
|
59
60
|
function useGenericKeyboardHandler(handler, deps) {
|
|
60
61
|
const context = (0, _context.useKeyboardContext)();
|
|
61
|
-
(0,
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
[key]: handler
|
|
65
|
-
});
|
|
66
|
-
return () => {
|
|
67
|
-
context.setKeyboardHandlers({
|
|
68
|
-
[key]: undefined
|
|
69
|
-
});
|
|
70
|
-
};
|
|
62
|
+
(0, _useSyncEffect.default)(() => {
|
|
63
|
+
const cleanup = context.setKeyboardHandlers(handler);
|
|
64
|
+
return () => cleanup();
|
|
71
65
|
}, deps);
|
|
72
66
|
}
|
|
73
67
|
function useKeyboardHandler(handler, deps) {
|
|
@@ -89,16 +83,9 @@ function useReanimatedFocusedInput() {
|
|
|
89
83
|
}
|
|
90
84
|
function useFocusedInputHandler(handler, deps) {
|
|
91
85
|
const context = (0, _context.useKeyboardContext)();
|
|
92
|
-
(0,
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
[key]: handler
|
|
96
|
-
});
|
|
97
|
-
return () => {
|
|
98
|
-
context.setInputHandlers({
|
|
99
|
-
[key]: undefined
|
|
100
|
-
});
|
|
101
|
-
};
|
|
86
|
+
(0, _useSyncEffect.default)(() => {
|
|
87
|
+
const cleanup = context.setInputHandlers(handler);
|
|
88
|
+
return () => cleanup();
|
|
102
89
|
}, deps);
|
|
103
90
|
}
|
|
104
91
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_bindings","_constants","_context","
|
|
1
|
+
{"version":3,"names":["_react","require","_bindings","_constants","_context","_useSyncEffect","_interopRequireDefault","_useWindowDimensions","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","e","__esModule","default","useResizeMode","useEffect","KeyboardController","setInputMode","AndroidSoftInputModes","SOFT_INPUT_ADJUST_RESIZE","setDefaultMode","useKeyboardAnimation","context","useKeyboardContext","animated","useReanimatedKeyboardAnimation","reanimated","useGenericKeyboardHandler","handler","deps","useSyncEffect","cleanup","setKeyboardHandlers","useKeyboardHandler","useKeyboardController","setEnabled","enabled","useReanimatedFocusedInput","input","layout","useFocusedInputHandler","setInputHandlers"],"sources":["index.ts"],"sourcesContent":["import { useEffect } from \"react\";\n\nimport { KeyboardController } from \"../bindings\";\nimport { AndroidSoftInputModes } from \"../constants\";\nimport { useKeyboardContext } from \"../context\";\n\nimport useSyncEffect from \"./useSyncEffect\";\n\nimport type { AnimatedContext, ReanimatedContext } from \"../context\";\nimport type { FocusedInputHandler, KeyboardHandler } from \"../types\";\nimport type { DependencyList } from \"react\";\n\nexport const useResizeMode = () => {\n useEffect(() => {\n KeyboardController.setInputMode(\n AndroidSoftInputModes.SOFT_INPUT_ADJUST_RESIZE,\n );\n\n return () => KeyboardController.setDefaultMode();\n }, []);\n};\n\nexport const useKeyboardAnimation = (): AnimatedContext => {\n useResizeMode();\n const context = useKeyboardContext();\n\n return context.animated;\n};\n\nexport const useReanimatedKeyboardAnimation = (): ReanimatedContext => {\n useResizeMode();\n const context = useKeyboardContext();\n\n return context.reanimated;\n};\n\nexport function useGenericKeyboardHandler(\n handler: KeyboardHandler,\n deps?: DependencyList,\n) {\n const context = useKeyboardContext();\n\n useSyncEffect(() => {\n const cleanup = context.setKeyboardHandlers(handler);\n\n return () => cleanup();\n }, deps);\n}\n\nexport function useKeyboardHandler(\n handler: KeyboardHandler,\n deps?: DependencyList,\n) {\n useResizeMode();\n useGenericKeyboardHandler(handler, deps);\n}\n\nexport function useKeyboardController() {\n const context = useKeyboardContext();\n\n return { setEnabled: context.setEnabled, enabled: context.enabled };\n}\n\nexport function useReanimatedFocusedInput() {\n const context = useKeyboardContext();\n\n return { input: context.layout };\n}\n\nexport function useFocusedInputHandler(\n handler: FocusedInputHandler,\n deps?: DependencyList,\n) {\n const context = useKeyboardContext();\n\n useSyncEffect(() => {\n const cleanup = context.setInputHandlers(handler);\n\n return () => cleanup();\n }, deps);\n}\n\nexport * from \"./useWindowDimensions\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAEA,IAAAI,cAAA,GAAAC,sBAAA,CAAAL,OAAA;AA4EA,IAAAM,oBAAA,GAAAN,OAAA;AAAAO,MAAA,CAAAC,IAAA,CAAAF,oBAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,oBAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,oBAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AAAsC,SAAAL,uBAAAc,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAtE/B,MAAMG,aAAa,GAAGA,CAAA,KAAM;EACjC,IAAAC,gBAAS,EAAC,MAAM;IACdC,4BAAkB,CAACC,YAAY,CAC7BC,gCAAqB,CAACC,wBACxB,CAAC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EAAC,CAAC;EAEpC,OAAO;IAAEe,KAAK,EAAEhB,OAAO,CAACiB;EAAO,CAAC;AAClC;AAEO,SAASC,sBAAsBA,CACpCZ,OAA4B,EAC5BC,IAAqB,EACrB;EACA,MAAMP,OAAO,GAAG,IAAAC,2BAAkB,EAAC,CAAC;EAEpC,IAAAO,sBAAa,EAAC,MAAM;IAClB,MAAMC,OAAO,GAAGT,OAAO,CAACmB,gBAAgB,CAACb,OAAO,CAAC;IAEjD,OAAO,MAAMG,OAAO,CAAC,CAAC;EACxB,CAAC,EAAEF,IAAI,CAAC;AACV","ignoreList":[]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
/**
|
|
9
|
+
* @description
|
|
10
|
+
* Equivalent to `useEffect` but will run the effect synchronously, i. e. before render.
|
|
11
|
+
*
|
|
12
|
+
* @param {effect} - imperative function
|
|
13
|
+
* @param {deps} - if present, effect will only activate if the values in the list change
|
|
14
|
+
*
|
|
15
|
+
* @author Kiryl Ziusko
|
|
16
|
+
* @since 1.13.0
|
|
17
|
+
* @version 1.0.0
|
|
18
|
+
*/
|
|
19
|
+
const useSyncEffect = (effect, deps) => {
|
|
20
|
+
const cachedDeps = (0, _react.useRef)(null);
|
|
21
|
+
const areDepsEqual = deps === null || deps === void 0 ? void 0 : deps.every((el, index) => cachedDeps.current && el === cachedDeps.current[index]);
|
|
22
|
+
const cleanupRef = (0, _react.useRef)();
|
|
23
|
+
if (!areDepsEqual || !cachedDeps.current) {
|
|
24
|
+
var _cleanupRef$current;
|
|
25
|
+
(_cleanupRef$current = cleanupRef.current) === null || _cleanupRef$current === void 0 || _cleanupRef$current.call(cleanupRef);
|
|
26
|
+
cleanupRef.current = effect();
|
|
27
|
+
cachedDeps.current = deps;
|
|
28
|
+
}
|
|
29
|
+
(0, _react.useEffect)(() => {
|
|
30
|
+
return () => {
|
|
31
|
+
var _cleanupRef$current2;
|
|
32
|
+
(_cleanupRef$current2 = cleanupRef.current) === null || _cleanupRef$current2 === void 0 || _cleanupRef$current2.call(cleanupRef);
|
|
33
|
+
};
|
|
34
|
+
}, []);
|
|
35
|
+
};
|
|
36
|
+
var _default = exports.default = useSyncEffect;
|
|
37
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","useSyncEffect","effect","deps","cachedDeps","useRef","areDepsEqual","every","el","index","current","cleanupRef","_cleanupRef$current","call","useEffect","_cleanupRef$current2","_default","exports","default"],"sources":["index.ts"],"sourcesContent":["import { useEffect, useRef } from \"react\";\n\nimport type { DependencyList } from \"react\";\n\n/**\n * @description\n * Equivalent to `useEffect` but will run the effect synchronously, i. e. before render.\n *\n * @param {effect} - imperative function\n * @param {deps} - if present, effect will only activate if the values in the list change\n *\n * @author Kiryl Ziusko\n * @since 1.13.0\n * @version 1.0.0\n */\nconst useSyncEffect: typeof useEffect = (effect, deps) => {\n const cachedDeps = useRef<DependencyList | undefined | null>(null);\n const areDepsEqual = deps?.every(\n (el, index) => cachedDeps.current && el === cachedDeps.current[index],\n );\n const cleanupRef = useRef<(() => void) | void>();\n\n if (!areDepsEqual || !cachedDeps.current) {\n cleanupRef.current?.();\n cleanupRef.current = effect();\n cachedDeps.current = deps;\n }\n\n useEffect(() => {\n return () => {\n cleanupRef.current?.();\n };\n }, []);\n};\n\nexport default useSyncEffect;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,aAA+B,GAAGA,CAACC,MAAM,EAAEC,IAAI,KAAK;EACxD,MAAMC,UAAU,GAAG,IAAAC,aAAM,EAAoC,IAAI,CAAC;EAClE,MAAMC,YAAY,GAAGH,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEI,KAAK,CAC9B,CAACC,EAAE,EAAEC,KAAK,KAAKL,UAAU,CAACM,OAAO,IAAIF,EAAE,KAAKJ,UAAU,CAACM,OAAO,CAACD,KAAK,CACtE,CAAC;EACD,MAAME,UAAU,GAAG,IAAAN,aAAM,EAAsB,CAAC;EAEhD,IAAI,CAACC,YAAY,IAAI,CAACF,UAAU,CAACM,OAAO,EAAE;IAAA,IAAAE,mBAAA;IACxC,CAAAA,mBAAA,GAAAD,UAAU,CAACD,OAAO,cAAAE,mBAAA,eAAlBA,mBAAA,CAAAC,IAAA,CAAAF,UAAqB,CAAC;IACtBA,UAAU,CAACD,OAAO,GAAGR,MAAM,CAAC,CAAC;IAC7BE,UAAU,CAACM,OAAO,GAAGP,IAAI;EAC3B;EAEA,IAAAW,gBAAS,EAAC,MAAM;IACd,OAAO,MAAM;MAAA,IAAAC,oBAAA;MACX,CAAAA,oBAAA,GAAAJ,UAAU,CAACD,OAAO,cAAAK,oBAAA,eAAlBA,oBAAA,CAAAF,IAAA,CAAAF,UAAqB,CAAC;IACxB,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;AACR,CAAC;AAAC,IAAAK,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEajB,aAAa","ignoreList":[]}
|
package/lib/commonjs/internal.js
CHANGED
|
@@ -4,53 +4,30 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.useAnimatedValue = useAnimatedValue;
|
|
7
|
-
exports.
|
|
7
|
+
exports.useEventHandlerRegistration = useEventHandlerRegistration;
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
var _reactNative = require("react-native");
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
* }
|
|
21
|
-
*/
|
|
22
|
-
function useSharedHandlers() {
|
|
23
|
-
const handlers = (0, _reactNativeReanimated.useSharedValue)({});
|
|
24
|
-
const jsHandlers = (0, _react.useRef)({});
|
|
10
|
+
var _eventHandler = require("./event-handler");
|
|
11
|
+
function useEventHandlerRegistration(map, viewTagRef) {
|
|
12
|
+
const onRegisterHandler = handler => {
|
|
13
|
+
const viewTag = (0, _reactNative.findNodeHandle)(viewTagRef.current);
|
|
14
|
+
const ids = Object.keys(handler).map(handlerName => {
|
|
15
|
+
const eventName = map.get(handlerName);
|
|
16
|
+
const functionToCall = handler[handlerName];
|
|
17
|
+
if (eventName && viewTag) {
|
|
18
|
+
return (0, _eventHandler.registerEventHandler)(event => {
|
|
19
|
+
"worklet";
|
|
25
20
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
// Below we are writing all handlers to `ref` and afterwards synchronize them with
|
|
31
|
-
// shared value (since `refs` are not referring to actual value in worklets).
|
|
32
|
-
// This approach allow us to update synchronously handlers in js thread (and it assures,
|
|
33
|
-
// that it will have all of them) and then update them in worklet thread (calls are
|
|
34
|
-
// happening in FIFO order, so we will always have actual value).
|
|
35
|
-
const updateSharedHandlers = () => {
|
|
36
|
-
handlers.value = jsHandlers.current;
|
|
37
|
-
};
|
|
38
|
-
const setHandlers = (0, _react.useCallback)(handler => {
|
|
39
|
-
jsHandlers.current = {
|
|
40
|
-
...jsHandlers.current,
|
|
41
|
-
...handler
|
|
42
|
-
};
|
|
43
|
-
updateSharedHandlers();
|
|
44
|
-
}, []);
|
|
45
|
-
const broadcast = (type, event) => {
|
|
46
|
-
"worklet";
|
|
47
|
-
|
|
48
|
-
Object.keys(handlers.value).forEach(key => {
|
|
49
|
-
var _handlers$value$key, _handlers$value$key$t;
|
|
50
|
-
(_handlers$value$key = handlers.value[key]) === null || _handlers$value$key === void 0 || (_handlers$value$key$t = _handlers$value$key[type]) === null || _handlers$value$key$t === void 0 || _handlers$value$key$t.call(_handlers$value$key, event);
|
|
21
|
+
functionToCall === null || functionToCall === void 0 || functionToCall(event);
|
|
22
|
+
}, eventName, viewTag);
|
|
23
|
+
}
|
|
24
|
+
return null;
|
|
51
25
|
});
|
|
26
|
+
return () => {
|
|
27
|
+
ids.forEach(id => id ? (0, _eventHandler.unregisterEventHandler)(id) : null);
|
|
28
|
+
};
|
|
52
29
|
};
|
|
53
|
-
return
|
|
30
|
+
return onRegisterHandler;
|
|
54
31
|
}
|
|
55
32
|
|
|
56
33
|
/**
|
|
@@ -64,7 +41,7 @@ function useSharedHandlers() {
|
|
|
64
41
|
*/
|
|
65
42
|
function useAnimatedValue(initialValue, config) {
|
|
66
43
|
const ref = (0, _react.useRef)(null);
|
|
67
|
-
if (ref.current
|
|
44
|
+
if (ref.current === null) {
|
|
68
45
|
ref.current = new _reactNative.Animated.Value(initialValue, config);
|
|
69
46
|
}
|
|
70
47
|
return ref.current;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_reactNative","
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","_eventHandler","useEventHandlerRegistration","map","viewTagRef","onRegisterHandler","handler","viewTag","findNodeHandle","current","ids","Object","keys","handlerName","eventName","get","functionToCall","registerEventHandler","event","forEach","id","unregisterEventHandler","useAnimatedValue","initialValue","config","ref","useRef","Animated","Value"],"sources":["internal.ts"],"sourcesContent":["import { useRef } from \"react\";\nimport { Animated, findNodeHandle } from \"react-native\";\n\nimport { registerEventHandler, unregisterEventHandler } from \"./event-handler\";\n\ntype EventHandler = (event: never) => void;\ntype ComponentOrHandle = Parameters<typeof findNodeHandle>[0];\n\nexport function useEventHandlerRegistration<\n H extends Partial<Record<string, EventHandler>>,\n>(\n map: Map<keyof H, string>,\n viewTagRef: React.MutableRefObject<ComponentOrHandle>,\n) {\n const onRegisterHandler = (handler: H) => {\n const viewTag = findNodeHandle(viewTagRef.current);\n const ids = Object.keys(handler).map((handlerName) => {\n const eventName = map.get(handlerName as keyof H);\n const functionToCall = handler[handlerName as keyof H];\n\n if (eventName && viewTag) {\n return registerEventHandler(\n (event: Parameters<NonNullable<H[keyof H]>>[0]) => {\n \"worklet\";\n\n functionToCall?.(event);\n },\n eventName,\n viewTag,\n );\n }\n\n return null;\n });\n\n return () => {\n ids.forEach((id) => (id ? unregisterEventHandler(id) : null));\n };\n };\n\n return onRegisterHandler;\n}\n\n/**\n * TS variant of `useAnimatedValue` hook which is added in RN 0.71\n * A better alternative of storing animated values in refs, since\n * it doesn't recreate a new `Animated.Value` object on every re-render\n * and therefore consumes less memory. We can not use a variant from\n * RN, since this library supports earlier versions of RN.\n *\n * @see https://github.com/facebook/react-native/commit/e22217fe8b9455e32695f88ca835e11442b0a937\n */\nexport function useAnimatedValue(\n initialValue: number,\n config?: Animated.AnimatedConfig,\n): Animated.Value {\n const ref = useRef<Animated.Value | null>(null);\n\n if (ref.current === null) {\n ref.current = new Animated.Value(initialValue, config);\n }\n\n return ref.current;\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,aAAA,GAAAF,OAAA;AAKO,SAASG,2BAA2BA,CAGzCC,GAAyB,EACzBC,UAAqD,EACrD;EACA,MAAMC,iBAAiB,GAAIC,OAAU,IAAK;IACxC,MAAMC,OAAO,GAAG,IAAAC,2BAAc,EAACJ,UAAU,CAACK,OAAO,CAAC;IAClD,MAAMC,GAAG,GAAGC,MAAM,CAACC,IAAI,CAACN,OAAO,CAAC,CAACH,GAAG,CAAEU,WAAW,IAAK;MACpD,MAAMC,SAAS,GAAGX,GAAG,CAACY,GAAG,CAACF,WAAsB,CAAC;MACjD,MAAMG,cAAc,GAAGV,OAAO,CAACO,WAAW,CAAY;MAEtD,IAAIC,SAAS,IAAIP,OAAO,EAAE;QACxB,OAAO,IAAAU,kCAAoB,EACxBC,KAA6C,IAAK;UACjD,SAAS;;UAETF,cAAc,aAAdA,cAAc,eAAdA,cAAc,CAAGE,KAAK,CAAC;QACzB,CAAC,EACDJ,SAAS,EACTP,OACF,CAAC;MACH;MAEA,OAAO,IAAI;IACb,CAAC,CAAC;IAEF,OAAO,MAAM;MACXG,GAAG,CAACS,OAAO,CAAEC,EAAE,IAAMA,EAAE,GAAG,IAAAC,oCAAsB,EAACD,EAAE,CAAC,GAAG,IAAK,CAAC;IAC/D,CAAC;EACH,CAAC;EAED,OAAOf,iBAAiB;AAC1B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASiB,gBAAgBA,CAC9BC,YAAoB,EACpBC,MAAgC,EAChB;EAChB,MAAMC,GAAG,GAAG,IAAAC,aAAM,EAAwB,IAAI,CAAC;EAE/C,IAAID,GAAG,CAAChB,OAAO,KAAK,IAAI,EAAE;IACxBgB,GAAG,CAAChB,OAAO,GAAG,IAAIkB,qBAAQ,CAACC,KAAK,CAACL,YAAY,EAAEC,MAAM,CAAC;EACxD;EAEA,OAAOC,GAAG,CAAChB,OAAO;AACpB","ignoreList":[]}
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.revertMonkeyPatch = exports.applyMonkeyPatch = void 0;
|
|
7
7
|
var NativeAndroidManager = _interopRequireWildcard(require("react-native/Libraries/Components/StatusBar/NativeStatusBarManagerAndroid"));
|
|
8
8
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
9
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u &&
|
|
9
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
10
10
|
// @ts-expect-error because there is no corresponding type definition
|
|
11
11
|
|
|
12
12
|
const RCTStatusBarManagerCompat =
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeAndroidManager","_interopRequireWildcard","require","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","
|
|
1
|
+
{"version":3,"names":["NativeAndroidManager","_interopRequireWildcard","require","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","RCTStatusBarManagerCompat","OriginalNativeAndroidManager","ModifiedNativeAndroidManager","setColor","color","animated","setTranslucent","translucent","setStyle","statusBarStyle","setHidden","hidden","applyMonkeyPatch","assign","exports","revertMonkeyPatch"],"sources":["monkey-patch.android.ts"],"sourcesContent":["// @ts-expect-error because there is no corresponding type definition\nimport * as NativeAndroidManager from \"react-native/Libraries/Components/StatusBar/NativeStatusBarManagerAndroid\";\n\nconst RCTStatusBarManagerCompat =\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n require(\"./specs/NativeStatusBarManagerCompat\").default;\n\n// Copy original default manager to keep its original state and methods\nconst OriginalNativeAndroidManager = { ...NativeAndroidManager.default };\n\n// Create a new object that modifies the necessary methods\n// On Android < 11 RN uses legacy API which breaks EdgeToEdge mode in RN, so\n// in order to use library on all available platforms we have to monkey patch\n// default RN implementation and use modern `WindowInsetsControllerCompat`.\nconst ModifiedNativeAndroidManager = {\n ...NativeAndroidManager.default, // Spread original properties to keep existing functionality\n setColor: (color: number, animated: boolean): void => {\n RCTStatusBarManagerCompat.setColor(color, animated);\n },\n setTranslucent: (translucent: boolean): void => {\n RCTStatusBarManagerCompat.setTranslucent(translucent);\n },\n /**\n * - statusBarStyles can be:\n * - 'default'\n * - 'dark-content'\n */\n setStyle: (statusBarStyle?: string): void => {\n RCTStatusBarManagerCompat.setStyle(statusBarStyle);\n },\n setHidden: (hidden: boolean): void => {\n RCTStatusBarManagerCompat.setHidden(hidden);\n },\n};\n\n// Define a function to apply the monkey patch\nexport const applyMonkeyPatch = () => {\n Object.assign(NativeAndroidManager.default, ModifiedNativeAndroidManager);\n};\n\n// Define a function to revert changes back to the original state\nexport const revertMonkeyPatch = () => {\n Object.assign(NativeAndroidManager.default, OriginalNativeAndroidManager);\n};\n"],"mappings":";;;;;;AACA,IAAAA,oBAAA,GAAAC,uBAAA,CAAAC,OAAA;AAAkH,SAAAC,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAH,wBAAAG,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,CAAA,SAAAG,CAAA,GAA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gBAAA;AACO,MAAMG,iBAAiB,GAAGA,CAAA,KAAM;EACrCvB,MAAM,CAACqB,MAAM,CAACpC,oBAAoB,CAACS,OAAO,EAAEe,4BAA4B,CAAC;AAC3E,CAAC;AAACa,OAAA,CAAAC,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NOOP","applyMonkeyPatch","exports","revertMonkeyPatch"],"sources":["monkey-patch.ts"],"sourcesContent":["// stub for all platforms\nconst NOOP = () => {};\nexport const applyMonkeyPatch = NOOP;\nexport const revertMonkeyPatch = NOOP;\n"],"mappings":";;;;;;AAAA;AACA,MAAMA,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;
|
|
1
|
+
{"version":3,"names":["NOOP","applyMonkeyPatch","exports","revertMonkeyPatch"],"sources":["monkey-patch.ts"],"sourcesContent":["// stub for all platforms\nconst NOOP = () => {};\n\nexport const applyMonkeyPatch = NOOP;\nexport const revertMonkeyPatch = NOOP;\n"],"mappings":";;;;;;AAAA;AACA,MAAMA,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AAEd,MAAMC,gBAAgB,GAAAC,OAAA,CAAAD,gBAAA,GAAGD,IAAI;AAC7B,MAAMG,iBAAiB,GAAAD,OAAA,CAAAC,iBAAA,GAAGH,IAAI","ignoreList":[]}
|