gridstack 4.2.4 → 4.3.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 -14
- package/dist/gridstack-dd.d.ts +1 -1
- package/dist/gridstack-dd.js +37 -32
- package/dist/gridstack-dd.js.map +1 -1
- package/dist/gridstack-ddi.d.ts +1 -1
- package/dist/gridstack-ddi.js +2 -1
- package/dist/gridstack-ddi.js.map +1 -1
- package/dist/gridstack-engine.d.ts +4 -3
- package/dist/gridstack-engine.js +25 -14
- package/dist/gridstack-engine.js.map +1 -1
- package/dist/gridstack-extra.css +800 -530
- package/dist/gridstack-extra.min.css +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-poly.js +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 +306 -228
- package/dist/gridstack.d.ts +10 -5
- package/dist/gridstack.js +54 -34
- package/dist/gridstack.js.map +1 -1
- package/dist/gridstack.min.css +1 -1
- package/dist/h5/dd-base-impl.d.ts +2 -2
- package/dist/h5/dd-base-impl.js +2 -1
- package/dist/h5/dd-base-impl.js.map +1 -1
- package/dist/h5/dd-draggable.d.ts +1 -1
- package/dist/h5/dd-draggable.js +5 -1
- package/dist/h5/dd-draggable.js.map +1 -1
- package/dist/h5/dd-droppable.d.ts +1 -1
- package/dist/h5/dd-droppable.js +2 -1
- package/dist/h5/dd-droppable.js.map +1 -1
- package/dist/h5/dd-element.d.ts +1 -1
- package/dist/h5/dd-element.js +2 -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 +2 -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 +2 -1
- package/dist/h5/dd-resizable-handle.js.map +1 -1
- package/dist/h5/dd-resizable.d.ts +1 -1
- package/dist/h5/dd-resizable.js +2 -1
- package/dist/h5/dd-resizable.js.map +1 -1
- package/dist/h5/dd-utils.d.ts +1 -1
- package/dist/h5/dd-utils.js +2 -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 +13 -5
- package/dist/h5/gridstack-dd-native.js.map +1 -1
- package/dist/jq/gridstack-dd-jqueryui.js +20 -5
- package/dist/jq/gridstack-dd-jqueryui.js.map +1 -1
- package/dist/src/gridstack-extra.scss +7 -5
- package/dist/src/gridstack.scss +8 -6
- 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 +8 -1
- package/dist/utils.js +35 -5
- package/dist/utils.js.map +1 -1
- package/doc/CHANGES.md +28 -0
- package/doc/README.md +8 -5
- package/package.json +3 -4
package/dist/gridstack.js
CHANGED
|
@@ -1,21 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*!
|
|
3
|
-
* GridStack 4.
|
|
3
|
+
* GridStack 4.3.0
|
|
4
4
|
* https://gridstackjs.com/
|
|
5
5
|
*
|
|
6
6
|
* Copyright (c) 2021 Alain Dumesny
|
|
7
7
|
* see root license https://github.com/gridstack/gridstack.js/tree/master/LICENSE
|
|
8
8
|
*/
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
}
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
17
|
+
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
|
|
18
|
+
};
|
|
12
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.GridStack = void 0;
|
|
13
21
|
const gridstack_engine_1 = require("./gridstack-engine");
|
|
14
22
|
const utils_1 = require("./utils");
|
|
15
23
|
const gridstack_ddi_1 = require("./gridstack-ddi");
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
24
|
+
// export all dependent file as well to make it easier for users to just import the main file
|
|
25
|
+
__exportStar(require("./types"), exports);
|
|
26
|
+
__exportStar(require("./utils"), exports);
|
|
27
|
+
__exportStar(require("./gridstack-engine"), exports);
|
|
28
|
+
__exportStar(require("./gridstack-ddi"), exports);
|
|
19
29
|
// default values for grid options - used during init and when saving out
|
|
20
30
|
const GridDefaults = {
|
|
21
31
|
column: 12,
|
|
@@ -87,7 +97,7 @@ class GridStack {
|
|
|
87
97
|
}
|
|
88
98
|
let rowAttr = utils_1.Utils.toNumber(el.getAttribute('gs-row'));
|
|
89
99
|
// elements attributes override any passed options (like CSS style) - merge the two together
|
|
90
|
-
let defaults = Object.assign(Object.assign({}, 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: {
|
|
100
|
+
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: {
|
|
91
101
|
autoHide: !(opts.alwaysShowResizeHandle || false),
|
|
92
102
|
handles: 'se'
|
|
93
103
|
}, draggable: {
|
|
@@ -127,6 +137,11 @@ class GridStack {
|
|
|
127
137
|
this.cellHeight(undefined, false);
|
|
128
138
|
}
|
|
129
139
|
else {
|
|
140
|
+
// append unit if any are set
|
|
141
|
+
if (typeof this.opts.cellHeight == 'number' && this.opts.cellHeightUnit && this.opts.cellHeightUnit !== GridDefaults.cellHeightUnit) {
|
|
142
|
+
this.opts.cellHeight = this.opts.cellHeight + this.opts.cellHeightUnit;
|
|
143
|
+
delete this.opts.cellHeightUnit;
|
|
144
|
+
}
|
|
130
145
|
this.cellHeight(this.opts.cellHeight, false);
|
|
131
146
|
}
|
|
132
147
|
this.el.classList.add(this.opts._styleSheetClass);
|
|
@@ -207,7 +222,7 @@ class GridStack {
|
|
|
207
222
|
return null;
|
|
208
223
|
}
|
|
209
224
|
if (!el.gridstack) {
|
|
210
|
-
el.gridstack = new GridStack(el,
|
|
225
|
+
el.gridstack = new GridStack(el, utils_1.Utils.cloneDeep(options));
|
|
211
226
|
}
|
|
212
227
|
return el.gridstack;
|
|
213
228
|
}
|
|
@@ -224,7 +239,7 @@ class GridStack {
|
|
|
224
239
|
let grids = [];
|
|
225
240
|
GridStack.getGridElements(selector).forEach(el => {
|
|
226
241
|
if (!el.gridstack) {
|
|
227
|
-
el.gridstack = new GridStack(el,
|
|
242
|
+
el.gridstack = new GridStack(el, utils_1.Utils.cloneDeep(options));
|
|
228
243
|
delete options.dragIn;
|
|
229
244
|
delete options.dragInOptions; // only need to be done once (really a static global thing, not per grid)
|
|
230
245
|
}
|
|
@@ -324,7 +339,7 @@ class GridStack {
|
|
|
324
339
|
// as the actual value are filled in when _prepareElement() calls el.getAttribute('gs-xyz) before adding the node.
|
|
325
340
|
// So make sure we load any DOM attributes that are not specified in passed in options (which override)
|
|
326
341
|
let domAttr = this._readAttr(el);
|
|
327
|
-
options =
|
|
342
|
+
options = utils_1.Utils.cloneDeep(options) || {}; // make a copy before we modify in case caller re-uses it
|
|
328
343
|
utils_1.Utils.defaults(options, domAttr);
|
|
329
344
|
let node = this.engine.prepareNode(options);
|
|
330
345
|
this._writeAttr(el, options);
|
|
@@ -347,34 +362,39 @@ class GridStack {
|
|
|
347
362
|
return el;
|
|
348
363
|
}
|
|
349
364
|
/**
|
|
350
|
-
|
|
351
|
-
*
|
|
352
|
-
*
|
|
365
|
+
/**
|
|
366
|
+
* saves the current layout returning a list of widgets for serialization which might include any nested grids.
|
|
367
|
+
* @param saveContent if true (default) the latest html inside .grid-stack-content will be saved to GridStackWidget.content field, else it will
|
|
368
|
+
* be removed.
|
|
369
|
+
* @param saveGridOpt if true (default false), save the grid options itself, so you can call the new GridStack.addGrid()
|
|
370
|
+
* to recreate everything from scratch. GridStackOptions.children would then contain the widget list instead.
|
|
371
|
+
* @returns list of widgets or full grid option, including .children list of widgets
|
|
353
372
|
*/
|
|
354
373
|
save(saveContent = true, saveGridOpt = false) {
|
|
355
374
|
// return copied nodes we can modify at will...
|
|
356
375
|
let list = this.engine.save(saveContent);
|
|
357
|
-
// check for HTML content
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
376
|
+
// check for HTML content and nested grids
|
|
377
|
+
list.forEach(n => {
|
|
378
|
+
if (saveContent && n.el && !n.subGrid) { // sub-grid are saved differently, not plain content
|
|
379
|
+
let sub = n.el.querySelector('.grid-stack-item-content');
|
|
380
|
+
n.content = sub ? sub.innerHTML : undefined;
|
|
381
|
+
if (!n.content)
|
|
382
|
+
delete n.content;
|
|
383
|
+
}
|
|
384
|
+
else {
|
|
385
|
+
if (!saveContent) {
|
|
386
|
+
delete n.content;
|
|
366
387
|
}
|
|
367
|
-
|
|
368
|
-
}
|
|
369
|
-
// check if save entire grid options (needed for recursive) + children...
|
|
370
|
-
if (saveGridOpt) {
|
|
371
|
-
// check for nested grid
|
|
372
|
-
list.forEach(n => {
|
|
388
|
+
// check for nested grid
|
|
373
389
|
if (n.subGrid) {
|
|
374
|
-
n.subGrid = n.subGrid.save(saveContent,
|
|
390
|
+
n.subGrid = n.subGrid.save(saveContent, true);
|
|
375
391
|
}
|
|
376
|
-
}
|
|
377
|
-
|
|
392
|
+
}
|
|
393
|
+
delete n.el;
|
|
394
|
+
});
|
|
395
|
+
// check if save entire grid options (needed for recursive) + children...
|
|
396
|
+
if (saveGridOpt) {
|
|
397
|
+
let o = utils_1.Utils.cloneDeep(this.opts);
|
|
378
398
|
// delete default values that will be recreated on launch
|
|
379
399
|
if (o.marginBottom === o.marginTop && o.marginRight === o.marginLeft && o.marginTop === o.marginRight) {
|
|
380
400
|
o.margin = o.marginTop;
|
|
@@ -856,7 +876,7 @@ class GridStack {
|
|
|
856
876
|
update(els, opt) {
|
|
857
877
|
// support legacy call for now ?
|
|
858
878
|
if (arguments.length > 2) {
|
|
859
|
-
console.warn('gridstack.ts: `update(el, x, y, w, h)` is deprecated. Use `update({x, w, content, ...})`. It will be removed soon');
|
|
879
|
+
console.warn('gridstack.ts: `update(el, x, y, w, h)` is deprecated. Use `update(el, {x, w, content, ...})`. It will be removed soon');
|
|
860
880
|
// eslint-disable-next-line prefer-rest-params
|
|
861
881
|
let a = arguments, i = 1;
|
|
862
882
|
opt = { x: a[i++], y: a[i++], w: a[i++], h: a[i++] };
|
|
@@ -866,7 +886,7 @@ class GridStack {
|
|
|
866
886
|
if (!el || !el.gridstackNode)
|
|
867
887
|
return;
|
|
868
888
|
let n = el.gridstackNode;
|
|
869
|
-
let w =
|
|
889
|
+
let w = utils_1.Utils.cloneDeep(opt); // make a copy we can modify in case they re-use it or multiple items
|
|
870
890
|
delete w.autoPosition;
|
|
871
891
|
// move/resize widget if anything changed
|
|
872
892
|
let keys = ['x', 'y', 'w', 'h'];
|