UNPKG

@replyke/ui-core-react-native

Version:

Replyke: Build interactive apps with social features like comments, votes, feeds, user lists, notifications, and more.

21 lines 914 B
import { useState, useCallback } from "react"; export default function useTextInputCursorIndicator() { const [cursorPosition, setCursorPosition] = useState(0); const [isSelectionActive, setIsSelectionActive] = useState(false); const handleSelectionChange = useCallback((event) => { const { selection } = event.nativeEvent; setCursorPosition(selection.start); // Keeps cursor position in sync setIsSelectionActive(selection.start !== selection.end); }, []); const handleTextChange = useCallback((text) => { setIsSelectionActive(false); // Reset selection state if typing // No need to modify cursorPosition, as onSelectionChange will update it automatically }, []); return { cursorPosition, isSelectionActive, handleSelectionChange, handleTextChange, }; } //# sourceMappingURL=useTextInputCursorIndicator.js.map