UNPKG

rn-inkpad

Version:

<img src="https://res.cloudinary.com/fercloudinary/image/upload/v1715452841/packages/inkpad-banner_acl0xl.png" />

54 lines (53 loc) 1.49 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useInput = void 0; const react_1 = require("react"); const _1 = require("."); const useInput = ({ borderRadius, borderColor, type = 'filled', password, search, rightIcon, label, onPress, }) => { const [passwordVisible, setPasswordVisible] = (0, react_1.useState)(!password); const [isFocused, setIsFocused] = (0, react_1.useState)(false); const { inputStyle, titleStyle } = (0, _1.useInputStyles)(type, isFocused, !!label, borderColor, borderRadius); const getRightIcon = () => { if (!!password) { if (passwordVisible) { return 'eye-off'; } else { return 'eye'; } } if (!!search) { return 'search'; } if (!!rightIcon) { return rightIcon; } return 'chevron-forward'; }; const handleFocus = () => { setIsFocused(true); }; const handleBlur = () => { setIsFocused(false); }; const handlePress = () => { if (!!password) { setPasswordVisible(!passwordVisible); } else { if (!!onPress) { onPress(); } } }; return { getRightIcon, handleBlur, handleFocus, handlePress, inputStyle, passwordVisible, titleStyle, }; }; exports.useInput = useInput;