gridstack 11.5.0 → 12.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 +15 -2
- package/dist/angular/README.md +0 -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/esm2020/lib/types.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 +5 -5
- 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/lib/types.d.ts +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 -1
- package/dist/dd-draggable.js +1 -1
- 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 +3 -2
- 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 -1
- package/dist/es5/dd-draggable.js +1 -1
- 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 +3 -2
- 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 +1 -1
- package/dist/es5/gridstack-engine.js.map +1 -1
- package/dist/es5/gridstack-poly.js +1 -1
- package/dist/es5/gridstack.d.ts +4 -5
- package/dist/es5/gridstack.js +88 -161
- package/dist/es5/gridstack.js.map +1 -1
- package/dist/es5/types.d.ts +5 -3
- package/dist/es5/types.js +1 -2
- package/dist/es5/types.js.map +1 -1
- package/dist/es5/utils.d.ts +1 -14
- package/dist/es5/utils.js +1 -45
- 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 +1 -1
- package/dist/gridstack-engine.js.map +1 -1
- package/dist/gridstack.css +25 -79
- package/dist/gridstack.d.ts +4 -5
- package/dist/gridstack.js +80 -153
- package/dist/gridstack.js.map +1 -1
- package/dist/gridstack.min.css +1 -1
- package/dist/src/gridstack.scss +22 -21
- package/dist/types.d.ts +5 -3
- package/dist/types.js +1 -2
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +1 -14
- package/dist/utils.js +1 -45
- package/dist/utils.js.map +1 -1
- package/doc/CHANGES.md +10 -0
- package/doc/README.md +0 -3
- package/package.json +1 -1
- package/dist/angular/node_modules/tslib/README.md +0 -164
- package/dist/gridstack-extra.css +0 -373
- package/dist/gridstack-extra.min.css +0 -1
- package/dist/src/gridstack-extra.scss +0 -25
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
|
|
39
|
+
* GridStack 12.0.0
|
|
40
40
|
* https://gridstackjs.com/
|
|
41
41
|
*
|
|
42
42
|
* Copyright (c) 2021-2024 Alain Dumesny
|
|
@@ -156,9 +156,9 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
156
156
|
}
|
|
157
157
|
opts = utils_1.Utils.defaults(opts, defaults);
|
|
158
158
|
this._initMargin(); // part of settings defaults...
|
|
159
|
-
// Now check if we're loading into
|
|
159
|
+
// Now check if we're loading into !12 column mode FIRST so we don't do un-necessary work (like cellHeight = width / 12 then go 1 column)
|
|
160
160
|
this.checkDynamicColumn();
|
|
161
|
-
this.
|
|
161
|
+
this._updateColumnVar(opts);
|
|
162
162
|
if (opts.rtl === 'auto') {
|
|
163
163
|
opts.rtl = (el.style.direction === 'rtl');
|
|
164
164
|
}
|
|
@@ -177,7 +177,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
177
177
|
this._isAutoCellHeight = (opts.cellHeight === 'auto');
|
|
178
178
|
if (this._isAutoCellHeight || opts.cellHeight === 'initial') {
|
|
179
179
|
// make the cell content square initially (will use resize/column event to keep it square)
|
|
180
|
-
this.cellHeight(undefined
|
|
180
|
+
this.cellHeight(undefined);
|
|
181
181
|
}
|
|
182
182
|
else {
|
|
183
183
|
// append unit if any are set
|
|
@@ -185,14 +185,14 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
185
185
|
opts.cellHeight = opts.cellHeight + opts.cellHeightUnit;
|
|
186
186
|
delete opts.cellHeightUnit;
|
|
187
187
|
}
|
|
188
|
-
|
|
188
|
+
var val = opts.cellHeight;
|
|
189
|
+
delete opts.cellHeight; // force initial cellHeight() call to set the value
|
|
190
|
+
this.cellHeight(val);
|
|
189
191
|
}
|
|
190
192
|
// see if we need to adjust auto-hide
|
|
191
193
|
if (opts.alwaysShowResizeHandle === 'mobile') {
|
|
192
194
|
opts.alwaysShowResizeHandle = dd_touch_1.isTouch;
|
|
193
195
|
}
|
|
194
|
-
this._styleSheetClass = 'gs-id-' + gridstack_engine_1.GridStackEngine._idSeq++;
|
|
195
|
-
this.el.classList.add(this._styleSheetClass);
|
|
196
196
|
this._setStaticClass();
|
|
197
197
|
var engineClass = opts.engineClass || GridStack.engineClass || gridstack_engine_1.GridStackEngine;
|
|
198
198
|
this.engine = new engineClass({
|
|
@@ -200,8 +200,6 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
200
200
|
float: opts.float,
|
|
201
201
|
maxRow: opts.maxRow,
|
|
202
202
|
onChange: function (cbNodes) {
|
|
203
|
-
var maxH = 0;
|
|
204
|
-
_this.engine.nodes.forEach(function (n) { maxH = Math.max(maxH, n.y + n.h); });
|
|
205
203
|
cbNodes.forEach(function (n) {
|
|
206
204
|
var el = n.el;
|
|
207
205
|
if (!el)
|
|
@@ -215,11 +213,9 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
215
213
|
_this._writePosAttr(el, n);
|
|
216
214
|
}
|
|
217
215
|
});
|
|
218
|
-
_this.
|
|
216
|
+
_this._updateContainerHeight();
|
|
219
217
|
}
|
|
220
218
|
});
|
|
221
|
-
// create initial global styles BEFORE loading children so resizeToContent margin can be calculated correctly
|
|
222
|
-
this._updateStyles(false, 0);
|
|
223
219
|
if (opts.auto) {
|
|
224
220
|
this.batchUpdate(); // prevent in between re-layout #1535 TODO: this only set float=true, need to prevent collision check...
|
|
225
221
|
this.engine._loading = true; // loading collision check
|
|
@@ -234,7 +230,6 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
234
230
|
if (children.length)
|
|
235
231
|
this.load(children); // don't load empty
|
|
236
232
|
}
|
|
237
|
-
// if (this.engine.nodes.length) this._updateStyles(); // update based on # of children. done in engine onChange CB
|
|
238
233
|
this.setAnimation();
|
|
239
234
|
// dynamic grids require pausing during drag to detect over to nest vs push
|
|
240
235
|
if (opts.subGridDynamic && !dd_manager_1.DDManager.pauseDrag)
|
|
@@ -363,6 +358,12 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
363
358
|
enumerable: false,
|
|
364
359
|
configurable: true
|
|
365
360
|
});
|
|
361
|
+
GridStack.prototype._updateColumnVar = function (opts) {
|
|
362
|
+
if (opts === void 0) { opts = this.opts; }
|
|
363
|
+
this.el.classList.add('gs-' + opts.column);
|
|
364
|
+
if (typeof opts.column === 'number')
|
|
365
|
+
this.el.style.setProperty('--gs-column-width', "".concat(100 / opts.column, "%"));
|
|
366
|
+
};
|
|
366
367
|
/**
|
|
367
368
|
* add a new widget and returns it.
|
|
368
369
|
*
|
|
@@ -652,8 +653,18 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
652
653
|
items.forEach(function (n) { maxColumn = Math.max(maxColumn, (n.x || 0) + n.w); });
|
|
653
654
|
if (maxColumn > this.engine.defaultColumn)
|
|
654
655
|
this.engine.defaultColumn = maxColumn;
|
|
655
|
-
if (maxColumn > column)
|
|
656
|
-
|
|
656
|
+
if (maxColumn > column) {
|
|
657
|
+
// if we're loading (from empty) into a smaller column, check for special responsive layout
|
|
658
|
+
if (this.engine.nodes.length === 0 && this.responseLayout) {
|
|
659
|
+
this.engine.nodes = items;
|
|
660
|
+
this.engine.columnChanged(maxColumn, column, this.responseLayout);
|
|
661
|
+
items = this.engine.nodes;
|
|
662
|
+
this.engine.nodes = [];
|
|
663
|
+
delete this.responseLayout;
|
|
664
|
+
}
|
|
665
|
+
else
|
|
666
|
+
this.engine.cacheLayout(items, maxColumn, true);
|
|
667
|
+
}
|
|
657
668
|
// if given a different callback, temporally set it as global option so creating will use it
|
|
658
669
|
var prevCB = GridStack.addRemoveCB;
|
|
659
670
|
if (typeof (addRemove) === 'function')
|
|
@@ -789,17 +800,15 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
789
800
|
*
|
|
790
801
|
* @param val the cell height. If not passed (undefined), cells content will be made square (match width minus margin),
|
|
791
802
|
* if pass 0 the CSS will be generated by the application instead.
|
|
792
|
-
* @param update (Optional) if false, styles will not be updated
|
|
793
803
|
*
|
|
794
804
|
* @example
|
|
795
805
|
* grid.cellHeight(100); // same as 100px
|
|
796
806
|
* grid.cellHeight('70px');
|
|
797
807
|
* grid.cellHeight(grid.cellWidth() * 1.2);
|
|
798
808
|
*/
|
|
799
|
-
GridStack.prototype.cellHeight = function (val
|
|
800
|
-
if (update === void 0) { update = true; }
|
|
809
|
+
GridStack.prototype.cellHeight = function (val) {
|
|
801
810
|
// if not called internally, check if we're changing mode
|
|
802
|
-
if (
|
|
811
|
+
if (val !== undefined) {
|
|
803
812
|
if (this._isAutoCellHeight !== (val === 'auto')) {
|
|
804
813
|
this._isAutoCellHeight = (val === 'auto');
|
|
805
814
|
this._updateResizeEvent();
|
|
@@ -820,10 +829,10 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
820
829
|
}
|
|
821
830
|
this.opts.cellHeightUnit = data.unit;
|
|
822
831
|
this.opts.cellHeight = data.h;
|
|
832
|
+
// finally update var and container
|
|
833
|
+
this.el.style.setProperty('--gs-cell-height', "".concat(this.opts.cellHeight).concat(this.opts.cellHeightUnit));
|
|
834
|
+
this._updateContainerHeight();
|
|
823
835
|
this.resizeToContentCheck();
|
|
824
|
-
if (update) {
|
|
825
|
-
this._updateStyles(true); // true = force re-create for current # of rows
|
|
826
|
-
}
|
|
827
836
|
return this;
|
|
828
837
|
};
|
|
829
838
|
/** Gets current cell width. */
|
|
@@ -882,8 +891,6 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
882
891
|
/**
|
|
883
892
|
* set the number of columns in the grid. Will update existing widgets to conform to new number of columns,
|
|
884
893
|
* as well as cache the original layout so you can revert back to previous positions without loss.
|
|
885
|
-
* Requires `gridstack-extra.css` or `gridstack-extra.min.css` for [2-11],
|
|
886
|
-
* else you will need to generate correct CSS (see https://github.com/gridstack/gridstack.js#change-grid-columns)
|
|
887
894
|
* @param column - Integer > 0 (default 12).
|
|
888
895
|
* @param layout specify the type of re-layout that will happen (position, size, etc...).
|
|
889
896
|
* Note: items will never be outside of the current column boundaries. default ('moveScale'). Ignored for 1 column
|
|
@@ -894,15 +901,16 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
894
901
|
return this;
|
|
895
902
|
var oldColumn = this.getColumn();
|
|
896
903
|
this.opts.column = column;
|
|
897
|
-
if (!this.engine)
|
|
898
|
-
|
|
904
|
+
if (!this.engine) {
|
|
905
|
+
// called in constructor, noting else to do but remember that breakpoint layout
|
|
906
|
+
this.responseLayout = layout;
|
|
907
|
+
return this;
|
|
908
|
+
}
|
|
899
909
|
this.engine.column = column;
|
|
900
910
|
this.el.classList.remove('gs-' + oldColumn);
|
|
901
|
-
this.
|
|
902
|
-
// update the items now
|
|
903
|
-
|
|
904
|
-
if (newChildren) this.load(newChildren);
|
|
905
|
-
else*/ this.engine.columnChanged(oldColumn, column, layout);
|
|
911
|
+
this._updateColumnVar();
|
|
912
|
+
// update the items now
|
|
913
|
+
this.engine.columnChanged(oldColumn, column, layout);
|
|
906
914
|
if (this._isAutoCellHeight)
|
|
907
915
|
this.cellHeight();
|
|
908
916
|
this.resizeToContentCheck(true); // wait for width resizing
|
|
@@ -929,7 +937,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
929
937
|
* @param removeDOM if `false` grid and items HTML elements will not be removed from the DOM (Optional. Default `true`).
|
|
930
938
|
*/
|
|
931
939
|
GridStack.prototype.destroy = function (removeDOM) {
|
|
932
|
-
var _a
|
|
940
|
+
var _a;
|
|
933
941
|
if (removeDOM === void 0) { removeDOM = true; }
|
|
934
942
|
if (!this.el)
|
|
935
943
|
return; // prevent multiple calls
|
|
@@ -939,17 +947,16 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
939
947
|
this.setAnimation(false);
|
|
940
948
|
if (!removeDOM) {
|
|
941
949
|
this.removeAll(removeDOM);
|
|
942
|
-
this.el.classList.remove(this._styleSheetClass);
|
|
943
950
|
this.el.removeAttribute('gs-current-row');
|
|
944
951
|
}
|
|
945
952
|
else {
|
|
946
953
|
this.el.parentNode.removeChild(this.el);
|
|
947
954
|
}
|
|
948
|
-
this.
|
|
949
|
-
|
|
955
|
+
if (this.parentGridNode)
|
|
956
|
+
delete this.parentGridNode.subGrid;
|
|
950
957
|
delete this.parentGridNode;
|
|
951
958
|
delete this.opts;
|
|
952
|
-
(
|
|
959
|
+
(_a = this._placeholder) === null || _a === void 0 ? true : delete _a.gridstackNode;
|
|
953
960
|
delete this._placeholder;
|
|
954
961
|
delete this.engine;
|
|
955
962
|
delete this.el.gridstack; // remove circular dependency that would prevent a freeing
|
|
@@ -1029,8 +1036,8 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
1029
1036
|
*/
|
|
1030
1037
|
GridStack.prototype.makeWidget = function (els, options) {
|
|
1031
1038
|
var el = GridStack.getElement(els);
|
|
1032
|
-
if (!el)
|
|
1033
|
-
return;
|
|
1039
|
+
if (!el || el.gridstackNode)
|
|
1040
|
+
return el;
|
|
1034
1041
|
if (!el.parentElement)
|
|
1035
1042
|
this.el.appendChild(el);
|
|
1036
1043
|
this._prepareElement(el, true, options);
|
|
@@ -1236,7 +1243,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
1236
1243
|
if (o.animate !== undefined)
|
|
1237
1244
|
this.setAnimation();
|
|
1238
1245
|
if (o.cellHeight) {
|
|
1239
|
-
this.cellHeight(o.cellHeight
|
|
1246
|
+
this.cellHeight(o.cellHeight);
|
|
1240
1247
|
delete o.cellHeight;
|
|
1241
1248
|
}
|
|
1242
1249
|
if (o.class && o.class !== opts.class) {
|
|
@@ -1309,8 +1316,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
1309
1316
|
// restore any sub-grid back
|
|
1310
1317
|
if ((_a = n.subGrid) === null || _a === void 0 ? void 0 : _a.el) {
|
|
1311
1318
|
itemContent.appendChild(n.subGrid.el);
|
|
1312
|
-
|
|
1313
|
-
n.subGrid._updateStyles(true); // force create
|
|
1319
|
+
n.subGrid._updateContainerHeight();
|
|
1314
1320
|
}
|
|
1315
1321
|
}
|
|
1316
1322
|
delete w.content;
|
|
@@ -1471,7 +1477,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
1471
1477
|
*/
|
|
1472
1478
|
GridStack.prototype.margin = function (value) {
|
|
1473
1479
|
var isMultiValue = (typeof value === 'string' && value.split(' ').length > 1);
|
|
1474
|
-
// check if we can skip
|
|
1480
|
+
// check if we can skip... won't check if multi values (too much hassle)
|
|
1475
1481
|
if (!isMultiValue) {
|
|
1476
1482
|
var data = utils_1.Utils.parseHeight(value);
|
|
1477
1483
|
if (this.opts.marginUnit === data.unit && this.opts.margin === data.h)
|
|
@@ -1481,7 +1487,6 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
1481
1487
|
this.opts.margin = value;
|
|
1482
1488
|
this.opts.marginTop = this.opts.marginBottom = this.opts.marginLeft = this.opts.marginRight = undefined;
|
|
1483
1489
|
this._initMargin();
|
|
1484
|
-
this._updateStyles(true); // true = force re-create
|
|
1485
1490
|
return this;
|
|
1486
1491
|
};
|
|
1487
1492
|
/** returns current margin number value (undefined if 4 sides don't match) */
|
|
@@ -1558,75 +1563,6 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
1558
1563
|
this.el.dispatchEvent(event);
|
|
1559
1564
|
return this;
|
|
1560
1565
|
};
|
|
1561
|
-
/** @internal called to delete the current dynamic style sheet used for our layout */
|
|
1562
|
-
GridStack.prototype._removeStylesheet = function () {
|
|
1563
|
-
if (this._styles) {
|
|
1564
|
-
var styleLocation = this.opts.styleInHead ? undefined : this.el.parentNode;
|
|
1565
|
-
utils_1.Utils.removeStylesheet(this._styleSheetClass, styleLocation);
|
|
1566
|
-
delete this._styles;
|
|
1567
|
-
}
|
|
1568
|
-
return this;
|
|
1569
|
-
};
|
|
1570
|
-
/** @internal updated/create the CSS styles for row based layout and initial margin setting */
|
|
1571
|
-
GridStack.prototype._updateStyles = function (forceUpdate, maxH) {
|
|
1572
|
-
if (forceUpdate === void 0) { forceUpdate = false; }
|
|
1573
|
-
// call to delete existing one if we change cellHeight / margin
|
|
1574
|
-
if (forceUpdate) {
|
|
1575
|
-
this._removeStylesheet();
|
|
1576
|
-
}
|
|
1577
|
-
if (maxH === undefined)
|
|
1578
|
-
maxH = this.getRow();
|
|
1579
|
-
this._updateContainerHeight();
|
|
1580
|
-
// if user is telling us they will handle the CSS themselves by setting heights to 0. Do we need this opts really ??
|
|
1581
|
-
if (this.opts.cellHeight === 0) {
|
|
1582
|
-
return this;
|
|
1583
|
-
}
|
|
1584
|
-
var cellHeight = this.opts.cellHeight;
|
|
1585
|
-
var cellHeightUnit = this.opts.cellHeightUnit;
|
|
1586
|
-
var prefix = ".".concat(this._styleSheetClass, " > .").concat(this.opts.itemClass);
|
|
1587
|
-
// create one as needed
|
|
1588
|
-
if (!this._styles) {
|
|
1589
|
-
// insert style to parent (instead of 'head' by default) to support WebComponent
|
|
1590
|
-
var styleLocation = this.opts.styleInHead ? undefined : this.el.parentNode;
|
|
1591
|
-
this._styles = utils_1.Utils.createStylesheet(this._styleSheetClass, styleLocation, {
|
|
1592
|
-
nonce: this.opts.nonce,
|
|
1593
|
-
});
|
|
1594
|
-
if (!this._styles)
|
|
1595
|
-
return this;
|
|
1596
|
-
this._styles._max = 0;
|
|
1597
|
-
// these are done once only
|
|
1598
|
-
utils_1.Utils.addCSSRule(this._styles, prefix, "height: ".concat(cellHeight).concat(cellHeightUnit));
|
|
1599
|
-
// content margins
|
|
1600
|
-
var top_1 = this.opts.marginTop + this.opts.marginUnit;
|
|
1601
|
-
var bottom = this.opts.marginBottom + this.opts.marginUnit;
|
|
1602
|
-
var right = this.opts.marginRight + this.opts.marginUnit;
|
|
1603
|
-
var left = this.opts.marginLeft + this.opts.marginUnit;
|
|
1604
|
-
var content = "".concat(prefix, " > .grid-stack-item-content");
|
|
1605
|
-
var placeholder = ".".concat(this._styleSheetClass, " > .grid-stack-placeholder > .placeholder-content");
|
|
1606
|
-
utils_1.Utils.addCSSRule(this._styles, content, "top: ".concat(top_1, "; right: ").concat(right, "; bottom: ").concat(bottom, "; left: ").concat(left, ";"));
|
|
1607
|
-
utils_1.Utils.addCSSRule(this._styles, placeholder, "top: ".concat(top_1, "; right: ").concat(right, "; bottom: ").concat(bottom, "; left: ").concat(left, ";"));
|
|
1608
|
-
// resize handles offset (to match margin)
|
|
1609
|
-
utils_1.Utils.addCSSRule(this._styles, "".concat(prefix, " > .ui-resizable-n"), "top: ".concat(top_1, ";"));
|
|
1610
|
-
utils_1.Utils.addCSSRule(this._styles, "".concat(prefix, " > .ui-resizable-s"), "bottom: ".concat(bottom));
|
|
1611
|
-
utils_1.Utils.addCSSRule(this._styles, "".concat(prefix, " > .ui-resizable-ne"), "right: ".concat(right, "; top: ").concat(top_1));
|
|
1612
|
-
utils_1.Utils.addCSSRule(this._styles, "".concat(prefix, " > .ui-resizable-e"), "right: ".concat(right));
|
|
1613
|
-
utils_1.Utils.addCSSRule(this._styles, "".concat(prefix, " > .ui-resizable-se"), "right: ".concat(right, "; bottom: ").concat(bottom));
|
|
1614
|
-
utils_1.Utils.addCSSRule(this._styles, "".concat(prefix, " > .ui-resizable-nw"), "left: ".concat(left, "; top: ").concat(top_1));
|
|
1615
|
-
utils_1.Utils.addCSSRule(this._styles, "".concat(prefix, " > .ui-resizable-w"), "left: ".concat(left));
|
|
1616
|
-
utils_1.Utils.addCSSRule(this._styles, "".concat(prefix, " > .ui-resizable-sw"), "left: ".concat(left, "; bottom: ").concat(bottom));
|
|
1617
|
-
}
|
|
1618
|
-
// now update the height specific fields
|
|
1619
|
-
maxH = maxH || this._styles._max;
|
|
1620
|
-
if (maxH > this._styles._max) {
|
|
1621
|
-
var getHeight = function (rows) { return (cellHeight * rows) + cellHeightUnit; };
|
|
1622
|
-
for (var i = this._styles._max + 1; i <= maxH; i++) { // start at 1
|
|
1623
|
-
utils_1.Utils.addCSSRule(this._styles, "".concat(prefix, "[gs-y=\"").concat(i, "\"]"), "top: ".concat(getHeight(i)));
|
|
1624
|
-
utils_1.Utils.addCSSRule(this._styles, "".concat(prefix, "[gs-h=\"").concat(i + 1, "\"]"), "height: ".concat(getHeight(i + 1))); // start at 2
|
|
1625
|
-
}
|
|
1626
|
-
this._styles._max = maxH;
|
|
1627
|
-
}
|
|
1628
|
-
return this;
|
|
1629
|
-
};
|
|
1630
1566
|
/** @internal */
|
|
1631
1567
|
GridStack.prototype._updateContainerHeight = function () {
|
|
1632
1568
|
if (!this.engine || this.engine.batchMode)
|
|
@@ -1679,14 +1615,19 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
1679
1615
|
this.prepareDragDrop(node.el);
|
|
1680
1616
|
return this;
|
|
1681
1617
|
};
|
|
1682
|
-
/** @internal
|
|
1618
|
+
/** @internal write position CSS vars and x,y,w,h attributes (not used for CSS but by users) back to element */
|
|
1683
1619
|
GridStack.prototype._writePosAttr = function (el, n) {
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
el.
|
|
1689
|
-
|
|
1620
|
+
// Avoid overwriting the inline style of the element during drag/resize, but always update the placeholder
|
|
1621
|
+
if ((!n._moving && !n._resizing) || this._placeholder === el) {
|
|
1622
|
+
// width/height:1 x/y:0 is set by default in the main CSS, so no need to set inlined vars
|
|
1623
|
+
el.style.top = n.y ? (n.y === 1 ? "var(--gs-cell-height)" : "calc(".concat(n.y, " * var(--gs-cell-height))")) : null;
|
|
1624
|
+
el.style.left = n.x ? (n.x === 1 ? "var(--gs-column-width)" : "calc(".concat(n.x, " * var(--gs-column-width))")) : null;
|
|
1625
|
+
el.style.width = n.w > 1 ? "calc(".concat(n.w, " * var(--gs-column-width))") : null;
|
|
1626
|
+
el.style.height = n.h > 1 ? "calc(".concat(n.h, " * var(--gs-cell-height))") : null;
|
|
1627
|
+
}
|
|
1628
|
+
// NOTE: those are technically not needed anymore (v12+) as we have CSS vars for everything, but some users depends on them to render item size using CSS
|
|
1629
|
+
n.x > 0 ? el.setAttribute('gs-x', String(n.x)) : el.removeAttribute('gs-x');
|
|
1630
|
+
n.y > 0 ? el.setAttribute('gs-y', String(n.y)) : el.removeAttribute('gs-y');
|
|
1690
1631
|
n.w > 1 ? el.setAttribute('gs-w', String(n.w)) : el.removeAttribute('gs-w');
|
|
1691
1632
|
n.h > 1 ? el.setAttribute('gs-h', String(n.h)) : el.removeAttribute('gs-h');
|
|
1692
1633
|
return this;
|
|
@@ -1884,6 +1825,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
1884
1825
|
GridStack.getGridElements = function (els) { return utils_1.Utils.getElements(els); };
|
|
1885
1826
|
/** @internal initialize margin top/bottom/left/right and units */
|
|
1886
1827
|
GridStack.prototype._initMargin = function () {
|
|
1828
|
+
var _this = this;
|
|
1887
1829
|
var data;
|
|
1888
1830
|
var margin = 0;
|
|
1889
1831
|
// support passing multiple values like CSS (ex: '5px 10px 0 20px')
|
|
@@ -1907,42 +1849,27 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
1907
1849
|
margin = this.opts.margin = data.h;
|
|
1908
1850
|
}
|
|
1909
1851
|
// see if top/bottom/left/right need to be set as well
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
}
|
|
1921
|
-
else {
|
|
1922
|
-
data = utils_1.Utils.parseHeight(this.opts.marginBottom);
|
|
1923
|
-
this.opts.marginBottom = data.h;
|
|
1924
|
-
delete this.opts.margin;
|
|
1925
|
-
}
|
|
1926
|
-
if (this.opts.marginRight === undefined) {
|
|
1927
|
-
this.opts.marginRight = margin;
|
|
1928
|
-
}
|
|
1929
|
-
else {
|
|
1930
|
-
data = utils_1.Utils.parseHeight(this.opts.marginRight);
|
|
1931
|
-
this.opts.marginRight = data.h;
|
|
1932
|
-
delete this.opts.margin;
|
|
1933
|
-
}
|
|
1934
|
-
if (this.opts.marginLeft === undefined) {
|
|
1935
|
-
this.opts.marginLeft = margin;
|
|
1936
|
-
}
|
|
1937
|
-
else {
|
|
1938
|
-
data = utils_1.Utils.parseHeight(this.opts.marginLeft);
|
|
1939
|
-
this.opts.marginLeft = data.h;
|
|
1940
|
-
delete this.opts.margin;
|
|
1941
|
-
}
|
|
1852
|
+
var keys = ['marginTop', 'marginRight', 'marginBottom', 'marginLeft'];
|
|
1853
|
+
keys.forEach(function (k) {
|
|
1854
|
+
if (_this.opts[k] === undefined) {
|
|
1855
|
+
_this.opts[k] = margin;
|
|
1856
|
+
}
|
|
1857
|
+
else {
|
|
1858
|
+
data = utils_1.Utils.parseHeight(_this.opts[k]);
|
|
1859
|
+
_this.opts[k] = data.h;
|
|
1860
|
+
delete _this.opts.margin;
|
|
1861
|
+
}
|
|
1862
|
+
});
|
|
1942
1863
|
this.opts.marginUnit = data.unit; // in case side were spelled out, use those units instead...
|
|
1943
1864
|
if (this.opts.marginTop === this.opts.marginBottom && this.opts.marginLeft === this.opts.marginRight && this.opts.marginTop === this.opts.marginRight) {
|
|
1944
1865
|
this.opts.margin = this.opts.marginTop; // makes it easier to check for no-ops in setMargin()
|
|
1945
1866
|
}
|
|
1867
|
+
// finally Update the CSS margin variables (inside the cell height) */
|
|
1868
|
+
var style = this.el.style;
|
|
1869
|
+
style.setProperty('--gs-item-margin-top', "".concat(this.opts.marginTop).concat(this.opts.marginUnit));
|
|
1870
|
+
style.setProperty('--gs-item-margin-bottom', "".concat(this.opts.marginBottom).concat(this.opts.marginUnit));
|
|
1871
|
+
style.setProperty('--gs-item-margin-right', "".concat(this.opts.marginRight).concat(this.opts.marginUnit));
|
|
1872
|
+
style.setProperty('--gs-item-margin-left', "".concat(this.opts.marginLeft).concat(this.opts.marginUnit));
|
|
1946
1873
|
return this;
|
|
1947
1874
|
};
|
|
1948
1875
|
/* ===========================================================================================
|
|
@@ -2365,8 +2292,6 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
2365
2292
|
_this.resizeToContentCheck(false, node);
|
|
2366
2293
|
if (subGrid) {
|
|
2367
2294
|
subGrid.parentGridNode = node;
|
|
2368
|
-
if (!subGrid.opts.styleInHead)
|
|
2369
|
-
subGrid._updateStyles(true); // re-create sub-grid styles now that we've moved
|
|
2370
2295
|
}
|
|
2371
2296
|
_this._updateContainerHeight();
|
|
2372
2297
|
}
|
|
@@ -2425,16 +2350,16 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
2425
2350
|
var noMove = node.noMove || this.opts.disableDrag;
|
|
2426
2351
|
var noResize = node.noResize || this.opts.disableResize;
|
|
2427
2352
|
// check for disabled grid first
|
|
2428
|
-
var disable =
|
|
2353
|
+
var disable = this.opts.staticGrid || (noMove && noResize);
|
|
2429
2354
|
if (force || disable) {
|
|
2430
2355
|
if (node._initDD) {
|
|
2431
2356
|
this._removeDD(el); // nukes everything instead of just disable, will add some styles back next
|
|
2432
2357
|
delete node._initDD;
|
|
2433
2358
|
}
|
|
2434
|
-
if (disable)
|
|
2359
|
+
if (disable)
|
|
2435
2360
|
el.classList.add('ui-draggable-disabled', 'ui-resizable-disabled'); // add styles one might depend on #1435
|
|
2361
|
+
if (!force)
|
|
2436
2362
|
return this;
|
|
2437
|
-
}
|
|
2438
2363
|
}
|
|
2439
2364
|
if (!node._initDD) {
|
|
2440
2365
|
// variables used/cashed between the 3 start/move/end methods, in addition to node passed above
|
|
@@ -2459,6 +2384,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
2459
2384
|
_this.placeholder.remove();
|
|
2460
2385
|
delete _this.placeholder.gridstackNode;
|
|
2461
2386
|
delete node._moving;
|
|
2387
|
+
delete node._resizing;
|
|
2462
2388
|
delete node._event;
|
|
2463
2389
|
delete node._lastTried;
|
|
2464
2390
|
var widthChanged = node.w !== node._orig.w;
|
|
@@ -2552,6 +2478,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
2552
2478
|
node._lastUiPosition = ui.position;
|
|
2553
2479
|
node._prevYPix = ui.position.top;
|
|
2554
2480
|
node._moving = (event.type === 'dragstart'); // 'dropover' are not initially moving so they can go exactly where they enter (will push stuff out of the way)
|
|
2481
|
+
node._resizing = (event.type === 'resizestart');
|
|
2555
2482
|
delete node._lastTried;
|
|
2556
2483
|
if (event.type === 'dropover' && node._temporaryRemoved) {
|
|
2557
2484
|
// console.log('engine.addNode x=' + node.x); // TEST
|
|
@@ -2592,9 +2519,9 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
2592
2519
|
}
|
|
2593
2520
|
// get new position taking into account the margin in the direction we are moving! (need to pass mid point by margin)
|
|
2594
2521
|
var left = ui.position.left + (ui.position.left > node._lastUiPosition.left ? -mRight : mLeft);
|
|
2595
|
-
var
|
|
2522
|
+
var top_1 = ui.position.top + (ui.position.top > node._lastUiPosition.top ? -mBottom : mTop);
|
|
2596
2523
|
p.x = Math.round(left / cellWidth);
|
|
2597
|
-
p.y = Math.round(
|
|
2524
|
+
p.y = Math.round(top_1 / cellHeight);
|
|
2598
2525
|
// @ts-ignore// if we're at the bottom hitting something else, grow the grid so cursor doesn't leave when trying to place below others
|
|
2599
2526
|
var prev = this._extraDragRow;
|
|
2600
2527
|
if (this.engine.collide(node, p)) {
|
|
@@ -2628,9 +2555,9 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
2628
2555
|
return; // skip one we tried (but failed)
|
|
2629
2556
|
// if we size on left/top side this might move us, so get possible new position as well
|
|
2630
2557
|
var left = ui.position.left + mLeft;
|
|
2631
|
-
var
|
|
2558
|
+
var top_2 = ui.position.top + mTop;
|
|
2632
2559
|
p.x = Math.round(left / cellWidth);
|
|
2633
|
-
p.y = Math.round(
|
|
2560
|
+
p.y = Math.round(top_2 / cellHeight);
|
|
2634
2561
|
resizing = true;
|
|
2635
2562
|
}
|
|
2636
2563
|
node._event = event;
|
|
@@ -2711,7 +2638,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
2711
2638
|
GridStack.Utils = utils_1.Utils;
|
|
2712
2639
|
/** scoping so users can call new GridStack.Engine(12) for example */
|
|
2713
2640
|
GridStack.Engine = gridstack_engine_1.GridStackEngine;
|
|
2714
|
-
GridStack.GDRev = '
|
|
2641
|
+
GridStack.GDRev = '12.0.0';
|
|
2715
2642
|
return GridStack;
|
|
2716
2643
|
}());
|
|
2717
2644
|
//# sourceMappingURL=gridstack.js.map
|