Skip to content

Commit b85f5e2

Browse files
committed
Rename trigger hook, make ref param optional, add native menu support
1 parent 0971d87 commit b85f5e2

17 files changed

+179
-139
lines changed

lib/ContextMenuWrapper.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/ContextMenuWrapper.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/globalState.d.ts

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { EventEmitter } from 'events';
21
import { Undefinable } from 'tsdef';
32
import { ContextMenuEvent } from './handlers';
43
export declare enum EventName {
@@ -11,20 +10,6 @@ export declare enum HideReason {
1110
}
1211
export declare type EventListener = (data: any) => void;
1312
export declare type InternalHandler = (event: ContextMenuEvent) => void;
14-
declare global {
15-
interface Window {
16-
__ReactContextMenuWrapper: {
17-
emitter: EventEmitter;
18-
localMenuHandlers: {
19-
[externalId: string]: InternalHandler;
20-
};
21-
globalMenuHandlers: InternalHandler[];
22-
dataMap: {
23-
[randomId: string]: string;
24-
};
25-
};
26-
}
27-
}
2813
export declare const initWindowState: () => void;
2914
export declare const hideAllMenus: () => void;
3015
export declare const addGenericListener: (name: EventName, listener: EventListener) => void;
@@ -35,7 +20,10 @@ export declare const removeLocalMenuHandler: (menuId: string) => void;
3520
export declare const addGlobalMenuHandler: (handler: InternalHandler) => void;
3621
export declare const getGlobalMenuHandler: () => Undefinable<InternalHandler>;
3722
export declare const removeGlobalMenuHandler: (handler: InternalHandler) => void;
38-
export declare const generateDataId: () => string;
39-
export declare const saveData: (dataId: string, data: any) => void;
40-
export declare const fetchData: (dataId: string) => string;
41-
export declare const deleteData: (dataId: string) => void;
23+
export declare const addLongPressTimeout: (callback: () => void, timeout: number) => void;
24+
export declare const hasLongPressTimeout: () => boolean;
25+
export declare const clearLongPressTimeout: () => void;
26+
export declare const generateHandlerDataId: () => string;
27+
export declare const saveHandlerData: (dataId: string, data: any) => void;
28+
export declare const fetchHandlerData: (dataId: string) => any;
29+
export declare const deleteHandlerData: (dataId: string) => void;

lib/globalState.js

Lines changed: 40 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/globalState.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/handlers.d.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,22 @@ export declare enum DataAttributes {
22
MenuId = "data-contextmenu-menu-id",
33
DataId = "data-contextmenu-data-id"
44
}
5-
export declare enum ContextMenuEventType {
6-
Show = "Show",
7-
Hide = "Hide"
8-
}
95
export interface ContextMenuEvent {
10-
type: ContextMenuEventType;
116
clientX: number;
127
clientY: number;
138
data: any;
149
}
1510
export declare const GlobalHandlers: {
16-
readonly handleContextMenu: (event: MouseEvent) => void;
11+
readonly handleContextMenu: (e: MouseEvent) => void;
12+
readonly handleTouchStart: (e: TouchEvent) => void;
13+
readonly handleTouchMove: (e: TouchEvent) => void;
14+
readonly handleTouchEnd: (e: TouchEvent) => void;
15+
readonly handleTouchCancel: (e: TouchEvent) => void;
1716
};
1817
export declare const LocalHandlers: {
19-
readonly handleContextMenu: (event: MouseEvent) => void;
18+
readonly handleContextMenu: (e: MouseEvent) => void;
19+
readonly handleTouchStart: (e: TouchEvent) => void;
20+
readonly handleTouchMove: (e: TouchEvent) => void;
21+
readonly handleTouchEnd: (e: TouchEvent) => void;
22+
readonly handleTouchCancel: (e: TouchEvent) => void;
2023
};

0 commit comments

Comments
 (0)