gridstack 9.3.0 → 9.5.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/.github/FUNDING.yml +1 -1
- package/angular/package.json +1 -1
- package/angular/projects/lib/package.json +1 -1
- package/angular/projects/lib/src/lib/base-widget.ts +1 -1
- package/angular/projects/lib/src/lib/gridstack-item.component.ts +1 -1
- package/angular/projects/lib/src/lib/gridstack.component.ts +1 -1
- package/angular/projects/lib/src/lib/gridstack.module.ts +1 -1
- package/dist/angular/esm2020/lib/base-widget.mjs +2 -2
- package/dist/angular/esm2020/lib/gridstack-item.component.mjs +2 -2
- package/dist/angular/esm2020/lib/gridstack.component.mjs +2 -2
- package/dist/angular/esm2020/lib/gridstack.module.mjs +2 -2
- package/dist/angular/fesm2015/gridstack-angular.mjs +4 -4
- package/dist/angular/fesm2015/gridstack-angular.mjs.map +1 -1
- package/dist/angular/fesm2020/gridstack-angular.mjs +4 -4
- package/dist/angular/fesm2020/gridstack-angular.mjs.map +1 -1
- package/dist/angular/lib/gridstack-item.component.d.ts +1 -1
- package/dist/angular/lib/gridstack.component.d.ts +1 -1
- package/dist/angular/package.json +1 -1
- package/dist/angular/src/base-widget.ts +1 -1
- package/dist/angular/src/gridstack-item.component.ts +1 -1
- package/dist/angular/src/gridstack.component.ts +1 -1
- package/dist/angular/src/gridstack.module.ts +1 -1
- package/dist/dd-base-impl.d.ts +1 -1
- package/dist/dd-base-impl.js +1 -1
- package/dist/dd-base-impl.js.map +1 -1
- package/dist/dd-draggable.d.ts +1 -5
- package/dist/dd-draggable.js +52 -24
- package/dist/dd-draggable.js.map +1 -1
- package/dist/dd-droppable.d.ts +1 -1
- package/dist/dd-droppable.js +1 -1
- package/dist/dd-droppable.js.map +1 -1
- package/dist/dd-element.d.ts +1 -1
- package/dist/dd-element.js +1 -1
- package/dist/dd-element.js.map +1 -1
- package/dist/dd-gridstack.d.ts +1 -1
- package/dist/dd-gridstack.js +1 -1
- package/dist/dd-gridstack.js.map +1 -1
- package/dist/dd-manager.d.ts +1 -1
- package/dist/dd-manager.js +1 -1
- package/dist/dd-manager.js.map +1 -1
- package/dist/dd-resizable-handle.d.ts +1 -1
- package/dist/dd-resizable-handle.js +1 -1
- package/dist/dd-resizable-handle.js.map +1 -1
- package/dist/dd-resizable.d.ts +1 -1
- package/dist/dd-resizable.js +46 -23
- package/dist/dd-resizable.js.map +1 -1
- package/dist/dd-touch.d.ts +1 -1
- package/dist/dd-touch.js +1 -1
- package/dist/dd-touch.js.map +1 -1
- package/dist/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 -5
- package/dist/es5/dd-draggable.js +52 -27
- 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 +1 -1
- 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 +47 -25
- package/dist/es5/dd-resizable.js.map +1 -1
- package/dist/es5/dd-touch.d.ts +1 -1
- package/dist/es5/dd-touch.js +1 -1
- 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 +1 -1
- package/dist/es5/gridstack-engine.js +3 -3
- package/dist/es5/gridstack-engine.js.map +1 -1
- package/dist/es5/gridstack-poly.js +1 -1
- package/dist/es5/gridstack.d.ts +2 -2
- package/dist/es5/gridstack.js +54 -41
- package/dist/es5/gridstack.js.map +1 -1
- package/dist/es5/types.d.ts +3 -1
- package/dist/es5/types.js +1 -1
- package/dist/es5/types.js.map +1 -1
- package/dist/es5/utils.d.ts +3 -7
- package/dist/es5/utils.js +8 -34
- 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 +1 -1
- package/dist/gridstack-engine.js +3 -3
- package/dist/gridstack-engine.js.map +1 -1
- package/dist/gridstack.css +1 -1
- package/dist/gridstack.d.ts +2 -2
- package/dist/gridstack.js +50 -37
- package/dist/gridstack.js.map +1 -1
- package/dist/src/gridstack.scss +1 -1
- package/dist/types.d.ts +3 -1
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +3 -7
- package/dist/utils.js +8 -34
- package/dist/utils.js.map +1 -1
- package/doc/CHANGES.md +12 -0
- package/package.json +1 -1
package/dist/gridstack.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* GridStack 9.
|
|
2
|
+
* GridStack 9.5.0
|
|
3
3
|
* https://gridstackjs.com/
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) 2021-2022 Alain Dumesny
|
|
@@ -542,10 +542,12 @@ class GridStack {
|
|
|
542
542
|
* @example
|
|
543
543
|
* see http://gridstackjs.com/demo/serialization.html
|
|
544
544
|
*/
|
|
545
|
-
load(
|
|
545
|
+
load(items, addRemove = GridStack.addRemoveCB || true) {
|
|
546
|
+
items = Utils.cloneDeep(items); // so we can mod
|
|
546
547
|
// if passed list has coordinates, use them (insert from end to beginning for conflict resolution) else force widget same order
|
|
547
|
-
const haveCoord =
|
|
548
|
-
|
|
548
|
+
const haveCoord = items.some(w => w.x !== undefined || w.y !== undefined);
|
|
549
|
+
if (haveCoord)
|
|
550
|
+
items = Utils.sort(items, -1, this._prevColumn || this.getColumn());
|
|
549
551
|
this._insertNotAppend = haveCoord; // if we create in reverse order...
|
|
550
552
|
// if we're loading a layout into for example 1 column (_prevColumn is set only when going to 1) and items don't fit, make sure to save
|
|
551
553
|
// the original wanted layout so we can scale back up correctly #1471
|
|
@@ -563,7 +565,9 @@ class GridStack {
|
|
|
563
565
|
if (addRemove) {
|
|
564
566
|
let copyNodes = [...this.engine.nodes]; // don't loop through array you modify
|
|
565
567
|
copyNodes.forEach(n => {
|
|
566
|
-
|
|
568
|
+
if (!n.id)
|
|
569
|
+
return;
|
|
570
|
+
let item = Utils.find(items, n.id);
|
|
567
571
|
if (!item) {
|
|
568
572
|
if (GridStack.addRemoveCB)
|
|
569
573
|
GridStack.addRemoveCB(this.el, n, false, false);
|
|
@@ -572,19 +576,36 @@ class GridStack {
|
|
|
572
576
|
}
|
|
573
577
|
});
|
|
574
578
|
}
|
|
575
|
-
// now add/update the widgets - starting with
|
|
576
|
-
|
|
577
|
-
|
|
579
|
+
// now add/update the widgets - starting with removing items in the new layout we will reposition
|
|
580
|
+
// to reduce collision and add no-coord ones at next available spot
|
|
581
|
+
let updateNodes = [];
|
|
582
|
+
this.engine.nodes = this.engine.nodes.filter(n => {
|
|
583
|
+
if (Utils.find(items, n.id)) {
|
|
584
|
+
updateNodes.push(n);
|
|
585
|
+
return false;
|
|
586
|
+
} // remove if found from list
|
|
587
|
+
return true;
|
|
588
|
+
});
|
|
589
|
+
let widthChanged = false;
|
|
578
590
|
items.forEach(w => {
|
|
579
|
-
let item =
|
|
591
|
+
let item = Utils.find(updateNodes, w.id);
|
|
580
592
|
if (item) {
|
|
593
|
+
// if item sizes to content, re-use the exiting height so it's a better guess at the final size 9same if width doesn't change)
|
|
594
|
+
if (Utils.shouldSizeToContent(item))
|
|
595
|
+
w.h = item.h;
|
|
581
596
|
// check if missing coord, in which case find next empty slot with new (or old if missing) sizes
|
|
582
597
|
if (w.autoPosition || w.x === undefined || w.y === undefined) {
|
|
583
598
|
w.w = w.w || item.w;
|
|
584
599
|
w.h = w.h || item.h;
|
|
585
600
|
this.engine.findEmptyPosition(w);
|
|
586
601
|
}
|
|
587
|
-
|
|
602
|
+
widthChanged = widthChanged || (w.w !== undefined && w.w !== item.w);
|
|
603
|
+
// add back to current list BUT force a collision check if it 'appears' we didn't change to make sure we don't overlap others now
|
|
604
|
+
this.engine.nodes.push(item);
|
|
605
|
+
if (Utils.samePos(item, w)) {
|
|
606
|
+
this.moveNode(item, { ...w, forceCollide: true });
|
|
607
|
+
Utils.copyPos(w, item, true);
|
|
608
|
+
}
|
|
588
609
|
this.update(item.el, w);
|
|
589
610
|
if (w.subGridOpts?.children) { // update any sub grid as well
|
|
590
611
|
let sub = item.el.querySelector('.grid-stack');
|
|
@@ -599,6 +620,7 @@ class GridStack {
|
|
|
599
620
|
}
|
|
600
621
|
});
|
|
601
622
|
this.engine.removedNodes = removed;
|
|
623
|
+
this.doContentResize(widthChanged, true); // we only need to wait for animation if we changed any widths
|
|
602
624
|
this.batchUpdate(false);
|
|
603
625
|
// after commit, clear that flag
|
|
604
626
|
delete this._ignoreLayoutsNodeChange;
|
|
@@ -716,9 +738,9 @@ class GridStack {
|
|
|
716
738
|
if (!column || column < 1 || this.opts.column === column)
|
|
717
739
|
return this;
|
|
718
740
|
let oldColumn = this.getColumn();
|
|
719
|
-
// if we go into 1 column mode
|
|
741
|
+
// if we go into 1 column mode due to size change (disableOneColumnMode is off and we hit min width)
|
|
720
742
|
// then remember the original columns so we can restore.
|
|
721
|
-
if (column === 1) {
|
|
743
|
+
if (column === 1 && !this.opts.disableOneColumnMode) {
|
|
722
744
|
this._prevColumn = oldColumn;
|
|
723
745
|
}
|
|
724
746
|
else {
|
|
@@ -1056,6 +1078,7 @@ class GridStack {
|
|
|
1056
1078
|
return;
|
|
1057
1079
|
let w = Utils.cloneDeep(opt); // make a copy we can modify in case they re-use it or multiple items
|
|
1058
1080
|
delete w.autoPosition;
|
|
1081
|
+
delete w.id;
|
|
1059
1082
|
// move/resize widget if anything changed
|
|
1060
1083
|
let keys = ['x', 'y', 'w', 'h'];
|
|
1061
1084
|
let m;
|
|
@@ -1073,14 +1096,14 @@ class GridStack {
|
|
|
1073
1096
|
// check for content changing
|
|
1074
1097
|
if (w.content !== undefined) {
|
|
1075
1098
|
const itemContent = el.querySelector('.grid-stack-item-content');
|
|
1076
|
-
if (
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1099
|
+
if (itemContent && itemContent.innerHTML !== w.content) {
|
|
1100
|
+
itemContent.innerHTML = w.content;
|
|
1101
|
+
// restore any sub-grid back
|
|
1102
|
+
if (n.subGrid?.el) {
|
|
1103
|
+
itemContent.appendChild(n.subGrid.el);
|
|
1104
|
+
if (!n.subGrid.opts.styleInHead)
|
|
1105
|
+
n.subGrid._updateStyles(true); // force create
|
|
1106
|
+
}
|
|
1084
1107
|
}
|
|
1085
1108
|
delete w.content;
|
|
1086
1109
|
}
|
|
@@ -1096,7 +1119,7 @@ class GridStack {
|
|
|
1096
1119
|
}
|
|
1097
1120
|
Utils.sanitizeMinMax(n);
|
|
1098
1121
|
// finally move the widget
|
|
1099
|
-
if (m)
|
|
1122
|
+
if (m !== undefined)
|
|
1100
1123
|
this.moveNode(n, m);
|
|
1101
1124
|
if (changed) { // move will only update x,y,w,h so update the rest too
|
|
1102
1125
|
this._writeAttr(el, n);
|
|
@@ -1557,7 +1580,7 @@ class GridStack {
|
|
|
1557
1580
|
|| this.engine.nodes.find(n => n.sizeToContent));
|
|
1558
1581
|
if (!forceRemove && trackSize && !this.resizeObserver) {
|
|
1559
1582
|
this._sizeThrottle = Utils.throttle(() => this.onResize(), this.opts.cellHeightThrottle);
|
|
1560
|
-
this.resizeObserver = new ResizeObserver(
|
|
1583
|
+
this.resizeObserver = new ResizeObserver(() => this._sizeThrottle());
|
|
1561
1584
|
this.resizeObserver.observe(this.el);
|
|
1562
1585
|
this._skipInitialResize = true; // makeWidget will originally have called on startup
|
|
1563
1586
|
}
|
|
@@ -1792,10 +1815,9 @@ class GridStack {
|
|
|
1792
1815
|
return;
|
|
1793
1816
|
helper = helper || el;
|
|
1794
1817
|
let parent = this.el.getBoundingClientRect();
|
|
1795
|
-
const { scaleX, scaleY } = Utils.getScaleForElement(helper);
|
|
1796
1818
|
let { top, left } = helper.getBoundingClientRect();
|
|
1797
|
-
left
|
|
1798
|
-
top
|
|
1819
|
+
left -= parent.left;
|
|
1820
|
+
top -= parent.top;
|
|
1799
1821
|
let ui = { position: { top, left } };
|
|
1800
1822
|
if (node._temporaryRemoved) {
|
|
1801
1823
|
node.x = Math.max(0, Math.round(left / cellWidth));
|
|
@@ -1958,6 +1980,7 @@ class GridStack {
|
|
|
1958
1980
|
this.engine.cleanupNode(node); // removes all internal _xyz values
|
|
1959
1981
|
node.grid = this;
|
|
1960
1982
|
}
|
|
1983
|
+
delete node.grid._isTemp;
|
|
1961
1984
|
dd.off(el, 'drag');
|
|
1962
1985
|
// if we made a copy ('helper' which is temp) of the original node then insert a copy, else we move the original node (#1102)
|
|
1963
1986
|
// as the helper will be nuked by jquery-ui otherwise. TODO: update old code path
|
|
@@ -1988,6 +2011,7 @@ class GridStack {
|
|
|
1988
2011
|
if (!subGrid.opts.styleInHead)
|
|
1989
2012
|
subGrid._updateStyles(true); // re-create sub-grid styles now that we've moved
|
|
1990
2013
|
}
|
|
2014
|
+
this._prepareDragDropByNode(node);
|
|
1991
2015
|
this._updateContainerHeight();
|
|
1992
2016
|
this.engine.addedNodes.push(node); // @ts-ignore
|
|
1993
2017
|
this._triggerAddEvent(); // @ts-ignore
|
|
@@ -1996,17 +2020,6 @@ class GridStack {
|
|
|
1996
2020
|
if (this._gsEventHandler['dropped']) {
|
|
1997
2021
|
this._gsEventHandler['dropped']({ ...event, type: 'dropped' }, origNode && origNode.grid ? origNode : undefined, node);
|
|
1998
2022
|
}
|
|
1999
|
-
// wait till we return out of the drag callback to set the new drag&resize handler or they may get messed up
|
|
2000
|
-
window.setTimeout(() => {
|
|
2001
|
-
// IFF we are still there (some application will use as placeholder and insert their real widget instead and better call makeWidget())
|
|
2002
|
-
if (node.el && node.el.parentElement) {
|
|
2003
|
-
this._prepareDragDropByNode(node);
|
|
2004
|
-
}
|
|
2005
|
-
else {
|
|
2006
|
-
this.engine.removeNode(node);
|
|
2007
|
-
}
|
|
2008
|
-
delete node.grid._isTemp;
|
|
2009
|
-
});
|
|
2010
2023
|
return false; // prevent parent from receiving msg (which may be grid as well)
|
|
2011
2024
|
});
|
|
2012
2025
|
return this;
|
|
@@ -2288,6 +2301,6 @@ GridStack.resizeToContentParent = '.grid-stack-item-content';
|
|
|
2288
2301
|
GridStack.Utils = Utils;
|
|
2289
2302
|
/** scoping so users can call new GridStack.Engine(12) for example */
|
|
2290
2303
|
GridStack.Engine = GridStackEngine;
|
|
2291
|
-
GridStack.GDRev = '9.
|
|
2304
|
+
GridStack.GDRev = '9.5.0';
|
|
2292
2305
|
export { GridStack };
|
|
2293
2306
|
//# sourceMappingURL=gridstack.js.map
|