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/gridstack.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* GridStack 11.
|
|
2
|
+
* GridStack 11.4.0
|
|
3
3
|
* https://gridstackjs.com/
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) 2021-2024 Alain Dumesny
|
|
@@ -355,7 +355,7 @@ class GridStack {
|
|
|
355
355
|
el = GridStack.addRemoveCB(this.el, w, true, false);
|
|
356
356
|
}
|
|
357
357
|
else {
|
|
358
|
-
el =
|
|
358
|
+
el = this.createWidgetDivs(node);
|
|
359
359
|
}
|
|
360
360
|
if (!el)
|
|
361
361
|
return;
|
|
@@ -374,6 +374,27 @@ class GridStack {
|
|
|
374
374
|
this.makeWidget(el, w);
|
|
375
375
|
return el;
|
|
376
376
|
}
|
|
377
|
+
/** create the default grid item divs, and content (possibly lazy loaded) by using GridStack.renderCB() */
|
|
378
|
+
createWidgetDivs(n) {
|
|
379
|
+
const el = Utils.createDiv(['grid-stack-item', this.opts.itemClass]);
|
|
380
|
+
const cont = Utils.createDiv(['grid-stack-item-content'], el);
|
|
381
|
+
if (Utils.lazyLoad(n)) {
|
|
382
|
+
if (!n.visibleObservable) {
|
|
383
|
+
n.visibleObservable = new IntersectionObserver(([entry]) => {
|
|
384
|
+
if (entry.isIntersecting) {
|
|
385
|
+
n.visibleObservable?.disconnect();
|
|
386
|
+
delete n.visibleObservable;
|
|
387
|
+
GridStack.renderCB(cont, n);
|
|
388
|
+
n.grid?.prepareDragDrop(n.el);
|
|
389
|
+
}
|
|
390
|
+
});
|
|
391
|
+
window.setTimeout(() => n.visibleObservable?.observe(el)); // wait until callee sets position attributes
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
else
|
|
395
|
+
GridStack.renderCB(cont, n);
|
|
396
|
+
return el;
|
|
397
|
+
}
|
|
377
398
|
/**
|
|
378
399
|
* Convert an existing gridItem element into a sub-grid with the given (optional) options, else inherit them
|
|
379
400
|
* from the parent's subGrid options.
|
|
@@ -433,7 +454,7 @@ class GridStack {
|
|
|
433
454
|
newItem.appendChild(content);
|
|
434
455
|
content = Utils.createDiv(['grid-stack-item-content'], node.el);
|
|
435
456
|
}
|
|
436
|
-
this.
|
|
457
|
+
this.prepareDragDrop(node.el); // ... and restore original D&D
|
|
437
458
|
}
|
|
438
459
|
// if we're adding an additional item, make the container large enough to have them both
|
|
439
460
|
if (nodeToAdd) {
|
|
@@ -562,8 +583,8 @@ class GridStack {
|
|
|
562
583
|
/**
|
|
563
584
|
* load the widgets from a list. This will call update() on each (matching by id) or add/remove widgets that are not there.
|
|
564
585
|
*
|
|
565
|
-
* @param
|
|
566
|
-
* @param
|
|
586
|
+
* @param items list of widgets definition to update/create
|
|
587
|
+
* @param addRemove boolean (default true) or callback method can be passed to control if and how missing widgets can be added/removed, giving
|
|
567
588
|
* the user control of insertion.
|
|
568
589
|
*
|
|
569
590
|
* @example
|
|
@@ -576,16 +597,15 @@ class GridStack {
|
|
|
576
597
|
items.forEach(n => { n.w = n.w || 1; n.h = n.h || 1; });
|
|
577
598
|
// sort items. those without coord will be appended last
|
|
578
599
|
items = Utils.sort(items);
|
|
600
|
+
this.engine.skipCacheUpdate = this._ignoreLayoutsNodeChange = true; // skip layout update
|
|
579
601
|
// if we're loading a layout into for example 1 column and items don't fit, make sure to save
|
|
580
602
|
// the original wanted layout so we can scale back up correctly #1471
|
|
581
603
|
let maxColumn = 0;
|
|
582
604
|
items.forEach(n => { maxColumn = Math.max(maxColumn, (n.x || 0) + n.w); });
|
|
583
605
|
if (maxColumn > this.engine.defaultColumn)
|
|
584
606
|
this.engine.defaultColumn = maxColumn;
|
|
585
|
-
if (maxColumn > column)
|
|
586
|
-
this._ignoreLayoutsNodeChange = true; // skip layout update
|
|
607
|
+
if (maxColumn > column)
|
|
587
608
|
this.engine.cacheLayout(items, maxColumn, true);
|
|
588
|
-
}
|
|
589
609
|
// if given a different callback, temporally set it as global option so creating will use it
|
|
590
610
|
const prevCB = GridStack.addRemoveCB;
|
|
591
611
|
if (typeof (addRemove) === 'function')
|
|
@@ -658,6 +678,7 @@ class GridStack {
|
|
|
658
678
|
this.batchUpdate(false);
|
|
659
679
|
// after commit, clear that flag
|
|
660
680
|
delete this._ignoreLayoutsNodeChange;
|
|
681
|
+
delete this.engine.skipCacheUpdate;
|
|
661
682
|
prevCB ? GridStack.addRemoveCB = prevCB : delete GridStack.addRemoveCB;
|
|
662
683
|
// delay adding animation back
|
|
663
684
|
if (blank && this.opts?.animate)
|
|
@@ -842,6 +863,8 @@ class GridStack {
|
|
|
842
863
|
return Array.from(this.el.children)
|
|
843
864
|
.filter((el) => el.matches('.' + this.opts.itemClass) && !el.matches('.' + this.opts.placeholderClass));
|
|
844
865
|
}
|
|
866
|
+
/** true if changeCB should be ignored due to column change, sizeToContent, loading, etc... which caller can ignore for dirty flag case */
|
|
867
|
+
isIgnoreChangeCB() { return this._ignoreLayoutsNodeChange; }
|
|
845
868
|
/**
|
|
846
869
|
* Destroys a grid instance. DO NOT CALL any methods or access any vars after this as it will free up members.
|
|
847
870
|
* @param removeDOM if `false` grid and items HTML elements will not be removed from the DOM (Optional. Default `true`).
|
|
@@ -957,12 +980,14 @@ class GridStack {
|
|
|
957
980
|
}
|
|
958
981
|
// if we're adding an item into 1 column make sure
|
|
959
982
|
// we don't override the larger 12 column layout that was already saved. #1985
|
|
960
|
-
|
|
961
|
-
|
|
983
|
+
let resetIgnoreLayoutsNodeChange;
|
|
984
|
+
if (this.opts.column === 1 && !this._ignoreLayoutsNodeChange) {
|
|
985
|
+
resetIgnoreLayoutsNodeChange = this._ignoreLayoutsNodeChange = true;
|
|
962
986
|
}
|
|
963
987
|
this._triggerAddEvent();
|
|
964
988
|
this._triggerChangeEvent();
|
|
965
|
-
|
|
989
|
+
if (resetIgnoreLayoutsNodeChange)
|
|
990
|
+
delete this._ignoreLayoutsNodeChange;
|
|
966
991
|
return el;
|
|
967
992
|
}
|
|
968
993
|
on(name, callback) {
|
|
@@ -1113,7 +1138,7 @@ class GridStack {
|
|
|
1113
1138
|
this._setupRemoveDrop();
|
|
1114
1139
|
this._setupAcceptWidget();
|
|
1115
1140
|
this.engine.nodes.forEach(n => {
|
|
1116
|
-
this.
|
|
1141
|
+
this.prepareDragDrop(n.el); // either delete or init Drag&drop
|
|
1117
1142
|
if (n.subGrid && recurse)
|
|
1118
1143
|
n.subGrid.setStatic(val, updateClass, recurse);
|
|
1119
1144
|
});
|
|
@@ -1128,20 +1153,11 @@ class GridStack {
|
|
|
1128
1153
|
* @param opt new widget options (x,y,w,h, etc..). Only those set will be updated.
|
|
1129
1154
|
*/
|
|
1130
1155
|
update(els, opt) {
|
|
1131
|
-
// support legacy call for now ?
|
|
1132
|
-
if (arguments.length > 2) {
|
|
1133
|
-
console.warn('gridstack.ts: `update(el, x, y, w, h)` is deprecated. Use `update(el, {x, w, content, ...})`. It will be removed soon');
|
|
1134
|
-
// eslint-disable-next-line prefer-rest-params
|
|
1135
|
-
const a = arguments;
|
|
1136
|
-
let i = 1;
|
|
1137
|
-
opt = { x: a[i++], y: a[i++], w: a[i++], h: a[i++] };
|
|
1138
|
-
return this.update(els, opt);
|
|
1139
|
-
}
|
|
1140
1156
|
GridStack.getElements(els).forEach(el => {
|
|
1141
1157
|
const n = el?.gridstackNode;
|
|
1142
1158
|
if (!n)
|
|
1143
1159
|
return;
|
|
1144
|
-
const w = Utils.cloneDeep(opt); // make a copy we can modify in case they re-use it or multiple items
|
|
1160
|
+
const w = { ...Utils.copyPos({}, n), ...Utils.cloneDeep(opt) }; // make a copy we can modify in case they re-use it or multiple items
|
|
1145
1161
|
this.engine.nodeBoundFix(w);
|
|
1146
1162
|
delete w.autoPosition;
|
|
1147
1163
|
// move/resize widget if anything changed
|
|
@@ -1201,7 +1217,7 @@ class GridStack {
|
|
|
1201
1217
|
this._writeAttr(el, n);
|
|
1202
1218
|
}
|
|
1203
1219
|
if (ddChanged) {
|
|
1204
|
-
this.
|
|
1220
|
+
this.prepareDragDrop(n.el);
|
|
1205
1221
|
}
|
|
1206
1222
|
});
|
|
1207
1223
|
return this;
|
|
@@ -1527,7 +1543,8 @@ class GridStack {
|
|
|
1527
1543
|
sizeToContent ? el.classList.add('size-to-content') : el.classList.remove('size-to-content');
|
|
1528
1544
|
if (sizeToContent)
|
|
1529
1545
|
this.resizeToContentCheck(false, node);
|
|
1530
|
-
|
|
1546
|
+
if (!Utils.lazyLoad(node))
|
|
1547
|
+
this.prepareDragDrop(node.el);
|
|
1531
1548
|
return this;
|
|
1532
1549
|
}
|
|
1533
1550
|
/** @internal call to write position x,y,w,h attributes back to element */
|
|
@@ -1820,7 +1837,7 @@ class GridStack {
|
|
|
1820
1837
|
if (!n)
|
|
1821
1838
|
return;
|
|
1822
1839
|
val ? delete n.noMove : n.noMove = true;
|
|
1823
|
-
this.
|
|
1840
|
+
this.prepareDragDrop(n.el); // init DD if need be, and adjust
|
|
1824
1841
|
});
|
|
1825
1842
|
return this;
|
|
1826
1843
|
}
|
|
@@ -1837,7 +1854,7 @@ class GridStack {
|
|
|
1837
1854
|
if (!n)
|
|
1838
1855
|
return;
|
|
1839
1856
|
val ? delete n.noResize : n.noResize = true;
|
|
1840
|
-
this.
|
|
1857
|
+
this.prepareDragDrop(n.el); // init DD if need be, and adjust
|
|
1841
1858
|
});
|
|
1842
1859
|
return this;
|
|
1843
1860
|
}
|
|
@@ -1885,7 +1902,7 @@ class GridStack {
|
|
|
1885
1902
|
return this; // can't move a static grid!
|
|
1886
1903
|
doEnable ? delete this.opts.disableDrag : this.opts.disableDrag = true; // FIRST before we update children as grid overrides #1658
|
|
1887
1904
|
this.engine.nodes.forEach(n => {
|
|
1888
|
-
this.
|
|
1905
|
+
this.prepareDragDrop(n.el);
|
|
1889
1906
|
if (n.subGrid && recurse)
|
|
1890
1907
|
n.subGrid.enableMove(doEnable, recurse);
|
|
1891
1908
|
});
|
|
@@ -1900,7 +1917,7 @@ class GridStack {
|
|
|
1900
1917
|
return this; // can't size a static grid!
|
|
1901
1918
|
doEnable ? delete this.opts.disableResize : this.opts.disableResize = true; // FIRST before we update children as grid overrides #1658
|
|
1902
1919
|
this.engine.nodes.forEach(n => {
|
|
1903
|
-
this.
|
|
1920
|
+
this.prepareDragDrop(n.el);
|
|
1904
1921
|
if (n.subGrid && recurse)
|
|
1905
1922
|
n.subGrid.enableResize(doEnable, recurse);
|
|
1906
1923
|
});
|
|
@@ -2221,9 +2238,9 @@ class GridStack {
|
|
|
2221
2238
|
}
|
|
2222
2239
|
return this;
|
|
2223
2240
|
}
|
|
2224
|
-
/**
|
|
2225
|
-
|
|
2226
|
-
const
|
|
2241
|
+
/** prepares the element for drag&drop - this is normally called by makeWiget() unless are are delay loading */
|
|
2242
|
+
prepareDragDrop(el) {
|
|
2243
|
+
const node = el.gridstackNode;
|
|
2227
2244
|
const noMove = node.noMove || this.opts.disableDrag;
|
|
2228
2245
|
const noResize = node.noResize || this.opts.disableResize;
|
|
2229
2246
|
// check for disabled grid first
|
|
@@ -2504,6 +2521,6 @@ GridStack.resizeToContentParent = '.grid-stack-item-content';
|
|
|
2504
2521
|
GridStack.Utils = Utils;
|
|
2505
2522
|
/** scoping so users can call new GridStack.Engine(12) for example */
|
|
2506
2523
|
GridStack.Engine = GridStackEngine;
|
|
2507
|
-
GridStack.GDRev = '11.
|
|
2524
|
+
GridStack.GDRev = '11.4.0';
|
|
2508
2525
|
export { GridStack };
|
|
2509
2526
|
//# sourceMappingURL=gridstack.js.map
|