gridstack 12.0.0 → 12.1.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 +1 -1
- package/dist/angular/esm2020/lib/base-widget.mjs +2 -2
- package/dist/angular/esm2020/lib/gridstack-item.component.mjs +2 -2
- package/dist/angular/esm2020/lib/gridstack.component.mjs +2 -2
- package/dist/angular/esm2020/lib/gridstack.module.mjs +2 -2
- package/dist/angular/esm2020/lib/types.mjs +2 -2
- package/dist/angular/fesm2015/gridstack-angular.mjs +4 -4
- package/dist/angular/fesm2015/gridstack-angular.mjs.map +1 -1
- package/dist/angular/fesm2020/gridstack-angular.mjs +5 -5
- package/dist/angular/fesm2020/gridstack-angular.mjs.map +1 -1
- package/dist/angular/lib/gridstack-item.component.d.ts +1 -1
- package/dist/angular/lib/gridstack.component.d.ts +1 -1
- package/dist/angular/lib/types.d.ts +1 -1
- package/dist/angular/src/base-widget.ts +1 -1
- package/dist/angular/src/gridstack-item.component.ts +1 -1
- package/dist/angular/src/gridstack.component.ts +1 -1
- package/dist/angular/src/gridstack.module.ts +1 -1
- package/dist/dd-base-impl.d.ts +1 -1
- package/dist/dd-base-impl.js +1 -1
- package/dist/dd-base-impl.js.map +1 -1
- package/dist/dd-draggable.d.ts +1 -1
- package/dist/dd-draggable.js +1 -1
- package/dist/dd-draggable.js.map +1 -1
- package/dist/dd-droppable.d.ts +1 -1
- package/dist/dd-droppable.js +1 -1
- package/dist/dd-droppable.js.map +1 -1
- package/dist/dd-element.d.ts +1 -1
- package/dist/dd-element.js +1 -1
- package/dist/dd-element.js.map +1 -1
- package/dist/dd-gridstack.d.ts +1 -1
- package/dist/dd-gridstack.js +1 -1
- package/dist/dd-gridstack.js.map +1 -1
- package/dist/dd-manager.d.ts +1 -1
- package/dist/dd-manager.js +1 -1
- package/dist/dd-manager.js.map +1 -1
- package/dist/dd-resizable-handle.d.ts +1 -1
- package/dist/dd-resizable-handle.js +1 -1
- package/dist/dd-resizable-handle.js.map +1 -1
- package/dist/dd-resizable.d.ts +1 -1
- package/dist/dd-resizable.js +1 -1
- package/dist/dd-resizable.js.map +1 -1
- package/dist/dd-touch.d.ts +1 -1
- package/dist/dd-touch.js +1 -1
- package/dist/dd-touch.js.map +1 -1
- package/dist/gridstack-all.js +1 -1
- package/dist/gridstack-all.js.LICENSE.txt +1 -1
- package/dist/gridstack-all.js.map +1 -1
- package/dist/gridstack-engine.d.ts +1 -1
- package/dist/gridstack-engine.js +1 -1
- package/dist/gridstack-engine.js.map +1 -1
- package/dist/gridstack.css +1 -1
- package/dist/gridstack.d.ts +3 -1
- package/dist/gridstack.js +57 -55
- package/dist/gridstack.js.map +1 -1
- package/dist/src/gridstack.scss +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +1 -1
- package/dist/utils.js.map +1 -1
- package/doc/CHANGES.md +10 -0
- package/package.json +2 -4
- package/dist/es5/dd-base-impl.d.ts +0 -20
- package/dist/es5/dd-base-impl.js +0 -41
- package/dist/es5/dd-base-impl.js.map +0 -1
- package/dist/es5/dd-draggable.d.ts +0 -20
- package/dist/es5/dd-draggable.js +0 -408
- package/dist/es5/dd-draggable.js.map +0 -1
- package/dist/es5/dd-droppable.d.ts +0 -26
- package/dist/es5/dd-droppable.js +0 -185
- package/dist/es5/dd-droppable.js.map +0 -1
- package/dist/es5/dd-element.d.ts +0 -27
- package/dist/es5/dd-element.js +0 -96
- package/dist/es5/dd-element.js.map +0 -1
- package/dist/es5/dd-gridstack.d.ts +0 -34
- package/dist/es5/dd-gridstack.js +0 -154
- package/dist/es5/dd-gridstack.js.map +0 -1
- package/dist/es5/dd-manager.d.ts +0 -22
- package/dist/es5/dd-manager.js +0 -17
- package/dist/es5/dd-manager.js.map +0 -1
- package/dist/es5/dd-resizable-handle.d.ts +0 -18
- package/dist/es5/dd-resizable-handle.js +0 -117
- package/dist/es5/dd-resizable-handle.js.map +0 -1
- package/dist/es5/dd-resizable.d.ts +0 -30
- package/dist/es5/dd-resizable.js +0 -331
- package/dist/es5/dd-resizable.js.map +0 -1
- package/dist/es5/dd-touch.d.ts +0 -33
- package/dist/es5/dd-touch.js +0 -157
- package/dist/es5/dd-touch.js.map +0 -1
- package/dist/es5/gridstack-all.js +0 -3
- package/dist/es5/gridstack-all.js.LICENSE.txt +0 -7
- package/dist/es5/gridstack-all.js.map +0 -1
- package/dist/es5/gridstack-engine.d.ts +0 -107
- package/dist/es5/gridstack-engine.js +0 -1070
- package/dist/es5/gridstack-engine.js.map +0 -1
- package/dist/es5/gridstack-poly.js +0 -356
- package/dist/es5/gridstack.d.ts +0 -452
- package/dist/es5/gridstack.js +0 -2644
- package/dist/es5/gridstack.js.map +0 -1
- package/dist/es5/types.d.ts +0 -326
- package/dist/es5/types.js +0 -38
- package/dist/es5/types.js.map +0 -1
- package/dist/es5/utils.d.ts +0 -104
- package/dist/es5/utils.js +0 -633
- package/dist/es5/utils.js.map +0 -1
package/dist/es5/dd-droppable.js
DELETED
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* dd-droppable.ts 12.0.0
|
|
4
|
-
* Copyright (c) 2021-2024 Alain Dumesny - see GridStack root license
|
|
5
|
-
*/
|
|
6
|
-
var __extends = (this && this.__extends) || (function () {
|
|
7
|
-
var extendStatics = function (d, b) {
|
|
8
|
-
extendStatics = Object.setPrototypeOf ||
|
|
9
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
10
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
11
|
-
return extendStatics(d, b);
|
|
12
|
-
};
|
|
13
|
-
return function (d, b) {
|
|
14
|
-
if (typeof b !== "function" && b !== null)
|
|
15
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
16
|
-
extendStatics(d, b);
|
|
17
|
-
function __() { this.constructor = d; }
|
|
18
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
19
|
-
};
|
|
20
|
-
})();
|
|
21
|
-
var __assign = (this && this.__assign) || function () {
|
|
22
|
-
__assign = Object.assign || function(t) {
|
|
23
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
24
|
-
s = arguments[i];
|
|
25
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
26
|
-
t[p] = s[p];
|
|
27
|
-
}
|
|
28
|
-
return t;
|
|
29
|
-
};
|
|
30
|
-
return __assign.apply(this, arguments);
|
|
31
|
-
};
|
|
32
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
-
exports.DDDroppable = void 0;
|
|
34
|
-
var dd_manager_1 = require("./dd-manager");
|
|
35
|
-
var dd_base_impl_1 = require("./dd-base-impl");
|
|
36
|
-
var utils_1 = require("./utils");
|
|
37
|
-
var dd_touch_1 = require("./dd-touch");
|
|
38
|
-
// let count = 0; // TEST
|
|
39
|
-
var DDDroppable = /** @class */ (function (_super) {
|
|
40
|
-
__extends(DDDroppable, _super);
|
|
41
|
-
function DDDroppable(el, option) {
|
|
42
|
-
if (option === void 0) { option = {}; }
|
|
43
|
-
var _this = _super.call(this) || this;
|
|
44
|
-
_this.el = el;
|
|
45
|
-
_this.option = option;
|
|
46
|
-
// create var event binding so we can easily remove and still look like TS methods (unlike anonymous functions)
|
|
47
|
-
_this._mouseEnter = _this._mouseEnter.bind(_this);
|
|
48
|
-
_this._mouseLeave = _this._mouseLeave.bind(_this);
|
|
49
|
-
_this.enable();
|
|
50
|
-
_this._setupAccept();
|
|
51
|
-
return _this;
|
|
52
|
-
}
|
|
53
|
-
DDDroppable.prototype.on = function (event, callback) {
|
|
54
|
-
_super.prototype.on.call(this, event, callback);
|
|
55
|
-
};
|
|
56
|
-
DDDroppable.prototype.off = function (event) {
|
|
57
|
-
_super.prototype.off.call(this, event);
|
|
58
|
-
};
|
|
59
|
-
DDDroppable.prototype.enable = function () {
|
|
60
|
-
if (this.disabled === false)
|
|
61
|
-
return;
|
|
62
|
-
_super.prototype.enable.call(this);
|
|
63
|
-
this.el.classList.add('ui-droppable');
|
|
64
|
-
this.el.classList.remove('ui-droppable-disabled');
|
|
65
|
-
this.el.addEventListener('mouseenter', this._mouseEnter);
|
|
66
|
-
this.el.addEventListener('mouseleave', this._mouseLeave);
|
|
67
|
-
if (dd_touch_1.isTouch) {
|
|
68
|
-
this.el.addEventListener('pointerenter', dd_touch_1.pointerenter);
|
|
69
|
-
this.el.addEventListener('pointerleave', dd_touch_1.pointerleave);
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
DDDroppable.prototype.disable = function (forDestroy) {
|
|
73
|
-
if (forDestroy === void 0) { forDestroy = false; }
|
|
74
|
-
if (this.disabled === true)
|
|
75
|
-
return;
|
|
76
|
-
_super.prototype.disable.call(this);
|
|
77
|
-
this.el.classList.remove('ui-droppable');
|
|
78
|
-
if (!forDestroy)
|
|
79
|
-
this.el.classList.add('ui-droppable-disabled');
|
|
80
|
-
this.el.removeEventListener('mouseenter', this._mouseEnter);
|
|
81
|
-
this.el.removeEventListener('mouseleave', this._mouseLeave);
|
|
82
|
-
if (dd_touch_1.isTouch) {
|
|
83
|
-
this.el.removeEventListener('pointerenter', dd_touch_1.pointerenter);
|
|
84
|
-
this.el.removeEventListener('pointerleave', dd_touch_1.pointerleave);
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
DDDroppable.prototype.destroy = function () {
|
|
88
|
-
this.disable(true);
|
|
89
|
-
this.el.classList.remove('ui-droppable');
|
|
90
|
-
this.el.classList.remove('ui-droppable-disabled');
|
|
91
|
-
_super.prototype.destroy.call(this);
|
|
92
|
-
};
|
|
93
|
-
DDDroppable.prototype.updateOption = function (opts) {
|
|
94
|
-
var _this = this;
|
|
95
|
-
Object.keys(opts).forEach(function (key) { return _this.option[key] = opts[key]; });
|
|
96
|
-
this._setupAccept();
|
|
97
|
-
return this;
|
|
98
|
-
};
|
|
99
|
-
/** @internal called when the cursor enters our area - prepare for a possible drop and track leaving */
|
|
100
|
-
DDDroppable.prototype._mouseEnter = function (e) {
|
|
101
|
-
// console.log(`${count++} Enter ${this.el.id || (this.el as GridHTMLElement).gridstack.opts.id}`); // TEST
|
|
102
|
-
if (!dd_manager_1.DDManager.dragElement)
|
|
103
|
-
return;
|
|
104
|
-
if (!this._canDrop(dd_manager_1.DDManager.dragElement.el))
|
|
105
|
-
return;
|
|
106
|
-
e.preventDefault();
|
|
107
|
-
e.stopPropagation();
|
|
108
|
-
// make sure when we enter this, that the last one gets a leave FIRST to correctly cleanup as we don't always do
|
|
109
|
-
if (dd_manager_1.DDManager.dropElement && dd_manager_1.DDManager.dropElement !== this) {
|
|
110
|
-
dd_manager_1.DDManager.dropElement._mouseLeave(e, true); // calledByEnter = true
|
|
111
|
-
}
|
|
112
|
-
dd_manager_1.DDManager.dropElement = this;
|
|
113
|
-
var ev = utils_1.Utils.initEvent(e, { target: this.el, type: 'dropover' });
|
|
114
|
-
if (this.option.over) {
|
|
115
|
-
this.option.over(ev, this._ui(dd_manager_1.DDManager.dragElement));
|
|
116
|
-
}
|
|
117
|
-
this.triggerEvent('dropover', ev);
|
|
118
|
-
this.el.classList.add('ui-droppable-over');
|
|
119
|
-
// console.log('tracking'); // TEST
|
|
120
|
-
};
|
|
121
|
-
/** @internal called when the item is leaving our area, stop tracking if we had moving item */
|
|
122
|
-
DDDroppable.prototype._mouseLeave = function (e, calledByEnter) {
|
|
123
|
-
var _a;
|
|
124
|
-
if (calledByEnter === void 0) { calledByEnter = false; }
|
|
125
|
-
// console.log(`${count++} Leave ${this.el.id || (this.el as GridHTMLElement).gridstack.opts.id}`); // TEST
|
|
126
|
-
if (!dd_manager_1.DDManager.dragElement || dd_manager_1.DDManager.dropElement !== this)
|
|
127
|
-
return;
|
|
128
|
-
e.preventDefault();
|
|
129
|
-
e.stopPropagation();
|
|
130
|
-
var ev = utils_1.Utils.initEvent(e, { target: this.el, type: 'dropout' });
|
|
131
|
-
if (this.option.out) {
|
|
132
|
-
this.option.out(ev, this._ui(dd_manager_1.DDManager.dragElement));
|
|
133
|
-
}
|
|
134
|
-
this.triggerEvent('dropout', ev);
|
|
135
|
-
if (dd_manager_1.DDManager.dropElement === this) {
|
|
136
|
-
delete dd_manager_1.DDManager.dropElement;
|
|
137
|
-
// console.log('not tracking'); // TEST
|
|
138
|
-
// if we're still over a parent droppable, send it an enter as we don't get one from leaving nested children
|
|
139
|
-
if (!calledByEnter) {
|
|
140
|
-
var parentDrop = void 0;
|
|
141
|
-
var parent_1 = this.el.parentElement;
|
|
142
|
-
while (!parentDrop && parent_1) {
|
|
143
|
-
parentDrop = (_a = parent_1.ddElement) === null || _a === void 0 ? void 0 : _a.ddDroppable;
|
|
144
|
-
parent_1 = parent_1.parentElement;
|
|
145
|
-
}
|
|
146
|
-
if (parentDrop) {
|
|
147
|
-
parentDrop._mouseEnter(e);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
/** item is being dropped on us - called by the drag mouseup handler - this calls the client drop event */
|
|
153
|
-
DDDroppable.prototype.drop = function (e) {
|
|
154
|
-
e.preventDefault();
|
|
155
|
-
var ev = utils_1.Utils.initEvent(e, { target: this.el, type: 'drop' });
|
|
156
|
-
if (this.option.drop) {
|
|
157
|
-
this.option.drop(ev, this._ui(dd_manager_1.DDManager.dragElement));
|
|
158
|
-
}
|
|
159
|
-
this.triggerEvent('drop', ev);
|
|
160
|
-
};
|
|
161
|
-
/** @internal true if element matches the string/method accept option */
|
|
162
|
-
DDDroppable.prototype._canDrop = function (el) {
|
|
163
|
-
return el && (!this.accept || this.accept(el));
|
|
164
|
-
};
|
|
165
|
-
/** @internal */
|
|
166
|
-
DDDroppable.prototype._setupAccept = function () {
|
|
167
|
-
var _this = this;
|
|
168
|
-
if (!this.option.accept)
|
|
169
|
-
return this;
|
|
170
|
-
if (typeof this.option.accept === 'string') {
|
|
171
|
-
this.accept = function (el) { return el.classList.contains(_this.option.accept) || el.matches(_this.option.accept); };
|
|
172
|
-
}
|
|
173
|
-
else {
|
|
174
|
-
this.accept = this.option.accept;
|
|
175
|
-
}
|
|
176
|
-
return this;
|
|
177
|
-
};
|
|
178
|
-
/** @internal */
|
|
179
|
-
DDDroppable.prototype._ui = function (drag) {
|
|
180
|
-
return __assign({ draggable: drag.el }, drag.ui());
|
|
181
|
-
};
|
|
182
|
-
return DDDroppable;
|
|
183
|
-
}(dd_base_impl_1.DDBaseImplement));
|
|
184
|
-
exports.DDDroppable = DDDroppable;
|
|
185
|
-
//# sourceMappingURL=dd-droppable.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dd-droppable.js","sourceRoot":"","sources":["../../src/dd-droppable.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGH,2CAAyC;AACzC,+CAAuE;AACvE,iCAAgC;AAEhC,uCAAiE;AAUjE,yBAAyB;AAEzB;IAAiC,+BAAe;IAI9C,qBAAmB,EAAe,EAAS,MAA2B;QAA3B,uBAAA,EAAA,WAA2B;QAAtE,YACE,iBAAO,SAMR;QAPkB,QAAE,GAAF,EAAE,CAAa;QAAS,YAAM,GAAN,MAAM,CAAqB;QAEpE,+GAA+G;QAC/G,KAAI,CAAC,WAAW,GAAG,KAAI,CAAC,WAAW,CAAC,IAAI,CAAC,KAAI,CAAC,CAAC;QAC/C,KAAI,CAAC,WAAW,GAAG,KAAI,CAAC,WAAW,CAAC,IAAI,CAAC,KAAI,CAAC,CAAC;QAC/C,KAAI,CAAC,MAAM,EAAE,CAAC;QACd,KAAI,CAAC,YAAY,EAAE,CAAC;;IACtB,CAAC;IAEM,wBAAE,GAAT,UAAU,KAAsC,EAAE,QAAoC;QACpF,iBAAM,EAAE,YAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC5B,CAAC;IAEM,yBAA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,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAI,CAAC,MAAM,CAAC,MAAgB,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,KAAI,CAAC,MAAM,CAAC,MAAgB,CAAC,EAA/F,CAA+F,CAAC;SACpI;aAAM;YACL,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;SAClC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,gBAAgB;IACN,yBAAG,GAAb,UAAc,IAAiB;QAC7B,kBACE,SAAS,EAAE,IAAI,CAAC,EAAE,IACf,IAAI,CAAC,EAAE,EAAE,EACZ;IACJ,CAAC;IACH,kBAAC;AAAD,CAAC,AApJD,CAAiC,8BAAe,GAoJ/C;AApJY,kCAAW","sourcesContent":["/**\n * dd-droppable.ts 12.0.0\n * Copyright (c) 2021-2024 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 { DDUIData } from './types';\n\nexport interface DDDroppableOpt {\n accept?: string | ((el: HTMLElement) => boolean);\n drop?: (event: DragEvent, ui: DDUIData) => void;\n over?: (event: DragEvent, ui: DDUIData) => void;\n out?: (event: DragEvent, ui: DDUIData) => 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\n constructor(public el: HTMLElement, public option: DDDroppableOpt = {}) {\n super();\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(DDManager.dragElement.el)) 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, true); // calledByEnter = true\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, calledByEnter = false): 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 if (!calledByEnter) {\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\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(el: HTMLElement): boolean {\n return el && (!this.accept || this.accept(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.classList.contains(this.option.accept as string) || 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): DDUIData {\n return {\n draggable: drag.el,\n ...drag.ui()\n };\n }\n}\n\n"]}
|
package/dist/es5/dd-element.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* dd-elements.ts 12.0.0
|
|
3
|
-
* Copyright (c) 2021-2024 Alain Dumesny - see GridStack root license
|
|
4
|
-
*/
|
|
5
|
-
import { DDResizable, DDResizableOpt } from './dd-resizable';
|
|
6
|
-
import { DDDragOpt, GridItemHTMLElement } from './types';
|
|
7
|
-
import { DDDraggable } from './dd-draggable';
|
|
8
|
-
import { DDDroppable, DDDroppableOpt } from './dd-droppable';
|
|
9
|
-
export interface DDElementHost extends GridItemHTMLElement {
|
|
10
|
-
ddElement?: DDElement;
|
|
11
|
-
}
|
|
12
|
-
export declare class DDElement {
|
|
13
|
-
el: DDElementHost;
|
|
14
|
-
static init(el: DDElementHost): DDElement;
|
|
15
|
-
ddDraggable?: DDDraggable;
|
|
16
|
-
ddDroppable?: DDDroppable;
|
|
17
|
-
ddResizable?: DDResizable;
|
|
18
|
-
constructor(el: DDElementHost);
|
|
19
|
-
on(eventName: string, callback: (event: MouseEvent) => void): DDElement;
|
|
20
|
-
off(eventName: string): DDElement;
|
|
21
|
-
setupDraggable(opts: DDDragOpt): DDElement;
|
|
22
|
-
cleanDraggable(): DDElement;
|
|
23
|
-
setupResizable(opts: DDResizableOpt): DDElement;
|
|
24
|
-
cleanResizable(): DDElement;
|
|
25
|
-
setupDroppable(opts: DDDroppableOpt): DDElement;
|
|
26
|
-
cleanDroppable(): DDElement;
|
|
27
|
-
}
|
package/dist/es5/dd-element.js
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* dd-elements.ts 12.0.0
|
|
4
|
-
* Copyright (c) 2021-2024 Alain Dumesny - see GridStack root license
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.DDElement = void 0;
|
|
8
|
-
var dd_resizable_1 = require("./dd-resizable");
|
|
9
|
-
var dd_draggable_1 = require("./dd-draggable");
|
|
10
|
-
var dd_droppable_1 = require("./dd-droppable");
|
|
11
|
-
var DDElement = /** @class */ (function () {
|
|
12
|
-
function DDElement(el) {
|
|
13
|
-
this.el = el;
|
|
14
|
-
}
|
|
15
|
-
DDElement.init = function (el) {
|
|
16
|
-
if (!el.ddElement) {
|
|
17
|
-
el.ddElement = new DDElement(el);
|
|
18
|
-
}
|
|
19
|
-
return el.ddElement;
|
|
20
|
-
};
|
|
21
|
-
DDElement.prototype.on = function (eventName, callback) {
|
|
22
|
-
if (this.ddDraggable && ['drag', 'dragstart', 'dragstop'].indexOf(eventName) > -1) {
|
|
23
|
-
this.ddDraggable.on(eventName, callback);
|
|
24
|
-
}
|
|
25
|
-
else if (this.ddDroppable && ['drop', 'dropover', 'dropout'].indexOf(eventName) > -1) {
|
|
26
|
-
this.ddDroppable.on(eventName, callback);
|
|
27
|
-
}
|
|
28
|
-
else if (this.ddResizable && ['resizestart', 'resize', 'resizestop'].indexOf(eventName) > -1) {
|
|
29
|
-
this.ddResizable.on(eventName, callback);
|
|
30
|
-
}
|
|
31
|
-
return this;
|
|
32
|
-
};
|
|
33
|
-
DDElement.prototype.off = function (eventName) {
|
|
34
|
-
if (this.ddDraggable && ['drag', 'dragstart', 'dragstop'].indexOf(eventName) > -1) {
|
|
35
|
-
this.ddDraggable.off(eventName);
|
|
36
|
-
}
|
|
37
|
-
else if (this.ddDroppable && ['drop', 'dropover', 'dropout'].indexOf(eventName) > -1) {
|
|
38
|
-
this.ddDroppable.off(eventName);
|
|
39
|
-
}
|
|
40
|
-
else if (this.ddResizable && ['resizestart', 'resize', 'resizestop'].indexOf(eventName) > -1) {
|
|
41
|
-
this.ddResizable.off(eventName);
|
|
42
|
-
}
|
|
43
|
-
return this;
|
|
44
|
-
};
|
|
45
|
-
DDElement.prototype.setupDraggable = function (opts) {
|
|
46
|
-
if (!this.ddDraggable) {
|
|
47
|
-
this.ddDraggable = new dd_draggable_1.DDDraggable(this.el, opts);
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
this.ddDraggable.updateOption(opts);
|
|
51
|
-
}
|
|
52
|
-
return this;
|
|
53
|
-
};
|
|
54
|
-
DDElement.prototype.cleanDraggable = function () {
|
|
55
|
-
if (this.ddDraggable) {
|
|
56
|
-
this.ddDraggable.destroy();
|
|
57
|
-
delete this.ddDraggable;
|
|
58
|
-
}
|
|
59
|
-
return this;
|
|
60
|
-
};
|
|
61
|
-
DDElement.prototype.setupResizable = function (opts) {
|
|
62
|
-
if (!this.ddResizable) {
|
|
63
|
-
this.ddResizable = new dd_resizable_1.DDResizable(this.el, opts);
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
this.ddResizable.updateOption(opts);
|
|
67
|
-
}
|
|
68
|
-
return this;
|
|
69
|
-
};
|
|
70
|
-
DDElement.prototype.cleanResizable = function () {
|
|
71
|
-
if (this.ddResizable) {
|
|
72
|
-
this.ddResizable.destroy();
|
|
73
|
-
delete this.ddResizable;
|
|
74
|
-
}
|
|
75
|
-
return this;
|
|
76
|
-
};
|
|
77
|
-
DDElement.prototype.setupDroppable = function (opts) {
|
|
78
|
-
if (!this.ddDroppable) {
|
|
79
|
-
this.ddDroppable = new dd_droppable_1.DDDroppable(this.el, opts);
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
this.ddDroppable.updateOption(opts);
|
|
83
|
-
}
|
|
84
|
-
return this;
|
|
85
|
-
};
|
|
86
|
-
DDElement.prototype.cleanDroppable = function () {
|
|
87
|
-
if (this.ddDroppable) {
|
|
88
|
-
this.ddDroppable.destroy();
|
|
89
|
-
delete this.ddDroppable;
|
|
90
|
-
}
|
|
91
|
-
return this;
|
|
92
|
-
};
|
|
93
|
-
return DDElement;
|
|
94
|
-
}());
|
|
95
|
-
exports.DDElement = DDElement;
|
|
96
|
-
//# sourceMappingURL=dd-element.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dd-element.js","sourceRoot":"","sources":["../../src/dd-element.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+CAA6D;AAE7D,+CAA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AE;YACpB,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;YAC3B,OAAO,IAAI,CAAC,WAAW,CAAC;SACzB;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,kCAAc,GAArB,UAAsB,IAAoB;QACxC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACrB,IAAI,CAAC,WAAW,GAAG,IAAI,0BAAW,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;SACnD;aAAM;YACL,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;SACrC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,kCAAc,GAArB;QACE,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;IACH,gBAAC;AAAD,CAAC,AArFD,IAqFC;AArFY,8BAAS","sourcesContent":["/**\n * dd-elements.ts 12.0.0\n * Copyright (c) 2021-2024 Alain Dumesny - see GridStack root license\n */\n\nimport { DDResizable, DDResizableOpt } from './dd-resizable';\nimport { DDDragOpt, GridItemHTMLElement } from './types';\nimport { DDDraggable } 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 ddDraggable?: DDDraggable;\n public ddDroppable?: DDDroppable;\n public ddResizable?: DDResizable;\n\n constructor(public el: DDElementHost) {}\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: DDDragOpt): 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"]}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* dd-gridstack.ts 12.0.0
|
|
3
|
-
* Copyright (c) 2021-2024 Alain Dumesny - see GridStack root license
|
|
4
|
-
*/
|
|
5
|
-
import { GridItemHTMLElement, GridStackElement, DDDragOpt } from './types';
|
|
6
|
-
import { DDElementHost } from './dd-element';
|
|
7
|
-
/** Drag&Drop drop options */
|
|
8
|
-
export 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 type DDOpts = 'enable' | 'disable' | 'destroy' | 'option' | string | any;
|
|
14
|
-
export type DDKey = 'minWidth' | 'minHeight' | 'maxWidth' | 'maxHeight' | 'maxHeightMoveUp' | 'maxWidthMoveLeft';
|
|
15
|
-
export type DDValue = number | string;
|
|
16
|
-
/** drag&drop events callbacks */
|
|
17
|
-
export 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
|
-
resizable(el: GridItemHTMLElement, opts: DDOpts, key?: DDKey, value?: DDValue): DDGridStack;
|
|
23
|
-
draggable(el: GridItemHTMLElement, opts: DDOpts, key?: DDKey, value?: DDValue): DDGridStack;
|
|
24
|
-
dragIn(el: GridStackElement, opts: DDDragOpt): DDGridStack;
|
|
25
|
-
droppable(el: GridItemHTMLElement, opts: DDOpts | DDDropOpt, key?: DDKey, value?: DDValue): DDGridStack;
|
|
26
|
-
/** true if element is droppable */
|
|
27
|
-
isDroppable(el: DDElementHost): boolean;
|
|
28
|
-
/** true if element is draggable */
|
|
29
|
-
isDraggable(el: DDElementHost): boolean;
|
|
30
|
-
/** true if element is draggable */
|
|
31
|
-
isResizable(el: DDElementHost): boolean;
|
|
32
|
-
on(el: GridItemHTMLElement, name: string, callback: DDCallback): DDGridStack;
|
|
33
|
-
off(el: GridItemHTMLElement, name: string): DDGridStack;
|
|
34
|
-
}
|
package/dist/es5/dd-gridstack.js
DELETED
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* dd-gridstack.ts 12.0.0
|
|
4
|
-
* Copyright (c) 2021-2024 Alain Dumesny - see GridStack root license
|
|
5
|
-
*/
|
|
6
|
-
var __assign = (this && this.__assign) || function () {
|
|
7
|
-
__assign = Object.assign || function(t) {
|
|
8
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
9
|
-
s = arguments[i];
|
|
10
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
11
|
-
t[p] = s[p];
|
|
12
|
-
}
|
|
13
|
-
return t;
|
|
14
|
-
};
|
|
15
|
-
return __assign.apply(this, arguments);
|
|
16
|
-
};
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.DDGridStack = void 0;
|
|
19
|
-
var utils_1 = require("./utils");
|
|
20
|
-
var dd_manager_1 = require("./dd-manager");
|
|
21
|
-
var dd_element_1 = require("./dd-element");
|
|
22
|
-
// let count = 0; // TEST
|
|
23
|
-
/**
|
|
24
|
-
* HTML Native Mouse and Touch Events Drag and Drop functionality.
|
|
25
|
-
*/
|
|
26
|
-
var DDGridStack = /** @class */ (function () {
|
|
27
|
-
function DDGridStack() {
|
|
28
|
-
}
|
|
29
|
-
DDGridStack.prototype.resizable = function (el, opts, key, value) {
|
|
30
|
-
this._getDDElements(el, opts).forEach(function (dEl) {
|
|
31
|
-
var _a;
|
|
32
|
-
if (opts === 'disable' || opts === 'enable') {
|
|
33
|
-
dEl.ddResizable && dEl.ddResizable[opts](); // can't create DD as it requires options for setupResizable()
|
|
34
|
-
}
|
|
35
|
-
else if (opts === 'destroy') {
|
|
36
|
-
dEl.ddResizable && dEl.cleanResizable();
|
|
37
|
-
}
|
|
38
|
-
else if (opts === 'option') {
|
|
39
|
-
dEl.setupResizable((_a = {}, _a[key] = value, _a));
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
var n = dEl.el.gridstackNode;
|
|
43
|
-
var grid = n.grid;
|
|
44
|
-
var handles = dEl.el.getAttribute('gs-resize-handles') || grid.opts.resizable.handles || 'e,s,se';
|
|
45
|
-
if (handles === 'all')
|
|
46
|
-
handles = 'n,e,s,w,se,sw,ne,nw';
|
|
47
|
-
// NOTE: keep the resize handles as e,w don't have enough space (10px) to show resize corners anyway. limit during drag instead
|
|
48
|
-
// restrict vertical resize if height is done to match content anyway... odd to have it spring back
|
|
49
|
-
// if (Utils.shouldSizeToContent(n, true)) {
|
|
50
|
-
// const doE = handles.indexOf('e') !== -1;
|
|
51
|
-
// const doW = handles.indexOf('w') !== -1;
|
|
52
|
-
// handles = doE ? (doW ? 'e,w' : 'e') : (doW ? 'w' : '');
|
|
53
|
-
// }
|
|
54
|
-
var autoHide = !grid.opts.alwaysShowResizeHandle;
|
|
55
|
-
dEl.setupResizable(__assign(__assign(__assign({}, grid.opts.resizable), { handles: handles, autoHide: autoHide }), {
|
|
56
|
-
start: opts.start,
|
|
57
|
-
stop: opts.stop,
|
|
58
|
-
resize: opts.resize
|
|
59
|
-
}));
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
return this;
|
|
63
|
-
};
|
|
64
|
-
DDGridStack.prototype.draggable = function (el, opts, key, value) {
|
|
65
|
-
this._getDDElements(el, opts).forEach(function (dEl) {
|
|
66
|
-
var _a;
|
|
67
|
-
if (opts === 'disable' || opts === 'enable') {
|
|
68
|
-
dEl.ddDraggable && dEl.ddDraggable[opts](); // can't create DD as it requires options for setupDraggable()
|
|
69
|
-
}
|
|
70
|
-
else if (opts === 'destroy') {
|
|
71
|
-
dEl.ddDraggable && dEl.cleanDraggable();
|
|
72
|
-
}
|
|
73
|
-
else if (opts === 'option') {
|
|
74
|
-
dEl.setupDraggable((_a = {}, _a[key] = value, _a));
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
var grid = dEl.el.gridstackNode.grid;
|
|
78
|
-
dEl.setupDraggable(__assign(__assign({}, grid.opts.draggable), {
|
|
79
|
-
// containment: (grid.parentGridNode && grid.opts.dragOut === false) ? grid.el.parentElement : (grid.opts.draggable.containment || null),
|
|
80
|
-
start: opts.start,
|
|
81
|
-
stop: opts.stop,
|
|
82
|
-
drag: opts.drag
|
|
83
|
-
}));
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
return this;
|
|
87
|
-
};
|
|
88
|
-
DDGridStack.prototype.dragIn = function (el, opts) {
|
|
89
|
-
this._getDDElements(el).forEach(function (dEl) { return dEl.setupDraggable(opts); });
|
|
90
|
-
return this;
|
|
91
|
-
};
|
|
92
|
-
DDGridStack.prototype.droppable = function (el, opts, key, value) {
|
|
93
|
-
if (typeof opts.accept === 'function' && !opts._accept) {
|
|
94
|
-
opts._accept = opts.accept;
|
|
95
|
-
opts.accept = function (el) { return opts._accept(el); };
|
|
96
|
-
}
|
|
97
|
-
this._getDDElements(el, opts).forEach(function (dEl) {
|
|
98
|
-
var _a;
|
|
99
|
-
if (opts === 'disable' || opts === 'enable') {
|
|
100
|
-
dEl.ddDroppable && dEl.ddDroppable[opts]();
|
|
101
|
-
}
|
|
102
|
-
else if (opts === 'destroy') {
|
|
103
|
-
dEl.ddDroppable && dEl.cleanDroppable();
|
|
104
|
-
}
|
|
105
|
-
else if (opts === 'option') {
|
|
106
|
-
dEl.setupDroppable((_a = {}, _a[key] = value, _a));
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
109
|
-
dEl.setupDroppable(opts);
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
return this;
|
|
113
|
-
};
|
|
114
|
-
/** true if element is droppable */
|
|
115
|
-
DDGridStack.prototype.isDroppable = function (el) {
|
|
116
|
-
var _a;
|
|
117
|
-
return !!(((_a = el === null || el === void 0 ? void 0 : el.ddElement) === null || _a === void 0 ? void 0 : _a.ddDroppable) && !el.ddElement.ddDroppable.disabled);
|
|
118
|
-
};
|
|
119
|
-
/** true if element is draggable */
|
|
120
|
-
DDGridStack.prototype.isDraggable = function (el) {
|
|
121
|
-
var _a;
|
|
122
|
-
return !!(((_a = el === null || el === void 0 ? void 0 : el.ddElement) === null || _a === void 0 ? void 0 : _a.ddDraggable) && !el.ddElement.ddDraggable.disabled);
|
|
123
|
-
};
|
|
124
|
-
/** true if element is draggable */
|
|
125
|
-
DDGridStack.prototype.isResizable = function (el) {
|
|
126
|
-
var _a;
|
|
127
|
-
return !!(((_a = el === null || el === void 0 ? void 0 : el.ddElement) === null || _a === void 0 ? void 0 : _a.ddResizable) && !el.ddElement.ddResizable.disabled);
|
|
128
|
-
};
|
|
129
|
-
DDGridStack.prototype.on = function (el, name, callback) {
|
|
130
|
-
this._getDDElements(el).forEach(function (dEl) {
|
|
131
|
-
return dEl.on(name, function (event) {
|
|
132
|
-
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);
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
return this;
|
|
136
|
-
};
|
|
137
|
-
DDGridStack.prototype.off = function (el, name) {
|
|
138
|
-
this._getDDElements(el).forEach(function (dEl) { return dEl.off(name); });
|
|
139
|
-
return this;
|
|
140
|
-
};
|
|
141
|
-
/** @internal returns a list of DD elements, creating them on the fly by default unless option is to destroy or disable */
|
|
142
|
-
DDGridStack.prototype._getDDElements = function (els, opts) {
|
|
143
|
-
// don't force create if we're going to destroy it, unless it's a grid which is used as drop target for it's children
|
|
144
|
-
var create = els.gridstack || opts !== 'destroy' && opts !== 'disable';
|
|
145
|
-
var hosts = utils_1.Utils.getElements(els);
|
|
146
|
-
if (!hosts.length)
|
|
147
|
-
return [];
|
|
148
|
-
var list = hosts.map(function (e) { return e.ddElement || (create ? dd_element_1.DDElement.init(e) : null); }).filter(function (d) { return d; }); // remove nulls
|
|
149
|
-
return list;
|
|
150
|
-
};
|
|
151
|
-
return DDGridStack;
|
|
152
|
-
}());
|
|
153
|
-
exports.DDGridStack = DDGridStack;
|
|
154
|
-
//# sourceMappingURL=dd-gridstack.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dd-gridstack.js","sourceRoot":"","sources":["../../src/dd-gridstack.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;AAIH,iCAAgC;AAChC,2CAAyC;AACzC,2CAAwD;AAkBxD,yBAAyB;AAEzB;;GAEG;AACH;IAAA;IA8HA,CAAC;IA5HQ,+BAAS,GAAhB,UAAiB,EAAuB,EAAE,IAAY,EAAE,GAAW,EAAE,KAAe;QAClF,IAAI,CAAC,cAAc,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC,OAAO,CAAC,UAAA,GAAG;;YACvC,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,QAAQ,EAAE;gBAC3C,GAAG,CAAC,WAAW,IAAI,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,8DAA8D;aAC3G;iBAAM,IAAI,IAAI,KAAK,SAAS,EAAE;gBAC7B,GAAG,CAAC,WAAW,IAAI,GAAG,CAAC,cAAc,EAAE,CAAC;aACzC;iBAAM,IAAI,IAAI,KAAK,QAAQ,EAAE;gBAC5B,GAAG,CAAC,cAAc,WAAG,GAAC,GAAG,IAAG,KAAK,MAAG,CAAC;aACtC;iBAAM;gBACL,IAAM,CAAC,GAAG,GAAG,CAAC,EAAE,CAAC,aAAa,CAAC;gBAC/B,IAAM,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC;gBACpB,IAAI,OAAO,GAAG,GAAG,CAAC,EAAE,CAAC,YAAY,CAAC,mBAAmB,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,IAAI,QAAQ,C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AC,CAAA;YAChE,CAAC,CAAC;QALF,CAKE,CACH,CAAC;QACF,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,yBAAG,GAAV,UAAW,EAAuB,EAAE,IAAY;QAC9C,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,UAAA,GAAG,IAAI,OAAA,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAb,CAAa,CAAC,CAAC;QACtD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,0HAA0H;IAChH,oCAAc,GAAxB,UAAyB,GAAqB,EAAE,IAAa;QAC3D,qHAAqH;QACrH,IAAM,MAAM,GAAI,GAAuB,CAAC,SAAS,IAAK,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,SAAS,CAAC;QAC/F,IAAM,KAAK,GAAG,aAAK,CAAC,WAAW,CAAC,GAAG,CAAoB,CAAC;QACxD,IAAI,CAAC,KAAK,CAAC,MAAM;YAAE,OAAO,EAAE,CAAC;QAC7B,IAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,SAAS,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,sBAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAlD,CAAkD,CAAC,CAAC,MAAM,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,EAAD,CAAC,CAAC,CAAC,CAAC,eAAe;QAC/G,OAAO,IAAI,CAAC;IACd,CAAC;IACH,kBAAC;AAAD,CAAC,AA9HD,IA8HC;AA9HY,kCAAW","sourcesContent":["/**\r\n * dd-gridstack.ts 12.0.0\r\n * Copyright (c) 2021-2024 Alain Dumesny - see GridStack root license\r\n */\r\n\r\n/* eslint-disable @typescript-eslint/no-unused-vars */\r\nimport { GridItemHTMLElement, GridStackElement, DDDragOpt } from './types';\r\nimport { Utils } from './utils';\r\nimport { DDManager } from './dd-manager';\r\nimport { DDElement, DDElementHost } from './dd-element';\r\nimport { GridHTMLElement } from './gridstack';\r\n\r\n/** Drag&Drop drop options */\r\nexport type DDDropOpt = {\r\n /** function or class type that this grid will accept as dropped items (see GridStackOptions.acceptWidgets) */\r\n accept?: (el: GridItemHTMLElement) => boolean;\r\n}\r\n\r\n/** drag&drop options currently called from the main code, but others can be passed in grid options */\r\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\r\nexport type DDOpts = 'enable' | 'disable' | 'destroy' | 'option' | string | any;\r\nexport type DDKey = 'minWidth' | 'minHeight' | 'maxWidth' | 'maxHeight' | 'maxHeightMoveUp' | 'maxWidthMoveLeft';\r\nexport type DDValue = number | string;\r\n\r\n/** drag&drop events callbacks */\r\nexport type DDCallback = (event: Event, arg2: GridItemHTMLElement, helper?: GridItemHTMLElement) => void;\r\n\r\n// let count = 0; // TEST\r\n\r\n/**\r\n * HTML Native Mouse and Touch Events Drag and Drop functionality.\r\n */\r\nexport class DDGridStack {\r\n\r\n public resizable(el: GridItemHTMLElement, opts: DDOpts, key?: DDKey, value?: DDValue): DDGridStack {\r\n this._getDDElements(el, opts).forEach(dEl => {\r\n if (opts === 'disable' || opts === 'enable') {\r\n dEl.ddResizable && dEl.ddResizable[opts](); // can't create DD as it requires options for setupResizable()\r\n } else if (opts === 'destroy') {\r\n dEl.ddResizable && dEl.cleanResizable();\r\n } else if (opts === 'option') {\r\n dEl.setupResizable({ [key]: value });\r\n } else {\r\n const n = dEl.el.gridstackNode;\r\n const grid = n.grid;\r\n let handles = dEl.el.getAttribute('gs-resize-handles') || grid.opts.resizable.handles || 'e,s,se';\r\n if (handles === 'all') handles = 'n,e,s,w,se,sw,ne,nw';\r\n // NOTE: keep the resize handles as e,w don't have enough space (10px) to show resize corners anyway. limit during drag instead\r\n // restrict vertical resize if height is done to match content anyway... odd to have it spring back\r\n // if (Utils.shouldSizeToContent(n, true)) {\r\n // const doE = handles.indexOf('e') !== -1;\r\n // const doW = handles.indexOf('w') !== -1;\r\n // handles = doE ? (doW ? 'e,w' : 'e') : (doW ? 'w' : '');\r\n // }\r\n const autoHide = !grid.opts.alwaysShowResizeHandle;\r\n dEl.setupResizable({\r\n ...grid.opts.resizable,\r\n ...{ handles, autoHide },\r\n ...{\r\n start: opts.start,\r\n stop: opts.stop,\r\n resize: opts.resize\r\n }\r\n });\r\n }\r\n });\r\n return this;\r\n }\r\n\r\n public draggable(el: GridItemHTMLElement, opts: DDOpts, key?: DDKey, value?: DDValue): DDGridStack {\r\n this._getDDElements(el, opts).forEach(dEl => {\r\n if (opts === 'disable' || opts === 'enable') {\r\n dEl.ddDraggable && dEl.ddDraggable[opts](); // can't create DD as it requires options for setupDraggable()\r\n } else if (opts === 'destroy') {\r\n dEl.ddDraggable && dEl.cleanDraggable();\r\n } else if (opts === 'option') {\r\n dEl.setupDraggable({ [key]: value });\r\n } else {\r\n const grid = dEl.el.gridstackNode.grid;\r\n dEl.setupDraggable({\r\n ...grid.opts.draggable,\r\n ...{\r\n // containment: (grid.parentGridNode && grid.opts.dragOut === false) ? grid.el.parentElement : (grid.opts.draggable.containment || null),\r\n start: opts.start,\r\n stop: opts.stop,\r\n drag: opts.drag\r\n }\r\n });\r\n }\r\n });\r\n return this;\r\n }\r\n\r\n public dragIn(el: GridStackElement, opts: DDDragOpt): DDGridStack {\r\n this._getDDElements(el).forEach(dEl => dEl.setupDraggable(opts));\r\n return this;\r\n }\r\n\r\n public droppable(el: GridItemHTMLElement, opts: DDOpts | DDDropOpt, key?: DDKey, value?: DDValue): DDGridStack {\r\n if (typeof opts.accept === 'function' && !opts._accept) {\r\n opts._accept = opts.accept;\r\n opts.accept = (el) => opts._accept(el);\r\n }\r\n this._getDDElements(el, opts).forEach(dEl => {\r\n if (opts === 'disable' || opts === 'enable') {\r\n dEl.ddDroppable && dEl.ddDroppable[opts]();\r\n } else if (opts === 'destroy') {\r\n dEl.ddDroppable && dEl.cleanDroppable();\r\n } else if (opts === 'option') {\r\n dEl.setupDroppable({ [key]: value });\r\n } else {\r\n dEl.setupDroppable(opts);\r\n }\r\n });\r\n return this;\r\n }\r\n\r\n /** true if element is droppable */\r\n public isDroppable(el: DDElementHost): boolean {\r\n return !!(el?.ddElement?.ddDroppable && !el.ddElement.ddDroppable.disabled);\r\n }\r\n\r\n /** true if element is draggable */\r\n public isDraggable(el: DDElementHost): boolean {\r\n return !!(el?.ddElement?.ddDraggable && !el.ddElement.ddDraggable.disabled);\r\n }\r\n\r\n /** true if element is draggable */\r\n public isResizable(el: DDElementHost): boolean {\r\n return !!(el?.ddElement?.ddResizable && !el.ddElement.ddResizable.disabled);\r\n }\r\n\r\n public on(el: GridItemHTMLElement, name: string, callback: DDCallback): DDGridStack {\r\n this._getDDElements(el).forEach(dEl =>\r\n dEl.on(name, (event: Event) => {\r\n callback(\r\n event,\r\n DDManager.dragElement ? DDManager.dragElement.el : event.target as GridItemHTMLElement,\r\n DDManager.dragElement ? DDManager.dragElement.helper : null)\r\n })\r\n );\r\n return this;\r\n }\r\n\r\n public off(el: GridItemHTMLElement, name: string): DDGridStack {\r\n this._getDDElements(el).forEach(dEl => dEl.off(name));\r\n return this;\r\n }\r\n\r\n /** @internal returns a list of DD elements, creating them on the fly by default unless option is to destroy or disable */\r\n protected _getDDElements(els: GridStackElement, opts?: DDOpts): DDElement[] {\r\n // don't force create if we're going to destroy it, unless it's a grid which is used as drop target for it's children\r\n const create = (els as GridHTMLElement).gridstack || opts !== 'destroy' && opts !== 'disable';\r\n const hosts = Utils.getElements(els) as DDElementHost[];\r\n if (!hosts.length) return [];\r\n const list = hosts.map(e => e.ddElement || (create ? DDElement.init(e) : null)).filter(d => d); // remove nulls\r\n return list;\r\n }\r\n}\r\n"]}
|
package/dist/es5/dd-manager.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* dd-manager.ts 12.0.0
|
|
3
|
-
* Copyright (c) 2021-2024 Alain Dumesny - see GridStack root license
|
|
4
|
-
*/
|
|
5
|
-
import { DDDraggable } from './dd-draggable';
|
|
6
|
-
import { DDDroppable } from './dd-droppable';
|
|
7
|
-
import { DDResizable } from './dd-resizable';
|
|
8
|
-
/**
|
|
9
|
-
* globals that are shared across Drag & Drop instances
|
|
10
|
-
*/
|
|
11
|
-
export declare class DDManager {
|
|
12
|
-
/** if set (true | in msec), dragging placement (collision) will only happen after a pause by the user*/
|
|
13
|
-
static pauseDrag: boolean | number;
|
|
14
|
-
/** true if a mouse down event was handled */
|
|
15
|
-
static mouseHandled: boolean;
|
|
16
|
-
/** item being dragged */
|
|
17
|
-
static dragElement: DDDraggable;
|
|
18
|
-
/** item we are currently over as drop target */
|
|
19
|
-
static dropElement: DDDroppable;
|
|
20
|
-
/** current item we're over for resizing purpose (ignore nested grid resize handles) */
|
|
21
|
-
static overResizeElement: DDResizable;
|
|
22
|
-
}
|
package/dist/es5/dd-manager.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* dd-manager.ts 12.0.0
|
|
4
|
-
* Copyright (c) 2021-2024 Alain Dumesny - see GridStack root license
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.DDManager = void 0;
|
|
8
|
-
/**
|
|
9
|
-
* globals that are shared across Drag & Drop instances
|
|
10
|
-
*/
|
|
11
|
-
var DDManager = /** @class */ (function () {
|
|
12
|
-
function DDManager() {
|
|
13
|
-
}
|
|
14
|
-
return DDManager;
|
|
15
|
-
}());
|
|
16
|
-
exports.DDManager = DDManager;
|
|
17
|
-
//# sourceMappingURL=dd-manager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dd-manager.js","sourceRoot":"","sources":["../../src/dd-manager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAMH;;GAEG;AACH;IAAA;IAgBA,CAAC;IAAD,gBAAC;AAAD,CAAC,AAhBD,IAgBC;AAhBY,8BAAS","sourcesContent":["/**\n * dd-manager.ts 12.0.0\n * Copyright (c) 2021-2024 Alain Dumesny - see GridStack root license\n */\n\nimport { DDDraggable } from './dd-draggable';\nimport { DDDroppable } from './dd-droppable';\nimport { DDResizable } from './dd-resizable';\n\n/**\n * globals that are shared across Drag & Drop instances\n */\nexport class DDManager {\n /** if set (true | in msec), dragging placement (collision) will only happen after a pause by the user*/\n public static pauseDrag: boolean | number;\n\n /** true if a mouse down event was handled */\n public static mouseHandled: boolean;\n\n /** item being dragged */\n public static dragElement: DDDraggable;\n\n /** item we are currently over as drop target */\n public static dropElement: DDDroppable;\n\n /** current item we're over for resizing purpose (ignore nested grid resize handles) */\n public static overResizeElement: DDResizable;\n\n}\n"]}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* dd-resizable-handle.ts 12.0.0
|
|
3
|
-
* Copyright (c) 2021-2024 Alain Dumesny - see GridStack root license
|
|
4
|
-
*/
|
|
5
|
-
import { GridItemHTMLElement } from './gridstack';
|
|
6
|
-
export interface DDResizableHandleOpt {
|
|
7
|
-
start?: (event: any) => void;
|
|
8
|
-
move?: (event: any) => void;
|
|
9
|
-
stop?: (event: any) => void;
|
|
10
|
-
}
|
|
11
|
-
export declare class DDResizableHandle {
|
|
12
|
-
protected host: GridItemHTMLElement;
|
|
13
|
-
protected dir: string;
|
|
14
|
-
protected option: DDResizableHandleOpt;
|
|
15
|
-
constructor(host: GridItemHTMLElement, dir: string, option: DDResizableHandleOpt);
|
|
16
|
-
/** call this when resize handle needs to be removed and cleaned up */
|
|
17
|
-
destroy(): DDResizableHandle;
|
|
18
|
-
}
|