gridstack 10.3.0 → 11.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -3
- package/dist/angular/README.md +47 -25
- package/dist/angular/{esm2020 → esm2022}/gridstack-angular.mjs +5 -5
- package/dist/angular/esm2022/index.mjs +8 -0
- package/dist/angular/esm2022/lib/base-widget.mjs +34 -0
- package/dist/angular/esm2022/lib/gridstack-item.component.mjs +72 -0
- package/dist/angular/esm2022/lib/gridstack.component.mjs +300 -0
- package/dist/angular/esm2022/lib/gridstack.module.mjs +39 -0
- package/dist/angular/{fesm2020 → fesm2022}/gridstack-angular.mjs +400 -369
- package/dist/angular/fesm2022/gridstack-angular.mjs.map +1 -0
- package/dist/angular/index.d.ts +4 -5
- package/dist/angular/lib/base-widget.d.ts +18 -16
- package/dist/angular/lib/gridstack-item.component.d.ts +37 -37
- package/dist/angular/lib/gridstack.component.d.ts +135 -129
- package/dist/angular/lib/gridstack.module.d.ts +10 -10
- package/dist/angular/src/base-widget.ts +36 -0
- package/dist/angular/src/gridstack-item.component.ts +82 -0
- package/dist/angular/src/gridstack.component.ts +312 -0
- package/dist/angular/src/gridstack.module.ts +32 -0
- package/dist/dd-base-impl.d.ts +2 -2
- package/dist/dd-base-impl.js +2 -2
- package/dist/dd-base-impl.js.map +1 -1
- package/dist/dd-draggable.d.ts +7 -16
- package/dist/dd-draggable.js +23 -34
- package/dist/dd-draggable.js.map +1 -1
- package/dist/dd-droppable.d.ts +2 -2
- package/dist/dd-droppable.js +2 -2
- package/dist/dd-droppable.js.map +1 -1
- package/dist/dd-element.d.ts +5 -5
- package/dist/dd-element.js +2 -2
- package/dist/dd-element.js.map +1 -1
- package/dist/dd-gridstack.d.ts +5 -5
- package/dist/dd-gridstack.js +8 -8
- package/dist/dd-gridstack.js.map +1 -1
- package/dist/dd-manager.d.ts +2 -2
- package/dist/dd-manager.js +2 -2
- package/dist/dd-manager.js.map +1 -1
- package/dist/dd-resizable-handle.d.ts +2 -2
- package/dist/dd-resizable-handle.js +3 -3
- package/dist/dd-resizable-handle.js.map +1 -1
- package/dist/dd-resizable.d.ts +4 -2
- package/dist/dd-resizable.js +15 -10
- package/dist/dd-resizable.js.map +1 -1
- package/dist/dd-touch.d.ts +2 -2
- package/dist/dd-touch.js +2 -2
- package/dist/dd-touch.js.map +1 -1
- package/dist/es5/dd-base-impl.d.ts +2 -2
- package/dist/es5/dd-base-impl.js +2 -2
- package/dist/es5/dd-base-impl.js.map +1 -1
- package/dist/es5/dd-draggable.d.ts +7 -16
- package/dist/es5/dd-draggable.js +20 -29
- package/dist/es5/dd-draggable.js.map +1 -1
- package/dist/es5/dd-droppable.d.ts +2 -2
- package/dist/es5/dd-droppable.js +2 -2
- package/dist/es5/dd-droppable.js.map +1 -1
- package/dist/es5/dd-element.d.ts +5 -5
- package/dist/es5/dd-element.js +2 -2
- package/dist/es5/dd-element.js.map +1 -1
- package/dist/es5/dd-gridstack.d.ts +5 -5
- package/dist/es5/dd-gridstack.js +9 -6
- package/dist/es5/dd-gridstack.js.map +1 -1
- package/dist/es5/dd-manager.d.ts +2 -2
- package/dist/es5/dd-manager.js +2 -2
- package/dist/es5/dd-manager.js.map +1 -1
- package/dist/es5/dd-resizable-handle.d.ts +2 -2
- package/dist/es5/dd-resizable-handle.js +2 -2
- package/dist/es5/dd-resizable-handle.js.map +1 -1
- package/dist/es5/dd-resizable.d.ts +4 -2
- package/dist/es5/dd-resizable.js +13 -8
- package/dist/es5/dd-resizable.js.map +1 -1
- package/dist/es5/dd-touch.d.ts +2 -2
- package/dist/es5/dd-touch.js +2 -2
- package/dist/es5/dd-touch.js.map +1 -1
- package/dist/es5/gridstack-all.js +1 -1
- package/dist/es5/gridstack-all.js.LICENSE.txt +2 -2
- package/dist/es5/gridstack-all.js.map +1 -1
- package/dist/es5/gridstack-engine.d.ts +2 -2
- package/dist/es5/gridstack-engine.js +5 -5
- package/dist/es5/gridstack-engine.js.map +1 -1
- package/dist/es5/gridstack-poly.js +2 -2
- package/dist/es5/gridstack.d.ts +22 -17
- package/dist/es5/gridstack.js +170 -142
- package/dist/es5/gridstack.js.map +1 -1
- package/dist/es5/types.d.ts +16 -8
- package/dist/es5/types.js +3 -10
- package/dist/es5/types.js.map +1 -1
- package/dist/es5/utils.d.ts +6 -2
- package/dist/es5/utils.js +43 -8
- package/dist/es5/utils.js.map +1 -1
- package/dist/gridstack-all.js +1 -1
- package/dist/gridstack-all.js.LICENSE.txt +2 -2
- package/dist/gridstack-all.js.map +1 -1
- package/dist/gridstack-engine.d.ts +2 -2
- package/dist/gridstack-engine.js +61 -61
- package/dist/gridstack-engine.js.map +1 -1
- package/dist/gridstack-extra.css +1 -1
- package/dist/gridstack.css +2 -2
- package/dist/gridstack.d.ts +22 -17
- package/dist/gridstack.js +255 -227
- package/dist/gridstack.js.map +1 -1
- package/dist/src/gridstack-extra.scss +25 -0
- package/dist/src/gridstack.scss +157 -0
- package/dist/types.d.ts +16 -8
- package/dist/types.js +2 -9
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +6 -2
- package/dist/utils.js +57 -25
- package/dist/utils.js.map +1 -1
- package/doc/CHANGES.md +16 -0
- package/doc/README.md +18 -23
- package/package.json +3 -2
- package/.github/FUNDING.yml +0 -12
- package/angular/.editorconfig +0 -16
- package/angular/.vscode/extensions.json +0 -4
- package/angular/.vscode/launch.json +0 -20
- package/angular/.vscode/tasks.json +0 -42
- package/angular/README.md +0 -170
- package/angular/README_build.md +0 -27
- package/angular/angular.json +0 -135
- package/angular/package.json +0 -40
- package/angular/projects/lib/README.md +0 -24
- package/angular/projects/lib/ng-package.json +0 -7
- package/angular/projects/lib/package.json +0 -11
- package/angular/projects/lib/tsconfig.lib.json +0 -15
- package/angular/projects/lib/tsconfig.lib.prod.json +0 -10
- package/angular/projects/lib/tsconfig.spec.json +0 -17
- package/dist/angular/esm2020/lib/base-widget.mjs +0 -30
- package/dist/angular/esm2020/lib/gridstack-item.component.mjs +0 -68
- package/dist/angular/esm2020/lib/gridstack.component.mjs +0 -280
- package/dist/angular/esm2020/lib/gridstack.module.mjs +0 -39
- package/dist/angular/esm2020/public-api.mjs +0 -8
- package/dist/angular/fesm2015/gridstack-angular.mjs +0 -420
- package/dist/angular/fesm2015/gridstack-angular.mjs.map +0 -1
- package/dist/angular/fesm2020/gridstack-angular.mjs.map +0 -1
- package/dist/angular/package.json +0 -31
- package/dist/angular/public-api.d.ts +0 -4
package/dist/es5/gridstack.js
CHANGED
|
@@ -36,10 +36,10 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
36
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
37
|
exports.GridStack = void 0;
|
|
38
38
|
/*!
|
|
39
|
-
* GridStack
|
|
39
|
+
* GridStack 11.0.0
|
|
40
40
|
* https://gridstackjs.com/
|
|
41
41
|
*
|
|
42
|
-
* Copyright (c) 2021-
|
|
42
|
+
* Copyright (c) 2021-2024 Alain Dumesny
|
|
43
43
|
* see root license https://github.com/gridstack/gridstack.js/tree/master/LICENSE
|
|
44
44
|
*/
|
|
45
45
|
var gridstack_engine_1 = require("./gridstack-engine");
|
|
@@ -79,7 +79,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
79
79
|
function GridStack(el, opts) {
|
|
80
80
|
if (opts === void 0) { opts = {}; }
|
|
81
81
|
var _this = this;
|
|
82
|
-
var _a, _b, _c
|
|
82
|
+
var _a, _b, _c;
|
|
83
83
|
this.el = el;
|
|
84
84
|
this.opts = opts;
|
|
85
85
|
/** @internal */
|
|
@@ -164,13 +164,13 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
164
164
|
this.el.classList.add('grid-stack-rtl');
|
|
165
165
|
}
|
|
166
166
|
// check if we're been nested, and if so update our style and keep pointer around (used during save)
|
|
167
|
-
var
|
|
168
|
-
var
|
|
169
|
-
if (
|
|
170
|
-
|
|
171
|
-
this.
|
|
167
|
+
var parentGridItem = this.el.closest('.' + types_1.gridDefaults.itemClass);
|
|
168
|
+
var parentNode = parentGridItem === null || parentGridItem === void 0 ? void 0 : parentGridItem.gridstackNode;
|
|
169
|
+
if (parentNode) {
|
|
170
|
+
parentNode.subGrid = this;
|
|
171
|
+
this.parentGridNode = parentNode;
|
|
172
172
|
this.el.classList.add('grid-stack-nested');
|
|
173
|
-
|
|
173
|
+
parentNode.el.classList.add('grid-stack-sub-grid');
|
|
174
174
|
}
|
|
175
175
|
this._isAutoCellHeight = (opts.cellHeight === 'auto');
|
|
176
176
|
if (this._isAutoCellHeight || opts.cellHeight === 'initial') {
|
|
@@ -237,7 +237,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
237
237
|
// dynamic grids require pausing during drag to detect over to nest vs push
|
|
238
238
|
if (opts.subGridDynamic && !dd_manager_1.DDManager.pauseDrag)
|
|
239
239
|
dd_manager_1.DDManager.pauseDrag = true;
|
|
240
|
-
if (((
|
|
240
|
+
if (((_c = opts.draggable) === null || _c === void 0 ? void 0 : _c.pause) !== undefined)
|
|
241
241
|
dd_manager_1.DDManager.pauseDrag = opts.draggable.pause;
|
|
242
242
|
this._setupRemoveDrop();
|
|
243
243
|
this._setupAcceptWidget();
|
|
@@ -251,10 +251,10 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
251
251
|
* @param elOrString element or CSS selector (first one used) to convert to a grid (default to '.grid-stack' class selector)
|
|
252
252
|
*
|
|
253
253
|
* @example
|
|
254
|
-
*
|
|
254
|
+
* const grid = GridStack.init();
|
|
255
255
|
*
|
|
256
256
|
* Note: the HTMLElement (of type GridHTMLElement) will store a `gridstack: GridStack` value that can be retrieve later
|
|
257
|
-
*
|
|
257
|
+
* const grid = document.querySelector('.grid-stack').gridstack;
|
|
258
258
|
*/
|
|
259
259
|
GridStack.init = function (options, elOrString) {
|
|
260
260
|
if (options === void 0) { options = {}; }
|
|
@@ -283,7 +283,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
283
283
|
* @param selector elements selector to convert to grids (default to '.grid-stack' class selector)
|
|
284
284
|
*
|
|
285
285
|
* @example
|
|
286
|
-
*
|
|
286
|
+
* const grids = GridStack.initAll();
|
|
287
287
|
* grids.forEach(...)
|
|
288
288
|
*/
|
|
289
289
|
GridStack.initAll = function (options, selector) {
|
|
@@ -332,10 +332,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
332
332
|
el = GridStack.addRemoveCB(parent, opt, true, true);
|
|
333
333
|
}
|
|
334
334
|
else {
|
|
335
|
-
|
|
336
|
-
doc.body.innerHTML = "<div class=\"grid-stack ".concat(opt.class || '', "\"></div>");
|
|
337
|
-
el = doc.body.children[0];
|
|
338
|
-
parent.appendChild(el);
|
|
335
|
+
el = utils_1.Utils.createDiv(['grid-stack', opt.class], parent);
|
|
339
336
|
}
|
|
340
337
|
}
|
|
341
338
|
// create grid class and load any children
|
|
@@ -356,7 +353,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
356
353
|
var placeholderChild = document.createElement('div'); // child so padding match item-content
|
|
357
354
|
placeholderChild.className = 'placeholder-content';
|
|
358
355
|
if (this.opts.placeholderText) {
|
|
359
|
-
placeholderChild.
|
|
356
|
+
placeholderChild.textContent = this.opts.placeholderText;
|
|
360
357
|
}
|
|
361
358
|
this._placeholder = document.createElement('div');
|
|
362
359
|
this._placeholder.classList.add(this.opts.placeholderClass, types_1.gridDefaults.itemClass, this.opts.itemClass);
|
|
@@ -372,44 +369,35 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
372
369
|
*
|
|
373
370
|
* Widget will be always placed even if result height is more than actual grid height.
|
|
374
371
|
* You need to use `willItFit()` before calling addWidget for additional check.
|
|
375
|
-
* See also `makeWidget()
|
|
372
|
+
* See also `makeWidget(el)` for DOM element.
|
|
376
373
|
*
|
|
377
374
|
* @example
|
|
378
|
-
*
|
|
375
|
+
* const grid = GridStack.init();
|
|
379
376
|
* grid.addWidget({w: 3, content: 'hello'});
|
|
380
|
-
* grid.addWidget('<div class="grid-stack-item"><div class="grid-stack-item-content">hello</div></div>', {w: 3});
|
|
381
377
|
*
|
|
382
|
-
* @param
|
|
378
|
+
* @param w GridStackWidget definition. used MakeWidget(el) if you have dom element instead.
|
|
383
379
|
* @param options widget position/size options (optional, and ignore if first param is already option) - see GridStackWidget
|
|
384
380
|
*/
|
|
385
|
-
GridStack.prototype.addWidget = function (
|
|
386
|
-
|
|
387
|
-
|
|
381
|
+
GridStack.prototype.addWidget = function (w) {
|
|
382
|
+
if (typeof w === 'string') {
|
|
383
|
+
console.error('V11: GridStack.addWidget() does not support string anymore. see #2736');
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
if (w.ELEMENT_NODE) {
|
|
387
|
+
console.error('V11: GridStack.addWidget() does not support HTMLElement anymore. use makeWidget()');
|
|
388
|
+
return this.makeWidget(w);
|
|
388
389
|
}
|
|
389
390
|
var el;
|
|
390
|
-
var node;
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
el = doc.body.children[0];
|
|
391
|
+
var node = w;
|
|
392
|
+
node.grid = this;
|
|
393
|
+
if (node === null || node === void 0 ? void 0 : node.el) {
|
|
394
|
+
el = node.el; // re-use element stored in the node
|
|
395
395
|
}
|
|
396
|
-
else if (
|
|
397
|
-
|
|
398
|
-
if (node === null || node === void 0 ? void 0 : node.el) {
|
|
399
|
-
el = node.el; // re-use element stored in the node
|
|
400
|
-
}
|
|
401
|
-
else if (GridStack.addRemoveCB) {
|
|
402
|
-
el = GridStack.addRemoveCB(this.el, options, true, false);
|
|
403
|
-
}
|
|
404
|
-
else {
|
|
405
|
-
var content = (options === null || options === void 0 ? void 0 : options.content) || '';
|
|
406
|
-
var doc = document.implementation.createHTMLDocument(''); // IE needs a param
|
|
407
|
-
doc.body.innerHTML = "<div class=\"grid-stack-item ".concat(this.opts.itemClass || '', "\"><div class=\"grid-stack-item-content\">").concat(content, "</div></div>");
|
|
408
|
-
el = doc.body.children[0];
|
|
409
|
-
}
|
|
396
|
+
else if (GridStack.addRemoveCB) {
|
|
397
|
+
el = GridStack.addRemoveCB(this.el, w, true, false);
|
|
410
398
|
}
|
|
411
399
|
else {
|
|
412
|
-
el =
|
|
400
|
+
el = utils_1.Utils.createWidgetDivs(this.opts.itemClass, node);
|
|
413
401
|
}
|
|
414
402
|
if (!el)
|
|
415
403
|
return;
|
|
@@ -421,12 +409,11 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
421
409
|
// as the actual value are filled in when _prepareElement() calls el.getAttribute('gs-xyz') before adding the node.
|
|
422
410
|
// So make sure we load any DOM attributes that are not specified in passed in options (which override)
|
|
423
411
|
var domAttr = this._readAttr(el);
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
this._writeAttr(el, options);
|
|
412
|
+
utils_1.Utils.defaults(w, domAttr);
|
|
413
|
+
this.engine.prepareNode(w);
|
|
414
|
+
this._writeAttr(el, w);
|
|
428
415
|
this.el.appendChild(el);
|
|
429
|
-
this.makeWidget(el,
|
|
416
|
+
this.makeWidget(el, w);
|
|
430
417
|
return el;
|
|
431
418
|
};
|
|
432
419
|
/**
|
|
@@ -452,7 +439,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
452
439
|
var grid = this;
|
|
453
440
|
while (grid && !subGridTemplate) {
|
|
454
441
|
subGridTemplate = (_b = grid.opts) === null || _b === void 0 ? void 0 : _b.subGridOpts;
|
|
455
|
-
grid = (_c = grid.
|
|
442
|
+
grid = (_c = grid.parentGridNode) === null || _c === void 0 ? void 0 : _c.grid;
|
|
456
443
|
}
|
|
457
444
|
//... and set the create options
|
|
458
445
|
ops = utils_1.Utils.cloneDeep(__assign(__assign(__assign({}, (subGridTemplate || {})), { children: undefined }), (ops || node.subGridOpts || {})));
|
|
@@ -481,13 +468,9 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
481
468
|
newItem = GridStack.addRemoveCB(this.el, newItemOpt, true, false);
|
|
482
469
|
}
|
|
483
470
|
else {
|
|
484
|
-
|
|
485
|
-
doc.body.innerHTML = "<div class=\"grid-stack-item\"></div>";
|
|
486
|
-
newItem = doc.body.children[0];
|
|
471
|
+
newItem = utils_1.Utils.createDiv(['grid-stack-item']);
|
|
487
472
|
newItem.appendChild(content);
|
|
488
|
-
|
|
489
|
-
content = doc.body.children[0];
|
|
490
|
-
node.el.appendChild(content);
|
|
473
|
+
content = utils_1.Utils.createDiv(['grid-stack-item-content'], node.el);
|
|
491
474
|
}
|
|
492
475
|
this._prepareDragDropByNode(node); // ... and restore original D&D
|
|
493
476
|
}
|
|
@@ -507,7 +490,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
507
490
|
subGrid._autoColumn = true;
|
|
508
491
|
// add the original content back as a child of hte newly created grid
|
|
509
492
|
if (saveContent) {
|
|
510
|
-
subGrid.
|
|
493
|
+
subGrid.makeWidget(newItem, newItemOpt);
|
|
511
494
|
}
|
|
512
495
|
// now add any additional node
|
|
513
496
|
if (nodeToAdd) {
|
|
@@ -516,7 +499,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
516
499
|
window.setTimeout(function () { return utils_1.Utils.simulateMouseEvent(nodeToAdd._event, 'mouseenter', subGrid.el); }, 0);
|
|
517
500
|
}
|
|
518
501
|
else {
|
|
519
|
-
subGrid.
|
|
502
|
+
subGrid.makeWidget(node.el, node);
|
|
520
503
|
}
|
|
521
504
|
}
|
|
522
505
|
return subGrid;
|
|
@@ -528,21 +511,21 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
528
511
|
GridStack.prototype.removeAsSubGrid = function (nodeThatRemoved) {
|
|
529
512
|
var _this = this;
|
|
530
513
|
var _a;
|
|
531
|
-
var pGrid = (_a = this.
|
|
514
|
+
var pGrid = (_a = this.parentGridNode) === null || _a === void 0 ? void 0 : _a.grid;
|
|
532
515
|
if (!pGrid)
|
|
533
516
|
return;
|
|
534
517
|
pGrid.batchUpdate();
|
|
535
|
-
pGrid.removeWidget(this.
|
|
518
|
+
pGrid.removeWidget(this.parentGridNode.el, true, true);
|
|
536
519
|
this.engine.nodes.forEach(function (n) {
|
|
537
520
|
// migrate any children over and offsetting by our location
|
|
538
|
-
n.x += _this.
|
|
539
|
-
n.y += _this.
|
|
540
|
-
pGrid.
|
|
521
|
+
n.x += _this.parentGridNode.x;
|
|
522
|
+
n.y += _this.parentGridNode.y;
|
|
523
|
+
pGrid.makeWidget(n.el, n);
|
|
541
524
|
});
|
|
542
525
|
pGrid.batchUpdate(false);
|
|
543
|
-
if (this.
|
|
544
|
-
delete this.
|
|
545
|
-
delete this.
|
|
526
|
+
if (this.parentGridNode)
|
|
527
|
+
delete this.parentGridNode.subGrid;
|
|
528
|
+
delete this.parentGridNode;
|
|
546
529
|
// create an artificial event for the original grid now that this one is gone (got a leave, but won't get enter)
|
|
547
530
|
if (nodeThatRemoved) {
|
|
548
531
|
window.setTimeout(function () { return utils_1.Utils.simulateMouseEvent(nodeThatRemoved._event, 'mouseenter', pGrid.el); }, 0);
|
|
@@ -567,8 +550,8 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
567
550
|
list.forEach(function (n) {
|
|
568
551
|
var _a;
|
|
569
552
|
if (saveContent && n.el && !n.subGrid && !saveCB) { // sub-grid are saved differently, not plain content
|
|
570
|
-
var
|
|
571
|
-
n.content =
|
|
553
|
+
var itemContent = n.el.querySelector('.grid-stack-item-content');
|
|
554
|
+
n.content = itemContent === null || itemContent === void 0 ? void 0 : itemContent.innerHTML;
|
|
572
555
|
if (!n.content)
|
|
573
556
|
delete n.content;
|
|
574
557
|
}
|
|
@@ -934,9 +917,9 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
934
917
|
this.el.parentNode.removeChild(this.el);
|
|
935
918
|
}
|
|
936
919
|
this._removeStylesheet();
|
|
937
|
-
if (this.
|
|
938
|
-
delete this.
|
|
939
|
-
delete this.
|
|
920
|
+
if (this.parentGridNode)
|
|
921
|
+
delete this.parentGridNode.subGrid;
|
|
922
|
+
delete this.parentGridNode;
|
|
940
923
|
delete this.opts;
|
|
941
924
|
delete this._placeholder;
|
|
942
925
|
delete this.engine;
|
|
@@ -1010,7 +993,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
1010
993
|
* @param options widget definition to use instead of reading attributes or using default sizing values
|
|
1011
994
|
*
|
|
1012
995
|
* @example
|
|
1013
|
-
*
|
|
996
|
+
* const grid = GridStack.init();
|
|
1014
997
|
* grid.el.appendChild('<div id="1" gs-w="3"></div>');
|
|
1015
998
|
* grid.el.appendChild('<div id="2"></div>');
|
|
1016
999
|
* grid.makeWidget('1');
|
|
@@ -1018,6 +1001,10 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
1018
1001
|
*/
|
|
1019
1002
|
GridStack.prototype.makeWidget = function (els, options) {
|
|
1020
1003
|
var el = GridStack.getElement(els);
|
|
1004
|
+
if (!el)
|
|
1005
|
+
return;
|
|
1006
|
+
if (!el.parentElement)
|
|
1007
|
+
this.el.appendChild(el);
|
|
1021
1008
|
this._prepareElement(el, true, options);
|
|
1022
1009
|
var node = el.gridstackNode;
|
|
1023
1010
|
this._updateContainerHeight();
|
|
@@ -1050,7 +1037,8 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
1050
1037
|
this._gsEventHandler[name] = function (event) { return callback(event); };
|
|
1051
1038
|
}
|
|
1052
1039
|
else {
|
|
1053
|
-
this._gsEventHandler[name] = function (event) {
|
|
1040
|
+
this._gsEventHandler[name] = function (event) { if (event.detail)
|
|
1041
|
+
callback(event, event.detail); };
|
|
1054
1042
|
}
|
|
1055
1043
|
this.el.addEventListener(name, this._gsEventHandler[name]);
|
|
1056
1044
|
}
|
|
@@ -1102,6 +1090,10 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
1102
1090
|
var _this = this;
|
|
1103
1091
|
if (removeDOM === void 0) { removeDOM = true; }
|
|
1104
1092
|
if (triggerEvent === void 0) { triggerEvent = true; }
|
|
1093
|
+
if (!els) {
|
|
1094
|
+
console.error('Error: GridStack.removeWidget(undefined) called');
|
|
1095
|
+
return this;
|
|
1096
|
+
}
|
|
1105
1097
|
GridStack.getElements(els).forEach(function (el) {
|
|
1106
1098
|
if (el.parentElement && el.parentElement !== _this.el)
|
|
1107
1099
|
return; // not our child!
|
|
@@ -1212,7 +1204,8 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
1212
1204
|
if (arguments.length > 2) {
|
|
1213
1205
|
console.warn('gridstack.ts: `update(el, x, y, w, h)` is deprecated. Use `update(el, {x, w, content, ...})`. It will be removed soon');
|
|
1214
1206
|
// eslint-disable-next-line prefer-rest-params
|
|
1215
|
-
var a = arguments
|
|
1207
|
+
var a = arguments;
|
|
1208
|
+
var i = 1;
|
|
1216
1209
|
opt = { x: a[i++], y: a[i++], w: a[i++], h: a[i++] };
|
|
1217
1210
|
return this.update(els, opt);
|
|
1218
1211
|
}
|
|
@@ -1242,8 +1235,8 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
1242
1235
|
// check for content changing
|
|
1243
1236
|
if (w.content !== undefined) {
|
|
1244
1237
|
var itemContent = el.querySelector('.grid-stack-item-content');
|
|
1245
|
-
if (itemContent && itemContent.
|
|
1246
|
-
itemContent
|
|
1238
|
+
if (itemContent && itemContent.textContent !== w.content) {
|
|
1239
|
+
GridStack.renderCB(itemContent, w);
|
|
1247
1240
|
// restore any sub-grid back
|
|
1248
1241
|
if ((_a = n.subGrid) === null || _a === void 0 ? void 0 : _a.el) {
|
|
1249
1242
|
itemContent.appendChild(n.subGrid.el);
|
|
@@ -1298,6 +1291,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
1298
1291
|
* @param useNodeH set to true if GridStackNode.h should be used instead of actual container height when we don't need to wait for animation to finish to get actual DOM heights
|
|
1299
1292
|
*/
|
|
1300
1293
|
GridStack.prototype.resizeToContent = function (el) {
|
|
1294
|
+
var _a, _b;
|
|
1301
1295
|
if (!el)
|
|
1302
1296
|
return;
|
|
1303
1297
|
el.classList.remove('size-to-content-max');
|
|
@@ -1327,6 +1321,10 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
1327
1321
|
// sub-grid - use their actual row count * their cell height
|
|
1328
1322
|
wantedH = n.subGrid.getRow() * n.subGrid.getCellHeight(true);
|
|
1329
1323
|
}
|
|
1324
|
+
else if ((_b = (_a = n.subGridOpts) === null || _a === void 0 ? void 0 : _a.children) === null || _b === void 0 ? void 0 : _b.length) {
|
|
1325
|
+
// not sub-grid just yet (case above) wait until we do
|
|
1326
|
+
return;
|
|
1327
|
+
}
|
|
1330
1328
|
else {
|
|
1331
1329
|
// NOTE: clientHeight & getBoundingClientRect() is undefined for text and other leaf nodes. use <div> container!
|
|
1332
1330
|
var child = item.firstElementChild;
|
|
@@ -1381,7 +1379,11 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
1381
1379
|
rot.x = n.x + pivotX - (n.h - (pivotY + 1));
|
|
1382
1380
|
rot.y = (n.y + pivotY) - pivotX;
|
|
1383
1381
|
}
|
|
1382
|
+
Object.keys(rot).forEach(function (k) { if (rot[k] === undefined)
|
|
1383
|
+
delete rot[k]; });
|
|
1384
|
+
var _orig = n._orig;
|
|
1384
1385
|
_this.update(el, rot);
|
|
1386
|
+
n._orig = _orig; // restore as move() will delete it
|
|
1385
1387
|
});
|
|
1386
1388
|
return this;
|
|
1387
1389
|
};
|
|
@@ -1423,7 +1425,8 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
1423
1425
|
if (arguments.length > 1) {
|
|
1424
1426
|
console.warn('gridstack.ts: `willItFit(x,y,w,h,autoPosition)` is deprecated. Use `willItFit({x, y,...})`. It will be removed soon');
|
|
1425
1427
|
// eslint-disable-next-line prefer-rest-params
|
|
1426
|
-
var a = arguments
|
|
1428
|
+
var a = arguments;
|
|
1429
|
+
var i = 0, w = { x: a[i++], y: a[i++], w: a[i++], h: a[i++], autoPosition: a[i++] };
|
|
1427
1430
|
return this.willItFit(w);
|
|
1428
1431
|
}
|
|
1429
1432
|
return this.engine.willItFit(node);
|
|
@@ -1550,7 +1553,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
1550
1553
|
GridStack.prototype._updateContainerHeight = function () {
|
|
1551
1554
|
if (!this.engine || this.engine.batchMode)
|
|
1552
1555
|
return this;
|
|
1553
|
-
var parent = this.
|
|
1556
|
+
var parent = this.parentGridNode;
|
|
1554
1557
|
var row = this.getRow() + this._extraDragRow; // this checks for minRow already
|
|
1555
1558
|
var cellHeight = this.opts.cellHeight;
|
|
1556
1559
|
var unit = this.opts.cellHeightUnit;
|
|
@@ -1615,7 +1618,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
1615
1618
|
return this;
|
|
1616
1619
|
this._writePosAttr(el, node);
|
|
1617
1620
|
var attrs /*: GridStackWidget but strings */ = {
|
|
1618
|
-
autoPosition: 'gs-auto-position',
|
|
1621
|
+
// autoPosition: 'gs-auto-position', // no need to write out as already in node and doesn't affect CSS
|
|
1619
1622
|
noResize: 'gs-no-resize',
|
|
1620
1623
|
noMove: 'gs-no-move',
|
|
1621
1624
|
locked: 'gs-locked',
|
|
@@ -1704,9 +1707,9 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
1704
1707
|
this.batchUpdate();
|
|
1705
1708
|
// see if we're nested and take our column count from our parent....
|
|
1706
1709
|
var columnChanged = false;
|
|
1707
|
-
if (this._autoColumn && this.
|
|
1708
|
-
if (this.opts.column !== this.
|
|
1709
|
-
this.column(this.
|
|
1710
|
+
if (this._autoColumn && this.parentGridNode) {
|
|
1711
|
+
if (this.opts.column !== this.parentGridNode.w) {
|
|
1712
|
+
this.column(this.parentGridNode.w, 'none');
|
|
1710
1713
|
columnChanged = true;
|
|
1711
1714
|
}
|
|
1712
1715
|
}
|
|
@@ -1762,7 +1765,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
1762
1765
|
if (forceRemove === void 0) { forceRemove = false; }
|
|
1763
1766
|
// only add event if we're not nested (parent will call us) and we're auto sizing cells or supporting dynamic column (i.e. doing work)
|
|
1764
1767
|
// or supporting new sizeToContent option.
|
|
1765
|
-
var trackSize = !this.
|
|
1768
|
+
var trackSize = !this.parentGridNode && (this._isAutoCellHeight || this.opts.sizeToContent || this.opts.columnOpts
|
|
1766
1769
|
|| this.engine.nodes.find(function (n) { return n.sizeToContent; }));
|
|
1767
1770
|
if (!forceRemove && trackSize && !this.resizeObserver) {
|
|
1768
1771
|
this._sizeThrottle = utils_1.Utils.throttle(function () { return _this.onResize(); }, this.opts.cellHeightThrottle);
|
|
@@ -1867,22 +1870,24 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
1867
1870
|
* call to setup dragging in from the outside (say toolbar), by specifying the class selection and options.
|
|
1868
1871
|
* Called during GridStack.init() as options, but can also be called directly (last param are used) in case the toolbar
|
|
1869
1872
|
* is dynamically create and needs to be set later.
|
|
1870
|
-
* @param dragIn string selector (ex: '.sidebar
|
|
1871
|
-
* @param dragInOptions options - see
|
|
1872
|
-
* @param
|
|
1873
|
+
* @param dragIn string selector (ex: '.sidebar-item') or list of dom elements
|
|
1874
|
+
* @param dragInOptions options - see DDDragOpt. (default: {handle: '.grid-stack-item-content', appendTo: 'body'}
|
|
1875
|
+
* @param widgets GridStackWidget def to assign to each element which defines what to create on drop
|
|
1876
|
+
* @param root optional root which defaults to document (for shadow dom pass the parent HTMLDocument)
|
|
1873
1877
|
*/
|
|
1874
|
-
GridStack.setupDragIn = function (dragIn, dragInOptions, root) {
|
|
1878
|
+
GridStack.setupDragIn = function (dragIn, dragInOptions, widgets, root) {
|
|
1875
1879
|
if (root === void 0) { root = document; }
|
|
1876
1880
|
if ((dragInOptions === null || dragInOptions === void 0 ? void 0 : dragInOptions.pause) !== undefined) {
|
|
1877
1881
|
dd_manager_1.DDManager.pauseDrag = dragInOptions.pause;
|
|
1878
1882
|
}
|
|
1879
|
-
dragInOptions = __assign(
|
|
1883
|
+
dragInOptions = __assign({ appendTo: 'body', helper: 'clone' }, (dragInOptions || {})); // default to handle:undefined = drag by the whole item
|
|
1880
1884
|
var els = (typeof dragIn === 'string') ? utils_1.Utils.getElements(dragIn, root) : dragIn;
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1885
|
+
els.forEach(function (el, i) {
|
|
1886
|
+
if (!dd.isDraggable(el))
|
|
1887
|
+
dd.dragIn(el, dragInOptions);
|
|
1888
|
+
if (widgets === null || widgets === void 0 ? void 0 : widgets[i])
|
|
1889
|
+
el.gridstackNode = widgets[i];
|
|
1890
|
+
});
|
|
1886
1891
|
};
|
|
1887
1892
|
/**
|
|
1888
1893
|
* Enables/Disables dragging by the user of specific grid element. If you want all items, and have it affect future items, use enableMove() instead. No-op for static grids.
|
|
@@ -2013,14 +2018,13 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
2013
2018
|
var cellHeight, cellWidth;
|
|
2014
2019
|
var onDrag = function (event, el, helper) {
|
|
2015
2020
|
var _a;
|
|
2016
|
-
|
|
2017
|
-
var node =
|
|
2021
|
+
helper = helper || el;
|
|
2022
|
+
var node = helper.gridstackNode;
|
|
2018
2023
|
if (!node)
|
|
2019
2024
|
return;
|
|
2020
|
-
helper = helper || el;
|
|
2021
2025
|
// if the element is being dragged from outside, scale it down to match the grid's scale
|
|
2022
2026
|
// and slightly adjust its position relative to the mouse
|
|
2023
|
-
if (!((
|
|
2027
|
+
if (!((_a = node.grid) === null || _a === void 0 ? void 0 : _a.el)) {
|
|
2024
2028
|
// this scales the helper down
|
|
2025
2029
|
helper.style.transform = "scale(".concat(1 / _this.dragTransform.xScale, ",").concat(1 / _this.dragTransform.yScale, ")");
|
|
2026
2030
|
// this makes it so that the helper is well positioned relative to the mouse after scaling
|
|
@@ -2029,10 +2033,10 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
2029
2033
|
helper.style.top = helperRect.y + (_this.dragTransform.yScale - 1) * (event.clientY - helperRect.y) / _this.dragTransform.yScale + 'px';
|
|
2030
2034
|
helper.style.transformOrigin = "0px 0px";
|
|
2031
2035
|
}
|
|
2032
|
-
var
|
|
2033
|
-
var
|
|
2034
|
-
left -=
|
|
2035
|
-
top -=
|
|
2036
|
+
var _b = helper.getBoundingClientRect(), top = _b.top, left = _b.left;
|
|
2037
|
+
var rect = _this.el.getBoundingClientRect();
|
|
2038
|
+
left -= rect.left;
|
|
2039
|
+
top -= rect.top;
|
|
2036
2040
|
var ui = {
|
|
2037
2041
|
position: {
|
|
2038
2042
|
top: top * _this.dragTransform.xScale,
|
|
@@ -2095,7 +2099,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
2095
2099
|
*/
|
|
2096
2100
|
.on(this.el, 'dropover', function (event, el, helper) {
|
|
2097
2101
|
// console.log(`over ${this.el.gridstack.opts.id} ${count++}`); // TEST
|
|
2098
|
-
var node = el.gridstackNode;
|
|
2102
|
+
var node = (helper === null || helper === void 0 ? void 0 : helper.gridstackNode) || el.gridstackNode;
|
|
2099
2103
|
// ignore drop enter on ourself (unless we temporarily removed) which happens on a simple drag of our item
|
|
2100
2104
|
if ((node === null || node === void 0 ? void 0 : node.grid) === _this && !node._temporaryRemoved) {
|
|
2101
2105
|
// delete node._added; // reset this to track placeholder again in case we were over other grid #1484 (dropout doesn't always clear)
|
|
@@ -2107,19 +2111,31 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
2107
2111
|
var otherGrid = node.grid;
|
|
2108
2112
|
otherGrid._leave(el, helper);
|
|
2109
2113
|
}
|
|
2114
|
+
helper = helper || el;
|
|
2110
2115
|
// cache cell dimensions (which don't change), position can animate if we removed an item in otherGrid that affects us...
|
|
2111
2116
|
cellWidth = _this.cellWidth();
|
|
2112
2117
|
cellHeight = _this.getCellHeight(true);
|
|
2113
|
-
// load any element attributes if we don't have a node
|
|
2118
|
+
// sidebar items: load any element attributes if we don't have a node
|
|
2114
2119
|
if (!node) {
|
|
2115
|
-
|
|
2120
|
+
if (helper.hasAttribute('gridstacknode')) {
|
|
2121
|
+
try {
|
|
2122
|
+
node = JSON.parse(helper.getAttribute('gridstacknode'));
|
|
2123
|
+
}
|
|
2124
|
+
catch (error) {
|
|
2125
|
+
console.error("Gridstack dropover: Bad JSON format: ", helper.getAttribute('gridstacknode'));
|
|
2126
|
+
}
|
|
2127
|
+
helper.removeAttribute('gridstacknode');
|
|
2128
|
+
}
|
|
2129
|
+
if (!node)
|
|
2130
|
+
node = _this._readAttr(helper); // used to pass false for #2354, but now we clone top level node
|
|
2116
2131
|
}
|
|
2117
|
-
if (!node.grid) {
|
|
2132
|
+
if (!node.grid) { // sidebar item
|
|
2133
|
+
if (!node.el)
|
|
2134
|
+
node = __assign({}, node); // clone first time we're coming from sidebar (since 'clone' doesn't copy vars)
|
|
2118
2135
|
node._isExternal = true;
|
|
2119
|
-
|
|
2136
|
+
helper.gridstackNode = node;
|
|
2120
2137
|
}
|
|
2121
2138
|
// calculate the grid size based on element outer size
|
|
2122
|
-
helper = helper || el;
|
|
2123
2139
|
var w = node.w || Math.round(helper.offsetWidth / cellWidth) || 1;
|
|
2124
2140
|
var h = node.h || Math.round(helper.offsetHeight / cellHeight) || 1;
|
|
2125
2141
|
// if the item came from another grid, make a copy and save the original info in case we go back there
|
|
@@ -2155,7 +2171,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
2155
2171
|
*/
|
|
2156
2172
|
.on(this.el, 'dropout', function (event, el, helper) {
|
|
2157
2173
|
// console.log(`out ${this.el.gridstack.opts.id} ${count++}`); // TEST
|
|
2158
|
-
var node = el.gridstackNode;
|
|
2174
|
+
var node = (helper === null || helper === void 0 ? void 0 : helper.gridstackNode) || el.gridstackNode;
|
|
2159
2175
|
if (!node)
|
|
2160
2176
|
return false;
|
|
2161
2177
|
// fix #1578 when dragging fast, we might get leave after other grid gets enter (which calls us to clean)
|
|
@@ -2174,11 +2190,12 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
2174
2190
|
*/
|
|
2175
2191
|
.on(this.el, 'drop', function (event, el, helper) {
|
|
2176
2192
|
var _a, _b, _c;
|
|
2177
|
-
var node = el.gridstackNode;
|
|
2193
|
+
var node = (helper === null || helper === void 0 ? void 0 : helper.gridstackNode) || el.gridstackNode;
|
|
2178
2194
|
// ignore drop on ourself from ourself that didn't come from the outside - dragend will handle the simple move instead
|
|
2179
2195
|
if ((node === null || node === void 0 ? void 0 : node.grid) === _this && !node._isExternal)
|
|
2180
2196
|
return false;
|
|
2181
2197
|
var wasAdded = !!_this.placeholder.parentElement; // skip items not actually added to us because of constrains, but do cleanup #1419
|
|
2198
|
+
var wasSidebar = el !== helper;
|
|
2182
2199
|
_this.placeholder.remove();
|
|
2183
2200
|
// disable animation when replacing a placeholder (already positioned) with actual content
|
|
2184
2201
|
var noAnim = wasAdded && _this.opts.animate;
|
|
@@ -2194,7 +2211,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
2194
2211
|
oGrid.engine.removedNodes.push(origNode);
|
|
2195
2212
|
oGrid._triggerRemoveEvent()._triggerChangeEvent();
|
|
2196
2213
|
// if it's an empty sub-grid that got auto-created, nuke it
|
|
2197
|
-
if (oGrid.
|
|
2214
|
+
if (oGrid.parentGridNode && !oGrid.engine.nodes.length && oGrid.opts.subGridDynamic) {
|
|
2198
2215
|
oGrid.removeAsSubGrid();
|
|
2199
2216
|
}
|
|
2200
2217
|
}
|
|
@@ -2207,37 +2224,39 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
2207
2224
|
}
|
|
2208
2225
|
(_a = node.grid) === null || _a === void 0 ? true : delete _a._isTemp;
|
|
2209
2226
|
dd.off(el, 'drag');
|
|
2210
|
-
// if we made a copy
|
|
2211
|
-
// as the helper will be nuked by jquery-ui otherwise. TODO: update old code path
|
|
2227
|
+
// if we made a copy insert that instead of the original (sidebar item)
|
|
2212
2228
|
if (helper !== el) {
|
|
2213
2229
|
helper.remove();
|
|
2214
|
-
el
|
|
2215
|
-
if (wasAdded) {
|
|
2216
|
-
el = el.cloneNode(true);
|
|
2217
|
-
}
|
|
2230
|
+
el = helper;
|
|
2218
2231
|
}
|
|
2219
2232
|
else {
|
|
2220
2233
|
el.remove(); // reduce flicker as we change depth here, and size further down
|
|
2221
|
-
_this._removeDD(el);
|
|
2222
2234
|
}
|
|
2235
|
+
_this._removeDD(el);
|
|
2223
2236
|
if (!wasAdded)
|
|
2224
2237
|
return false;
|
|
2225
|
-
el.gridstackNode = node;
|
|
2226
|
-
node.el = el;
|
|
2227
2238
|
var subGrid = (_c = (_b = node.subGrid) === null || _b === void 0 ? void 0 : _b.el) === null || _c === void 0 ? void 0 : _c.gridstack; // set when actual sub-grid present
|
|
2228
|
-
// @ts-ignore
|
|
2229
2239
|
utils_1.Utils.copyPos(node, _this._readAttr(_this.placeholder)); // placeholder values as moving VERY fast can throw things off #1578
|
|
2230
|
-
utils_1.Utils.removePositioningStyles(el);
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2240
|
+
utils_1.Utils.removePositioningStyles(el);
|
|
2241
|
+
// give the user a chance to alter the widget that will get inserted if new sidebar item
|
|
2242
|
+
if (wasSidebar && (node.content || node.subGridOpts || GridStack.addRemoveCB)) {
|
|
2243
|
+
delete node.el;
|
|
2244
|
+
el = _this.addWidget(node);
|
|
2245
|
+
}
|
|
2246
|
+
else {
|
|
2247
|
+
_this._prepareElement(el, true, node);
|
|
2248
|
+
_this.el.appendChild(el);
|
|
2249
|
+
// resizeToContent is skipped in _prepareElement() until node is visible (clientHeight=0) so call it now
|
|
2250
|
+
_this.resizeToContentCheck(false, node);
|
|
2251
|
+
if (subGrid) {
|
|
2252
|
+
subGrid.parentGridNode = node;
|
|
2253
|
+
if (!subGrid.opts.styleInHead)
|
|
2254
|
+
subGrid._updateStyles(true); // re-create sub-grid styles now that we've moved
|
|
2255
|
+
}
|
|
2256
|
+
_this._updateContainerHeight();
|
|
2257
|
+
}
|
|
2258
|
+
_this.engine.addedNodes.push(node);
|
|
2259
|
+
_this._triggerAddEvent();
|
|
2241
2260
|
_this._triggerChangeEvent();
|
|
2242
2261
|
_this.engine.endUpdate();
|
|
2243
2262
|
if (_this._gsEventHandler['dropped']) {
|
|
@@ -2252,6 +2271,8 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
2252
2271
|
};
|
|
2253
2272
|
/** @internal mark item for removal */
|
|
2254
2273
|
GridStack._itemRemoving = function (el, remove) {
|
|
2274
|
+
if (!el)
|
|
2275
|
+
return;
|
|
2255
2276
|
var node = el ? el.gridstackNode : undefined;
|
|
2256
2277
|
if (!(node === null || node === void 0 ? void 0 : node.grid) || el.classList.contains(node.grid.opts.removableOptions.decline))
|
|
2257
2278
|
return;
|
|
@@ -2419,7 +2440,9 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
2419
2440
|
dd.resizable(el, 'option', 'minWidth', cellWidth * Math.min(node.minW || 1, colLeft))
|
|
2420
2441
|
.resizable(el, 'option', 'minHeight', cellHeight * Math.min(node.minH || 1, rowLeft))
|
|
2421
2442
|
.resizable(el, 'option', 'maxWidth', cellWidth * Math.min(node.maxW || Number.MAX_SAFE_INTEGER, colLeft))
|
|
2422
|
-
.resizable(el, 'option', '
|
|
2443
|
+
.resizable(el, 'option', 'maxWidthMoveLeft', cellWidth * Math.min(node.maxW || Number.MAX_SAFE_INTEGER, node.x + node.w))
|
|
2444
|
+
.resizable(el, 'option', 'maxHeight', cellHeight * Math.min(node.maxH || Number.MAX_SAFE_INTEGER, rowLeft))
|
|
2445
|
+
.resizable(el, 'option', 'maxHeightMoveUp', cellHeight * Math.min(node.maxH || Number.MAX_SAFE_INTEGER, node.y + node.h));
|
|
2423
2446
|
}
|
|
2424
2447
|
};
|
|
2425
2448
|
/** @internal handles actual drag/resize */
|
|
@@ -2512,12 +2535,12 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
2512
2535
|
* our item to start with else restore prev node values from prev grid it came from.
|
|
2513
2536
|
*/
|
|
2514
2537
|
GridStack.prototype._leave = function (el, helper) {
|
|
2515
|
-
|
|
2538
|
+
helper = helper || el;
|
|
2539
|
+
var node = helper.gridstackNode;
|
|
2516
2540
|
if (!node)
|
|
2517
2541
|
return;
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
helper.style.transform = 'scale(1)';
|
|
2542
|
+
// remove the scale of the helper on leave
|
|
2543
|
+
helper.style.transform = helper.style.transformOrigin = null;
|
|
2521
2544
|
dd.off(el, 'drag'); // no need to track while being outside
|
|
2522
2545
|
// this gets called when cursor leaves and shape is outside, so only do this once
|
|
2523
2546
|
if (node._temporaryRemoved)
|
|
@@ -2525,6 +2548,8 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
2525
2548
|
node._temporaryRemoved = true;
|
|
2526
2549
|
this.engine.removeNode(node); // remove placeholder as well, otherwise it's a sign node is not in our list, which is a bigger issue
|
|
2527
2550
|
node.el = node._isExternal && helper ? helper : el; // point back to real item being dragged
|
|
2551
|
+
if (node._isExternal)
|
|
2552
|
+
this.engine.cleanupNode(node);
|
|
2528
2553
|
if (this.opts.removable === true) { // boolean vs a class string
|
|
2529
2554
|
// item leaving us and we are supposed to remove on leave (no need to drag onto trash) mark it so
|
|
2530
2555
|
GridStack._itemRemoving(el, true);
|
|
@@ -2536,22 +2561,25 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
2536
2561
|
delete el._gridstackNodeOrig;
|
|
2537
2562
|
}
|
|
2538
2563
|
else if (node._isExternal) {
|
|
2539
|
-
// item came from outside
|
|
2540
|
-
delete node.el;
|
|
2541
|
-
delete el.gridstackNode;
|
|
2542
|
-
// and restore all nodes back to original
|
|
2564
|
+
// item came from outside restore all nodes back to original
|
|
2543
2565
|
this.engine.restoreInitial();
|
|
2544
2566
|
}
|
|
2545
2567
|
};
|
|
2546
2568
|
// legacy method removed
|
|
2547
2569
|
GridStack.prototype.commit = function () { (0, utils_1.obsolete)(this, this.batchUpdate(false), 'commit', 'batchUpdate', '5.2'); return this; };
|
|
2570
|
+
/**
|
|
2571
|
+
* callback to create the content of widgets so the app can control how to store and restore it
|
|
2572
|
+
* By default this lib will do 'el.textContent = w.content' forcing text only support for avoiding potential XSS issues.
|
|
2573
|
+
*/
|
|
2574
|
+
GridStack.renderCB = function (el, w) { if (el && (w === null || w === void 0 ? void 0 : w.content))
|
|
2575
|
+
el.textContent = w.content; };
|
|
2548
2576
|
/** parent class for sizing content. defaults to '.grid-stack-item-content' */
|
|
2549
2577
|
GridStack.resizeToContentParent = '.grid-stack-item-content';
|
|
2550
2578
|
/** scoping so users can call GridStack.Utils.sort() for example */
|
|
2551
2579
|
GridStack.Utils = utils_1.Utils;
|
|
2552
2580
|
/** scoping so users can call new GridStack.Engine(12) for example */
|
|
2553
2581
|
GridStack.Engine = gridstack_engine_1.GridStackEngine;
|
|
2554
|
-
GridStack.GDRev = '
|
|
2582
|
+
GridStack.GDRev = '11.0.0';
|
|
2555
2583
|
return GridStack;
|
|
2556
2584
|
}());
|
|
2557
2585
|
//# sourceMappingURL=gridstack.js.map
|