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/gridstack.css
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* gridstack SASS styles
|
|
2
|
+
* gridstack SASS styles 5.0
|
|
3
3
|
* Copyright (c) 2021 Alain Dumesny - see GridStack root license
|
|
4
4
|
*/
|
|
5
5
|
:root .grid-stack-item > .ui-resizable-handle {
|
|
@@ -305,7 +305,4 @@
|
|
|
305
305
|
-ms-transition: left 0s, top 0s, height 0s, width 0s;
|
|
306
306
|
-o-transition: left 0s, top 0s, height 0s, width 0s;
|
|
307
307
|
transition: left 0s, top 0s, height 0s, width 0s;
|
|
308
|
-
}
|
|
309
|
-
.grid-stack.ui-droppable.ui-droppable-over > *:not(.ui-droppable) {
|
|
310
|
-
pointer-events: none;
|
|
311
308
|
}
|
package/dist/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/gridstack.js
CHANGED
|
@@ -12,7 +12,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
exports.GridStack = void 0;
|
|
14
14
|
/*!
|
|
15
|
-
* GridStack
|
|
15
|
+
* GridStack 5.0
|
|
16
16
|
* https://gridstackjs.com/
|
|
17
17
|
*
|
|
18
18
|
* Copyright (c) 2021 Alain Dumesny
|
|
@@ -96,6 +96,10 @@ class GridStack {
|
|
|
96
96
|
delete opts.row;
|
|
97
97
|
}
|
|
98
98
|
let rowAttr = utils_1.Utils.toNumber(el.getAttribute('gs-row'));
|
|
99
|
+
// flag only valid in sub-grids (handled by parent, not here)
|
|
100
|
+
if (opts.column === 'auto') {
|
|
101
|
+
delete opts.column;
|
|
102
|
+
}
|
|
99
103
|
// elements attributes override any passed options (like CSS style) - merge the two together
|
|
100
104
|
let defaults = Object.assign(Object.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: {
|
|
101
105
|
autoHide: !(opts.alwaysShowResizeHandle || false),
|
|
@@ -115,7 +119,7 @@ class GridStack {
|
|
|
115
119
|
this.initMargin(); // part of settings defaults...
|
|
116
120
|
// 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)
|
|
117
121
|
if (this.opts.column !== 1 && !this.opts.disableOneColumnMode && this._widthOrContainer() <= this.opts.minWidth) {
|
|
118
|
-
this._prevColumn = this.
|
|
122
|
+
this._prevColumn = this.getColumn();
|
|
119
123
|
this.opts.column = 1;
|
|
120
124
|
}
|
|
121
125
|
if (this.opts.rtl === 'auto') {
|
|
@@ -129,6 +133,7 @@ class GridStack {
|
|
|
129
133
|
if (parentGridItemEl && parentGridItemEl.gridstackNode) {
|
|
130
134
|
this.opts._isNested = parentGridItemEl.gridstackNode;
|
|
131
135
|
this.opts._isNested.subGrid = this;
|
|
136
|
+
parentGridItemEl.classList.add('grid-stack-nested');
|
|
132
137
|
this.el.classList.add('grid-stack-nested');
|
|
133
138
|
}
|
|
134
139
|
this._isAutoCellHeight = (this.opts.cellHeight === 'auto');
|
|
@@ -147,7 +152,7 @@ class GridStack {
|
|
|
147
152
|
this.el.classList.add(this.opts._styleSheetClass);
|
|
148
153
|
this._setStaticClass();
|
|
149
154
|
this.engine = new gridstack_engine_1.GridStackEngine({
|
|
150
|
-
column: this.
|
|
155
|
+
column: this.getColumn(),
|
|
151
156
|
float: this.opts.float,
|
|
152
157
|
maxRow: this.opts.maxRow,
|
|
153
158
|
onChange: (cbNodes) => {
|
|
@@ -178,7 +183,7 @@ class GridStack {
|
|
|
178
183
|
elements.push({
|
|
179
184
|
el,
|
|
180
185
|
// if x,y are missing (autoPosition) add them to end of list - but keep their respective DOM order
|
|
181
|
-
i: (Number.isNaN(x) ? 1000 : x) + (Number.isNaN(y) ? 1000 : y) * this.
|
|
186
|
+
i: (Number.isNaN(x) ? 1000 : x) + (Number.isNaN(y) ? 1000 : y) * this.getColumn()
|
|
182
187
|
});
|
|
183
188
|
});
|
|
184
189
|
elements.sort((a, b) => a.i - b.i).forEach(e => this._prepareElement(e.el));
|
|
@@ -356,8 +361,19 @@ class GridStack {
|
|
|
356
361
|
this._updateContainerHeight();
|
|
357
362
|
// check if nested grid definition is present
|
|
358
363
|
if (node.subGrid && !node.subGrid.el) { // see if there is a sub-grid to create too
|
|
364
|
+
// if column special case it set, remember that flag and set default
|
|
365
|
+
let autoColumn;
|
|
366
|
+
let ops = node.subGrid;
|
|
367
|
+
if (ops.column === 'auto') {
|
|
368
|
+
ops.column = node.w;
|
|
369
|
+
ops.disableOneColumnMode = true; // driven by parent
|
|
370
|
+
autoColumn = true;
|
|
371
|
+
}
|
|
359
372
|
let content = node.el.querySelector('.grid-stack-item-content');
|
|
360
373
|
node.subGrid = GridStack.addGrid(content, node.subGrid);
|
|
374
|
+
if (autoColumn) {
|
|
375
|
+
node.subGrid._autoColumn = true;
|
|
376
|
+
}
|
|
361
377
|
}
|
|
362
378
|
this._triggerAddEvent();
|
|
363
379
|
this._triggerChangeEvent();
|
|
@@ -411,6 +427,10 @@ class GridStack {
|
|
|
411
427
|
if (this._isAutoCellHeight) {
|
|
412
428
|
o.cellHeight = 'auto';
|
|
413
429
|
}
|
|
430
|
+
if (this._autoColumn) {
|
|
431
|
+
o.column = 'auto';
|
|
432
|
+
delete o.disableOneColumnMode;
|
|
433
|
+
}
|
|
414
434
|
utils_1.Utils.removeInternalAndSame(o, GridDefaults);
|
|
415
435
|
o.children = list;
|
|
416
436
|
return o;
|
|
@@ -428,7 +448,7 @@ class GridStack {
|
|
|
428
448
|
* see http://gridstackjs.com/demo/serialization.html
|
|
429
449
|
**/
|
|
430
450
|
load(layout, addAndRemove = true) {
|
|
431
|
-
let items = GridStack.Utils.sort([...layout], -1, this._prevColumn || this.
|
|
451
|
+
let items = GridStack.Utils.sort([...layout], -1, this._prevColumn || this.getColumn()); // make copy before we mod/sort
|
|
432
452
|
this._insertNotAppend = true; // since create in reverse order...
|
|
433
453
|
// 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
|
|
434
454
|
// the original wanted layout so we can scale back up correctly #1471
|
|
@@ -498,12 +518,15 @@ class GridStack {
|
|
|
498
518
|
(!forcePixel || !this.opts.cellHeightUnit || this.opts.cellHeightUnit === 'px')) {
|
|
499
519
|
return this.opts.cellHeight;
|
|
500
520
|
}
|
|
501
|
-
// else
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
521
|
+
// else get first cell height
|
|
522
|
+
let el = this.el.querySelector('.' + this.opts.itemClass);
|
|
523
|
+
if (el) {
|
|
524
|
+
let height = utils_1.Utils.toNumber(el.getAttribute('gs-h'));
|
|
525
|
+
return Math.round(el.offsetHeight / height);
|
|
526
|
+
}
|
|
527
|
+
// else do entire grid and # of rows (but doesn't work if min-height is the actual constrain)
|
|
528
|
+
let rows = parseInt(this.el.getAttribute('gs-current-row'));
|
|
529
|
+
return rows ? Math.round(this.el.getBoundingClientRect().height / rows) : this.opts.cellHeight;
|
|
507
530
|
}
|
|
508
531
|
/**
|
|
509
532
|
* Update current cell height - see `GridStackOptions.cellHeight` for format.
|
|
@@ -549,7 +572,7 @@ class GridStack {
|
|
|
549
572
|
}
|
|
550
573
|
/** Gets current cell width. */
|
|
551
574
|
cellWidth() {
|
|
552
|
-
return this._widthOrContainer() / this.
|
|
575
|
+
return this._widthOrContainer() / this.getColumn();
|
|
553
576
|
}
|
|
554
577
|
/** return our expected width (or parent) for 1 column check */
|
|
555
578
|
_widthOrContainer() {
|
|
@@ -585,7 +608,7 @@ class GridStack {
|
|
|
585
608
|
column(column, layout = 'moveScale') {
|
|
586
609
|
if (column < 1 || this.opts.column === column)
|
|
587
610
|
return this;
|
|
588
|
-
let oldColumn = this.
|
|
611
|
+
let oldColumn = this.getColumn();
|
|
589
612
|
// if we go into 1 column mode (which happens if we're sized less than minW unless disableOneColumnMode is on)
|
|
590
613
|
// then remember the original columns so we can restore.
|
|
591
614
|
if (column === 1) {
|
|
@@ -694,7 +717,7 @@ class GridStack {
|
|
|
694
717
|
}
|
|
695
718
|
let relativeLeft = position.left - containerPos.left;
|
|
696
719
|
let relativeTop = position.top - containerPos.top;
|
|
697
|
-
let columnWidth = (box.width / this.
|
|
720
|
+
let columnWidth = (box.width / this.getColumn());
|
|
698
721
|
let rowHeight = (box.height / parseInt(this.el.getAttribute('gs-current-row')));
|
|
699
722
|
return { x: Math.floor(relativeLeft / columnWidth), y: Math.floor(relativeTop / rowHeight) };
|
|
700
723
|
}
|
|
@@ -1100,13 +1123,15 @@ class GridStack {
|
|
|
1100
1123
|
return this;
|
|
1101
1124
|
let row = this.getRow() + this._extraDragRow; // checks for minRow already
|
|
1102
1125
|
// check for css min height
|
|
1103
|
-
|
|
1104
|
-
if
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1126
|
+
// Note: we don't handle %,rem correctly so comment out, beside we don't need need to create un-necessary
|
|
1127
|
+
// rows as the CSS will make us bigger than our set height if needed... not sure why we had this.
|
|
1128
|
+
// let cssMinHeight = parseInt(getComputedStyle(this.el)['min-height']);
|
|
1129
|
+
// if (cssMinHeight > 0) {
|
|
1130
|
+
// let minRow = Math.round(cssMinHeight / this.getCellHeight(true));
|
|
1131
|
+
// if (row < minRow) {
|
|
1132
|
+
// row = minRow;
|
|
1133
|
+
// }
|
|
1134
|
+
// }
|
|
1110
1135
|
this.el.setAttribute('gs-current-row', String(row));
|
|
1111
1136
|
if (row === 0) {
|
|
1112
1137
|
this.el.style.removeProperty('height');
|
|
@@ -1222,33 +1247,43 @@ class GridStack {
|
|
|
1222
1247
|
}
|
|
1223
1248
|
/**
|
|
1224
1249
|
* called when we are being resized by the window - check if the one Column Mode needs to be turned on/off
|
|
1225
|
-
* and remember the prev columns we used, as well as check for auto cell height (square)
|
|
1250
|
+
* and remember the prev columns we used, or get our count from parent, as well as check for auto cell height (square)
|
|
1226
1251
|
*/
|
|
1227
1252
|
onParentResize() {
|
|
1228
1253
|
if (!this.el || !this.el.clientWidth)
|
|
1229
1254
|
return; // return if we're gone or no size yet (will get called again)
|
|
1230
|
-
let
|
|
1231
|
-
|
|
1232
|
-
if (
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
this.
|
|
1236
|
-
}
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1255
|
+
let changedColumn = false;
|
|
1256
|
+
// see if we're nested and take our column count from our parent....
|
|
1257
|
+
if (this._autoColumn && this.opts._isNested) {
|
|
1258
|
+
if (this.opts.column !== this.opts._isNested.w) {
|
|
1259
|
+
changedColumn = true;
|
|
1260
|
+
this.column(this.opts._isNested.w, 'none');
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
else {
|
|
1264
|
+
// else check for 1 column in/out behavior
|
|
1265
|
+
let oneColumn = !this.opts.disableOneColumnMode && this.el.clientWidth <= this.opts.minWidth;
|
|
1266
|
+
if ((this.opts.column === 1) !== oneColumn) {
|
|
1267
|
+
changedColumn = true;
|
|
1268
|
+
if (this.opts.animate) {
|
|
1269
|
+
this.setAnimation(false);
|
|
1270
|
+
} // 1 <-> 12 is too radical, turn off animation
|
|
1271
|
+
this.column(oneColumn ? 1 : this._prevColumn);
|
|
1272
|
+
if (this.opts.animate) {
|
|
1273
|
+
this.setAnimation(true);
|
|
1274
|
+
}
|
|
1240
1275
|
}
|
|
1241
1276
|
}
|
|
1242
1277
|
// make the cells content square again
|
|
1243
1278
|
if (this._isAutoCellHeight) {
|
|
1244
|
-
if (!
|
|
1279
|
+
if (!changedColumn && this.opts.cellHeightThrottle) {
|
|
1245
1280
|
if (!this._cellHeightThrottle) {
|
|
1246
1281
|
this._cellHeightThrottle = utils_1.Utils.throttle(() => this.cellHeight(), this.opts.cellHeightThrottle);
|
|
1247
1282
|
}
|
|
1248
1283
|
this._cellHeightThrottle();
|
|
1249
1284
|
}
|
|
1250
1285
|
else {
|
|
1251
|
-
// immediate update if we've changed
|
|
1286
|
+
// immediate update if we've changed column count or have no threshold
|
|
1252
1287
|
this.cellHeight();
|
|
1253
1288
|
}
|
|
1254
1289
|
}
|