/** * Configuration options for the useLongPress hook */ interface LongPressOptions { /** Duration in milliseconds before long press is triggered (default: 400) */ delay?: number; /** Whether to disable context menu on long press (default: true) */ preventContext?: boolean; /** Callback fired when a normal press (shorter than delay) is completed */ onPress?: () => void; /** Callback fired when a long press is successfully triggered */ onLongPress?: () => void; /** Callback fired when a long press is canceled before completion */ onLongPressCanceled?: () => void; } /** * Hook that handles both normal press and long press interactions with progress tracking. * * Provides event handlers for detecting short taps vs long presses, with smooth progress * animation and customizable timing. Works with both mouse and touch events. * * @param options - Configuration options for the long press behavior * @param options.delay - Duration in milliseconds before triggering long press (default: 400) * @param options.preventContext - Whether to prevent context menu on long press (default: true) * @param options.onPress - Callback for normal press (when released before delay) * @param options.onLongPress - Callback for successful long press (when delay is reached) * @param options.onLongPressCanceled - Callback when long press is interrupted * * @returns Object containing: * - `handlers`: Event handlers to spread on your element * - `state`: Current press state with `isPressed`, `isLongPressed`, and `progress` (0-1) * * @example * ```tsx * function DeleteButton({ onDelete }) { * const { handlers, state } = useLongPress({ * delay: 1000, * onPress: () => console.log('Quick tap - no action'), * onLongPress: onDelete, * onLongPressCanceled: () => console.log('Canceled deletion') * }); * * return ( * * ); * } * ``` * * @see https://thibault.sh/hooks/use-long-press */ declare function useLongPress(options?: LongPressOptions): { /** Event handlers to attach to the target element */ handlers: { onMouseDown: (event: React.TouchEvent | React.MouseEvent) => void; onMouseUp: (event: React.TouchEvent | React.MouseEvent) => void; onMouseLeave: (event: React.TouchEvent | React.MouseEvent) => void; onTouchStart: (event: React.TouchEvent | React.MouseEvent) => void; onTouchEnd: (event: React.TouchEvent | React.MouseEvent) => void; onTouchCancel: (event: React.TouchEvent | React.MouseEvent) => void; }; /** Current state of the press interaction */ state: { isPressed: boolean; isLongPressed: boolean; progress: number; }; }; export { useLongPress };