gridstack 12.0.0 → 12.1.1

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.
Files changed (106) hide show
  1. package/README.md +5 -3
  2. package/dist/angular/esm2020/lib/base-widget.mjs +2 -2
  3. package/dist/angular/esm2020/lib/gridstack-item.component.mjs +2 -2
  4. package/dist/angular/esm2020/lib/gridstack.component.mjs +18 -4
  5. package/dist/angular/esm2020/lib/gridstack.module.mjs +2 -2
  6. package/dist/angular/esm2020/lib/types.mjs +2 -2
  7. package/dist/angular/fesm2015/gridstack-angular.mjs +22 -6
  8. package/dist/angular/fesm2015/gridstack-angular.mjs.map +1 -1
  9. package/dist/angular/fesm2020/gridstack-angular.mjs +21 -7
  10. package/dist/angular/fesm2020/gridstack-angular.mjs.map +1 -1
  11. package/dist/angular/lib/gridstack-item.component.d.ts +1 -1
  12. package/dist/angular/lib/gridstack.component.d.ts +1 -1
  13. package/dist/angular/lib/types.d.ts +1 -1
  14. package/dist/angular/src/base-widget.ts +1 -1
  15. package/dist/angular/src/gridstack-item.component.ts +1 -1
  16. package/dist/angular/src/gridstack.component.ts +15 -3
  17. package/dist/angular/src/gridstack.module.ts +1 -1
  18. package/dist/dd-base-impl.d.ts +1 -1
  19. package/dist/dd-base-impl.js +1 -1
  20. package/dist/dd-base-impl.js.map +1 -1
  21. package/dist/dd-draggable.d.ts +1 -1
  22. package/dist/dd-draggable.js +1 -1
  23. package/dist/dd-draggable.js.map +1 -1
  24. package/dist/dd-droppable.d.ts +1 -1
  25. package/dist/dd-droppable.js +1 -1
  26. package/dist/dd-droppable.js.map +1 -1
  27. package/dist/dd-element.d.ts +1 -1
  28. package/dist/dd-element.js +1 -1
  29. package/dist/dd-element.js.map +1 -1
  30. package/dist/dd-gridstack.d.ts +1 -1
  31. package/dist/dd-gridstack.js +1 -1
  32. package/dist/dd-gridstack.js.map +1 -1
  33. package/dist/dd-manager.d.ts +1 -1
  34. package/dist/dd-manager.js +1 -1
  35. package/dist/dd-manager.js.map +1 -1
  36. package/dist/dd-resizable-handle.d.ts +1 -1
  37. package/dist/dd-resizable-handle.js +1 -1
  38. package/dist/dd-resizable-handle.js.map +1 -1
  39. package/dist/dd-resizable.d.ts +1 -1
  40. package/dist/dd-resizable.js +1 -1
  41. package/dist/dd-resizable.js.map +1 -1
  42. package/dist/dd-touch.d.ts +1 -1
  43. package/dist/dd-touch.js +1 -1
  44. package/dist/dd-touch.js.map +1 -1
  45. package/dist/gridstack-all.js +1 -1
  46. package/dist/gridstack-all.js.LICENSE.txt +1 -1
  47. package/dist/gridstack-all.js.map +1 -1
  48. package/dist/gridstack-engine.d.ts +1 -1
  49. package/dist/gridstack-engine.js +1 -1
  50. package/dist/gridstack-engine.js.map +1 -1
  51. package/dist/gridstack.css +1 -1
  52. package/dist/gridstack.d.ts +3 -1
  53. package/dist/gridstack.js +58 -56
  54. package/dist/gridstack.js.map +1 -1
  55. package/dist/src/gridstack.scss +1 -1
  56. package/dist/types.d.ts +1 -1
  57. package/dist/types.js +1 -1
  58. package/dist/types.js.map +1 -1
  59. package/dist/utils.d.ts +1 -1
  60. package/dist/utils.js +1 -1
  61. package/dist/utils.js.map +1 -1
  62. package/doc/CHANGES.md +14 -0
  63. package/package.json +2 -4
  64. package/dist/es5/dd-base-impl.d.ts +0 -20
  65. package/dist/es5/dd-base-impl.js +0 -41
  66. package/dist/es5/dd-base-impl.js.map +0 -1
  67. package/dist/es5/dd-draggable.d.ts +0 -20
  68. package/dist/es5/dd-draggable.js +0 -408
  69. package/dist/es5/dd-draggable.js.map +0 -1
  70. package/dist/es5/dd-droppable.d.ts +0 -26
  71. package/dist/es5/dd-droppable.js +0 -185
  72. package/dist/es5/dd-droppable.js.map +0 -1
  73. package/dist/es5/dd-element.d.ts +0 -27
  74. package/dist/es5/dd-element.js +0 -96
  75. package/dist/es5/dd-element.js.map +0 -1
  76. package/dist/es5/dd-gridstack.d.ts +0 -34
  77. package/dist/es5/dd-gridstack.js +0 -154
  78. package/dist/es5/dd-gridstack.js.map +0 -1
  79. package/dist/es5/dd-manager.d.ts +0 -22
  80. package/dist/es5/dd-manager.js +0 -17
  81. package/dist/es5/dd-manager.js.map +0 -1
  82. package/dist/es5/dd-resizable-handle.d.ts +0 -18
  83. package/dist/es5/dd-resizable-handle.js +0 -117
  84. package/dist/es5/dd-resizable-handle.js.map +0 -1
  85. package/dist/es5/dd-resizable.d.ts +0 -30
  86. package/dist/es5/dd-resizable.js +0 -331
  87. package/dist/es5/dd-resizable.js.map +0 -1
  88. package/dist/es5/dd-touch.d.ts +0 -33
  89. package/dist/es5/dd-touch.js +0 -157
  90. package/dist/es5/dd-touch.js.map +0 -1
  91. package/dist/es5/gridstack-all.js +0 -3
  92. package/dist/es5/gridstack-all.js.LICENSE.txt +0 -7
  93. package/dist/es5/gridstack-all.js.map +0 -1
  94. package/dist/es5/gridstack-engine.d.ts +0 -107
  95. package/dist/es5/gridstack-engine.js +0 -1070
  96. package/dist/es5/gridstack-engine.js.map +0 -1
  97. package/dist/es5/gridstack-poly.js +0 -356
  98. package/dist/es5/gridstack.d.ts +0 -452
  99. package/dist/es5/gridstack.js +0 -2644
  100. package/dist/es5/gridstack.js.map +0 -1
  101. package/dist/es5/types.d.ts +0 -326
  102. package/dist/es5/types.js +0 -38
  103. package/dist/es5/types.js.map +0 -1
  104. package/dist/es5/utils.d.ts +0 -104
  105. package/dist/es5/utils.js +0 -633
  106. package/dist/es5/utils.js.map +0 -1
