preact-context-menu
Version:
A context menu in Preact
31 lines (30 loc) • 1.13 kB
TypeScript
import { JSX } from "preact";
import { Coords } from "./menu";
/**
* Open a context menu by its ID.
* @param id Context Menu ID
* @param data Data to pass to callback function
* @param coords Coordinates to place context menu at
*/
export declare const openContextMenu: (id: string, data?: any, coords?: Coords | undefined) => void;
/**
* Bind context menu events to a Ref.
* @param ref Ref object
* @param id Context Menu ID
* @param data Data to pass to callback function
* @param disabled Whether the context menu is disabled
* @param touchTimeout Long press duration to show context menu
*/
export declare const useTriggerEvents: (id: string, data?: any, disabled?: boolean | undefined, touchTimeout?: number) => {
onTouchStart: (event: JSX.TargetedTouchEvent<HTMLSpanElement>) => void;
onTouchCancel: () => void;
onTouchMove: () => void;
onTouchEnd: () => void;
onContextMenu?: undefined;
} | {
onContextMenu: (event: JSX.TargetedMouseEvent<HTMLSpanElement>) => void;
onTouchStart?: undefined;
onTouchCancel?: undefined;
onTouchMove?: undefined;
onTouchEnd?: undefined;
};