1 | export declare type Identifier = string | symbol;
|
2 | export declare type SourceType = Identifier;
|
3 | export declare type TargetType = Identifier | Identifier[];
|
4 | export declare type Unsubscribe = () => void;
|
5 | export declare type Listener = () => void;
|
6 | export interface XYCoord {
|
7 | x: number;
|
8 | y: number;
|
9 | }
|
10 | export declare enum HandlerRole {
|
11 | SOURCE = "SOURCE",
|
12 | TARGET = "TARGET"
|
13 | }
|
14 | export interface Backend {
|
15 | setup(): void;
|
16 | teardown(): void;
|
17 | connectDragSource(sourceId: any, node?: any, options?: any): Unsubscribe;
|
18 | connectDragPreview(sourceId: any, node?: any, options?: any): Unsubscribe;
|
19 | connectDropTarget(targetId: any, node?: any, options?: any): Unsubscribe;
|
20 | profile(): Record<string, number>;
|
21 | }
|
22 | export interface DragDropMonitor {
|
23 | subscribeToStateChange(listener: Listener, options?: {
|
24 | handlerIds: Identifier[] | undefined;
|
25 | }): Unsubscribe;
|
26 | subscribeToOffsetChange(listener: Listener): Unsubscribe;
|
27 | canDragSource(sourceId: Identifier | undefined): boolean;
|
28 | canDropOnTarget(targetId: Identifier | undefined): boolean;
|
29 | |
30 |
|
31 |
|
32 |
|
33 | isDragging(): boolean;
|
34 | isDraggingSource(sourceId: Identifier | undefined): boolean;
|
35 | isOverTarget(targetId: Identifier | undefined, options?: {
|
36 | shallow?: boolean;
|
37 | }): boolean;
|
38 | |
39 |
|
40 |
|
41 | getItemType(): Identifier | null;
|
42 | |
43 |
|
44 |
|
45 |
|
46 | getItem(): any;
|
47 | getSourceId(): Identifier | null;
|
48 | getTargetIds(): Identifier[];
|
49 | |
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 | getDropResult(): any;
|
56 | |
57 |
|
58 |
|
59 |
|
60 |
|
61 | didDrop(): boolean;
|
62 | isSourcePublic(): boolean | null;
|
63 | |
64 |
|
65 |
|
66 |
|
67 | getInitialClientOffset(): XYCoord | null;
|
68 | |
69 |
|
70 |
|
71 |
|
72 | getInitialSourceClientOffset(): XYCoord | null;
|
73 | |
74 |
|
75 |
|
76 |
|
77 | getClientOffset(): XYCoord | null;
|
78 | |
79 |
|
80 |
|
81 |
|
82 | getSourceClientOffset(): XYCoord | null;
|
83 | |
84 |
|
85 |
|
86 |
|
87 | getDifferenceFromInitialOffset(): XYCoord | null;
|
88 | }
|
89 | export interface HandlerRegistry {
|
90 | addSource(type: SourceType, source: DragSource): Identifier;
|
91 | addTarget(type: TargetType, target: DropTarget): Identifier;
|
92 | containsHandler(handler: DragSource | DropTarget): boolean;
|
93 | getSource(sourceId: Identifier, includePinned?: boolean): DragSource;
|
94 | getSourceType(sourceId: Identifier): SourceType;
|
95 | getTargetType(targetId: Identifier): TargetType;
|
96 | getTarget(targetId: Identifier): DropTarget;
|
97 | isSourceId(handlerId: Identifier): boolean;
|
98 | isTargetId(handlerId: Identifier): boolean;
|
99 | removeSource(sourceId: Identifier): void;
|
100 | removeTarget(targetId: Identifier): void;
|
101 | pinSource(sourceId: Identifier): void;
|
102 | unpinSource(): void;
|
103 | }
|
104 | export interface Action<Payload> {
|
105 | type: Identifier;
|
106 | payload: Payload;
|
107 | }
|
108 | export interface SentinelAction {
|
109 | type: Identifier;
|
110 | }
|
111 | export declare type ActionCreator<Payload> = (args: any[]) => Action<Payload>;
|
112 | export interface BeginDragOptions {
|
113 | publishSource?: boolean;
|
114 | clientOffset?: XYCoord;
|
115 | getSourceClientOffset?: (sourceId: Identifier) => XYCoord;
|
116 | }
|
117 | export interface InitCoordsPayload {
|
118 | clientOffset: XYCoord | null;
|
119 | sourceClientOffset: XYCoord | null;
|
120 | }
|
121 | export interface BeginDragPayload {
|
122 | itemType: Identifier;
|
123 | item: any;
|
124 | sourceId: Identifier;
|
125 | clientOffset: XYCoord | null;
|
126 | sourceClientOffset: XYCoord | null;
|
127 | isSourcePublic: boolean;
|
128 | }
|
129 | export interface HoverPayload {
|
130 | targetIds: Identifier[];
|
131 | clientOffset: XYCoord | null;
|
132 | }
|
133 | export interface HoverOptions {
|
134 | clientOffset?: XYCoord;
|
135 | }
|
136 | export interface DropPayload {
|
137 | dropResult: any;
|
138 | }
|
139 | export interface TargetIdPayload {
|
140 | targetId: Identifier;
|
141 | }
|
142 | export interface SourceIdPayload {
|
143 | sourceId: Identifier;
|
144 | }
|
145 | export interface DragDropActions {
|
146 | beginDrag(sourceIds?: Identifier[], options?: any): Action<BeginDragPayload> | undefined;
|
147 | publishDragSource(): SentinelAction | undefined;
|
148 | hover(targetIds: Identifier[], options?: any): Action<HoverPayload>;
|
149 | drop(options?: any): void;
|
150 | endDrag(): SentinelAction;
|
151 | }
|
152 | export interface DragDropManager {
|
153 | getMonitor(): DragDropMonitor;
|
154 | getBackend(): Backend;
|
155 | getRegistry(): HandlerRegistry;
|
156 | getActions(): DragDropActions;
|
157 | dispatch(action: any): void;
|
158 | }
|
159 | export declare type BackendFactory = (manager: DragDropManager, globalContext?: any, configuration?: any) => Backend;
|
160 | export interface DragSource {
|
161 | beginDrag(monitor: DragDropMonitor, targetId: Identifier): void;
|
162 | endDrag(monitor: DragDropMonitor, targetId: Identifier): void;
|
163 | canDrag(monitor: DragDropMonitor, targetId: Identifier): boolean;
|
164 | isDragging(monitor: DragDropMonitor, targetId: Identifier): boolean;
|
165 | }
|
166 | export interface DropTarget {
|
167 | canDrop(monitor: DragDropMonitor, targetId: Identifier): boolean;
|
168 | hover(monitor: DragDropMonitor, targetId: Identifier): void;
|
169 | drop(monitor: DragDropMonitor, targetId: Identifier): any;
|
170 | }
|