/** * Touch gesture mapping (#125). * * XP never had touch, so this is a **usability layer**, not a fidelity feature: * it lets the existing mouse metaphor be driven by a finger without changing any * mouse behavior. The hook is purely additive — it returns `onTouchStart/Move/End` * handlers you spread onto an element alongside its existing mouse handlers, and * synthesizes three intents from raw touches: * * - **tap** → a click/select * - **double-tap** (two taps within `doubleTapMs`) → a double-click / open * - **long-press** (held ~`longPressMs` without moving) → a right-click menu * * Coordinates from the triggering touch are passed back so callers can position a * context menu exactly where the finger is. A gesture that resolves to a * double-tap or long-press suppresses the trailing single `tap`, and the handlers * are only ever wired to touch events, so mouse and keyboard paths are untouched. */ export interface TapPoint { x: number; y: number; } export interface TapGestureOptions { /** Fired on a quick touch that neither moved far nor became a long-press. */ onTap?: (point: TapPoint) => void; /** Fired when two taps land within `doubleTapMs` at roughly the same spot. */ onDoubleTap?: (point: TapPoint) => void; /** Fired when a touch is held ~`longPressMs` without moving past `moveTolerance`. */ onLongPress?: (point: TapPoint) => void; /** Hold duration (ms) that turns a press into a long-press. Default 500. */ longPressMs?: number; /** Max time (ms) between two taps to count as a double-tap. Default 300. */ doubleTapMs?: number; /** Movement (px) beyond which a press is treated as a drag/scroll, not a tap. Default 10. */ moveTolerance?: number; } export interface TapGestureHandlers { onTouchStart: (e: React.TouchEvent) => void; onTouchMove: (e: React.TouchEvent) => void; onTouchEnd: (e: React.TouchEvent) => void; } /** * Map raw touch events to tap / double-tap / long-press intents. Returns handlers * to spread onto the target element; see the module doc for the contract. */ export declare function useTapGestures(options: TapGestureOptions): TapGestureHandlers;