gridstack 4.4.1 → 5.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 +8 -0
- package/dist/es5/gridstack-dd.d.ts +1 -1
- package/dist/es5/gridstack-dd.js +13 -10
- package/dist/es5/gridstack-dd.js.map +1 -1
- package/dist/es5/gridstack-ddi.d.ts +1 -1
- package/dist/es5/gridstack-ddi.js +1 -1
- package/dist/es5/gridstack-ddi.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-h5.d.ts +1 -1
- package/dist/es5/gridstack-h5.js +1 -1
- package/dist/es5/gridstack-h5.js.LICENSE.txt +1 -1
- package/dist/es5/gridstack-h5.js.map +1 -1
- package/dist/es5/gridstack-jq.d.ts +1 -1
- package/dist/es5/gridstack-jq.js +1 -1
- package/dist/es5/gridstack-jq.js.LICENSE.txt +1 -1
- package/dist/es5/gridstack-jq.js.map +1 -1
- package/dist/es5/gridstack-poly.js +3 -3
- package/dist/es5/gridstack-static.d.ts +1 -1
- package/dist/es5/gridstack-static.js +1 -1
- package/dist/es5/gridstack-static.js.LICENSE.txt +1 -1
- package/dist/es5/gridstack-static.js.map +1 -1
- package/dist/es5/gridstack.d.ts +2 -2
- package/dist/es5/gridstack.js +69 -34
- package/dist/es5/gridstack.js.map +1 -1
- package/dist/es5/h5/dd-base-impl.d.ts +1 -1
- package/dist/es5/h5/dd-base-impl.js +1 -1
- package/dist/es5/h5/dd-base-impl.js.map +1 -1
- package/dist/es5/h5/dd-draggable.d.ts +1 -2
- package/dist/es5/h5/dd-draggable.js +26 -16
- package/dist/es5/h5/dd-draggable.js.map +1 -1
- package/dist/es5/h5/dd-droppable.d.ts +2 -1
- package/dist/es5/h5/dd-droppable.js +42 -25
- package/dist/es5/h5/dd-droppable.js.map +1 -1
- package/dist/es5/h5/dd-element.d.ts +1 -1
- package/dist/es5/h5/dd-element.js +1 -1
- package/dist/es5/h5/dd-element.js.map +1 -1
- package/dist/es5/h5/dd-manager.d.ts +1 -1
- package/dist/es5/h5/dd-manager.js +1 -1
- package/dist/es5/h5/dd-manager.js.map +1 -1
- package/dist/es5/h5/dd-resizable-handle.d.ts +1 -1
- package/dist/es5/h5/dd-resizable-handle.js +1 -1
- package/dist/es5/h5/dd-resizable-handle.js.map +1 -1
- package/dist/es5/h5/dd-resizable.d.ts +1 -2
- package/dist/es5/h5/dd-resizable.js +2 -3
- package/dist/es5/h5/dd-resizable.js.map +1 -1
- package/dist/es5/h5/dd-utils.d.ts +3 -1
- package/dist/es5/h5/dd-utils.js +13 -1
- package/dist/es5/h5/dd-utils.js.map +1 -1
- package/dist/es5/h5/gridstack-dd-native.d.ts +1 -1
- package/dist/es5/h5/gridstack-dd-native.js +1 -1
- package/dist/es5/h5/gridstack-dd-native.js.map +1 -1
- package/dist/es5/jq/gridstack-dd-jqueryui.js.map +1 -1
- package/dist/es5/types.d.ts +8 -3
- package/dist/es5/types.js +1 -1
- package/dist/es5/types.js.map +1 -1
- package/dist/es5/utils.d.ts +2 -2
- package/dist/es5/utils.js +4 -3
- package/dist/es5/utils.js.map +1 -1
- package/dist/gridstack-dd.d.ts +1 -1
- package/dist/gridstack-dd.js +13 -10
- package/dist/gridstack-dd.js.map +1 -1
- package/dist/gridstack-ddi.d.ts +1 -1
- package/dist/gridstack-ddi.js +1 -1
- package/dist/gridstack-ddi.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-h5.d.ts +1 -1
- package/dist/gridstack-h5.js +1 -1
- package/dist/gridstack-h5.js.LICENSE.txt +1 -1
- package/dist/gridstack-h5.js.map +1 -1
- package/dist/gridstack-jq.d.ts +1 -1
- package/dist/gridstack-jq.js +1 -1
- package/dist/gridstack-jq.js.LICENSE.txt +1 -1
- package/dist/gridstack-jq.js.map +1 -1
- package/dist/gridstack-static.d.ts +1 -1
- package/dist/gridstack-static.js +1 -1
- package/dist/gridstack-static.js.LICENSE.txt +1 -1
- package/dist/gridstack-static.js.map +1 -1
- package/dist/gridstack.css +1 -4
- package/dist/gridstack.d.ts +2 -2
- package/dist/gridstack.js +69 -34
- package/dist/gridstack.js.map +1 -1
- package/dist/gridstack.min.css +1 -1
- package/dist/h5/dd-base-impl.d.ts +1 -1
- package/dist/h5/dd-base-impl.js +1 -1
- package/dist/h5/dd-base-impl.js.map +1 -1
- package/dist/h5/dd-draggable.d.ts +1 -2
- package/dist/h5/dd-draggable.js +26 -16
- package/dist/h5/dd-draggable.js.map +1 -1
- package/dist/h5/dd-droppable.d.ts +2 -1
- package/dist/h5/dd-droppable.js +42 -25
- package/dist/h5/dd-droppable.js.map +1 -1
- package/dist/h5/dd-element.d.ts +1 -1
- package/dist/h5/dd-element.js +1 -1
- package/dist/h5/dd-element.js.map +1 -1
- package/dist/h5/dd-manager.d.ts +1 -1
- package/dist/h5/dd-manager.js +1 -1
- package/dist/h5/dd-manager.js.map +1 -1
- package/dist/h5/dd-resizable-handle.d.ts +1 -1
- package/dist/h5/dd-resizable-handle.js +1 -1
- package/dist/h5/dd-resizable-handle.js.map +1 -1
- package/dist/h5/dd-resizable.d.ts +1 -2
- package/dist/h5/dd-resizable.js +2 -3
- package/dist/h5/dd-resizable.js.map +1 -1
- package/dist/h5/dd-utils.d.ts +3 -1
- package/dist/h5/dd-utils.js +13 -1
- package/dist/h5/dd-utils.js.map +1 -1
- package/dist/h5/gridstack-dd-native.d.ts +1 -1
- package/dist/h5/gridstack-dd-native.js +1 -1
- package/dist/h5/gridstack-dd-native.js.map +1 -1
- package/dist/jq/gridstack-dd-jqueryui.js.map +1 -1
- package/dist/src/gridstack.scss +5 -4
- package/dist/types.d.ts +8 -3
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +2 -2
- package/dist/utils.js +4 -3
- package/dist/utils.js.map +1 -1
- package/doc/CHANGES.md +8 -0
- package/doc/README.md +10 -5
- package/package.json +1 -1
package/dist/es5/gridstack.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* GridStack
|
|
2
|
+
* GridStack 5.0
|
|
3
3
|
* https://gridstackjs.com/
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) 2021 Alain Dumesny
|
|
@@ -290,7 +290,7 @@ export declare class GridStack {
|
|
|
290
290
|
willItFit(node: GridStackWidget): boolean;
|
|
291
291
|
/**
|
|
292
292
|
* called when we are being resized by the window - check if the one Column Mode needs to be turned on/off
|
|
293
|
-
* and remember the prev columns we used, as well as check for auto cell height (square)
|
|
293
|
+
* and remember the prev columns we used, or get our count from parent, as well as check for auto cell height (square)
|
|
294
294
|
*/
|
|
295
295
|
onParentResize(): GridStack;
|
|
296
296
|
/** add or remove the window size event handler */
|
package/dist/es5/gridstack.js
CHANGED
|
@@ -30,7 +30,7 @@ var __spreadArrays = (this && this.__spreadArrays) || function () {
|
|
|
30
30
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
31
|
exports.GridStack = void 0;
|
|
32
32
|
/*!
|
|
33
|
-
* GridStack
|
|
33
|
+
* GridStack 5.0
|
|
34
34
|
* https://gridstackjs.com/
|
|
35
35
|
*
|
|
36
36
|
* Copyright (c) 2021 Alain Dumesny
|
|
@@ -116,6 +116,10 @@ var GridStack = /** @class */ (function () {
|
|
|
116
116
|
delete opts.row;
|
|
117
117
|
}
|
|
118
118
|
var rowAttr = utils_1.Utils.toNumber(el.getAttribute('gs-row'));
|
|
119
|
+
// flag only valid in sub-grids (handled by parent, not here)
|
|
120
|
+
if (opts.column === 'auto') {
|
|
121
|
+
delete opts.column;
|
|
122
|
+
}
|
|
119
123
|
// elements attributes override any passed options (like CSS style) - merge the two together
|
|
120
124
|
var defaults = __assign(__assign({}, utils_1.Utils.cloneDeep(GridDefaults)), { column: utils_1.Utils.toNumber(el.getAttribute('gs-column')) || 12, minRow: rowAttr ? rowAttr : utils_1.Utils.toNumber(el.getAttribute('gs-min-row')) || 0, maxRow: rowAttr ? rowAttr : utils_1.Utils.toNumber(el.getAttribute('gs-max-row')) || 0, staticGrid: utils_1.Utils.toBool(el.getAttribute('gs-static')) || false, _styleSheetClass: 'grid-stack-instance-' + (Math.random() * 10000).toFixed(0), alwaysShowResizeHandle: opts.alwaysShowResizeHandle || false, resizable: {
|
|
121
125
|
autoHide: !(opts.alwaysShowResizeHandle || false),
|
|
@@ -135,7 +139,7 @@ var GridStack = /** @class */ (function () {
|
|
|
135
139
|
this.initMargin(); // part of settings defaults...
|
|
136
140
|
// Now check if we're loading into 1 column mode FIRST so we don't do un-necessary work (like cellHeight = width / 12 then go 1 column)
|
|
137
141
|
if (this.opts.column !== 1 && !this.opts.disableOneColumnMode && this._widthOrContainer() <= this.opts.minWidth) {
|
|
138
|
-
this._prevColumn = this.
|
|
142
|
+
this._prevColumn = this.getColumn();
|
|
139
143
|
this.opts.column = 1;
|
|
140
144
|
}
|
|
141
145
|
if (this.opts.rtl === 'auto') {
|
|
@@ -149,6 +153,7 @@ var GridStack = /** @class */ (function () {
|
|
|
149
153
|
if (parentGridItemEl && parentGridItemEl.gridstackNode) {
|
|
150
154
|
this.opts._isNested = parentGridItemEl.gridstackNode;
|
|
151
155
|
this.opts._isNested.subGrid = this;
|
|
156
|
+
parentGridItemEl.classList.add('grid-stack-nested');
|
|
152
157
|
this.el.classList.add('grid-stack-nested');
|
|
153
158
|
}
|
|
154
159
|
this._isAutoCellHeight = (this.opts.cellHeight === 'auto');
|
|
@@ -167,7 +172,7 @@ var GridStack = /** @class */ (function () {
|
|
|
167
172
|
this.el.classList.add(this.opts._styleSheetClass);
|
|
168
173
|
this._setStaticClass();
|
|
169
174
|
this.engine = new gridstack_engine_1.GridStackEngine({
|
|
170
|
-
column: this.
|
|
175
|
+
column: this.getColumn(),
|
|
171
176
|
float: this.opts.float,
|
|
172
177
|
maxRow: this.opts.maxRow,
|
|
173
178
|
onChange: function (cbNodes) {
|
|
@@ -198,7 +203,7 @@ var GridStack = /** @class */ (function () {
|
|
|
198
203
|
elements_1.push({
|
|
199
204
|
el: el,
|
|
200
205
|
// if x,y are missing (autoPosition) add them to end of list - but keep their respective DOM order
|
|
201
|
-
i: (Number.isNaN(x) ? 1000 : x) + (Number.isNaN(y) ? 1000 : y) * _this.
|
|
206
|
+
i: (Number.isNaN(x) ? 1000 : x) + (Number.isNaN(y) ? 1000 : y) * _this.getColumn()
|
|
202
207
|
});
|
|
203
208
|
});
|
|
204
209
|
elements_1.sort(function (a, b) { return a.i - b.i; }).forEach(function (e) { return _this._prepareElement(e.el); });
|
|
@@ -385,8 +390,19 @@ var GridStack = /** @class */ (function () {
|
|
|
385
390
|
this._updateContainerHeight();
|
|
386
391
|
// check if nested grid definition is present
|
|
387
392
|
if (node.subGrid && !node.subGrid.el) { // see if there is a sub-grid to create too
|
|
393
|
+
// if column special case it set, remember that flag and set default
|
|
394
|
+
var autoColumn = void 0;
|
|
395
|
+
var ops = node.subGrid;
|
|
396
|
+
if (ops.column === 'auto') {
|
|
397
|
+
ops.column = node.w;
|
|
398
|
+
ops.disableOneColumnMode = true; // driven by parent
|
|
399
|
+
autoColumn = true;
|
|
400
|
+
}
|
|
388
401
|
var content = node.el.querySelector('.grid-stack-item-content');
|
|
389
402
|
node.subGrid = GridStack.addGrid(content, node.subGrid);
|
|
403
|
+
if (autoColumn) {
|
|
404
|
+
node.subGrid._autoColumn = true;
|
|
405
|
+
}
|
|
390
406
|
}
|
|
391
407
|
this._triggerAddEvent();
|
|
392
408
|
this._triggerChangeEvent();
|
|
@@ -442,6 +458,10 @@ var GridStack = /** @class */ (function () {
|
|
|
442
458
|
if (this._isAutoCellHeight) {
|
|
443
459
|
o.cellHeight = 'auto';
|
|
444
460
|
}
|
|
461
|
+
if (this._autoColumn) {
|
|
462
|
+
o.column = 'auto';
|
|
463
|
+
delete o.disableOneColumnMode;
|
|
464
|
+
}
|
|
445
465
|
utils_1.Utils.removeInternalAndSame(o, GridDefaults);
|
|
446
466
|
o.children = list;
|
|
447
467
|
return o;
|
|
@@ -461,7 +481,7 @@ var GridStack = /** @class */ (function () {
|
|
|
461
481
|
GridStack.prototype.load = function (layout, addAndRemove) {
|
|
462
482
|
var _this = this;
|
|
463
483
|
if (addAndRemove === void 0) { addAndRemove = true; }
|
|
464
|
-
var items = GridStack.Utils.sort(__spreadArrays(layout), -1, this._prevColumn || this.
|
|
484
|
+
var items = GridStack.Utils.sort(__spreadArrays(layout), -1, this._prevColumn || this.getColumn()); // make copy before we mod/sort
|
|
465
485
|
this._insertNotAppend = true; // since create in reverse order...
|
|
466
486
|
// if we're loading a layout into 1 column (_prevColumn is set only when going to 1) and items don't fit, make sure to save
|
|
467
487
|
// the original wanted layout so we can scale back up correctly #1471
|
|
@@ -532,12 +552,15 @@ var GridStack = /** @class */ (function () {
|
|
|
532
552
|
(!forcePixel || !this.opts.cellHeightUnit || this.opts.cellHeightUnit === 'px')) {
|
|
533
553
|
return this.opts.cellHeight;
|
|
534
554
|
}
|
|
535
|
-
// else
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
555
|
+
// else get first cell height
|
|
556
|
+
var el = this.el.querySelector('.' + this.opts.itemClass);
|
|
557
|
+
if (el) {
|
|
558
|
+
var height = utils_1.Utils.toNumber(el.getAttribute('gs-h'));
|
|
559
|
+
return Math.round(el.offsetHeight / height);
|
|
560
|
+
}
|
|
561
|
+
// else do entire grid and # of rows (but doesn't work if min-height is the actual constrain)
|
|
562
|
+
var rows = parseInt(this.el.getAttribute('gs-current-row'));
|
|
563
|
+
return rows ? Math.round(this.el.getBoundingClientRect().height / rows) : this.opts.cellHeight;
|
|
541
564
|
};
|
|
542
565
|
/**
|
|
543
566
|
* Update current cell height - see `GridStackOptions.cellHeight` for format.
|
|
@@ -584,7 +607,7 @@ var GridStack = /** @class */ (function () {
|
|
|
584
607
|
};
|
|
585
608
|
/** Gets current cell width. */
|
|
586
609
|
GridStack.prototype.cellWidth = function () {
|
|
587
|
-
return this._widthOrContainer() / this.
|
|
610
|
+
return this._widthOrContainer() / this.getColumn();
|
|
588
611
|
};
|
|
589
612
|
/** return our expected width (or parent) for 1 column check */
|
|
590
613
|
GridStack.prototype._widthOrContainer = function () {
|
|
@@ -621,7 +644,7 @@ var GridStack = /** @class */ (function () {
|
|
|
621
644
|
if (layout === void 0) { layout = 'moveScale'; }
|
|
622
645
|
if (column < 1 || this.opts.column === column)
|
|
623
646
|
return this;
|
|
624
|
-
var oldColumn = this.
|
|
647
|
+
var oldColumn = this.getColumn();
|
|
625
648
|
// if we go into 1 column mode (which happens if we're sized less than minW unless disableOneColumnMode is on)
|
|
626
649
|
// then remember the original columns so we can restore.
|
|
627
650
|
if (column === 1) {
|
|
@@ -733,7 +756,7 @@ var GridStack = /** @class */ (function () {
|
|
|
733
756
|
}
|
|
734
757
|
var relativeLeft = position.left - containerPos.left;
|
|
735
758
|
var relativeTop = position.top - containerPos.top;
|
|
736
|
-
var columnWidth = (box.width / this.
|
|
759
|
+
var columnWidth = (box.width / this.getColumn());
|
|
737
760
|
var rowHeight = (box.height / parseInt(this.el.getAttribute('gs-current-row')));
|
|
738
761
|
return { x: Math.floor(relativeLeft / columnWidth), y: Math.floor(relativeTop / rowHeight) };
|
|
739
762
|
};
|
|
@@ -1149,13 +1172,15 @@ var GridStack = /** @class */ (function () {
|
|
|
1149
1172
|
return this;
|
|
1150
1173
|
var row = this.getRow() + this._extraDragRow; // checks for minRow already
|
|
1151
1174
|
// check for css min height
|
|
1152
|
-
|
|
1153
|
-
if
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1175
|
+
// Note: we don't handle %,rem correctly so comment out, beside we don't need need to create un-necessary
|
|
1176
|
+
// rows as the CSS will make us bigger than our set height if needed... not sure why we had this.
|
|
1177
|
+
// let cssMinHeight = parseInt(getComputedStyle(this.el)['min-height']);
|
|
1178
|
+
// if (cssMinHeight > 0) {
|
|
1179
|
+
// let minRow = Math.round(cssMinHeight / this.getCellHeight(true));
|
|
1180
|
+
// if (row < minRow) {
|
|
1181
|
+
// row = minRow;
|
|
1182
|
+
// }
|
|
1183
|
+
// }
|
|
1159
1184
|
this.el.setAttribute('gs-current-row', String(row));
|
|
1160
1185
|
if (row === 0) {
|
|
1161
1186
|
this.el.style.removeProperty('height');
|
|
@@ -1273,34 +1298,44 @@ var GridStack = /** @class */ (function () {
|
|
|
1273
1298
|
};
|
|
1274
1299
|
/**
|
|
1275
1300
|
* called when we are being resized by the window - check if the one Column Mode needs to be turned on/off
|
|
1276
|
-
* and remember the prev columns we used, as well as check for auto cell height (square)
|
|
1301
|
+
* and remember the prev columns we used, or get our count from parent, as well as check for auto cell height (square)
|
|
1277
1302
|
*/
|
|
1278
1303
|
GridStack.prototype.onParentResize = function () {
|
|
1279
1304
|
var _this = this;
|
|
1280
1305
|
if (!this.el || !this.el.clientWidth)
|
|
1281
1306
|
return; // return if we're gone or no size yet (will get called again)
|
|
1282
|
-
var
|
|
1283
|
-
|
|
1284
|
-
if (
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
this.
|
|
1288
|
-
}
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1307
|
+
var changedColumn = false;
|
|
1308
|
+
// see if we're nested and take our column count from our parent....
|
|
1309
|
+
if (this._autoColumn && this.opts._isNested) {
|
|
1310
|
+
if (this.opts.column !== this.opts._isNested.w) {
|
|
1311
|
+
changedColumn = true;
|
|
1312
|
+
this.column(this.opts._isNested.w, 'none');
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
else {
|
|
1316
|
+
// else check for 1 column in/out behavior
|
|
1317
|
+
var oneColumn = !this.opts.disableOneColumnMode && this.el.clientWidth <= this.opts.minWidth;
|
|
1318
|
+
if ((this.opts.column === 1) !== oneColumn) {
|
|
1319
|
+
changedColumn = true;
|
|
1320
|
+
if (this.opts.animate) {
|
|
1321
|
+
this.setAnimation(false);
|
|
1322
|
+
} // 1 <-> 12 is too radical, turn off animation
|
|
1323
|
+
this.column(oneColumn ? 1 : this._prevColumn);
|
|
1324
|
+
if (this.opts.animate) {
|
|
1325
|
+
this.setAnimation(true);
|
|
1326
|
+
}
|
|
1292
1327
|
}
|
|
1293
1328
|
}
|
|
1294
1329
|
// make the cells content square again
|
|
1295
1330
|
if (this._isAutoCellHeight) {
|
|
1296
|
-
if (!
|
|
1331
|
+
if (!changedColumn && this.opts.cellHeightThrottle) {
|
|
1297
1332
|
if (!this._cellHeightThrottle) {
|
|
1298
1333
|
this._cellHeightThrottle = utils_1.Utils.throttle(function () { return _this.cellHeight(); }, this.opts.cellHeightThrottle);
|
|
1299
1334
|
}
|
|
1300
1335
|
this._cellHeightThrottle();
|
|
1301
1336
|
}
|
|
1302
1337
|
else {
|
|
1303
|
-
// immediate update if we've changed
|
|
1338
|
+
// immediate update if we've changed column count or have no threshold
|
|
1304
1339
|
this.cellHeight();
|
|
1305
1340
|
}
|
|
1306
1341
|
}
|