UNPKG

4.71 kBTypeScriptView Raw
1// Type definitions for ag-grid v18.1.2
2// Project: http://www.ag-grid.com/
3// Definitions by: Niall Crosby <https://github.com/ag-grid/>
4import { Column } from "../entities/column";
5import { RowNode } from "../entities/rowNode";
6export declare enum DragSourceType {
7 ToolPanel = 0,
8 HeaderCell = 1,
9 RowDrag = 2,
10}
11export interface DragItem {
12 rowNode?: RowNode;
13 columns?: Column[];
14 visibleState?: {
15 [key: string]: boolean;
16 };
17}
18export interface DragSource {
19 /** So the drop target knows what type of event it is, useful for columns,
20 * we we re-ordering or moving dropping from toolPanel */
21 type: DragSourceType;
22 /** Element which, when dragged, will kick off the DnD process */
23 eElement: HTMLElement;
24 /** If eElement is dragged, then the dragItem is the object that gets passed around. */
25 dragItemCallback: () => DragItem;
26 /** This name appears in the ghost icon when dragging */
27 dragItemName: string;
28 /** The drop target associated with this dragSource. So when dragging starts, this target does not get
29 * onDragEnter event. */
30 dragSourceDropTarget?: DropTarget;
31 /** After how many pixels of dragging should the drag operation start. Default is 4px. */
32 dragStartPixels?: number;
33 /** Callback for drag started */
34 dragStarted?: () => void;
35 /** Callback for drag stopped */
36 dragStopped?: () => void;
37}
38export interface DropTarget {
39 /** The main container that will get the drop. */
40 getContainer(): HTMLElement;
41 /** If any secondary containers. For example when moving columns in ag-Grid, we listen for drops
42 * in the header as well as the body (main rows and pinned rows) of the grid. */
43 getSecondaryContainers?(): HTMLElement[];
44 /** Icon to show when drag is over*/
45 getIconName?(): string;
46 isInterestedIn(type: DragSourceType): boolean;
47 /** Callback for when drag enters */
48 onDragEnter?(params: DraggingEvent): void;
49 /** Callback for when drag leaves */
50 onDragLeave?(params: DraggingEvent): void;
51 /** Callback for when dragging */
52 onDragging?(params: DraggingEvent): void;
53 /** Callback for when drag stops */
54 onDragStop?(params: DraggingEvent): void;
55}
56export declare enum VDirection {
57 Up = 0,
58 Down = 1,
59}
60export declare enum HDirection {
61 Left = 0,
62 Right = 1,
63}
64export interface DraggingEvent {
65 event: MouseEvent;
66 x: number;
67 y: number;
68 vDirection: VDirection;
69 hDirection: HDirection;
70 dragSource: DragSource;
71 dragItem: DragItem;
72 fromNudge: boolean;
73}
74export declare class DragAndDropService {
75 private gridOptionsWrapper;
76 private dragService;
77 private environment;
78 private columnController;
79 static ICON_PINNED: string;
80 static ICON_ADD: string;
81 static ICON_MOVE: string;
82 static ICON_LEFT: string;
83 static ICON_RIGHT: string;
84 static ICON_GROUP: string;
85 static ICON_AGGREGATE: string;
86 static ICON_PIVOT: string;
87 static ICON_NOT_ALLOWED: string;
88 static GHOST_TEMPLATE: string;
89 private logger;
90 private dragSourceAndParamsList;
91 private dragItem;
92 private eventLastTime;
93 private dragSource;
94 private dragging;
95 private eGhost;
96 private eGhostParent;
97 private eGhostIcon;
98 private dropTargets;
99 private lastDropTarget;
100 private ePinnedIcon;
101 private ePlusIcon;
102 private eHiddenIcon;
103 private eMoveIcon;
104 private eLeftIcon;
105 private eRightIcon;
106 private eGroupIcon;
107 private eAggregateIcon;
108 private ePivotIcon;
109 private eDropNotAllowedIcon;
110 private init();
111 private setBeans(loggerFactory);
112 private getStringType(type);
113 addDragSource(dragSource: DragSource, allowTouch?: boolean): void;
114 removeDragSource(dragSource: DragSource): void;
115 private destroy();
116 nudge(): void;
117 private onDragStart(dragSource, mouseEvent);
118 private onDragStop(mouseEvent);
119 private onDragging(mouseEvent, fromNudge);
120 private enterDragTargetIfExists(dropTarget, mouseEvent, hDirection, vDirection, fromNudge);
121 private leaveLastTargetIfExists(mouseEvent, hDirection, vDirection, fromNudge);
122 private getAllContainersFromDropTarget(dropTarget);
123 private isMouseOnDropTarget(mouseEvent, dropTarget);
124 addDropTarget(dropTarget: DropTarget): void;
125 workOutHDirection(event: MouseEvent): HDirection;
126 workOutVDirection(event: MouseEvent): VDirection;
127 createDropTargetEvent(dropTarget: DropTarget, event: MouseEvent, hDirection: HDirection, vDirection: VDirection, fromNudge: boolean): DraggingEvent;
128 private positionGhost(event);
129 private removeGhost();
130 private createGhost();
131 setGhostIcon(iconName: string, shake?: boolean): void;
132}