gridstack 11.2.0 → 11.4.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 +4 -4
- package/dist/angular/README.md +4 -4
- package/dist/angular/esm2020/index.mjs +3 -2
- 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 +10 -10
- package/dist/angular/esm2020/lib/types.mjs +6 -0
- package/dist/angular/fesm2015/gridstack-angular.mjs +40 -40
- package/dist/angular/fesm2015/gridstack-angular.mjs.map +1 -1
- package/dist/angular/fesm2020/gridstack-angular.mjs +45 -40
- package/dist/angular/fesm2020/gridstack-angular.mjs.map +1 -1
- package/dist/angular/index.d.ts +2 -1
- package/dist/angular/lib/base-widget.d.ts +1 -1
- package/dist/angular/lib/gridstack-item.component.d.ts +1 -1
- package/dist/angular/lib/gridstack.component.d.ts +3 -21
- package/dist/angular/lib/gridstack.module.d.ts +3 -3
- package/dist/angular/lib/types.d.ts +24 -0
- package/dist/angular/src/base-widget.ts +2 -2
- package/dist/angular/src/gridstack-item.component.ts +1 -1
- package/dist/angular/src/gridstack.component.ts +3 -21
- package/dist/angular/src/gridstack.module.ts +4 -4
- 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 +2 -2
- 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 +10 -13
- 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 +4 -39
- package/dist/dd-touch.js.map +1 -1
- package/dist/es5/dd-base-impl.d.ts +1 -1
- package/dist/es5/dd-base-impl.js +1 -1
- package/dist/es5/dd-base-impl.js.map +1 -1
- package/dist/es5/dd-draggable.d.ts +1 -1
- package/dist/es5/dd-draggable.js +2 -2
- package/dist/es5/dd-draggable.js.map +1 -1
- package/dist/es5/dd-droppable.d.ts +1 -1
- package/dist/es5/dd-droppable.js +1 -1
- package/dist/es5/dd-droppable.js.map +1 -1
- package/dist/es5/dd-element.d.ts +1 -1
- package/dist/es5/dd-element.js +1 -1
- package/dist/es5/dd-element.js.map +1 -1
- package/dist/es5/dd-gridstack.d.ts +1 -1
- package/dist/es5/dd-gridstack.js +10 -14
- package/dist/es5/dd-gridstack.js.map +1 -1
- package/dist/es5/dd-manager.d.ts +1 -1
- package/dist/es5/dd-manager.js +1 -1
- package/dist/es5/dd-manager.js.map +1 -1
- package/dist/es5/dd-resizable-handle.d.ts +1 -1
- package/dist/es5/dd-resizable-handle.js +1 -1
- package/dist/es5/dd-resizable-handle.js.map +1 -1
- package/dist/es5/dd-resizable.d.ts +1 -1
- package/dist/es5/dd-resizable.js +1 -1
- package/dist/es5/dd-resizable.js.map +1 -1
- package/dist/es5/dd-touch.d.ts +1 -1
- package/dist/es5/dd-touch.js +4 -39
- 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 +1 -1
- package/dist/es5/gridstack-all.js.map +1 -1
- package/dist/es5/gridstack-engine.d.ts +3 -1
- package/dist/es5/gridstack-engine.js +11 -14
- package/dist/es5/gridstack-engine.js.map +1 -1
- package/dist/es5/gridstack-poly.js +1 -1
- package/dist/es5/gridstack.d.ts +9 -3
- package/dist/es5/gridstack.js +51 -32
- package/dist/es5/gridstack.js.map +1 -1
- package/dist/es5/types.d.ts +2 -2
- package/dist/es5/types.js +1 -1
- package/dist/es5/types.js.map +1 -1
- package/dist/es5/utils.d.ts +5 -5
- package/dist/es5/utils.js +24 -42
- package/dist/es5/utils.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 +3 -1
- package/dist/gridstack-engine.js +11 -14
- package/dist/gridstack-engine.js.map +1 -1
- package/dist/gridstack.css +1 -1
- package/dist/gridstack.d.ts +9 -3
- package/dist/gridstack.js +49 -32
- package/dist/gridstack.js.map +1 -1
- package/dist/src/gridstack.scss +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +5 -5
- package/dist/utils.js +23 -40
- package/dist/utils.js.map +1 -1
- package/doc/CHANGES.md +15 -0
- package/doc/README.md +4 -4
- package/package.json +1 -1
package/dist/es5/gridstack.js
CHANGED
|
@@ -36,7 +36,7 @@ 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 11.
|
|
39
|
+
* GridStack 11.4.0
|
|
40
40
|
* https://gridstackjs.com/
|
|
41
41
|
*
|
|
42
42
|
* Copyright (c) 2021-2024 Alain Dumesny
|
|
@@ -395,7 +395,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
395
395
|
el = GridStack.addRemoveCB(this.el, w, true, false);
|
|
396
396
|
}
|
|
397
397
|
else {
|
|
398
|
-
el =
|
|
398
|
+
el = this.createWidgetDivs(node);
|
|
399
399
|
}
|
|
400
400
|
if (!el)
|
|
401
401
|
return;
|
|
@@ -414,6 +414,29 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
414
414
|
this.makeWidget(el, w);
|
|
415
415
|
return el;
|
|
416
416
|
};
|
|
417
|
+
/** create the default grid item divs, and content (possibly lazy loaded) by using GridStack.renderCB() */
|
|
418
|
+
GridStack.prototype.createWidgetDivs = function (n) {
|
|
419
|
+
var el = utils_1.Utils.createDiv(['grid-stack-item', this.opts.itemClass]);
|
|
420
|
+
var cont = utils_1.Utils.createDiv(['grid-stack-item-content'], el);
|
|
421
|
+
if (utils_1.Utils.lazyLoad(n)) {
|
|
422
|
+
if (!n.visibleObservable) {
|
|
423
|
+
n.visibleObservable = new IntersectionObserver(function (_a) {
|
|
424
|
+
var _b, _c;
|
|
425
|
+
var entry = _a[0];
|
|
426
|
+
if (entry.isIntersecting) {
|
|
427
|
+
(_b = n.visibleObservable) === null || _b === void 0 ? void 0 : _b.disconnect();
|
|
428
|
+
delete n.visibleObservable;
|
|
429
|
+
GridStack.renderCB(cont, n);
|
|
430
|
+
(_c = n.grid) === null || _c === void 0 ? void 0 : _c.prepareDragDrop(n.el);
|
|
431
|
+
}
|
|
432
|
+
});
|
|
433
|
+
window.setTimeout(function () { var _a; return (_a = n.visibleObservable) === null || _a === void 0 ? void 0 : _a.observe(el); }); // wait until callee sets position attributes
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
else
|
|
437
|
+
GridStack.renderCB(cont, n);
|
|
438
|
+
return el;
|
|
439
|
+
};
|
|
417
440
|
/**
|
|
418
441
|
* Convert an existing gridItem element into a sub-grid with the given (optional) options, else inherit them
|
|
419
442
|
* from the parent's subGrid options.
|
|
@@ -470,7 +493,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
470
493
|
newItem.appendChild(content);
|
|
471
494
|
content = utils_1.Utils.createDiv(['grid-stack-item-content'], node.el);
|
|
472
495
|
}
|
|
473
|
-
this.
|
|
496
|
+
this.prepareDragDrop(node.el); // ... and restore original D&D
|
|
474
497
|
}
|
|
475
498
|
// if we're adding an additional item, make the container large enough to have them both
|
|
476
499
|
if (nodeToAdd) {
|
|
@@ -605,8 +628,8 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
605
628
|
/**
|
|
606
629
|
* load the widgets from a list. This will call update() on each (matching by id) or add/remove widgets that are not there.
|
|
607
630
|
*
|
|
608
|
-
* @param
|
|
609
|
-
* @param
|
|
631
|
+
* @param items list of widgets definition to update/create
|
|
632
|
+
* @param addRemove boolean (default true) or callback method can be passed to control if and how missing widgets can be added/removed, giving
|
|
610
633
|
* the user control of insertion.
|
|
611
634
|
*
|
|
612
635
|
* @example
|
|
@@ -622,16 +645,15 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
622
645
|
items.forEach(function (n) { n.w = n.w || 1; n.h = n.h || 1; });
|
|
623
646
|
// sort items. those without coord will be appended last
|
|
624
647
|
items = utils_1.Utils.sort(items);
|
|
648
|
+
this.engine.skipCacheUpdate = this._ignoreLayoutsNodeChange = true; // skip layout update
|
|
625
649
|
// if we're loading a layout into for example 1 column and items don't fit, make sure to save
|
|
626
650
|
// the original wanted layout so we can scale back up correctly #1471
|
|
627
651
|
var maxColumn = 0;
|
|
628
652
|
items.forEach(function (n) { maxColumn = Math.max(maxColumn, (n.x || 0) + n.w); });
|
|
629
653
|
if (maxColumn > this.engine.defaultColumn)
|
|
630
654
|
this.engine.defaultColumn = maxColumn;
|
|
631
|
-
if (maxColumn > column)
|
|
632
|
-
this._ignoreLayoutsNodeChange = true; // skip layout update
|
|
655
|
+
if (maxColumn > column)
|
|
633
656
|
this.engine.cacheLayout(items, maxColumn, true);
|
|
634
|
-
}
|
|
635
657
|
// if given a different callback, temporally set it as global option so creating will use it
|
|
636
658
|
var prevCB = GridStack.addRemoveCB;
|
|
637
659
|
if (typeof (addRemove) === 'function')
|
|
@@ -705,6 +727,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
705
727
|
this.batchUpdate(false);
|
|
706
728
|
// after commit, clear that flag
|
|
707
729
|
delete this._ignoreLayoutsNodeChange;
|
|
730
|
+
delete this.engine.skipCacheUpdate;
|
|
708
731
|
prevCB ? GridStack.addRemoveCB = prevCB : delete GridStack.addRemoveCB;
|
|
709
732
|
// delay adding animation back
|
|
710
733
|
if (blank && ((_a = this.opts) === null || _a === void 0 ? void 0 : _a.animate))
|
|
@@ -899,6 +922,8 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
899
922
|
return Array.from(this.el.children)
|
|
900
923
|
.filter(function (el) { return el.matches('.' + _this.opts.itemClass) && !el.matches('.' + _this.opts.placeholderClass); });
|
|
901
924
|
};
|
|
925
|
+
/** true if changeCB should be ignored due to column change, sizeToContent, loading, etc... which caller can ignore for dirty flag case */
|
|
926
|
+
GridStack.prototype.isIgnoreChangeCB = function () { return this._ignoreLayoutsNodeChange; };
|
|
902
927
|
/**
|
|
903
928
|
* Destroys a grid instance. DO NOT CALL any methods or access any vars after this as it will free up members.
|
|
904
929
|
* @param removeDOM if `false` grid and items HTML elements will not be removed from the DOM (Optional. Default `true`).
|
|
@@ -1017,12 +1042,14 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
1017
1042
|
}
|
|
1018
1043
|
// if we're adding an item into 1 column make sure
|
|
1019
1044
|
// we don't override the larger 12 column layout that was already saved. #1985
|
|
1020
|
-
|
|
1021
|
-
|
|
1045
|
+
var resetIgnoreLayoutsNodeChange;
|
|
1046
|
+
if (this.opts.column === 1 && !this._ignoreLayoutsNodeChange) {
|
|
1047
|
+
resetIgnoreLayoutsNodeChange = this._ignoreLayoutsNodeChange = true;
|
|
1022
1048
|
}
|
|
1023
1049
|
this._triggerAddEvent();
|
|
1024
1050
|
this._triggerChangeEvent();
|
|
1025
|
-
|
|
1051
|
+
if (resetIgnoreLayoutsNodeChange)
|
|
1052
|
+
delete this._ignoreLayoutsNodeChange;
|
|
1026
1053
|
return el;
|
|
1027
1054
|
};
|
|
1028
1055
|
GridStack.prototype.on = function (name, callback) {
|
|
@@ -1187,7 +1214,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
1187
1214
|
this._setupRemoveDrop();
|
|
1188
1215
|
this._setupAcceptWidget();
|
|
1189
1216
|
this.engine.nodes.forEach(function (n) {
|
|
1190
|
-
_this.
|
|
1217
|
+
_this.prepareDragDrop(n.el); // either delete or init Drag&drop
|
|
1191
1218
|
if (n.subGrid && recurse)
|
|
1192
1219
|
n.subGrid.setStatic(val, updateClass, recurse);
|
|
1193
1220
|
});
|
|
@@ -1203,21 +1230,12 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
1203
1230
|
*/
|
|
1204
1231
|
GridStack.prototype.update = function (els, opt) {
|
|
1205
1232
|
var _this = this;
|
|
1206
|
-
// support legacy call for now ?
|
|
1207
|
-
if (arguments.length > 2) {
|
|
1208
|
-
console.warn('gridstack.ts: `update(el, x, y, w, h)` is deprecated. Use `update(el, {x, w, content, ...})`. It will be removed soon');
|
|
1209
|
-
// eslint-disable-next-line prefer-rest-params
|
|
1210
|
-
var a = arguments;
|
|
1211
|
-
var i = 1;
|
|
1212
|
-
opt = { x: a[i++], y: a[i++], w: a[i++], h: a[i++] };
|
|
1213
|
-
return this.update(els, opt);
|
|
1214
|
-
}
|
|
1215
1233
|
GridStack.getElements(els).forEach(function (el) {
|
|
1216
1234
|
var _a;
|
|
1217
1235
|
var n = el === null || el === void 0 ? void 0 : el.gridstackNode;
|
|
1218
1236
|
if (!n)
|
|
1219
1237
|
return;
|
|
1220
|
-
var w = utils_1.Utils.cloneDeep(opt); // make a copy we can modify in case they re-use it or multiple items
|
|
1238
|
+
var w = __assign(__assign({}, utils_1.Utils.copyPos({}, n)), utils_1.Utils.cloneDeep(opt)); // make a copy we can modify in case they re-use it or multiple items
|
|
1221
1239
|
_this.engine.nodeBoundFix(w);
|
|
1222
1240
|
delete w.autoPosition;
|
|
1223
1241
|
// move/resize widget if anything changed
|
|
@@ -1277,7 +1295,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
1277
1295
|
_this._writeAttr(el, n);
|
|
1278
1296
|
}
|
|
1279
1297
|
if (ddChanged) {
|
|
1280
|
-
_this.
|
|
1298
|
+
_this.prepareDragDrop(n.el);
|
|
1281
1299
|
}
|
|
1282
1300
|
});
|
|
1283
1301
|
return this;
|
|
@@ -1609,7 +1627,8 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
1609
1627
|
sizeToContent ? el.classList.add('size-to-content') : el.classList.remove('size-to-content');
|
|
1610
1628
|
if (sizeToContent)
|
|
1611
1629
|
this.resizeToContentCheck(false, node);
|
|
1612
|
-
|
|
1630
|
+
if (!utils_1.Utils.lazyLoad(node))
|
|
1631
|
+
this.prepareDragDrop(node.el);
|
|
1613
1632
|
return this;
|
|
1614
1633
|
};
|
|
1615
1634
|
/** @internal call to write position x,y,w,h attributes back to element */
|
|
@@ -1919,7 +1938,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
1919
1938
|
if (!n)
|
|
1920
1939
|
return;
|
|
1921
1940
|
val ? delete n.noMove : n.noMove = true;
|
|
1922
|
-
_this.
|
|
1941
|
+
_this.prepareDragDrop(n.el); // init DD if need be, and adjust
|
|
1923
1942
|
});
|
|
1924
1943
|
return this;
|
|
1925
1944
|
};
|
|
@@ -1937,7 +1956,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
1937
1956
|
if (!n)
|
|
1938
1957
|
return;
|
|
1939
1958
|
val ? delete n.noResize : n.noResize = true;
|
|
1940
|
-
_this.
|
|
1959
|
+
_this.prepareDragDrop(n.el); // init DD if need be, and adjust
|
|
1941
1960
|
});
|
|
1942
1961
|
return this;
|
|
1943
1962
|
};
|
|
@@ -1989,7 +2008,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
1989
2008
|
return this; // can't move a static grid!
|
|
1990
2009
|
doEnable ? delete this.opts.disableDrag : this.opts.disableDrag = true; // FIRST before we update children as grid overrides #1658
|
|
1991
2010
|
this.engine.nodes.forEach(function (n) {
|
|
1992
|
-
_this.
|
|
2011
|
+
_this.prepareDragDrop(n.el);
|
|
1993
2012
|
if (n.subGrid && recurse)
|
|
1994
2013
|
n.subGrid.enableMove(doEnable, recurse);
|
|
1995
2014
|
});
|
|
@@ -2006,7 +2025,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
2006
2025
|
return this; // can't size a static grid!
|
|
2007
2026
|
doEnable ? delete this.opts.disableResize : this.opts.disableResize = true; // FIRST before we update children as grid overrides #1658
|
|
2008
2027
|
this.engine.nodes.forEach(function (n) {
|
|
2009
|
-
_this.
|
|
2028
|
+
_this.prepareDragDrop(n.el);
|
|
2010
2029
|
if (n.subGrid && recurse)
|
|
2011
2030
|
n.subGrid.enableResize(doEnable, recurse);
|
|
2012
2031
|
});
|
|
@@ -2331,10 +2350,10 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
2331
2350
|
}
|
|
2332
2351
|
return this;
|
|
2333
2352
|
};
|
|
2334
|
-
/**
|
|
2335
|
-
GridStack.prototype.
|
|
2353
|
+
/** prepares the element for drag&drop - this is normally called by makeWiget() unless are are delay loading */
|
|
2354
|
+
GridStack.prototype.prepareDragDrop = function (el) {
|
|
2336
2355
|
var _this = this;
|
|
2337
|
-
var
|
|
2356
|
+
var node = el.gridstackNode;
|
|
2338
2357
|
var noMove = node.noMove || this.opts.disableDrag;
|
|
2339
2358
|
var noResize = node.noResize || this.opts.disableResize;
|
|
2340
2359
|
// check for disabled grid first
|
|
@@ -2615,7 +2634,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
2615
2634
|
GridStack.Utils = utils_1.Utils;
|
|
2616
2635
|
/** scoping so users can call new GridStack.Engine(12) for example */
|
|
2617
2636
|
GridStack.Engine = gridstack_engine_1.GridStackEngine;
|
|
2618
|
-
GridStack.GDRev = '11.
|
|
2637
|
+
GridStack.GDRev = '11.4.0';
|
|
2619
2638
|
return GridStack;
|
|
2620
2639
|
}());
|
|
2621
2640
|
//# sourceMappingURL=gridstack.js.map
|