gridstack 10.0.1 → 10.1.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 +2 -2
- 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 -1
- package/dist/dd-draggable.js +18 -29
- package/dist/dd-draggable.js.map +1 -1
- package/dist/dd-droppable.d.ts +1 -1
- package/dist/dd-droppable.js +13 -11
- 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 +14 -4
- 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 +3 -3
- package/dist/dd-resizable-handle.js.map +1 -1
- package/dist/dd-resizable.d.ts +3 -3
- package/dist/dd-resizable.js +7 -22
- 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 +18 -29
- package/dist/es5/dd-draggable.js.map +1 -1
- package/dist/es5/dd-droppable.d.ts +1 -1
- package/dist/es5/dd-droppable.js +14 -11
- 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 +13 -3
- 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 +3 -3
- package/dist/es5/dd-resizable-handle.js.map +1 -1
- package/dist/es5/dd-resizable.d.ts +3 -3
- package/dist/es5/dd-resizable.js +7 -22
- 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 +9 -24
- package/dist/es5/gridstack-engine.js.map +1 -1
- package/dist/es5/gridstack-poly.js +1 -1
- package/dist/es5/gridstack.d.ts +12 -7
- package/dist/es5/gridstack.js +68 -27
- package/dist/es5/gridstack.js.map +1 -1
- package/dist/es5/types.d.ts +1 -1
- package/dist/es5/types.js +1 -1
- package/dist/es5/types.js.map +1 -1
- package/dist/es5/utils.d.ts +12 -1
- package/dist/es5/utils.js +28 -2
- 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 +9 -24
- package/dist/gridstack-engine.js.map +1 -1
- package/dist/gridstack.css +2 -2
- package/dist/gridstack.d.ts +12 -7
- package/dist/gridstack.js +67 -28
- package/dist/gridstack.js.map +1 -1
- package/dist/gridstack.min.css +1 -1
- package/dist/src/gridstack.scss +2 -2
- package/dist/types.d.ts +1 -1
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +12 -1
- package/dist/utils.js +28 -2
- package/dist/utils.js.map +1 -1
- package/doc/CHANGES.md +12 -0
- package/doc/README.md +1 -1
- package/package.json +1 -1
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 10.0
|
|
39
|
+
* GridStack 10.1.0
|
|
40
40
|
* https://gridstackjs.com/
|
|
41
41
|
*
|
|
42
42
|
* Copyright (c) 2021-2022 Alain Dumesny
|
|
@@ -84,6 +84,8 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
84
84
|
this._gsEventHandler = {};
|
|
85
85
|
/** @internal extra row added when dragging at the bottom of the grid */
|
|
86
86
|
this._extraDragRow = 0;
|
|
87
|
+
/** @internal meant to store the scale of the active grid */
|
|
88
|
+
this.dragTransform = { xScale: 1, yScale: 1, xOffset: 0, yOffset: 0 };
|
|
87
89
|
el.gridstack = this;
|
|
88
90
|
this.el = el; // exposed HTML element to the user
|
|
89
91
|
opts = opts || {}; // handles null/undefined/0
|
|
@@ -109,7 +111,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
109
111
|
var oldOpts = opts;
|
|
110
112
|
if (oldOpts.oneColumnModeDomSort) {
|
|
111
113
|
delete oldOpts.oneColumnModeDomSort;
|
|
112
|
-
console.log('
|
|
114
|
+
console.log('warning: Gridstack oneColumnModeDomSort no longer supported. Use GridStackOptions.columnOpts instead.');
|
|
113
115
|
}
|
|
114
116
|
if (oldOpts.oneColumnSize || oldOpts.disableOneColumnMode === false) {
|
|
115
117
|
var oneSize = oldOpts.oneColumnSize || 768;
|
|
@@ -255,6 +257,8 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
255
257
|
GridStack.init = function (options, elOrString) {
|
|
256
258
|
if (options === void 0) { options = {}; }
|
|
257
259
|
if (elOrString === void 0) { elOrString = '.grid-stack'; }
|
|
260
|
+
if (typeof document === 'undefined')
|
|
261
|
+
return null; // temp workaround SSR
|
|
258
262
|
var el = GridStack.getGridElement(elOrString);
|
|
259
263
|
if (!el) {
|
|
260
264
|
if (typeof elOrString === 'string') {
|
|
@@ -284,6 +288,8 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
284
288
|
if (options === void 0) { options = {}; }
|
|
285
289
|
if (selector === void 0) { selector = '.grid-stack'; }
|
|
286
290
|
var grids = [];
|
|
291
|
+
if (typeof document === 'undefined')
|
|
292
|
+
return grids; // temp workaround SSR
|
|
287
293
|
GridStack.getGridElements(selector).forEach(function (el) {
|
|
288
294
|
if (!el.gridstack) {
|
|
289
295
|
el.gridstack = new GridStack(el, utils_1.Utils.cloneDeep(options));
|
|
@@ -432,6 +438,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
432
438
|
* @param el gridItem element to convert
|
|
433
439
|
* @param ops (optional) sub-grid options, else default to node, then parent settings, else defaults
|
|
434
440
|
* @param nodeToAdd (optional) node to add to the newly created sub grid (used when dragging over existing regular item)
|
|
441
|
+
* @param saveContent if true (default) the html inside .grid-stack-content will be saved to child widget
|
|
435
442
|
* @returns newly created grid
|
|
436
443
|
*/
|
|
437
444
|
GridStack.prototype.makeSubGrid = function (el, ops, nodeToAdd, saveContent) {
|
|
@@ -451,7 +458,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
451
458
|
grid = (_c = grid.parentGridItem) === null || _c === void 0 ? void 0 : _c.grid;
|
|
452
459
|
}
|
|
453
460
|
//... and set the create options
|
|
454
|
-
ops = utils_1.Utils.cloneDeep(__assign(__assign(__assign({}, (subGridTemplate || {})), { children: undefined }), (ops || node.subGridOpts)));
|
|
461
|
+
ops = utils_1.Utils.cloneDeep(__assign(__assign(__assign({}, (subGridTemplate || {})), { children: undefined }), (ops || node.subGridOpts || {})));
|
|
455
462
|
node.subGridOpts = ops;
|
|
456
463
|
// if column special case it set, remember that flag and set default
|
|
457
464
|
var autoColumn;
|
|
@@ -743,13 +750,20 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
743
750
|
(!forcePixel || !this.opts.cellHeightUnit || this.opts.cellHeightUnit === 'px')) {
|
|
744
751
|
return this.opts.cellHeight;
|
|
745
752
|
}
|
|
746
|
-
// do rem/em to px conversion
|
|
753
|
+
// do rem/em/cm/mm to px conversion
|
|
747
754
|
if (this.opts.cellHeightUnit === 'rem') {
|
|
748
755
|
return this.opts.cellHeight * parseFloat(getComputedStyle(document.documentElement).fontSize);
|
|
749
756
|
}
|
|
750
757
|
if (this.opts.cellHeightUnit === 'em') {
|
|
751
758
|
return this.opts.cellHeight * parseFloat(getComputedStyle(this.el).fontSize);
|
|
752
759
|
}
|
|
760
|
+
if (this.opts.cellHeightUnit === 'cm') {
|
|
761
|
+
// 1cm = 96px/2.54. See https://www.w3.org/TR/css-values-3/#absolute-lengths
|
|
762
|
+
return this.opts.cellHeight * (96 / 2.54);
|
|
763
|
+
}
|
|
764
|
+
if (this.opts.cellHeightUnit === 'mm') {
|
|
765
|
+
return this.opts.cellHeight * (96 / 2.54) / 10;
|
|
766
|
+
}
|
|
753
767
|
// else get first cell height
|
|
754
768
|
var el = this.el.querySelector('.' + this.opts.itemClass);
|
|
755
769
|
if (el) {
|
|
@@ -880,7 +894,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
880
894
|
// update the items now, checking if we have a custom children layout
|
|
881
895
|
/*const newChildren = this.opts.columnOpts?.breakpoints?.find(r => r.c === column)?.children;
|
|
882
896
|
if (newChildren) this.load(newChildren);
|
|
883
|
-
else*/ this.engine.columnChanged(oldColumn, column,
|
|
897
|
+
else*/ this.engine.columnChanged(oldColumn, column, layout);
|
|
884
898
|
if (this._isAutoCellHeight)
|
|
885
899
|
this.cellHeight();
|
|
886
900
|
this.resizeToContentCheck(true); // wait for width resizing
|
|
@@ -1022,22 +1036,6 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
1022
1036
|
delete this._ignoreLayoutsNodeChange;
|
|
1023
1037
|
return el;
|
|
1024
1038
|
};
|
|
1025
|
-
/**
|
|
1026
|
-
* Event handler that extracts our CustomEvent data out automatically for receiving custom
|
|
1027
|
-
* notifications (see doc for supported events)
|
|
1028
|
-
* @param name of the event (see possible values) or list of names space separated
|
|
1029
|
-
* @param callback function called with event and optional second/third param
|
|
1030
|
-
* (see README documentation for each signature).
|
|
1031
|
-
*
|
|
1032
|
-
* @example
|
|
1033
|
-
* grid.on('added', function(e, items) { log('added ', items)} );
|
|
1034
|
-
* or
|
|
1035
|
-
* grid.on('added removed change', function(e, items) { log(e.type, items)} );
|
|
1036
|
-
*
|
|
1037
|
-
* Note: in some cases it is the same as calling native handler and parsing the event.
|
|
1038
|
-
* grid.el.addEventListener('added', function(event) { log('added ', event.detail)} );
|
|
1039
|
-
*
|
|
1040
|
-
*/
|
|
1041
1039
|
GridStack.prototype.on = function (name, callback) {
|
|
1042
1040
|
var _this = this;
|
|
1043
1041
|
// check for array of names being passed instead
|
|
@@ -1064,13 +1062,13 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
1064
1062
|
this._gsEventHandler[name] = callback;
|
|
1065
1063
|
}
|
|
1066
1064
|
else {
|
|
1067
|
-
console.
|
|
1065
|
+
console.error('GridStack.on(' + name + ') event not supported');
|
|
1068
1066
|
}
|
|
1069
1067
|
return this;
|
|
1070
1068
|
};
|
|
1071
1069
|
/**
|
|
1072
|
-
* unsubscribe from the 'on' event
|
|
1073
|
-
* @param name of the event (see possible values)
|
|
1070
|
+
* unsubscribe from the 'on' event GridStackEvent
|
|
1071
|
+
* @param name of the event (see possible values) or list of names space separated
|
|
1074
1072
|
*/
|
|
1075
1073
|
GridStack.prototype.off = function (name) {
|
|
1076
1074
|
var _this = this;
|
|
@@ -1315,7 +1313,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
1315
1313
|
// NOTE: clientHeight & getBoundingClientRect() is undefined for text and other leaf nodes. use <div> container!
|
|
1316
1314
|
var child = item.firstElementChild;
|
|
1317
1315
|
if (!child) {
|
|
1318
|
-
console.
|
|
1316
|
+
console.error("Error: GridStack.resizeToContent() widget id:".concat(n.id, " '").concat(GridStack.resizeToContentParent, "'.firstElementChild is null, make sure to have a div like container. Skipping sizing."));
|
|
1319
1317
|
return;
|
|
1320
1318
|
}
|
|
1321
1319
|
wantedH = child.getBoundingClientRect().height || itemH;
|
|
@@ -1485,6 +1483,8 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
1485
1483
|
utils_1.Utils.addCSSRule(this._styles, content, "top: ".concat(top_1, "; right: ").concat(right, "; bottom: ").concat(bottom, "; left: ").concat(left, ";"));
|
|
1486
1484
|
utils_1.Utils.addCSSRule(this._styles, placeholder, "top: ".concat(top_1, "; right: ").concat(right, "; bottom: ").concat(bottom, "; left: ").concat(left, ";"));
|
|
1487
1485
|
// resize handles offset (to match margin)
|
|
1486
|
+
utils_1.Utils.addCSSRule(this._styles, "".concat(prefix, " > .ui-resizable-n"), "top: ".concat(top_1, ";"));
|
|
1487
|
+
utils_1.Utils.addCSSRule(this._styles, "".concat(prefix, " > .ui-resizable-s"), "bottom: ".concat(bottom));
|
|
1488
1488
|
utils_1.Utils.addCSSRule(this._styles, "".concat(prefix, " > .ui-resizable-ne"), "right: ".concat(right));
|
|
1489
1489
|
utils_1.Utils.addCSSRule(this._styles, "".concat(prefix, " > .ui-resizable-e"), "right: ".concat(right));
|
|
1490
1490
|
utils_1.Utils.addCSSRule(this._styles, "".concat(prefix, " > .ui-resizable-se"), "right: ".concat(right, "; bottom: ").concat(bottom));
|
|
@@ -1971,15 +1971,32 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
1971
1971
|
var cellHeight, cellWidth;
|
|
1972
1972
|
var onDrag = function (event, el, helper) {
|
|
1973
1973
|
var _a;
|
|
1974
|
+
var _b;
|
|
1974
1975
|
var node = el.gridstackNode;
|
|
1975
1976
|
if (!node)
|
|
1976
1977
|
return;
|
|
1977
1978
|
helper = helper || el;
|
|
1979
|
+
// if the element is being dragged from outside, scale it down to match the grid's scale
|
|
1980
|
+
// and slightly adjust its position relative to the mouse
|
|
1981
|
+
if (!((_b = node.grid) === null || _b === void 0 ? void 0 : _b.el)) {
|
|
1982
|
+
// this scales the helper down
|
|
1983
|
+
helper.style.transform = "scale(".concat(1 / _this.dragTransform.xScale, ",").concat(1 / _this.dragTransform.yScale, ")");
|
|
1984
|
+
// this makes it so that the helper is well positioned relative to the mouse after scaling
|
|
1985
|
+
var helperRect = helper.getBoundingClientRect();
|
|
1986
|
+
helper.style.left = helperRect.x + (_this.dragTransform.xScale - 1) * (event.clientX - helperRect.x) / _this.dragTransform.xScale + 'px';
|
|
1987
|
+
helper.style.top = helperRect.y + (_this.dragTransform.yScale - 1) * (event.clientY - helperRect.y) / _this.dragTransform.yScale + 'px';
|
|
1988
|
+
helper.style.transformOrigin = "0px 0px";
|
|
1989
|
+
}
|
|
1978
1990
|
var parent = _this.el.getBoundingClientRect();
|
|
1979
1991
|
var top = (_a = helper.getBoundingClientRect(), _a.top), left = _a.left;
|
|
1980
1992
|
left -= parent.left;
|
|
1981
1993
|
top -= parent.top;
|
|
1982
|
-
var ui = {
|
|
1994
|
+
var ui = {
|
|
1995
|
+
position: {
|
|
1996
|
+
top: top * _this.dragTransform.xScale,
|
|
1997
|
+
left: left * _this.dragTransform.yScale
|
|
1998
|
+
}
|
|
1999
|
+
};
|
|
1983
2000
|
if (node._temporaryRemoved) {
|
|
1984
2001
|
node.x = Math.max(0, Math.round(left / cellWidth));
|
|
1985
2002
|
node.y = Math.max(0, Math.round(top / cellHeight));
|
|
@@ -2315,12 +2332,33 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
2315
2332
|
};
|
|
2316
2333
|
/** @internal handles actual drag/resize start */
|
|
2317
2334
|
GridStack.prototype._onStartMoving = function (el, event, ui, node, cellWidth, cellHeight) {
|
|
2335
|
+
var _a;
|
|
2318
2336
|
this.engine.cleanNodes()
|
|
2319
2337
|
.beginUpdate(node);
|
|
2320
2338
|
// @ts-ignore
|
|
2321
2339
|
this._writePosAttr(this.placeholder, node);
|
|
2322
2340
|
this.el.appendChild(this.placeholder);
|
|
2323
2341
|
// console.log('_onStartMoving placeholder') // TEST
|
|
2342
|
+
// if the element is inside a grid, it has already been scaled
|
|
2343
|
+
// we can use that as a scale reference
|
|
2344
|
+
if ((_a = node.grid) === null || _a === void 0 ? void 0 : _a.el) {
|
|
2345
|
+
this.dragTransform = utils_1.Utils.getValuesFromTransformedElement(el);
|
|
2346
|
+
}
|
|
2347
|
+
// if the element is being dragged from outside (not from any grid)
|
|
2348
|
+
// we use the grid as the transformation reference, since the helper is not subject to transformation
|
|
2349
|
+
else if (this.placeholder && this.placeholder.closest('.grid-stack')) {
|
|
2350
|
+
var gridEl = this.placeholder.closest('.grid-stack');
|
|
2351
|
+
this.dragTransform = utils_1.Utils.getValuesFromTransformedElement(gridEl);
|
|
2352
|
+
}
|
|
2353
|
+
// Fallback
|
|
2354
|
+
else {
|
|
2355
|
+
this.dragTransform = {
|
|
2356
|
+
xScale: 1,
|
|
2357
|
+
xOffset: 0,
|
|
2358
|
+
yScale: 1,
|
|
2359
|
+
yOffset: 0,
|
|
2360
|
+
};
|
|
2361
|
+
}
|
|
2324
2362
|
node.el = this.placeholder;
|
|
2325
2363
|
node._lastUiPosition = ui.position;
|
|
2326
2364
|
node._prevYPix = ui.position.top;
|
|
@@ -2437,6 +2475,9 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
2437
2475
|
var node = el.gridstackNode;
|
|
2438
2476
|
if (!node)
|
|
2439
2477
|
return;
|
|
2478
|
+
helper = helper || el;
|
|
2479
|
+
// restore the scale of the helper on leave
|
|
2480
|
+
helper.style.transform = 'scale(1)';
|
|
2440
2481
|
dd.off(el, 'drag'); // no need to track while being outside
|
|
2441
2482
|
// this gets called when cursor leaves and shape is outside, so only do this once
|
|
2442
2483
|
if (node._temporaryRemoved)
|
|
@@ -2470,7 +2511,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
2470
2511
|
GridStack.Utils = utils_1.Utils;
|
|
2471
2512
|
/** scoping so users can call new GridStack.Engine(12) for example */
|
|
2472
2513
|
GridStack.Engine = gridstack_engine_1.GridStackEngine;
|
|
2473
|
-
GridStack.GDRev = '10.0
|
|
2514
|
+
GridStack.GDRev = '10.1.0';
|
|
2474
2515
|
return GridStack;
|
|
2475
2516
|
}());
|
|
2476
2517
|
//# sourceMappingURL=gridstack.js.map
|