@@ -1,408 +0,0 @@
1
- "use strict";
2
- /**
3
- * dd-draggable.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.DDDraggable = void 0;
34
- var dd_manager_1 = require("./dd-manager");
35
- var utils_1 = require("./utils");
36
- var dd_base_impl_1 = require("./dd-base-impl");
37
- var dd_touch_1 = require("./dd-touch");
38
- // make sure we are not clicking on known object that handles mouseDown
39
- var skipMouseDown = 'input,textarea,button,select,option,[contenteditable="true"],.ui-resizable-handle';
40
- // let count = 0; // TEST
41
- var DDDraggable = exports.DDDraggable = /** @class */ (function (_super) {
42
- __extends(DDDraggable, _super);
43
- function DDDraggable(el, option) {
44
- if (option === void 0) { option = {}; }
45
- var _this = this;
46
- var _a;
47
- _this = _super.call(this) || this;
48
- _this.el = el;
49
- _this.option = option;
50
- /** @internal */
51
- _this.dragTransform = {
52
- xScale: 1,
53
- yScale: 1,
54
- xOffset: 0,
55
- yOffset: 0
56
- };
57
- // get the element that is actually supposed to be dragged by
58
- var handleName = (_a = option === null || option === void 0 ? void 0 : option.handle) === null || _a === void 0 ? void 0 : _a.substring(1);
59
- var n = el.gridstackNode;
60
- _this.dragEls = !handleName || el.classList.contains(handleName) ? [el] : ((n === null || n === void 0 ? void 0 : n.subGrid) ? [el.querySelector(option.handle) || el] : Array.from(el.querySelectorAll(option.handle)));
61
- if (_this.dragEls.length === 0) {
62
- _this.dragEls = [el];
63
- }
64
- // create var event binding so we can easily remove and still look like TS methods (unlike anonymous functions)
65
- _this._mouseDown = _this._mouseDown.bind(_this);
66
- _this._mouseMove = _this._mouseMove.bind(_this);
67
- _this._mouseUp = _this._mouseUp.bind(_this);
68
- _this._keyEvent = _this._keyEvent.bind(_this);
69
- _this.enable();
70
- return _this;
71
- }
72
- DDDraggable.prototype.on = function (event, callback) {
73
- _super.prototype.on.call(this, event, callback);
74
- };
75
- DDDraggable.prototype.off = function (event) {
76
- _super.prototype.off.call(this, event);
77
- };
78
- DDDraggable.prototype.enable = function () {
79
- var _this = this;
80
- if (this.disabled === false)
81
- return;
82
- _super.prototype.enable.call(this);
83
- this.dragEls.forEach(function (dragEl) {
84
- dragEl.addEventListener('mousedown', _this._mouseDown);
85
- if (dd_touch_1.isTouch) {
86
- dragEl.addEventListener('touchstart', dd_touch_1.touchstart);
87
- dragEl.addEventListener('pointerdown', dd_touch_1.pointerdown);
88
- // dragEl.style.touchAction = 'none'; // not needed unlike pointerdown doc comment
89
- }
90
- });
91
- this.el.classList.remove('ui-draggable-disabled');
92
- };
93
- DDDraggable.prototype.disable = function (forDestroy) {
94
- var _this = this;
95
- if (forDestroy === void 0) { forDestroy = false; }
96
- if (this.disabled === true)
97
- return;
98
- _super.prototype.disable.call(this);
99
- this.dragEls.forEach(function (dragEl) {
100
- dragEl.removeEventListener('mousedown', _this._mouseDown);
101
- if (dd_touch_1.isTouch) {
102
- dragEl.removeEventListener('touchstart', dd_touch_1.touchstart);
103
- dragEl.removeEventListener('pointerdown', dd_touch_1.pointerdown);
104
- }
105
- });
106
- if (!forDestroy)
107
- this.el.classList.add('ui-draggable-disabled');
108
- };
109
- DDDraggable.prototype.destroy = function () {
110
- if (this.dragTimeout)
111
- window.clearTimeout(this.dragTimeout);
112
- delete this.dragTimeout;
113
- if (this.mouseDownEvent)
114
- this._mouseUp(this.mouseDownEvent);
115
- this.disable(true);
116
- delete this.el;
117
- delete this.helper;
118
- delete this.option;
119
- _super.prototype.destroy.call(this);
120
- };
121
- DDDraggable.prototype.updateOption = function (opts) {
122
- var _this = this;
123
- Object.keys(opts).forEach(function (key) { return _this.option[key] = opts[key]; });
124
- return this;
125
- };
126
- /** @internal call when mouse goes down before a dragstart happens */
127
- DDDraggable.prototype._mouseDown = function (e) {
128
- // don't let more than one widget handle mouseStart
129
- if (dd_manager_1.DDManager.mouseHandled)
130
- return;
131
- if (e.button !== 0)
132
- return true; // only left click
133
- // make sure we are not clicking on known object that handles mouseDown, or ones supplied by the user
134
- if (!this.dragEls.find(function (el) { return el === e.target; }) && e.target.closest(skipMouseDown))
135
- return true;
136
- if (this.option.cancel) {
137
- if (e.target.closest(this.option.cancel))
138
- return true;
139
- }
140
- this.mouseDownEvent = e;
141
- delete this.dragging;
142
- delete dd_manager_1.DDManager.dragElement;
143
- delete dd_manager_1.DDManager.dropElement;
144
- // document handler so we can continue receiving moves as the item is 'fixed' position, and capture=true so WE get a first crack
145
- document.addEventListener('mousemove', this._mouseMove, { capture: true, passive: true }); // true=capture, not bubble
146
- document.addEventListener('mouseup', this._mouseUp, true);
147
- if (dd_touch_1.isTouch) {
148
- e.currentTarget.addEventListener('touchmove', dd_touch_1.touchmove);
149
- e.currentTarget.addEventListener('touchend', dd_touch_1.touchend);
150
- }
151
- e.preventDefault();
152
- // preventDefault() prevents blur event which occurs just after mousedown event.
153
- // if an editable content has focus, then blur must be call
154
- if (document.activeElement)
155
- document.activeElement.blur();
156
- dd_manager_1.DDManager.mouseHandled = true;
157
- return true;
158
- };
159
- /** @internal method to call actual drag event */
160
- DDDraggable.prototype._callDrag = function (e) {
161
- if (!this.dragging)
162
- return;
163
- var ev = utils_1.Utils.initEvent(e, { target: this.el, type: 'drag' });
164
- if (this.option.drag) {
165
- this.option.drag(ev, this.ui());
166
- }
167
- this.triggerEvent('drag', ev);
168
- };
169
- /** @internal called when the main page (after successful mousedown) receives a move event to drag the item around the screen */
170
- DDDraggable.prototype._mouseMove = function (e) {
171
- var _this = this;
172
- var _a;
173
- // console.log(`${count++} move ${e.x},${e.y}`)
174
- var s = this.mouseDownEvent;
175
- this.lastDrag = e;
176
- if (this.dragging) {
177
- this._dragFollow(e);
178
- // delay actual grid handling drag until we pause for a while if set
179
- if (dd_manager_1.DDManager.pauseDrag) {
180
- var pause = Number.isInteger(dd_manager_1.DDManager.pauseDrag) ? dd_manager_1.DDManager.pauseDrag : 100;
181
- if (this.dragTimeout)
182
- window.clearTimeout(this.dragTimeout);
183
- this.dragTimeout = window.setTimeout(function () { return _this._callDrag(e); }, pause);
184
- }
185
- else {
186
- this._callDrag(e);
187
- }
188
- }
189
- else if (Math.abs(e.x - s.x) + Math.abs(e.y - s.y) > 3) {
190
- /**
191
- * don't start unless we've moved at least 3 pixels
192
- */
193
- this.dragging = true;
194
- dd_manager_1.DDManager.dragElement = this;
195
- // if we're dragging an actual grid item, set the current drop as the grid (to detect enter/leave)
196
- var grid = (_a = this.el.gridstackNode) === null || _a === void 0 ? void 0 : _a.grid;
197
- if (grid) {
198
- dd_manager_1.DDManager.dropElement = grid.el.ddElement.ddDroppable;
199
- }
200
- else {
201
- delete dd_manager_1.DDManager.dropElement;
202
- }
203
- this.helper = this._createHelper();
204
- this._setupHelperContainmentStyle();
205
- this.dragTransform = utils_1.Utils.getValuesFromTransformedElement(this.helperContainment);
206
- this.dragOffset = this._getDragOffset(e, this.el, this.helperContainment);
207
- this._setupHelperStyle(e);
208
- var ev = utils_1.Utils.initEvent(e, { target: this.el, type: 'dragstart' });
209
- if (this.option.start) {
210
- this.option.start(ev, this.ui());
211
- }
212
- this.triggerEvent('dragstart', ev);
213
- // now track keyboard events to cancel or rotate
214
- document.addEventListener('keydown', this._keyEvent);
215
- }
216
- // e.preventDefault(); // passive = true. OLD: was needed otherwise we get text sweep text selection as we drag around
217
- return true;
218
- };
219
- /** @internal call when the mouse gets released to drop the item at current location */
220
- DDDraggable.prototype._mouseUp = function (e) {
221
- var _a, _b;
222
- document.removeEventListener('mousemove', this._mouseMove, true);
223
- document.removeEventListener('mouseup', this._mouseUp, true);
224
- if (dd_touch_1.isTouch && e.currentTarget) { // destroy() during nested grid call us again wit fake _mouseUp
225
- e.currentTarget.removeEventListener('touchmove', dd_touch_1.touchmove, true);
226
- e.currentTarget.removeEventListener('touchend', dd_touch_1.touchend, true);
227
- }
228
- if (this.dragging) {
229
- delete this.dragging;
230
- (_a = this.el.gridstackNode) === null || _a === void 0 ? true : delete _a._origRotate;
231
- document.removeEventListener('keydown', this._keyEvent);
232
- // reset the drop target if dragging over ourself (already parented, just moving during stop callback below)
233
- if (((_b = dd_manager_1.DDManager.dropElement) === null || _b === void 0 ? void 0 : _b.el) === this.el.parentElement) {
234
- delete dd_manager_1.DDManager.dropElement;
235
- }
236
- this.helperContainment.style.position = this.parentOriginStylePosition || null;
237
- if (this.helper !== this.el)
238
- this.helper.remove(); // hide now
239
- this._removeHelperStyle();
240
- var ev = utils_1.Utils.initEvent(e, { target: this.el, type: 'dragstop' });
241
- if (this.option.stop) {
242
- this.option.stop(ev); // NOTE: destroy() will be called when removing item, so expect NULL ptr after!
243
- }
244
- this.triggerEvent('dragstop', ev);
245
- // call the droppable method to receive the item
246
- if (dd_manager_1.DDManager.dropElement) {
247
- dd_manager_1.DDManager.dropElement.drop(e);
248
- }
249
- }
250
- delete this.helper;
251
- delete this.mouseDownEvent;
252
- delete dd_manager_1.DDManager.dragElement;
253
- delete dd_manager_1.DDManager.dropElement;
254
- delete dd_manager_1.DDManager.mouseHandled;
255
- e.preventDefault();
256
- };
257
- /** @internal call when keys are being pressed - use Esc to cancel, R to rotate */
258
- DDDraggable.prototype._keyEvent = function (e) {
259
- var _a, _b;
260
- var n = this.el.gridstackNode;
261
- var grid = (n === null || n === void 0 ? void 0 : n.grid) || ((_b = (_a = dd_manager_1.DDManager.dropElement) === null || _a === void 0 ? void 0 : _a.el) === null || _b === void 0 ? void 0 : _b.gridstack);
262
- if (e.key === 'Escape') {
263
- if (n && n._origRotate) {
264
- n._orig = n._origRotate;
265
- delete n._origRotate;
266
- }
267
- grid === null || grid === void 0 ? void 0 : grid.cancelDrag();
268
- this._mouseUp(this.mouseDownEvent);
269
- }
270
- else if (n && grid && (e.key === 'r' || e.key === 'R')) {
271
- if (!utils_1.Utils.canBeRotated(n))
272
- return;
273
- n._origRotate = n._origRotate || __assign({}, n._orig); // store the real orig size in case we Esc after doing rotation
274
- delete n._moving; // force rotate to happen (move waits for >50% coverage otherwise)
275
- grid.setAnimation(false) // immediate rotate so _getDragOffset() gets the right dom size below
276
- .rotate(n.el, { top: -this.dragOffset.offsetTop, left: -this.dragOffset.offsetLeft })
277
- .setAnimation();
278
- n._moving = true;
279
- this.dragOffset = this._getDragOffset(this.lastDrag, n.el, this.helperContainment);
280
- this.helper.style.width = this.dragOffset.width + 'px';
281
- this.helper.style.height = this.dragOffset.height + 'px';
282
- utils_1.Utils.swap(n._orig, 'w', 'h');
283
- delete n._rect;
284
- this._mouseMove(this.lastDrag);
285
- }
286
- };
287
- /** @internal create a clone copy (or user defined method) of the original drag item if set */
288
- DDDraggable.prototype._createHelper = function () {
289
- var _this = this;
290
- var helper = this.el;
291
- if (typeof this.option.helper === 'function') {
292
- helper = this.option.helper(this.el);
293
- }
294
- else if (this.option.helper === 'clone') {
295
- helper = utils_1.Utils.cloneNode(this.el);
296
- }
297
- if (!helper.parentElement) {
298
- utils_1.Utils.appendTo(helper, this.option.appendTo === 'parent' ? this.el.parentElement : this.option.appendTo);
299
- }
300
- this.dragElementOriginStyle = DDDraggable.originStyleProp.map(function (prop) { return _this.el.style[prop]; });
301
- return helper;
302
- };
303
- /** @internal set the fix position of the dragged item */
304
- DDDraggable.prototype._setupHelperStyle = function (e) {
305
- var _this = this;
306
- this.helper.classList.add('ui-draggable-dragging');
307
- // TODO: set all at once with style.cssText += ... ? https://stackoverflow.com/questions/3968593
308
- var style = this.helper.style;
309
- style.pointerEvents = 'none'; // needed for over items to get enter/leave
310
- // style.cursor = 'move'; // TODO: can't set with pointerEvents=none ! (done in CSS as well)
311
- style.width = this.dragOffset.width + 'px';
312
- style.height = this.dragOffset.height + 'px';
313
- style.willChange = 'left, top';
314
- style.position = 'fixed'; // let us drag between grids by not clipping as parent .grid-stack is position: 'relative'
315
- this._dragFollow(e); // now position it
316
- style.transition = 'none'; // show up instantly
317
- setTimeout(function () {
318
- if (_this.helper) {
319
- style.transition = null; // recover animation
320
- }
321
- }, 0);
322
- return this;
323
- };
324
- /** @internal restore back the original style before dragging */
325
- DDDraggable.prototype._removeHelperStyle = function () {
326
- var _this = this;
327
- var _a;
328
- this.helper.classList.remove('ui-draggable-dragging');
329
- var node = (_a = this.helper) === null || _a === void 0 ? void 0 : _a.gridstackNode;
330
- // don't bother restoring styles if we're gonna remove anyway...
331
- if (!(node === null || node === void 0 ? void 0 : node._isAboutToRemove) && this.dragElementOriginStyle) {
332
- var helper_1 = this.helper;
333
- // don't animate, otherwise we animate offseted when switching back to 'absolute' from 'fixed'.
334
- // TODO: this also removes resizing animation which doesn't have this issue, but others.
335
- // Ideally both would animate ('move' would immediately restore 'absolute' and adjust coordinate to match,
336
- // then trigger a delay (repaint) to restore to final dest with animate) but then we need to make sure 'resizestop'
337
- // is called AFTER 'transitionend' event is received (see https://github.com/gridstack/gridstack.js/issues/2033)
338
- var transition_1 = this.dragElementOriginStyle['transition'] || null;
339
- helper_1.style.transition = this.dragElementOriginStyle['transition'] = 'none'; // can't be NULL #1973
340
- DDDraggable.originStyleProp.forEach(function (prop) { return helper_1.style[prop] = _this.dragElementOriginStyle[prop] || null; });
341
- setTimeout(function () { return helper_1.style.transition = transition_1; }, 50); // recover animation from saved vars after a pause (0 isn't enough #1973)
342
- }
343
- delete this.dragElementOriginStyle;
344
- return this;
345
- };
346
- /** @internal updates the top/left position to follow the mouse */
347
- DDDraggable.prototype._dragFollow = function (e) {
348
- var containmentRect = { left: 0, top: 0 };
349
- // if (this.helper.style.position === 'absolute') { // we use 'fixed'
350
- // const { left, top } = this.helperContainment.getBoundingClientRect();
351
- // containmentRect = { left, top };
352
- // }
353
- var style = this.helper.style;
354
- var offset = this.dragOffset;
355
- style.left = (e.clientX + offset.offsetLeft - containmentRect.left) * this.dragTransform.xScale + 'px';
356
- style.top = (e.clientY + offset.offsetTop - containmentRect.top) * this.dragTransform.yScale + 'px';
357
- };
358
- /** @internal */
359
- DDDraggable.prototype._setupHelperContainmentStyle = function () {
360
- this.helperContainment = this.helper.parentElement;
361
- if (this.helper.style.position !== 'fixed') {
362
- this.parentOriginStylePosition = this.helperContainment.style.position;
363
- if (getComputedStyle(this.helperContainment).position.match(/static/)) {
364
- this.helperContainment.style.position = 'relative';
365
- }
366
- }
367
- return this;
368
- };
369
- /** @internal */
370
- DDDraggable.prototype._getDragOffset = function (event, el, parent) {
371
- // in case ancestor has transform/perspective css properties that change the viewpoint
372
- var xformOffsetX = 0;
373
- var xformOffsetY = 0;
374
- if (parent) {
375
- xformOffsetX = this.dragTransform.xOffset;
376
- xformOffsetY = this.dragTransform.yOffset;
377
- }
378
- var targetOffset = el.getBoundingClientRect();
379
- return {
380
- left: targetOffset.left,
381
- top: targetOffset.top,
382
- offsetLeft: -event.clientX + targetOffset.left - xformOffsetX,
383
- offsetTop: -event.clientY + targetOffset.top - xformOffsetY,
384
- width: targetOffset.width * this.dragTransform.xScale,
385
- height: targetOffset.height * this.dragTransform.yScale
386
- };
387
- };
388
- /** @internal TODO: set to public as called by DDDroppable! */
389
- DDDraggable.prototype.ui = function () {
390
- var containmentEl = this.el.parentElement;
391
- var containmentRect = containmentEl.getBoundingClientRect();
392
- var offset = this.helper.getBoundingClientRect();
393
- return {
394
- position: {
395
- top: (offset.top - containmentRect.top) * this.dragTransform.yScale,
396
- left: (offset.left - containmentRect.left) * this.dragTransform.xScale
397
- }
398
- /* not used by GridStack for now...
399
- helper: [this.helper], //The object arr representing the helper that's being dragged.
400
- offset: { top: offset.top, left: offset.left } // Current offset position of the helper as { top, left } object.
401
- */
402
- };
403
- };
404
- /** @internal properties we change during dragging, and restore back */
405
- DDDraggable.originStyleProp = ['width', 'height', 'transform', 'transform-origin', 'transition', 'pointerEvents', 'position', 'left', 'top', 'minWidth', 'willChange'];
406
- return DDDraggable;
407
- }(dd_base_impl_1.DDBaseImplement));
408
- //# sourceMappingURL=dd-draggable.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dd-draggable.js","sourceRoot":"","sources":["../../src/dd-draggable.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,2CAAyC;AACzC,iCAA+C;AAC/C,+CAAuE;AAGvE,uCAAmF;AAkBnF,uEAAuE;AACvE,IAAM,aAAa,GAAG,mFAAmF,CAAC;AAE1G,yBAAyB;AAEzB;IAAiC,+BAAe;IA+B9C,qBAAmB,EAAuB,EAAS,MAAsB;QAAtB,uBAAA,EAAA,WAAsB;QAAzE,iBAgBC;;gBAfC,iBAAO;QADU,QAAE,GAAF,EAAE,CAAqB;QAAS,YAAM,GAAN,MAAM,CAAgB;QARzE,gBAAgB;QACN,mBAAa,GAAkB;YACvC,MAAM,EAAE,CAAC;YACT,MAAM,EAAE,CAAC;YACT,OAAO,EAAE,CAAC;YACV,OAAO,EAAE,CAAC;SACX,CAAC;QAKA,6DAA6D;QAC7D,IAAM,UAAU,GAAG,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,0CAAE,SAAS,CAAC,CAAC,CAAC,CAAC;QAChD,IAAM,CAAC,GAAG,EAAE,CAAC,aAAa,CAAC;QAC3B,KAAI,CAAC,OAAO,GAAG,CAAC,UAAU,IAAI,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,OAAO,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,gBAAgB,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,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC;QAC5C,IAAM,eAAe,GAAG,aAAa,CAAC,qBAAqB,EAAE,CAAC;QAC9D,IAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,qBAAqB,EAAE,CAAC;QACnD,OAAO;YACL,QAAQ,EAAE;gBACR,GAAG,EAAE,CAAC,MAAM,CAAC,GAAG,GAAG,eAAe,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM;gBACnE,IAAI,EAAE,CAAC,MAAM,CAAC,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM;aACvE;YACD;;;cAGE;SACH,CAAC;IACJ,CAAC;IAxWD,uEAAuE;IACtD,2BAAe,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,kBAAkB,EAAE,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,YAAY,CAAC,AAA3I,CAA4I;IAwW9K,kBAAC;CAAA,AA5XD,CAAiC,8BAAe,GA4X/C","sourcesContent":["/**\n * dd-draggable.ts 12.0.0\n * Copyright (c) 2021-2024 Alain Dumesny - see GridStack root license\n */\n\nimport { DDManager } from './dd-manager';\nimport { DragTransform, Utils } from './utils';\nimport { DDBaseImplement, HTMLElementExtendOpt } from './dd-base-impl';\nimport { GridItemHTMLElement, DDUIData, GridStackNode, GridStackPosition, DDDragOpt } from './types';\nimport { DDElementHost } from './dd-element';\nimport { isTouch, touchend, touchmove, touchstart, pointerdown } from './dd-touch';\nimport { GridHTMLElement } from './gridstack';\n\ninterface DragOffset {\n left: number;\n top: number;\n width: number;\n height: number;\n offsetLeft: number;\n offsetTop: number;\n}\n\ninterface GridStackNodeRotate extends GridStackNode {\n _origRotate?: GridStackPosition;\n}\n\ntype DDDragEvent = 'drag' | 'dragstart' | 'dragstop';\n\n// make sure we are not clicking on known object that handles mouseDown\nconst skipMouseDown = 'input,textarea,button,select,option,[contenteditable=\"true\"],.ui-resizable-handle';\n\n// let count = 0; // TEST\n\nexport class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt<DDDragOpt> {\n public helper: HTMLElement; // used by GridStackDDNative\n\n /** @internal */\n protected mouseDownEvent: MouseEvent;\n /** @internal */\n protected dragOffset: DragOffset;\n /** @internal */\n protected dragElementOriginStyle: Array<string>;\n /** @internal */\n protected dragEls: HTMLElement[];\n /** @internal true while we are dragging an item around */\n protected dragging: boolean;\n /** @internal last drag event */\n protected lastDrag: DragEvent;\n /** @internal */\n protected parentOriginStylePosition: string;\n /** @internal */\n protected helperContainment: HTMLElement;\n /** @internal properties we change during dragging, and restore back */\n protected static originStyleProp = ['width', 'height', 'transform', 'transform-origin', 'transition', 'pointerEvents', 'position', 'left', 'top', 'minWidth', 'willChange'];\n /** @internal pause before we call the actual drag hit collision code */\n protected dragTimeout: number;\n /** @internal */\n protected dragTransform: DragTransform = {\n xScale: 1,\n yScale: 1,\n xOffset: 0,\n yOffset: 0\n };\n\n constructor(public el: GridItemHTMLElement, public option: DDDragOpt = {}) {\n super();\n\n // get the element that is actually supposed to be dragged by\n const handleName = option?.handle?.substring(1);\n const n = el.gridstackNode;\n this.dragEls = !handleName || el.classList.contains(handleName) ? [el] : (n?.subGrid ? [el.querySelector(option.handle) || el] : Array.from(el.querySelectorAll(option.handle)));\n if (this.dragEls.length === 0) {\n this.dragEls = [el];\n }\n // create var event binding so we can easily remove and still look like TS methods (unlike anonymous functions)\n this._mouseDown = this._mouseDown.bind(this);\n this._mouseMove = this._mouseMove.bind(this);\n this._mouseUp = this._mouseUp.bind(this);\n this._keyEvent = this._keyEvent.bind(this);\n this.enable();\n }\n\n public on(event: DDDragEvent, callback: (event: DragEvent) => void): void {\n super.on(event, callback);\n }\n\n public off(event: DDDragEvent): void {\n super.off(event);\n }\n\n public enable(): void {\n if (this.disabled === false) return;\n super.enable();\n this.dragEls.forEach(dragEl => {\n dragEl.addEventListener('mousedown', this._mouseDown);\n if (isTouch) {\n dragEl.addEventListener('touchstart', touchstart);\n dragEl.addEventListener('pointerdown', pointerdown);\n // dragEl.style.touchAction = 'none'; // not needed unlike pointerdown doc comment\n }\n });\n this.el.classList.remove('ui-draggable-disabled');\n }\n\n public disable(forDestroy = false): void {\n if (this.disabled === true) return;\n super.disable();\n this.dragEls.forEach(dragEl => {\n dragEl.removeEventListener('mousedown', this._mouseDown);\n if (isTouch) {\n dragEl.removeEventListener('touchstart', touchstart);\n dragEl.removeEventListener('pointerdown', pointerdown);\n }\n });\n if (!forDestroy) this.el.classList.add('ui-draggable-disabled');\n }\n\n public destroy(): void {\n if (this.dragTimeout) window.clearTimeout(this.dragTimeout);\n delete this.dragTimeout;\n if (this.mouseDownEvent) this._mouseUp(this.mouseDownEvent);\n this.disable(true);\n delete this.el;\n delete this.helper;\n delete this.option;\n super.destroy();\n }\n\n public updateOption(opts: DDDragOpt): DDDraggable {\n Object.keys(opts).forEach(key => this.option[key] = opts[key]);\n return this;\n }\n\n /** @internal call when mouse goes down before a dragstart happens */\n protected _mouseDown(e: MouseEvent): boolean {\n // don't let more than one widget handle mouseStart\n if (DDManager.mouseHandled) return;\n if (e.button !== 0) return true; // only left click\n\n // make sure we are not clicking on known object that handles mouseDown, or ones supplied by the user\n if (!this.dragEls.find(el => el === e.target) && (e.target as HTMLElement).closest(skipMouseDown)) return true;\n if (this.option.cancel) {\n if ((e.target as HTMLElement).closest(this.option.cancel)) return true;\n }\n\n this.mouseDownEvent = e;\n delete this.dragging;\n delete DDManager.dragElement;\n delete DDManager.dropElement;\n // document handler so we can continue receiving moves as the item is 'fixed' position, and capture=true so WE get a first crack\n document.addEventListener('mousemove', this._mouseMove, { capture: true, passive: true }); // true=capture, not bubble\n document.addEventListener('mouseup', this._mouseUp, true);\n if (isTouch) {\n e.currentTarget.addEventListener('touchmove', touchmove);\n e.currentTarget.addEventListener('touchend', touchend);\n }\n\n e.preventDefault();\n // preventDefault() prevents blur event which occurs just after mousedown event.\n // if an editable content has focus, then blur must be call\n if (document.activeElement) (document.activeElement as HTMLElement).blur();\n\n DDManager.mouseHandled = true;\n return true;\n }\n\n /** @internal method to call actual drag event */\n protected _callDrag(e: DragEvent): void {\n if (!this.dragging) return;\n const ev = Utils.initEvent<DragEvent>(e, { target: this.el, type: 'drag' });\n if (this.option.drag) {\n this.option.drag(ev, this.ui());\n }\n this.triggerEvent('drag', ev);\n }\n\n /** @internal called when the main page (after successful mousedown) receives a move event to drag the item around the screen */\n protected _mouseMove(e: DragEvent): boolean {\n // console.log(`${count++} move ${e.x},${e.y}`)\n const s = this.mouseDownEvent;\n this.lastDrag = e;\n\n if (this.dragging) {\n this._dragFollow(e);\n // delay actual grid handling drag until we pause for a while if set\n if (DDManager.pauseDrag) {\n const pause = Number.isInteger(DDManager.pauseDrag) ? DDManager.pauseDrag as number : 100;\n if (this.dragTimeout) window.clearTimeout(this.dragTimeout);\n this.dragTimeout = window.setTimeout(() => this._callDrag(e), pause);\n } else {\n this._callDrag(e);\n }\n } else if (Math.abs(e.x - s.x) + Math.abs(e.y - s.y) > 3) {\n /**\n * don't start unless we've moved at least 3 pixels\n */\n this.dragging = true;\n DDManager.dragElement = this;\n // if we're dragging an actual grid item, set the current drop as the grid (to detect enter/leave)\n const grid = this.el.gridstackNode?.grid;\n if (grid) {\n DDManager.dropElement = (grid.el as DDElementHost).ddElement.ddDroppable;\n } else {\n delete DDManager.dropElement;\n }\n this.helper = this._createHelper();\n this._setupHelperContainmentStyle();\n this.dragTransform = Utils.getValuesFromTransformedElement(this.helperContainment);\n this.dragOffset = this._getDragOffset(e, this.el, this.helperContainment);\n this._setupHelperStyle(e);\n\n const ev = Utils.initEvent<DragEvent>(e, { target: this.el, type: 'dragstart' });\n if (this.option.start) {\n this.option.start(ev, this.ui());\n }\n this.triggerEvent('dragstart', ev);\n // now track keyboard events to cancel or rotate\n document.addEventListener('keydown', this._keyEvent);\n }\n // e.preventDefault(); // passive = true. OLD: was needed otherwise we get text sweep text selection as we drag around\n return true;\n }\n\n /** @internal call when the mouse gets released to drop the item at current location */\n protected _mouseUp(e: MouseEvent): void {\n document.removeEventListener('mousemove', this._mouseMove, true);\n document.removeEventListener('mouseup', this._mouseUp, true);\n if (isTouch && e.currentTarget) { // destroy() during nested grid call us again wit fake _mouseUp\n e.currentTarget.removeEventListener('touchmove', touchmove, true);\n e.currentTarget.removeEventListener('touchend', touchend, true);\n }\n if (this.dragging) {\n delete this.dragging;\n delete (this.el.gridstackNode as GridStackNodeRotate)?._origRotate;\n document.removeEventListener('keydown', this._keyEvent);\n\n // reset the drop target if dragging over ourself (already parented, just moving during stop callback below)\n if (DDManager.dropElement?.el === this.el.parentElement) {\n delete DDManager.dropElement;\n }\n\n this.helperContainment.style.position = this.parentOriginStylePosition || null;\n if (this.helper !== this.el) this.helper.remove(); // hide now\n this._removeHelperStyle();\n\n const ev = Utils.initEvent<DragEvent>(e, { target: this.el, type: 'dragstop' });\n if (this.option.stop) {\n this.option.stop(ev); // NOTE: destroy() will be called when removing item, so expect NULL ptr after!\n }\n this.triggerEvent('dragstop', ev);\n\n // call the droppable method to receive the item\n if (DDManager.dropElement) {\n DDManager.dropElement.drop(e);\n }\n }\n delete this.helper;\n delete this.mouseDownEvent;\n delete DDManager.dragElement;\n delete DDManager.dropElement;\n delete DDManager.mouseHandled;\n e.preventDefault();\n }\n\n /** @internal call when keys are being pressed - use Esc to cancel, R to rotate */\n protected _keyEvent(e: KeyboardEvent): void {\n const n = this.el.gridstackNode as GridStackNodeRotate;\n const grid = n?.grid || (DDManager.dropElement?.el as GridHTMLElement)?.gridstack;\n\n if (e.key === 'Escape') {\n if (n && n._origRotate) {\n n._orig = n._origRotate;\n delete n._origRotate;\n }\n grid?.cancelDrag();\n this._mouseUp(this.mouseDownEvent);\n } else if (n && grid && (e.key === 'r' || e.key === 'R')) {\n if (!Utils.canBeRotated(n)) return;\n n._origRotate = n._origRotate || { ...n._orig }; // store the real orig size in case we Esc after doing rotation\n delete n._moving; // force rotate to happen (move waits for >50% coverage otherwise)\n grid.setAnimation(false) // immediate rotate so _getDragOffset() gets the right dom size below\n .rotate(n.el, { top: -this.dragOffset.offsetTop, left: -this.dragOffset.offsetLeft })\n .setAnimation();\n n._moving = true;\n this.dragOffset = this._getDragOffset(this.lastDrag, n.el, this.helperContainment);\n this.helper.style.width = this.dragOffset.width + 'px';\n this.helper.style.height = this.dragOffset.height + 'px';\n Utils.swap(n._orig, 'w', 'h');\n delete n._rect;\n this._mouseMove(this.lastDrag);\n }\n }\n\n /** @internal create a clone copy (or user defined method) of the original drag item if set */\n protected _createHelper(): HTMLElement {\n let helper = this.el;\n if (typeof this.option.helper === 'function') {\n helper = this.option.helper(this.el);\n } else if (this.option.helper === 'clone') {\n helper = Utils.cloneNode(this.el);\n }\n if (!helper.parentElement) {\n Utils.appendTo(helper, this.option.appendTo === 'parent' ? this.el.parentElement : this.option.appendTo);\n }\n this.dragElementOriginStyle = DDDraggable.originStyleProp.map(prop => this.el.style[prop]);\n return helper;\n }\n\n /** @internal set the fix position of the dragged item */\n protected _setupHelperStyle(e: DragEvent): DDDraggable {\n this.helper.classList.add('ui-draggable-dragging');\n // TODO: set all at once with style.cssText += ... ? https://stackoverflow.com/questions/3968593\n const style = this.helper.style;\n style.pointerEvents = 'none'; // needed for over items to get enter/leave\n // style.cursor = 'move'; // TODO: can't set with pointerEvents=none ! (done in CSS as well)\n style.width = this.dragOffset.width + 'px';\n style.height = this.dragOffset.height + 'px';\n style.willChange = 'left, top';\n style.position = 'fixed'; // let us drag between grids by not clipping as parent .grid-stack is position: 'relative'\n this._dragFollow(e); // now position it\n style.transition = 'none'; // show up instantly\n setTimeout(() => {\n if (this.helper) {\n style.transition = null; // recover animation\n }\n }, 0);\n return this;\n }\n\n /** @internal restore back the original style before dragging */\n protected _removeHelperStyle(): DDDraggable {\n this.helper.classList.remove('ui-draggable-dragging');\n const node = (this.helper as GridItemHTMLElement)?.gridstackNode;\n // don't bother restoring styles if we're gonna remove anyway...\n if (!node?._isAboutToRemove && this.dragElementOriginStyle) {\n const helper = this.helper;\n // don't animate, otherwise we animate offseted when switching back to 'absolute' from 'fixed'.\n // TODO: this also removes resizing animation which doesn't have this issue, but others.\n // Ideally both would animate ('move' would immediately restore 'absolute' and adjust coordinate to match,\n // then trigger a delay (repaint) to restore to final dest with animate) but then we need to make sure 'resizestop'\n // is called AFTER 'transitionend' event is received (see https://github.com/gridstack/gridstack.js/issues/2033)\n const transition = this.dragElementOriginStyle['transition'] || null;\n helper.style.transition = this.dragElementOriginStyle['transition'] = 'none'; // can't be NULL #1973\n DDDraggable.originStyleProp.forEach(prop => helper.style[prop] = this.dragElementOriginStyle[prop] || null);\n setTimeout(() => helper.style.transition = transition, 50); // recover animation from saved vars after a pause (0 isn't enough #1973)\n }\n delete this.dragElementOriginStyle;\n return this;\n }\n\n /** @internal updates the top/left position to follow the mouse */\n protected _dragFollow(e: DragEvent): void {\n const containmentRect = { left: 0, top: 0 };\n // if (this.helper.style.position === 'absolute') { // we use 'fixed'\n // const { left, top } = this.helperContainment.getBoundingClientRect();\n // containmentRect = { left, top };\n // }\n const style = this.helper.style;\n const offset = this.dragOffset;\n style.left = (e.clientX + offset.offsetLeft - containmentRect.left) * this.dragTransform.xScale + 'px';\n style.top = (e.clientY + offset.offsetTop - containmentRect.top) * this.dragTransform.yScale + 'px';\n }\n\n /** @internal */\n protected _setupHelperContainmentStyle(): DDDraggable {\n this.helperContainment = this.helper.parentElement;\n if (this.helper.style.position !== 'fixed') {\n this.parentOriginStylePosition = this.helperContainment.style.position;\n if (getComputedStyle(this.helperContainment).position.match(/static/)) {\n this.helperContainment.style.position = 'relative';\n }\n }\n return this;\n }\n\n /** @internal */\n protected _getDragOffset(event: DragEvent, el: HTMLElement, parent: HTMLElement): DragOffset {\n\n // in case ancestor has transform/perspective css properties that change the viewpoint\n let xformOffsetX = 0;\n let xformOffsetY = 0;\n if (parent) {\n xformOffsetX = this.dragTransform.xOffset;\n xformOffsetY = this.dragTransform.yOffset;\n }\n\n const targetOffset = el.getBoundingClientRect();\n return {\n left: targetOffset.left,\n top: targetOffset.top,\n offsetLeft: - event.clientX + targetOffset.left - xformOffsetX,\n offsetTop: - event.clientY + targetOffset.top - xformOffsetY,\n width: targetOffset.width * this.dragTransform.xScale,\n height: targetOffset.height * this.dragTransform.yScale\n };\n }\n\n /** @internal TODO: set to public as called by DDDroppable! */\n public ui(): DDUIData {\n const containmentEl = this.el.parentElement;\n const containmentRect = containmentEl.getBoundingClientRect();\n const offset = this.helper.getBoundingClientRect();\n return {\n position: { //Current CSS position of the helper as { top, left } object\n top: (offset.top - containmentRect.top) * this.dragTransform.yScale,\n left: (offset.left - containmentRect.left) * this.dragTransform.xScale\n }\n /* not used by GridStack for now...\n helper: [this.helper], //The object arr representing the helper that's being dragged.\n offset: { top: offset.top, left: offset.left } // Current offset position of the helper as { top, left } object.\n */\n };\n }\n}\n"]}
@@ -1,26 +0,0 @@
1
- /**
2
- * dd-droppable.ts 12.0.0
3
- * Copyright (c) 2021-2024 Alain Dumesny - see GridStack root license
4
- */
5
- import { DDBaseImplement, HTMLElementExtendOpt } from './dd-base-impl';
6
- import { DDUIData } from './types';
7
- export interface DDDroppableOpt {
8
- accept?: string | ((el: HTMLElement) => boolean);
9
- drop?: (event: DragEvent, ui: DDUIData) => void;
10
- over?: (event: DragEvent, ui: DDUIData) => void;
11
- out?: (event: DragEvent, ui: DDUIData) => void;
12
- }
13
- export declare class DDDroppable extends DDBaseImplement implements HTMLElementExtendOpt<DDDroppableOpt> {
14
- el: HTMLElement;
15
- option: DDDroppableOpt;
16
- accept: (el: HTMLElement) => boolean;
17
- constructor(el: HTMLElement, option?: DDDroppableOpt);
18
- on(event: 'drop' | 'dropover' | 'dropout', callback: (event: DragEvent) => void): void;
19
- off(event: 'drop' | 'dropover' | 'dropout'): void;
20
- enable(): void;
21
- disable(forDestroy?: boolean): void;
22
- destroy(): void;
23
- updateOption(opts: DDDroppableOpt): DDDroppable;
24
- /** item is being dropped on us - called by the drag mouseup handler - this calls the client drop event */
25
- drop(e: MouseEvent): void;
26
- }