import { DeepMaybeObservable, Fn } from '@usels/core'; import { MaybeEventTarget } from '../../types.mjs'; interface UseOnLongPressModifiers { /** Call `stopPropagation()` on pointer events */ stop?: boolean; /** Remove listeners after the first long press cycle */ once?: boolean; /** Call `preventDefault()` on pointer events */ prevent?: boolean; /** Use capturing phase for event listeners */ capture?: boolean; /** Only trigger when `event.target` is the element itself */ self?: boolean; } interface UseOnLongPressOptions { /** * Time in ms till `longpress` gets called * @default 500 */ delay?: number; /** * Allowance of moving distance in pixels. * The action will get canceled when moving too far from the pointerdown position. * Set to `false` to disable distance checking. * @default 10 */ distanceThreshold?: number | false; /** * Event modifiers */ modifiers?: UseOnLongPressModifiers; /** * Function called when the element is released. * @param duration - How long the element was pressed in ms * @param distance - Distance from the pointerdown position * @param isLongPress - Whether the action was a long press or not * @param event - The native PointerEvent */ onMouseUp?: (duration: number, distance: number, isLongPress: boolean, event: PointerEvent) => void; } /** * Framework-agnostic long press gesture detector. * * Listens for `pointerdown`/`pointermove`/`pointerup`/`pointerleave` events * and fires the handler callback after the configured delay when held. * * @param target - The element to detect long presses on * @param handler - Callback fired when a long press is detected * @param options - Configuration options * @returns A stop function that removes all event listeners and clears timers */ declare function createOnLongPress(target: MaybeEventTarget, handler: (evt: PointerEvent) => void, options?: DeepMaybeObservable): Fn; export { type UseOnLongPressModifiers, type UseOnLongPressOptions, createOnLongPress };