UNPKG

@gorhom/bottom-sheet

Version:

A performant interactive bottom sheet with fully configurable options 🚀

41 lines (36 loc) • 1.48 kB
function _extends() { _extends = Object.assign || 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); } import React, { memo, useCallback, forwardRef } 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 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