react-native-input-code-otp
Version:
react-native-input-code-otp is a high-performance and fully customizable OTP input component for React Native, inspired by @shadcn/ui.
43 lines (42 loc) • 1.21 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Caret = Caret;
var _react = require("react");
var _reactNative = require("react-native");
var _constants = require("../constants.js");
var _useTextInputOtp = require("../hooks/use-text-input-otp.js");
var _jsxRuntime = require("react/jsx-runtime");
function Caret() {
const opacity = (0, _reactNative.useAnimatedValue)(0);
const {
caretColor
} = (0, _useTextInputOtp.useTextInputOTP)();
(0, _react.useEffect)(() => {
_reactNative.Animated.loop(_reactNative.Animated.sequence([_reactNative.Animated.timing(opacity, {
toValue: 0,
duration: 500,
useNativeDriver: true
}), _reactNative.Animated.timing(opacity, {
toValue: 1,
duration: 500,
useNativeDriver: true
})])).start();
}, [opacity]);
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Animated.View, {
testID: "caret",
style: [styles.caret, {
opacity,
backgroundColor: caretColor ?? _constants.DEFAULT_DARK_COLOR
}]
});
}
const styles = _reactNative.StyleSheet.create({
caret: {
width: 2,
height: 16,
borderRadius: 16
}
});
//# sourceMappingURL=caret.js.map