gridstack 5.1.1 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +49 -38
- package/dist/{h5/dd-base-impl.d.ts → dd-base-impl.d.ts} +1 -1
- package/dist/{h5/dd-base-impl.js → dd-base-impl.js} +1 -3
- package/dist/dd-base-impl.js.map +1 -0
- package/dist/{es5/h5/dd-draggable.d.ts → dd-draggable.d.ts} +6 -7
- package/dist/dd-draggable.js +313 -0
- package/dist/dd-draggable.js.map +1 -0
- package/dist/{h5/dd-droppable.d.ts → dd-droppable.d.ts} +3 -2
- package/dist/dd-droppable.js +149 -0
- package/dist/dd-droppable.js.map +1 -0
- package/dist/{h5/dd-element.d.ts → dd-element.d.ts} +2 -2
- package/dist/{h5/dd-element.js → dd-element.js} +1 -1
- package/dist/dd-element.js.map +1 -0
- package/dist/dd-gridstack.d.ts +36 -0
- package/dist/{gridstack-dd.js → dd-gridstack.js} +154 -52
- package/dist/dd-gridstack.js.map +1 -0
- package/dist/dd-manager.d.ts +17 -0
- package/dist/{h5/dd-manager.js → dd-manager.js} +4 -1
- package/dist/dd-manager.js.map +1 -0
- package/dist/{es5/h5/dd-resizable-handle.d.ts → dd-resizable-handle.d.ts} +1 -1
- package/dist/{h5/dd-resizable-handle.js → dd-resizable-handle.js} +32 -8
- package/dist/dd-resizable-handle.js.map +1 -0
- package/dist/{es5/h5/dd-resizable.d.ts → dd-resizable.d.ts} +2 -2
- package/dist/{h5/dd-resizable.js → dd-resizable.js} +28 -27
- package/dist/dd-resizable.js.map +1 -0
- package/dist/dd-touch.d.ts +33 -0
- package/dist/dd-touch.js +179 -0
- package/dist/dd-touch.js.map +1 -0
- package/dist/es5/{h5/dd-base-impl.d.ts → dd-base-impl.d.ts} +1 -1
- package/dist/es5/{h5/dd-base-impl.js → dd-base-impl.js} +1 -3
- package/dist/es5/dd-base-impl.js.map +1 -0
- package/dist/{h5 → es5}/dd-draggable.d.ts +6 -7
- package/dist/es5/dd-draggable.js +335 -0
- package/dist/es5/dd-draggable.js.map +1 -0
- package/dist/es5/{h5/dd-droppable.d.ts → dd-droppable.d.ts} +3 -2
- package/dist/es5/dd-droppable.js +180 -0
- package/dist/es5/dd-droppable.js.map +1 -0
- package/dist/es5/{h5/dd-element.d.ts → dd-element.d.ts} +2 -2
- package/dist/es5/{h5/dd-element.js → dd-element.js} +1 -1
- package/dist/es5/dd-element.js.map +1 -0
- package/dist/es5/dd-gridstack.d.ts +36 -0
- package/dist/es5/{gridstack-dd.js → dd-gridstack.js} +164 -71
- package/dist/es5/dd-gridstack.js.map +1 -0
- package/dist/es5/dd-manager.d.ts +17 -0
- package/dist/es5/{h5/dd-manager.js → dd-manager.js} +4 -1
- package/dist/es5/dd-manager.js.map +1 -0
- package/dist/{h5 → es5}/dd-resizable-handle.d.ts +1 -1
- package/dist/es5/{h5/dd-resizable-handle.js → dd-resizable-handle.js} +32 -8
- package/dist/es5/dd-resizable-handle.js.map +1 -0
- package/dist/{h5 → es5}/dd-resizable.d.ts +2 -2
- package/dist/es5/{h5/dd-resizable.js → dd-resizable.js} +28 -27
- package/dist/es5/dd-resizable.js.map +1 -0
- package/dist/es5/dd-touch.d.ts +33 -0
- package/dist/es5/dd-touch.js +182 -0
- package/dist/es5/dd-touch.js.map +1 -0
- package/dist/es5/gridstack-all.js +3 -0
- package/dist/{gridstack-static.js.LICENSE.txt → es5/gridstack-all.js.LICENSE.txt} +1 -1
- package/dist/es5/gridstack-all.js.map +1 -0
- package/dist/es5/gridstack-engine.d.ts +2 -3
- package/dist/es5/gridstack-engine.js +18 -18
- package/dist/es5/gridstack-engine.js.map +1 -1
- package/dist/es5/gridstack-poly.js +1 -1
- package/dist/es5/gridstack.d.ts +8 -9
- package/dist/es5/gridstack.js +47 -35
- package/dist/es5/gridstack.js.map +1 -1
- package/dist/es5/types.d.ts +12 -16
- package/dist/es5/types.js +1 -1
- package/dist/es5/types.js.map +1 -1
- package/dist/es5/utils.d.ts +11 -1
- package/dist/es5/utils.js +67 -6
- package/dist/es5/utils.js.map +1 -1
- package/dist/gridstack-all.js +3 -0
- package/dist/{es5/gridstack-h5.js.LICENSE.txt → gridstack-all.js.LICENSE.txt} +1 -1
- package/dist/gridstack-all.js.map +1 -0
- package/dist/gridstack-engine.d.ts +2 -3
- package/dist/gridstack-engine.js +17 -18
- package/dist/gridstack-engine.js.map +1 -1
- package/dist/gridstack.css +21 -9
- package/dist/gridstack.d.ts +8 -9
- package/dist/gridstack.js +45 -35
- package/dist/gridstack.js.map +1 -1
- package/dist/gridstack.min.css +1 -1
- package/dist/src/gridstack.scss +19 -12
- package/dist/types.d.ts +12 -16
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +11 -1
- package/dist/utils.js +64 -6
- package/dist/utils.js.map +1 -1
- package/doc/CHANGES.md +7 -0
- package/doc/README.md +17 -18
- package/package.json +2 -2
- package/dist/es5/gridstack-dd.d.ts +0 -35
- package/dist/es5/gridstack-dd.js.map +0 -1
- package/dist/es5/gridstack-ddi.d.ts +0 -17
- package/dist/es5/gridstack-ddi.js +0 -31
- package/dist/es5/gridstack-ddi.js.map +0 -1
- package/dist/es5/gridstack-h5.d.ts +0 -10
- package/dist/es5/gridstack-h5.js +0 -3
- package/dist/es5/gridstack-h5.js.map +0 -1
- package/dist/es5/gridstack-jq.d.ts +0 -10
- package/dist/es5/gridstack-jq.js +0 -3
- package/dist/es5/gridstack-jq.js.LICENSE.txt +0 -99
- package/dist/es5/gridstack-jq.js.map +0 -1
- package/dist/es5/gridstack-static.d.ts +0 -9
- package/dist/es5/gridstack-static.js +0 -3
- package/dist/es5/gridstack-static.js.LICENSE.txt +0 -7
- package/dist/es5/gridstack-static.js.map +0 -1
- package/dist/es5/h5/dd-base-impl.js.map +0 -1
- package/dist/es5/h5/dd-draggable.js +0 -326
- package/dist/es5/h5/dd-draggable.js.map +0 -1
- package/dist/es5/h5/dd-droppable.js +0 -199
- package/dist/es5/h5/dd-droppable.js.map +0 -1
- package/dist/es5/h5/dd-element.js.map +0 -1
- package/dist/es5/h5/dd-manager.d.ts +0 -8
- package/dist/es5/h5/dd-manager.js.map +0 -1
- package/dist/es5/h5/dd-resizable-handle.js.map +0 -1
- package/dist/es5/h5/dd-resizable.js.map +0 -1
- package/dist/es5/h5/dd-utils.d.ts +0 -19
- package/dist/es5/h5/dd-utils.js +0 -111
- package/dist/es5/h5/dd-utils.js.map +0 -1
- package/dist/es5/h5/gridstack-dd-native.d.ts +0 -26
- package/dist/es5/h5/gridstack-dd-native.js +0 -175
- package/dist/es5/h5/gridstack-dd-native.js.map +0 -1
- package/dist/es5/jq/gridstack-dd-jqueryui.d.ts +0 -22
- package/dist/es5/jq/gridstack-dd-jqueryui.js +0 -162
- package/dist/es5/jq/gridstack-dd-jqueryui.js.map +0 -1
- package/dist/gridstack-dd.d.ts +0 -35
- package/dist/gridstack-dd.js.map +0 -1
- package/dist/gridstack-ddi.d.ts +0 -17
- package/dist/gridstack-ddi.js +0 -28
- package/dist/gridstack-ddi.js.map +0 -1
- package/dist/gridstack-h5.d.ts +0 -10
- package/dist/gridstack-h5.js +0 -3
- package/dist/gridstack-h5.js.LICENSE.txt +0 -7
- package/dist/gridstack-h5.js.map +0 -1
- package/dist/gridstack-jq.d.ts +0 -10
- package/dist/gridstack-jq.js +0 -3
- package/dist/gridstack-jq.js.LICENSE.txt +0 -99
- package/dist/gridstack-jq.js.map +0 -1
- package/dist/gridstack-static.d.ts +0 -9
- package/dist/gridstack-static.js +0 -3
- package/dist/gridstack-static.js.map +0 -1
- package/dist/h5/dd-base-impl.js.map +0 -1
- package/dist/h5/dd-draggable.js +0 -302
- package/dist/h5/dd-draggable.js.map +0 -1
- package/dist/h5/dd-droppable.js +0 -168
- package/dist/h5/dd-droppable.js.map +0 -1
- package/dist/h5/dd-element.js.map +0 -1
- package/dist/h5/dd-manager.d.ts +0 -8
- package/dist/h5/dd-manager.js.map +0 -1
- package/dist/h5/dd-resizable-handle.js.map +0 -1
- package/dist/h5/dd-resizable.js.map +0 -1
- package/dist/h5/dd-utils.d.ts +0 -19
- package/dist/h5/dd-utils.js +0 -94
- package/dist/h5/dd-utils.js.map +0 -1
- package/dist/h5/gridstack-dd-native.d.ts +0 -26
- package/dist/h5/gridstack-dd-native.js +0 -140
- package/dist/h5/gridstack-dd-native.js.map +0 -1
- package/dist/jq/gridstack-dd-jqueryui.d.ts +0 -22
- package/dist/jq/gridstack-dd-jqueryui.js +0 -133
- package/dist/jq/gridstack-dd-jqueryui.js.map +0 -1
- package/dist/jq/jquery-ui.js +0 -2
- package/dist/jq/jquery-ui.js.map +0 -1
- package/dist/jq/jquery.js +0 -2
- package/dist/jq/jquery.js.map +0 -1
- package/dist/jq/jquery.ui.touch-punch.js +0 -2
- package/dist/jq/jquery.ui.touch-punch.js.map +0 -1
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* dd-droppable.ts 6.0.0
|
|
4
|
+
* Copyright (c) 2021-2022 Alain Dumesny - see GridStack root license
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.DDDroppable = void 0;
|
|
8
|
+
const dd_manager_1 = require("./dd-manager");
|
|
9
|
+
const dd_base_impl_1 = require("./dd-base-impl");
|
|
10
|
+
const utils_1 = require("./utils");
|
|
11
|
+
const dd_touch_1 = require("./dd-touch");
|
|
12
|
+
// let count = 0; // TEST
|
|
13
|
+
class DDDroppable extends dd_base_impl_1.DDBaseImplement {
|
|
14
|
+
constructor(el, opts = {}) {
|
|
15
|
+
super();
|
|
16
|
+
this.el = el;
|
|
17
|
+
this.option = opts;
|
|
18
|
+
// create var event binding so we can easily remove and still look like TS methods (unlike anonymous functions)
|
|
19
|
+
this._mouseEnter = this._mouseEnter.bind(this);
|
|
20
|
+
this._mouseLeave = this._mouseLeave.bind(this);
|
|
21
|
+
this.enable();
|
|
22
|
+
this._setupAccept();
|
|
23
|
+
}
|
|
24
|
+
on(event, callback) {
|
|
25
|
+
super.on(event, callback);
|
|
26
|
+
}
|
|
27
|
+
off(event) {
|
|
28
|
+
super.off(event);
|
|
29
|
+
}
|
|
30
|
+
enable() {
|
|
31
|
+
if (this.disabled === false)
|
|
32
|
+
return;
|
|
33
|
+
super.enable();
|
|
34
|
+
this.el.classList.add('ui-droppable');
|
|
35
|
+
this.el.classList.remove('ui-droppable-disabled');
|
|
36
|
+
this.el.addEventListener('mouseenter', this._mouseEnter);
|
|
37
|
+
this.el.addEventListener('mouseleave', this._mouseLeave);
|
|
38
|
+
if (dd_touch_1.isTouch) {
|
|
39
|
+
this.el.addEventListener('pointerenter', dd_touch_1.pointerenter);
|
|
40
|
+
this.el.addEventListener('pointerleave', dd_touch_1.pointerleave);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
disable(forDestroy = false) {
|
|
44
|
+
if (this.disabled === true)
|
|
45
|
+
return;
|
|
46
|
+
super.disable();
|
|
47
|
+
this.el.classList.remove('ui-droppable');
|
|
48
|
+
if (!forDestroy)
|
|
49
|
+
this.el.classList.add('ui-droppable-disabled');
|
|
50
|
+
this.el.removeEventListener('mouseenter', this._mouseEnter);
|
|
51
|
+
this.el.removeEventListener('mouseleave', this._mouseLeave);
|
|
52
|
+
if (dd_touch_1.isTouch) {
|
|
53
|
+
this.el.removeEventListener('pointerenter', dd_touch_1.pointerenter);
|
|
54
|
+
this.el.removeEventListener('pointerleave', dd_touch_1.pointerleave);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
destroy() {
|
|
58
|
+
this.disable(true);
|
|
59
|
+
this.el.classList.remove('ui-droppable');
|
|
60
|
+
this.el.classList.remove('ui-droppable-disabled');
|
|
61
|
+
super.destroy();
|
|
62
|
+
}
|
|
63
|
+
updateOption(opts) {
|
|
64
|
+
Object.keys(opts).forEach(key => this.option[key] = opts[key]);
|
|
65
|
+
this._setupAccept();
|
|
66
|
+
return this;
|
|
67
|
+
}
|
|
68
|
+
/** @internal called when the cursor enters our area - prepare for a possible drop and track leaving */
|
|
69
|
+
_mouseEnter(e) {
|
|
70
|
+
// console.log(`${count++} Enter ${this.el.id || (this.el as GridHTMLElement).gridstack.opts.id}`); // TEST
|
|
71
|
+
if (!dd_manager_1.DDManager.dragElement)
|
|
72
|
+
return;
|
|
73
|
+
if (!this._canDrop())
|
|
74
|
+
return;
|
|
75
|
+
e.preventDefault();
|
|
76
|
+
e.stopPropagation();
|
|
77
|
+
// make sure when we enter this, that the last one gets a leave FIRST to correctly cleanup as we don't always do
|
|
78
|
+
if (dd_manager_1.DDManager.dropElement && dd_manager_1.DDManager.dropElement !== this) {
|
|
79
|
+
dd_manager_1.DDManager.dropElement._mouseLeave(e);
|
|
80
|
+
}
|
|
81
|
+
dd_manager_1.DDManager.dropElement = this;
|
|
82
|
+
const ev = utils_1.Utils.initEvent(e, { target: this.el, type: 'dropover' });
|
|
83
|
+
if (this.option.over) {
|
|
84
|
+
this.option.over(ev, this._ui(dd_manager_1.DDManager.dragElement));
|
|
85
|
+
}
|
|
86
|
+
this.triggerEvent('dropover', ev);
|
|
87
|
+
this.el.classList.add('ui-droppable-over');
|
|
88
|
+
// console.log('tracking'); // TEST
|
|
89
|
+
}
|
|
90
|
+
/** @internal called when the item is leaving our area, stop tracking if we had moving item */
|
|
91
|
+
_mouseLeave(e) {
|
|
92
|
+
var _a;
|
|
93
|
+
// console.log(`${count++} Leave ${this.el.id || (this.el as GridHTMLElement).gridstack.opts.id}`); // TEST
|
|
94
|
+
if (!dd_manager_1.DDManager.dragElement || dd_manager_1.DDManager.dropElement !== this)
|
|
95
|
+
return;
|
|
96
|
+
e.preventDefault();
|
|
97
|
+
e.stopPropagation();
|
|
98
|
+
const ev = utils_1.Utils.initEvent(e, { target: this.el, type: 'dropout' });
|
|
99
|
+
if (this.option.out) {
|
|
100
|
+
this.option.out(ev, this._ui(dd_manager_1.DDManager.dragElement));
|
|
101
|
+
}
|
|
102
|
+
this.triggerEvent('dropout', ev);
|
|
103
|
+
if (dd_manager_1.DDManager.dropElement === this) {
|
|
104
|
+
delete dd_manager_1.DDManager.dropElement;
|
|
105
|
+
// console.log('not tracking'); // TEST
|
|
106
|
+
// if we're still over a parent droppable, send it an enter as we don't get one from leaving nested children
|
|
107
|
+
let parentDrop;
|
|
108
|
+
let parent = this.el.parentElement;
|
|
109
|
+
while (!parentDrop && parent) {
|
|
110
|
+
parentDrop = (_a = parent.ddElement) === null || _a === void 0 ? void 0 : _a.ddDroppable;
|
|
111
|
+
parent = parent.parentElement;
|
|
112
|
+
}
|
|
113
|
+
if (parentDrop) {
|
|
114
|
+
parentDrop._mouseEnter(e);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/** item is being dropped on us - called by the drag mouseup handler - this calls the client drop event */
|
|
119
|
+
drop(e) {
|
|
120
|
+
e.preventDefault();
|
|
121
|
+
const ev = utils_1.Utils.initEvent(e, { target: this.el, type: 'drop' });
|
|
122
|
+
if (this.option.drop) {
|
|
123
|
+
this.option.drop(ev, this._ui(dd_manager_1.DDManager.dragElement));
|
|
124
|
+
}
|
|
125
|
+
this.triggerEvent('drop', ev);
|
|
126
|
+
}
|
|
127
|
+
/** @internal true if element matches the string/method accept option */
|
|
128
|
+
_canDrop() {
|
|
129
|
+
return dd_manager_1.DDManager.dragElement && (!this.accept || this.accept(dd_manager_1.DDManager.dragElement.el));
|
|
130
|
+
}
|
|
131
|
+
/** @internal */
|
|
132
|
+
_setupAccept() {
|
|
133
|
+
if (!this.option.accept)
|
|
134
|
+
return this;
|
|
135
|
+
if (typeof this.option.accept === 'string') {
|
|
136
|
+
this.accept = (el) => el.matches(this.option.accept);
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
this.accept = this.option.accept;
|
|
140
|
+
}
|
|
141
|
+
return this;
|
|
142
|
+
}
|
|
143
|
+
/** @internal */
|
|
144
|
+
_ui(drag) {
|
|
145
|
+
return Object.assign({ draggable: drag.el }, drag.ui());
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
exports.DDDroppable = DDDroppable;
|
|
149
|
+
//# sourceMappingURL=dd-droppable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dd-droppable.js","sourceRoot":"","sources":["../src/dd-droppable.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,6CAAyC;AACzC,iDAAuE;AACvE,mCAAgC;AAEhC,yCAAiE;AAUjE,yBAAyB;AAEzB,MAAa,WAAY,SAAQ,8BAAe;IAM9C,YAAY,EAAe,EAAE,OAAuB,EAAE;QACpD,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,+GAA+G;QAC/G,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/C,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/C,IAAI,CAAC,MAAM,EAAE,CAAC;QACd,IAAI,CAAC,YAAY,EAAE,CAAC;IACtB,CAAC;IAEM,EAAE,CAAC,KAAsC,EAAE,QAAoC;QACpF,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC5B,CAAC;IAEM,GAAG,CAAC,KAAsC;QAC/C,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACnB,CAAC;IAEM,MAAM;QACX,IAAI,IAAI,CAAC,QAAQ,KAAK,KAAK;YAAE,OAAO;QACpC,KAAK,CAAC,MAAM,EAAE,CAAC;QACf,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;QACtC,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,uBAAuB,CAAC,CAAC;QAClD,IAAI,CAAC,EAAE,CAAC,gBAAgB,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AAC,IAAI,EAAE;YACpB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,sBAAS,CAAC,WAAW,CAAC,CAAC,CAAA;SACtD;QACD,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAChC,CAAC;IAED,wEAAwE;IAC9D,QAAQ;QAChB,OAAO,sBAAS,CAAC,WAAW,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,sBAAS,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC;IAC1F,CAAC;IAED,gBAAgB;IACN,YAAY;QACpB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM;YAAE,OAAO,IAAI,CAAC;QACrC,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,QAAQ,EAAE;YAC1C,IAAI,CAAC,MAAM,GAAG,CAAC,EAAe,EAAE,EAAE,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,MAAgB,CAAC,CAAC;SAC7E;aAAM;YACL,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;SAClC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,gBAAgB;IACN,GAAG,CAAC,IAAiB;QAC7B,uBACE,SAAS,EAAE,IAAI,CAAC,EAAE,IACf,IAAI,CAAC,EAAE,EAAE,EACZ;IACJ,CAAC;CACF;AAtJD,kCAsJC","sourcesContent":["/**\n * dd-droppable.ts 6.0.0\n * Copyright (c) 2021-2022 Alain Dumesny - see GridStack root license\n */\n\nimport { DDDraggable } from './dd-draggable';\nimport { DDManager } from './dd-manager';\nimport { DDBaseImplement, HTMLElementExtendOpt } from './dd-base-impl';\nimport { Utils } from './utils';\nimport { DDElementHost } from './dd-element';\nimport { isTouch, pointerenter, pointerleave } from './dd-touch';\nimport { GridHTMLElement } from './gridstack';\n\nexport interface DDDroppableOpt {\n accept?: string | ((el: HTMLElement) => boolean);\n drop?: (event: DragEvent, ui) => void;\n over?: (event: DragEvent, ui) => void;\n out?: (event: DragEvent, ui) => void;\n}\n\n// let count = 0; // TEST\n\nexport class DDDroppable extends DDBaseImplement implements HTMLElementExtendOpt<DDDroppableOpt> {\n\n public accept: (el: HTMLElement) => boolean;\n public el: HTMLElement;\n public option: DDDroppableOpt;\n\n constructor(el: HTMLElement, opts: DDDroppableOpt = {}) {\n super();\n this.el = el;\n this.option = opts;\n // create var event binding so we can easily remove and still look like TS methods (unlike anonymous functions)\n this._mouseEnter = this._mouseEnter.bind(this);\n this._mouseLeave = this._mouseLeave.bind(this);\n this.enable();\n this._setupAccept();\n }\n\n public on(event: 'drop' | 'dropover' | 'dropout', callback: (event: DragEvent) => void): void {\n super.on(event, callback);\n }\n\n public off(event: 'drop' | 'dropover' | 'dropout'): void {\n super.off(event);\n }\n\n public enable(): void {\n if (this.disabled === false) return;\n super.enable();\n this.el.classList.add('ui-droppable');\n this.el.classList.remove('ui-droppable-disabled');\n this.el.addEventListener('mouseenter', this._mouseEnter);\n this.el.addEventListener('mouseleave', this._mouseLeave);\n if (isTouch) {\n this.el.addEventListener('pointerenter', pointerenter);\n this.el.addEventListener('pointerleave', pointerleave);\n }\n }\n\n public disable(forDestroy = false): void {\n if (this.disabled === true) return;\n super.disable();\n this.el.classList.remove('ui-droppable');\n if (!forDestroy) this.el.classList.add('ui-droppable-disabled');\n this.el.removeEventListener('mouseenter', this._mouseEnter);\n this.el.removeEventListener('mouseleave', this._mouseLeave);\n if (isTouch) {\n this.el.removeEventListener('pointerenter', pointerenter);\n this.el.removeEventListener('pointerleave', pointerleave);\n }\n }\n\n public destroy(): void {\n this.disable(true);\n this.el.classList.remove('ui-droppable');\n this.el.classList.remove('ui-droppable-disabled');\n super.destroy();\n }\n\n public updateOption(opts: DDDroppableOpt): DDDroppable {\n Object.keys(opts).forEach(key => this.option[key] = opts[key]);\n this._setupAccept();\n return this;\n }\n\n /** @internal called when the cursor enters our area - prepare for a possible drop and track leaving */\n protected _mouseEnter(e: MouseEvent): void {\n // console.log(`${count++} Enter ${this.el.id || (this.el as GridHTMLElement).gridstack.opts.id}`); // TEST\n if (!DDManager.dragElement) return;\n if (!this._canDrop()) return;\n e.preventDefault();\n e.stopPropagation();\n\n // make sure when we enter this, that the last one gets a leave FIRST to correctly cleanup as we don't always do\n if (DDManager.dropElement && DDManager.dropElement !== this) {\n DDManager.dropElement._mouseLeave(e as DragEvent);\n }\n DDManager.dropElement = this;\n\n const ev = Utils.initEvent<DragEvent>(e, { target: this.el, type: 'dropover' });\n if (this.option.over) {\n this.option.over(ev, this._ui(DDManager.dragElement))\n }\n this.triggerEvent('dropover', ev);\n this.el.classList.add('ui-droppable-over');\n // console.log('tracking'); // TEST\n }\n\n /** @internal called when the item is leaving our area, stop tracking if we had moving item */\n protected _mouseLeave(e: MouseEvent): void {\n // console.log(`${count++} Leave ${this.el.id || (this.el as GridHTMLElement).gridstack.opts.id}`); // TEST\n if (!DDManager.dragElement || DDManager.dropElement !== this) return;\n e.preventDefault();\n e.stopPropagation();\n\n const ev = Utils.initEvent<DragEvent>(e, { target: this.el, type: 'dropout' });\n if (this.option.out) {\n this.option.out(ev, this._ui(DDManager.dragElement))\n }\n this.triggerEvent('dropout', ev);\n\n if (DDManager.dropElement === this) {\n delete DDManager.dropElement;\n // console.log('not tracking'); // TEST\n\n // if we're still over a parent droppable, send it an enter as we don't get one from leaving nested children\n let parentDrop: DDDroppable;\n let parent: DDElementHost = this.el.parentElement;\n while (!parentDrop && parent) {\n parentDrop = parent.ddElement?.ddDroppable;\n parent = parent.parentElement;\n }\n if (parentDrop) {\n parentDrop._mouseEnter(e);\n }\n }\n }\n\n /** item is being dropped on us - called by the drag mouseup handler - this calls the client drop event */\n public drop(e: MouseEvent): void {\n e.preventDefault();\n const ev = Utils.initEvent<DragEvent>(e, { target: this.el, type: 'drop' });\n if (this.option.drop) {\n this.option.drop(ev, this._ui(DDManager.dragElement))\n }\n this.triggerEvent('drop', ev);\n }\n\n /** @internal true if element matches the string/method accept option */\n protected _canDrop(): boolean {\n return DDManager.dragElement && (!this.accept || this.accept(DDManager.dragElement.el));\n }\n\n /** @internal */\n protected _setupAccept(): DDDroppable {\n if (!this.option.accept) return this;\n if (typeof this.option.accept === 'string') {\n this.accept = (el: HTMLElement) => el.matches(this.option.accept as string);\n } else {\n this.accept = this.option.accept;\n }\n return this;\n }\n\n /** @internal */\n protected _ui(drag: DDDraggable) {\n return {\n draggable: drag.el,\n ...drag.ui()\n };\n }\n}\n\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* dd-elements.ts
|
|
2
|
+
* dd-elements.ts 6.0.0
|
|
3
3
|
* Copyright (c) 2021 Alain Dumesny - see GridStack root license
|
|
4
4
|
*/
|
|
5
5
|
import { DDResizable, DDResizableOpt } from './dd-resizable';
|
|
6
|
-
import { GridItemHTMLElement } from '
|
|
6
|
+
import { GridItemHTMLElement } from './types';
|
|
7
7
|
import { DDDraggable, DDDraggableOpt } from './dd-draggable';
|
|
8
8
|
import { DDDroppable, DDDroppableOpt } from './dd-droppable';
|
|
9
9
|
export interface DDElementHost extends GridItemHTMLElement {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dd-element.js","sourceRoot":"","sources":["../src/dd-element.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,iDAA6D;AAE7D,iDAA6D;AAC7D,iDAA6D;AAM7D,MAAa,SAAS;IAYpB,YAAY,EAAiB;QAC3B,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACf,CAAC;IAZD,MAAM,CAAC,IAAI,CAAC,EAAiB;QAC3B,IAAI,CAAC,EAAE,CAAC,SAAS,EAAE;YAAE,EAAE,CAAC,SAAS,GAAG,IAAI,SAAS,CAAC,EAAE,CAAC,CAAC;SAAE;QACxD,OAAO,EAAE,CAAC,SAAS,CAAC;IACtB,CAAC;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YAAY,CAAC,IAAI,CAAC,CAAC;SACrC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,cAAc;QACnB,IAAI,IAAI,CAAC,WAAW,EAAE;YACpB,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;YAC3B,OAAO,IAAI,CAAC,WAAW,CAAC;SACzB;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAxFD,8BAwFC","sourcesContent":["/**\n * dd-elements.ts 6.0.0\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\n */\n\nimport { DDResizable, DDResizableOpt } from './dd-resizable';\nimport { GridItemHTMLElement } from './types';\nimport { DDDraggable, DDDraggableOpt } from './dd-draggable';\nimport { DDDroppable, DDDroppableOpt } from './dd-droppable';\n\nexport interface DDElementHost extends GridItemHTMLElement {\n ddElement?: DDElement;\n}\n\nexport class DDElement {\n\n static init(el: DDElementHost): DDElement {\n if (!el.ddElement) { el.ddElement = new DDElement(el); }\n return el.ddElement;\n }\n\n public el: DDElementHost;\n public ddDraggable?: DDDraggable;\n public ddDroppable?: DDDroppable;\n public ddResizable?: DDResizable;\n\n constructor(el: DDElementHost) {\n this.el = el;\n }\n\n public on(eventName: string, callback: (event: MouseEvent) => void): DDElement {\n if (this.ddDraggable && ['drag', 'dragstart', 'dragstop'].indexOf(eventName) > -1) {\n this.ddDraggable.on(eventName as 'drag' | 'dragstart' | 'dragstop', callback);\n } else if (this.ddDroppable && ['drop', 'dropover', 'dropout'].indexOf(eventName) > -1) {\n this.ddDroppable.on(eventName as 'drop' | 'dropover' | 'dropout', callback);\n } else if (this.ddResizable && ['resizestart', 'resize', 'resizestop'].indexOf(eventName) > -1) {\n this.ddResizable.on(eventName as 'resizestart' | 'resize' | 'resizestop', callback);\n }\n return this;\n }\n\n public off(eventName: string): DDElement {\n if (this.ddDraggable && ['drag', 'dragstart', 'dragstop'].indexOf(eventName) > -1) {\n this.ddDraggable.off(eventName as 'drag' | 'dragstart' | 'dragstop');\n } else if (this.ddDroppable && ['drop', 'dropover', 'dropout'].indexOf(eventName) > -1) {\n this.ddDroppable.off(eventName as 'drop' | 'dropover' | 'dropout');\n } else if (this.ddResizable && ['resizestart', 'resize', 'resizestop'].indexOf(eventName) > -1) {\n this.ddResizable.off(eventName as 'resizestart' | 'resize' | 'resizestop');\n }\n return this;\n }\n\n public setupDraggable(opts: DDDraggableOpt): DDElement {\n if (!this.ddDraggable) {\n this.ddDraggable = new DDDraggable(this.el, opts);\n } else {\n this.ddDraggable.updateOption(opts);\n }\n return this;\n }\n\n public cleanDraggable(): DDElement {\n if (this.ddDraggable) {\n this.ddDraggable.destroy();\n delete this.ddDraggable;\n }\n return this;\n }\n\n public setupResizable(opts: DDResizableOpt): DDElement {\n if (!this.ddResizable) {\n this.ddResizable = new DDResizable(this.el, opts);\n } else {\n this.ddResizable.updateOption(opts);\n }\n return this;\n }\n\n public cleanResizable(): DDElement {\n if (this.ddResizable) {\n this.ddResizable.destroy();\n delete this.ddResizable;\n }\n return this;\n }\n\n public setupDroppable(opts: DDDroppableOpt): DDElement {\n if (!this.ddDroppable) {\n this.ddDroppable = new DDDroppable(this.el, opts);\n } else {\n this.ddDroppable.updateOption(opts);\n }\n return this;\n }\n\n public cleanDroppable(): DDElement {\n if (this.ddDroppable) {\n this.ddDroppable.destroy();\n delete this.ddDroppable;\n }\n return this;\n }\n}\n"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dd-gridstack.ts 6.0.0
|
|
3
|
+
* Copyright (c) 2021 Alain Dumesny - see GridStack root license
|
|
4
|
+
*/
|
|
5
|
+
import { GridItemHTMLElement, GridStackElement, DDDragInOpt } from './types';
|
|
6
|
+
import { DDElementHost } from './dd-element';
|
|
7
|
+
/** Drag&Drop drop options */
|
|
8
|
+
export declare type DDDropOpt = {
|
|
9
|
+
/** function or class type that this grid will accept as dropped items (see GridStackOptions.acceptWidgets) */
|
|
10
|
+
accept?: (el: GridItemHTMLElement) => boolean;
|
|
11
|
+
};
|
|
12
|
+
/** drag&drop options currently called from the main code, but others can be passed in grid options */
|
|
13
|
+
export declare type DDOpts = 'enable' | 'disable' | 'destroy' | 'option' | string | any;
|
|
14
|
+
export declare type DDKey = 'minWidth' | 'minHeight' | 'maxWidth' | 'maxHeight';
|
|
15
|
+
export declare type DDValue = number | string;
|
|
16
|
+
/** drag&drop events callbacks */
|
|
17
|
+
export declare type DDCallback = (event: Event, arg2: GridItemHTMLElement, helper?: GridItemHTMLElement) => void;
|
|
18
|
+
/**
|
|
19
|
+
* HTML Native Mouse and Touch Events Drag and Drop functionality.
|
|
20
|
+
*/
|
|
21
|
+
export declare class DDGridStack {
|
|
22
|
+
/** get the global (but static to this code) DD implementation */
|
|
23
|
+
static get(): DDGridStack;
|
|
24
|
+
resizable(el: GridItemHTMLElement, opts: DDOpts, key?: DDKey, value?: DDValue): DDGridStack;
|
|
25
|
+
draggable(el: GridItemHTMLElement, opts: DDOpts, key?: DDKey, value?: DDValue): DDGridStack;
|
|
26
|
+
dragIn(el: GridStackElement, opts: DDDragInOpt): DDGridStack;
|
|
27
|
+
droppable(el: GridItemHTMLElement, opts: DDOpts | DDDropOpt, key?: DDKey, value?: DDValue): DDGridStack;
|
|
28
|
+
/** true if element is droppable */
|
|
29
|
+
isDroppable(el: DDElementHost): boolean;
|
|
30
|
+
/** true if element is draggable */
|
|
31
|
+
isDraggable(el: DDElementHost): boolean;
|
|
32
|
+
/** true if element is draggable */
|
|
33
|
+
isResizable(el: DDElementHost): boolean;
|
|
34
|
+
on(el: GridItemHTMLElement, name: string, callback: DDCallback): DDGridStack;
|
|
35
|
+
off(el: GridItemHTMLElement, name: string): DDGridStack;
|
|
36
|
+
}
|
|
@@ -1,36 +1,137 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* gridstack
|
|
3
|
+
* dd-gridstack.ts 6.0.0
|
|
4
4
|
* Copyright (c) 2021 Alain Dumesny - see GridStack root license
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.
|
|
8
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
9
|
-
const gridstack_ddi_1 = require("./gridstack-ddi");
|
|
7
|
+
exports.DDGridStack = void 0;
|
|
10
8
|
const gridstack_1 = require("./gridstack");
|
|
11
9
|
const utils_1 = require("./utils");
|
|
12
|
-
|
|
10
|
+
const dd_manager_1 = require("./dd-manager");
|
|
11
|
+
const dd_element_1 = require("./dd-element");
|
|
12
|
+
// let count = 0; // TEST
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* HTML Native Mouse and Touch Events Drag and Drop functionality.
|
|
15
15
|
*/
|
|
16
|
-
class
|
|
17
|
-
/**
|
|
16
|
+
class DDGridStack {
|
|
17
|
+
/** get the global (but static to this code) DD implementation */
|
|
18
18
|
static get() {
|
|
19
|
-
return
|
|
19
|
+
return dd;
|
|
20
20
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
resizable(el, opts, key, value) {
|
|
22
|
+
this._getDDElements(el).forEach(dEl => {
|
|
23
|
+
if (opts === 'disable' || opts === 'enable') {
|
|
24
|
+
dEl.ddResizable && dEl.ddResizable[opts](); // can't create DD as it requires options for setupResizable()
|
|
25
|
+
}
|
|
26
|
+
else if (opts === 'destroy') {
|
|
27
|
+
dEl.ddResizable && dEl.cleanResizable();
|
|
28
|
+
}
|
|
29
|
+
else if (opts === 'option') {
|
|
30
|
+
dEl.setupResizable({ [key]: value });
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
const grid = dEl.el.gridstackNode.grid;
|
|
34
|
+
let handles = dEl.el.getAttribute('gs-resize-handles') ? dEl.el.getAttribute('gs-resize-handles') : grid.opts.resizable.handles;
|
|
35
|
+
let autoHide = !grid.opts.alwaysShowResizeHandle;
|
|
36
|
+
dEl.setupResizable(Object.assign(Object.assign(Object.assign({}, grid.opts.resizable), { handles, autoHide }), {
|
|
37
|
+
start: opts.start,
|
|
38
|
+
stop: opts.stop,
|
|
39
|
+
resize: opts.resize
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
return this;
|
|
44
|
+
}
|
|
45
|
+
draggable(el, opts, key, value) {
|
|
46
|
+
this._getDDElements(el).forEach(dEl => {
|
|
47
|
+
if (opts === 'disable' || opts === 'enable') {
|
|
48
|
+
dEl.ddDraggable && dEl.ddDraggable[opts](); // can't create DD as it requires options for setupDraggable()
|
|
49
|
+
}
|
|
50
|
+
else if (opts === 'destroy') {
|
|
51
|
+
dEl.ddDraggable && dEl.cleanDraggable();
|
|
52
|
+
}
|
|
53
|
+
else if (opts === 'option') {
|
|
54
|
+
dEl.setupDraggable({ [key]: value });
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
const grid = dEl.el.gridstackNode.grid;
|
|
58
|
+
dEl.setupDraggable(Object.assign(Object.assign({}, grid.opts.draggable), {
|
|
59
|
+
// containment: (grid.opts._isNested && !grid.opts.dragOut) ? grid.el.parentElement : (grid.opts.draggable.containment || null),
|
|
60
|
+
start: opts.start,
|
|
61
|
+
stop: opts.stop,
|
|
62
|
+
drag: opts.drag
|
|
63
|
+
}));
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
return this;
|
|
67
|
+
}
|
|
68
|
+
dragIn(el, opts) {
|
|
69
|
+
this._getDDElements(el).forEach(dEl => dEl.setupDraggable(opts));
|
|
70
|
+
return this;
|
|
71
|
+
}
|
|
72
|
+
droppable(el, opts, key, value) {
|
|
73
|
+
if (typeof opts.accept === 'function' && !opts._accept) {
|
|
74
|
+
opts._accept = opts.accept;
|
|
75
|
+
opts.accept = (el) => opts._accept(el);
|
|
26
76
|
}
|
|
77
|
+
this._getDDElements(el).forEach(dEl => {
|
|
78
|
+
if (opts === 'disable' || opts === 'enable') {
|
|
79
|
+
dEl.ddDroppable && dEl.ddDroppable[opts]();
|
|
80
|
+
}
|
|
81
|
+
else if (opts === 'destroy') {
|
|
82
|
+
if (dEl.ddDroppable) { // error to call destroy if not there
|
|
83
|
+
dEl.cleanDroppable();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
else if (opts === 'option') {
|
|
87
|
+
dEl.setupDroppable({ [key]: value });
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
dEl.setupDroppable(opts);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
27
93
|
return this;
|
|
28
94
|
}
|
|
95
|
+
/** true if element is droppable */
|
|
96
|
+
isDroppable(el) {
|
|
97
|
+
return !!(el && el.ddElement && el.ddElement.ddDroppable && !el.ddElement.ddDroppable.disabled);
|
|
98
|
+
}
|
|
99
|
+
/** true if element is draggable */
|
|
100
|
+
isDraggable(el) {
|
|
101
|
+
return !!(el && el.ddElement && el.ddElement.ddDraggable && !el.ddElement.ddDraggable.disabled);
|
|
102
|
+
}
|
|
103
|
+
/** true if element is draggable */
|
|
104
|
+
isResizable(el) {
|
|
105
|
+
return !!(el && el.ddElement && el.ddElement.ddResizable && !el.ddElement.ddResizable.disabled);
|
|
106
|
+
}
|
|
107
|
+
on(el, name, callback) {
|
|
108
|
+
this._getDDElements(el).forEach(dEl => dEl.on(name, (event) => {
|
|
109
|
+
callback(event, dd_manager_1.DDManager.dragElement ? dd_manager_1.DDManager.dragElement.el : event.target, dd_manager_1.DDManager.dragElement ? dd_manager_1.DDManager.dragElement.helper : null);
|
|
110
|
+
}));
|
|
111
|
+
return this;
|
|
112
|
+
}
|
|
113
|
+
off(el, name) {
|
|
114
|
+
this._getDDElements(el).forEach(dEl => dEl.off(name));
|
|
115
|
+
return this;
|
|
116
|
+
}
|
|
117
|
+
/** @internal returns a list of DD elements, creating them on the fly by default */
|
|
118
|
+
_getDDElements(els, create = true) {
|
|
119
|
+
let hosts = utils_1.Utils.getElements(els);
|
|
120
|
+
if (!hosts.length)
|
|
121
|
+
return [];
|
|
122
|
+
let list = hosts.map(e => e.ddElement || (create ? dd_element_1.DDElement.init(e) : null));
|
|
123
|
+
if (!create) {
|
|
124
|
+
list.filter(d => d);
|
|
125
|
+
} // remove nulls
|
|
126
|
+
return list;
|
|
127
|
+
}
|
|
29
128
|
}
|
|
30
|
-
exports.
|
|
129
|
+
exports.DDGridStack = DDGridStack;
|
|
130
|
+
/** global instance */
|
|
131
|
+
const dd = new DDGridStack;
|
|
31
132
|
/********************************************************************************
|
|
32
133
|
* GridStack code that is doing drag&drop extracted here so main class is smaller
|
|
33
|
-
* for static grid that don't do any of this work anyway. Saves about
|
|
134
|
+
* for static grid that don't do any of this work anyway. Saves about 31k (41k -> 72k)
|
|
34
135
|
* https://www.typescriptlang.org/docs/handbook/declaration-merging.html
|
|
35
136
|
* https://www.typescriptlang.org/docs/handbook/mixins.html
|
|
36
137
|
********************************************************************************/
|
|
@@ -38,7 +139,7 @@ exports.GridStackDD = GridStackDD;
|
|
|
38
139
|
gridstack_1.GridStack.prototype._setupAcceptWidget = function () {
|
|
39
140
|
// check if we need to disable things
|
|
40
141
|
if (this.opts.staticGrid || (!this.opts.acceptWidgets && !this.opts.removable)) {
|
|
41
|
-
|
|
142
|
+
dd.droppable(this.el, 'destroy');
|
|
42
143
|
return this;
|
|
43
144
|
}
|
|
44
145
|
// vars shared across all methods
|
|
@@ -62,7 +163,7 @@ gridstack_1.GridStack.prototype._setupAcceptWidget = function () {
|
|
|
62
163
|
if (!this.engine.willItFit(node)) {
|
|
63
164
|
node.autoPosition = true; // ignore x,y and try for any slot...
|
|
64
165
|
if (!this.engine.willItFit(node)) {
|
|
65
|
-
|
|
166
|
+
dd.off(el, 'drag'); // stop calling us
|
|
66
167
|
return; // full grid or can't grow
|
|
67
168
|
}
|
|
68
169
|
if (node._willFitPos) {
|
|
@@ -79,8 +180,7 @@ gridstack_1.GridStack.prototype._setupAcceptWidget = function () {
|
|
|
79
180
|
this._dragOrResize(helper, event, ui, node, cellWidth, cellHeight);
|
|
80
181
|
}
|
|
81
182
|
};
|
|
82
|
-
|
|
83
|
-
.droppable(this.el, {
|
|
183
|
+
dd.droppable(this.el, {
|
|
84
184
|
accept: (el) => {
|
|
85
185
|
let node = el.gridstackNode;
|
|
86
186
|
// set accept drop to true on ourself (which we ignore) so we don't get "can't drop" icon in HTML5 mode while moving
|
|
@@ -112,7 +212,7 @@ gridstack_1.GridStack.prototype._setupAcceptWidget = function () {
|
|
|
112
212
|
* entering our grid area
|
|
113
213
|
*/
|
|
114
214
|
.on(this.el, 'dropover', (event, el, helper) => {
|
|
115
|
-
//
|
|
215
|
+
// console.log(`over ${this.el.gridstack.opts.id} ${count++}`); // TEST
|
|
116
216
|
let node = el.gridstackNode;
|
|
117
217
|
// ignore drop enter on ourself (unless we temporarily removed) which happens on a simple drag of our item
|
|
118
218
|
if ((node === null || node === void 0 ? void 0 : node.grid) === this && !node._temporaryRemoved) {
|
|
@@ -121,7 +221,7 @@ gridstack_1.GridStack.prototype._setupAcceptWidget = function () {
|
|
|
121
221
|
}
|
|
122
222
|
// fix #1578 when dragging fast, we may not get a leave on the previous grid so force one now
|
|
123
223
|
if ((node === null || node === void 0 ? void 0 : node.grid) && node.grid !== this && !node._temporaryRemoved) {
|
|
124
|
-
//
|
|
224
|
+
// console.log('dropover without leave'); // TEST
|
|
125
225
|
let otherGrid = node.grid;
|
|
126
226
|
otherGrid._leave(el, helper);
|
|
127
227
|
}
|
|
@@ -143,7 +243,7 @@ gridstack_1.GridStack.prototype._setupAcceptWidget = function () {
|
|
|
143
243
|
// if the item came from another grid, make a copy and save the original info in case we go back there
|
|
144
244
|
if (node.grid && node.grid !== this) {
|
|
145
245
|
// copy the node original values (min/max/id/etc...) but override width/height/other flags which are this grid specific
|
|
146
|
-
//
|
|
246
|
+
// console.log('dropover cloning node'); // TEST
|
|
147
247
|
if (!el._gridstackNodeOrig)
|
|
148
248
|
el._gridstackNodeOrig = node; // shouldn't have multiple nested!
|
|
149
249
|
el.gridstackNode = node = Object.assign(Object.assign({}, node), { w, h, grid: this });
|
|
@@ -161,7 +261,7 @@ gridstack_1.GridStack.prototype._setupAcceptWidget = function () {
|
|
|
161
261
|
}
|
|
162
262
|
// clear any marked for complete removal (Note: don't check _isAboutToRemove as that is cleared above - just do it)
|
|
163
263
|
_itemRemoving(node.el, false);
|
|
164
|
-
|
|
264
|
+
dd.on(el, 'drag', onDrag);
|
|
165
265
|
// make sure this is called at least once when going fast #1578
|
|
166
266
|
onDrag(event, el, helper);
|
|
167
267
|
return false; // prevent parent from receiving msg (which may be a grid as well)
|
|
@@ -170,7 +270,7 @@ gridstack_1.GridStack.prototype._setupAcceptWidget = function () {
|
|
|
170
270
|
* Leaving our grid area...
|
|
171
271
|
*/
|
|
172
272
|
.on(this.el, 'dropout', (event, el, helper) => {
|
|
173
|
-
//
|
|
273
|
+
// console.log(`out ${this.el.gridstack.opts.id} ${count++}`); // TEST
|
|
174
274
|
let node = el.gridstackNode;
|
|
175
275
|
if (!node)
|
|
176
276
|
return false;
|
|
@@ -192,7 +292,7 @@ gridstack_1.GridStack.prototype._setupAcceptWidget = function () {
|
|
|
192
292
|
let wasAdded = !!this.placeholder.parentElement; // skip items not actually added to us because of constrains, but do cleanup #1419
|
|
193
293
|
this.placeholder.remove();
|
|
194
294
|
// notify previous grid of removal
|
|
195
|
-
//
|
|
295
|
+
// console.log('drop delete _gridstackNodeOrig') // TEST
|
|
196
296
|
let origNode = el._gridstackNodeOrig;
|
|
197
297
|
delete el._gridstackNodeOrig;
|
|
198
298
|
if (wasAdded && origNode && origNode.grid && origNode.grid !== this) {
|
|
@@ -207,7 +307,7 @@ gridstack_1.GridStack.prototype._setupAcceptWidget = function () {
|
|
|
207
307
|
this.engine.cleanupNode(node); // removes all internal _xyz values
|
|
208
308
|
node.grid = this;
|
|
209
309
|
}
|
|
210
|
-
|
|
310
|
+
dd.off(el, 'drag');
|
|
211
311
|
// if we made a copy ('helper' which is temp) of the original node then insert a copy, else we move the original node (#1102)
|
|
212
312
|
// as the helper will be nuked by jquery-ui otherwise
|
|
213
313
|
if (helper !== el) {
|
|
@@ -219,7 +319,7 @@ gridstack_1.GridStack.prototype._setupAcceptWidget = function () {
|
|
|
219
319
|
}
|
|
220
320
|
else {
|
|
221
321
|
el.remove(); // reduce flicker as we change depth here, and size further down
|
|
222
|
-
|
|
322
|
+
this._removeDD(el);
|
|
223
323
|
}
|
|
224
324
|
if (!wasAdded)
|
|
225
325
|
return false;
|
|
@@ -229,7 +329,7 @@ gridstack_1.GridStack.prototype._setupAcceptWidget = function () {
|
|
|
229
329
|
utils_1.Utils.copyPos(node, this._readAttr(this.placeholder)); // placeholder values as moving VERY fast can throw things off #1578
|
|
230
330
|
utils_1.Utils.removePositioningStyles(el); // @ts-ignore
|
|
231
331
|
this._writeAttr(el, node);
|
|
232
|
-
this.el.appendChild(el); // @ts-ignore
|
|
332
|
+
this.el.appendChild(el); // @ts-ignore // TODO: now would be ideal time to _removeHelperStyle() overriding floating styles (native only)
|
|
233
333
|
this._updateContainerHeight();
|
|
234
334
|
this.engine.addedNodes.push(node); // @ts-ignore
|
|
235
335
|
this._triggerAddEvent(); // @ts-ignore
|
|
@@ -269,8 +369,8 @@ gridstack_1.GridStack.prototype._setupRemoveDrop = function () {
|
|
|
269
369
|
// only register ONE drop-over/dropout callback for the 'trash', and it will
|
|
270
370
|
// update the passed in item and parent grid because the 'trash' is a shared resource anyway,
|
|
271
371
|
// and Native DD only has 1 event CB (having a list and technically a per grid removableOptions complicates things greatly)
|
|
272
|
-
if (!
|
|
273
|
-
|
|
372
|
+
if (!dd.isDroppable(trashEl)) {
|
|
373
|
+
dd.droppable(trashEl, this.opts.removableOptions)
|
|
274
374
|
.on(trashEl, 'dropover', (event, el) => _itemRemoving(el, true))
|
|
275
375
|
.on(trashEl, 'dropout', (event, el) => _itemRemoving(el, false));
|
|
276
376
|
}
|
|
@@ -286,10 +386,8 @@ gridstack_1.GridStack.setupDragIn = function (_dragIn, _dragInOptions) {
|
|
|
286
386
|
let dragIn;
|
|
287
387
|
let dragInOptions;
|
|
288
388
|
const dragInDefaultOptions = {
|
|
289
|
-
revert: 'invalid',
|
|
290
389
|
handle: '.grid-stack-item-content',
|
|
291
|
-
|
|
292
|
-
appendTo: 'body'
|
|
390
|
+
appendTo: 'body',
|
|
293
391
|
};
|
|
294
392
|
// cache in the passed in values (form grid init?) so they don't have to resend them each time
|
|
295
393
|
if (_dragIn) {
|
|
@@ -298,7 +396,6 @@ gridstack_1.GridStack.setupDragIn = function (_dragIn, _dragInOptions) {
|
|
|
298
396
|
}
|
|
299
397
|
if (typeof dragIn !== 'string')
|
|
300
398
|
return;
|
|
301
|
-
let dd = GridStackDD.get();
|
|
302
399
|
utils_1.Utils.getElements(dragIn).forEach(el => {
|
|
303
400
|
if (!dd.isDraggable(el))
|
|
304
401
|
dd.dragIn(el, dragInOptions);
|
|
@@ -307,11 +404,10 @@ gridstack_1.GridStack.setupDragIn = function (_dragIn, _dragInOptions) {
|
|
|
307
404
|
/** @internal prepares the element for drag&drop **/
|
|
308
405
|
gridstack_1.GridStack.prototype._prepareDragDropByNode = function (node) {
|
|
309
406
|
let el = node.el;
|
|
310
|
-
let dd = GridStackDD.get();
|
|
311
407
|
// check for disabled grid first
|
|
312
408
|
if (this.opts.staticGrid || ((node.noMove || this.opts.disableDrag) && (node.noResize || this.opts.disableResize))) {
|
|
313
409
|
if (node._initDD) {
|
|
314
|
-
|
|
410
|
+
this._removeDD(el); // nukes everything instead of just disable, will add some styles back next
|
|
315
411
|
delete node._initDD;
|
|
316
412
|
}
|
|
317
413
|
el.classList.add('ui-draggable-disabled', 'ui-resizable-disabled'); // add styles one might depend on #1435
|
|
@@ -350,7 +446,7 @@ gridstack_1.GridStack.prototype._prepareDragDropByNode = function (node) {
|
|
|
350
446
|
if (gridToNotify._gsEventHandler[event.type]) {
|
|
351
447
|
gridToNotify._gsEventHandler[event.type](event, target);
|
|
352
448
|
}
|
|
353
|
-
|
|
449
|
+
this._removeDD(el);
|
|
354
450
|
gridToNotify.engine.removedNodes.push(node);
|
|
355
451
|
gridToNotify._triggerRemoveEvent();
|
|
356
452
|
// break circular links and remove DOM
|
|
@@ -359,18 +455,17 @@ gridstack_1.GridStack.prototype._prepareDragDropByNode = function (node) {
|
|
|
359
455
|
el.remove();
|
|
360
456
|
}
|
|
361
457
|
else {
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
utils_1.Utils.removePositioningStyles(target); // @ts-ignore
|
|
365
|
-
this._writePosAttr(target, node);
|
|
366
|
-
}
|
|
367
|
-
else {
|
|
458
|
+
utils_1.Utils.removePositioningStyles(target);
|
|
459
|
+
if (node._temporaryRemoved) {
|
|
368
460
|
// got removed - restore item back to before dragging position
|
|
369
|
-
utils_1.Utils.removePositioningStyles(target);
|
|
370
461
|
utils_1.Utils.copyPos(node, node._orig); // @ts-ignore
|
|
371
462
|
this._writePosAttr(target, node);
|
|
372
463
|
this.engine.addNode(node);
|
|
373
464
|
}
|
|
465
|
+
else {
|
|
466
|
+
// move to new placeholder location
|
|
467
|
+
this._writePosAttr(target, node);
|
|
468
|
+
}
|
|
374
469
|
if (this._gsEventHandler[event.type]) {
|
|
375
470
|
this._gsEventHandler[event.type](event, target);
|
|
376
471
|
}
|
|
@@ -418,22 +513,21 @@ gridstack_1.GridStack.prototype._onStartMoving = function (el, event, ui, node,
|
|
|
418
513
|
// @ts-ignore
|
|
419
514
|
this._writePosAttr(this.placeholder, node);
|
|
420
515
|
this.el.appendChild(this.placeholder);
|
|
421
|
-
//
|
|
516
|
+
// console.log('_onStartMoving placeholder') // TEST
|
|
422
517
|
node.el = this.placeholder;
|
|
423
518
|
node._lastUiPosition = ui.position;
|
|
424
519
|
node._prevYPix = ui.position.top;
|
|
425
520
|
node._moving = (event.type === 'dragstart'); // 'dropover' are not initially moving so they can go exactly where they enter (will push stuff out of the way)
|
|
426
521
|
delete node._lastTried;
|
|
427
522
|
if (event.type === 'dropover' && node._temporaryRemoved) {
|
|
428
|
-
//
|
|
523
|
+
// console.log('engine.addNode x=' + node.x); // TEST
|
|
429
524
|
this.engine.addNode(node); // will add, fix collisions, update attr and clear _temporaryRemoved
|
|
430
525
|
node._moving = true; // AFTER, mark as moving object (wanted fix location before)
|
|
431
526
|
}
|
|
432
527
|
// set the min/max resize info
|
|
433
528
|
this.engine.cacheRects(cellWidth, cellHeight, this.opts.marginTop, this.opts.marginRight, this.opts.marginBottom, this.opts.marginLeft);
|
|
434
529
|
if (event.type === 'resizestart') {
|
|
435
|
-
|
|
436
|
-
.resizable(el, 'option', 'minWidth', cellWidth * (node.minW || 1))
|
|
530
|
+
dd.resizable(el, 'option', 'minWidth', cellWidth * (node.minW || 1))
|
|
437
531
|
.resizable(el, 'option', 'minHeight', cellHeight * (node.minH || 1));
|
|
438
532
|
if (node.maxW) {
|
|
439
533
|
dd.resizable(el, 'option', 'maxWidth', cellWidth * node.maxW);
|
|
@@ -451,7 +545,7 @@ gridstack_1.GridStack.prototype._leave = function (el, helper) {
|
|
|
451
545
|
let node = el.gridstackNode;
|
|
452
546
|
if (!node)
|
|
453
547
|
return;
|
|
454
|
-
|
|
548
|
+
dd.off(el, 'drag'); // no need to track while being outside
|
|
455
549
|
// this gets called when cursor leaves and shape is outside, so only do this once
|
|
456
550
|
if (node._temporaryRemoved)
|
|
457
551
|
return;
|
|
@@ -464,7 +558,7 @@ gridstack_1.GridStack.prototype._leave = function (el, helper) {
|
|
|
464
558
|
}
|
|
465
559
|
// finally if item originally came from another grid, but left us, restore things back to prev info
|
|
466
560
|
if (el._gridstackNodeOrig) {
|
|
467
|
-
//
|
|
561
|
+
// console.log('leave delete _gridstackNodeOrig') // TEST
|
|
468
562
|
el.gridstackNode = el._gridstackNodeOrig;
|
|
469
563
|
delete el._gridstackNodeOrig;
|
|
470
564
|
}
|
|
@@ -648,4 +742,12 @@ gridstack_1.GridStack.prototype.enableResize = function (doEnable) {
|
|
|
648
742
|
this.engine.nodes.forEach(n => this.resizable(n.el, doEnable));
|
|
649
743
|
return this;
|
|
650
744
|
};
|
|
651
|
-
|
|
745
|
+
/** removes any drag&drop present (called during destroy) */
|
|
746
|
+
gridstack_1.GridStack.prototype._removeDD = function (el) {
|
|
747
|
+
dd.draggable(el, 'destroy').resizable(el, 'destroy');
|
|
748
|
+
if (el.gridstackNode) {
|
|
749
|
+
delete el.gridstackNode._initDD; // reset our DD init flag
|
|
750
|
+
}
|
|
751
|
+
return this;
|
|
752
|
+
};
|
|
753
|
+
//# sourceMappingURL=dd-gridstack.js.map
|