@gorhom/bottom-sheet
Version:
A performant interactive bottom sheet with fully configurable options 🚀
48 lines (46 loc) • 1.65 kB
JavaScript
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
import React, { memo, useCallback, forwardRef, useEffect } from 'react';
import { TextInput } from 'react-native-gesture-handler';
import { useBottomSheetInternal } from '../../hooks';
const BottomSheetTextInputComponent = /*#__PURE__*/forwardRef(({
onFocus,
onBlur,
...rest
}, ref) => {
//#region hooks
const {
shouldHandleKeyboardEvents
} = useBottomSheetInternal();
//#endregion
//#region callbacks
const handleOnFocus = useCallback(args => {
shouldHandleKeyboardEvents.value = true;
if (onFocus) {
onFocus(args);
}
}, [onFocus, shouldHandleKeyboardEvents]);
const handleOnBlur = useCallback(args => {
shouldHandleKeyboardEvents.value = false;
if (onBlur) {
onBlur(args);
}
}, [onBlur, shouldHandleKeyboardEvents]);
//#endregion
//#region effects
useEffect(() => {
return () => {
// Reset the flag on unmount
shouldHandleKeyboardEvents.value = false;
};
}, [shouldHandleKeyboardEvents]);
//#endregion
return /*#__PURE__*/React.createElement(TextInput, _extends({
ref: ref,
onFocus: handleOnFocus,
onBlur: handleOnBlur
}, rest));
});
const BottomSheetTextInput = /*#__PURE__*/memo(BottomSheetTextInputComponent);
BottomSheetTextInput.displayName = 'BottomSheetTextInput';
export default BottomSheetTextInput;
//# sourceMappingURL=BottomSheetTextInput.js.map