forked from gridstack/gridstack.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgridstack-dd.ts
More file actions
80 lines (63 loc) · 2.52 KB
/
Copy pathgridstack-dd.ts
File metadata and controls
80 lines (63 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// gridstack-dd.ts 2.0.2-dev @preserve
/**
* https://gridstackjs.com/
* (c) 2014-2020 Alain Dumesny, Dylan Weiss, Pavel Reznikov
* gridstack.js may be freely distributed under the MIT license.
*/
/* eslint-disable @typescript-eslint/no-unused-vars */
import { GridStack, GridStackElement } from './gridstack';
import { GridItemHTMLElement, DDDragInOpt } from './types';
/** Drag&Drop drop options */
export type DDDropOpt = {
/** function or class type that this grid will accept as dropped items (see GridStackOptions.acceptWidgets) */
accept?: (el: GridItemHTMLElement) => boolean;
}
/** drag&drop options currently called from the main code, but others can be passed in grid options */
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type DDOpts = 'enable' | 'disable' | 'destroy' | 'option' | string | {} | any;
export type DDKey = 'minWidth' | 'minHeight' | string;
export type DDValue = number | string;
/** drag&drop events callbacks */
export type DDCallback = (event: Event, arg2: GridItemHTMLElement, helper?: GridItemHTMLElement) => void;
/**
* Base class for drag'n'drop plugin.
*/
export class GridStackDD {
protected grid: GridStack;
static registeredPlugins: typeof GridStackDD;
/** call this method to register your plugin instead of the default no-op one */
static registerPlugin(pluginClass: typeof GridStackDD) {
GridStackDD.registeredPlugins = pluginClass;
}
/** get the current registered plugin to use */
static get(): typeof GridStackDD {
return GridStackDD.registeredPlugins || GridStackDD;
}
public constructor(grid: GridStack) {
this.grid = grid;
}
public resizable(el: GridItemHTMLElement, opts: DDOpts, key?: DDKey, value?: DDValue): GridStackDD {
return this;
}
public draggable(el: GridItemHTMLElement, opts: DDOpts, key?: DDKey, value?: DDValue): GridStackDD {
return this;
}
public dragIn(el: GridStackElement, opts: DDDragInOpt): GridStackDD {
return this;
}
public isDraggable(el: GridStackElement): boolean {
return false;
}
public droppable(el: GridItemHTMLElement, opts: DDOpts | DDDropOpt, key?: DDKey, value?: DDValue): GridStackDD {
return this;
}
public isDroppable(el: GridItemHTMLElement): boolean {
return false;
}
public on(el: GridItemHTMLElement, eventName: string, callback: DDCallback): GridStackDD {
return this;
}
public off(el: GridItemHTMLElement, eventName: string): GridStackDD {
return this;
}
}