gridstack 4.3.1 → 4.4.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.
Files changed (125) hide show
  1. package/README.md +14 -5
  2. package/dist/es5/gridstack-dd.d.ts +35 -0
  3. package/dist/es5/gridstack-dd.js +683 -0
  4. package/dist/es5/gridstack-dd.js.map +1 -0
  5. package/dist/es5/gridstack-ddi.d.ts +17 -0
  6. package/dist/es5/gridstack-ddi.js +31 -0
  7. package/dist/es5/gridstack-ddi.js.map +1 -0
  8. package/dist/es5/gridstack-engine.d.ts +93 -0
  9. package/dist/es5/gridstack-engine.js +955 -0
  10. package/dist/es5/gridstack-engine.js.map +1 -0
  11. package/dist/es5/gridstack-h5.d.ts +10 -0
  12. package/dist/es5/gridstack-h5.js +3 -0
  13. package/dist/es5/gridstack-h5.js.LICENSE.txt +7 -0
  14. package/dist/es5/gridstack-h5.js.map +1 -0
  15. package/dist/es5/gridstack-jq.d.ts +10 -0
  16. package/dist/es5/gridstack-jq.js +3 -0
  17. package/dist/es5/gridstack-jq.js.LICENSE.txt +99 -0
  18. package/dist/es5/gridstack-jq.js.map +1 -0
  19. package/dist/{gridstack-poly.js → es5/gridstack-poly.js} +152 -1
  20. package/dist/es5/gridstack-static.d.ts +9 -0
  21. package/dist/es5/gridstack-static.js +3 -0
  22. package/dist/es5/gridstack-static.js.LICENSE.txt +7 -0
  23. package/dist/es5/gridstack-static.js.map +1 -0
  24. package/dist/es5/gridstack.d.ts +346 -0
  25. package/dist/es5/gridstack.js +1482 -0
  26. package/dist/es5/gridstack.js.map +1 -0
  27. package/dist/es5/h5/dd-base-impl.d.ts +20 -0
  28. package/dist/es5/h5/dd-base-impl.js +43 -0
  29. package/dist/es5/h5/dd-base-impl.js.map +1 -0
  30. package/dist/es5/h5/dd-draggable.d.ts +30 -0
  31. package/dist/es5/h5/dd-draggable.js +319 -0
  32. package/dist/es5/h5/dd-draggable.js.map +1 -0
  33. package/dist/es5/h5/dd-droppable.d.ts +23 -0
  34. package/dist/es5/h5/dd-droppable.js +182 -0
  35. package/dist/es5/h5/dd-droppable.js.map +1 -0
  36. package/dist/es5/h5/dd-element.d.ts +27 -0
  37. package/dist/es5/h5/dd-element.js +96 -0
  38. package/dist/es5/h5/dd-element.js.map +1 -0
  39. package/dist/es5/h5/dd-manager.d.ts +8 -0
  40. package/dist/es5/h5/dd-manager.js +14 -0
  41. package/dist/es5/h5/dd-manager.js.map +1 -0
  42. package/dist/es5/h5/dd-resizable-handle.d.ts +14 -0
  43. package/dist/es5/h5/dd-resizable-handle.js +83 -0
  44. package/dist/es5/h5/dd-resizable-handle.js.map +1 -0
  45. package/dist/es5/h5/dd-resizable.d.ts +29 -0
  46. package/dist/es5/h5/dd-resizable.js +302 -0
  47. package/dist/es5/h5/dd-resizable.js.map +1 -0
  48. package/dist/es5/h5/dd-utils.d.ts +17 -0
  49. package/dist/es5/h5/dd-utils.js +99 -0
  50. package/dist/es5/h5/dd-utils.js.map +1 -0
  51. package/dist/es5/h5/gridstack-dd-native.d.ts +26 -0
  52. package/dist/es5/h5/gridstack-dd-native.js +175 -0
  53. package/dist/es5/h5/gridstack-dd-native.js.map +1 -0
  54. package/dist/es5/jq/gridstack-dd-jqueryui.d.ts +22 -0
  55. package/dist/es5/jq/gridstack-dd-jqueryui.js +162 -0
  56. package/dist/es5/jq/gridstack-dd-jqueryui.js.map +1 -0
  57. package/dist/es5/types.d.ts +258 -0
  58. package/dist/es5/types.js +7 -0
  59. package/dist/es5/types.js.map +1 -0
  60. package/dist/es5/utils.d.ts +73 -0
  61. package/dist/es5/utils.js +444 -0
  62. package/dist/es5/utils.js.map +1 -0
  63. package/dist/gridstack-dd.d.ts +1 -1
  64. package/dist/gridstack-dd.js +7 -5
  65. package/dist/gridstack-dd.js.map +1 -1
  66. package/dist/gridstack-ddi.d.ts +1 -1
  67. package/dist/gridstack-ddi.js +1 -1
  68. package/dist/gridstack-ddi.js.map +1 -1
  69. package/dist/gridstack-engine.d.ts +1 -1
  70. package/dist/gridstack-engine.js +63 -45
  71. package/dist/gridstack-engine.js.map +1 -1
  72. package/dist/gridstack-h5.d.ts +1 -1
  73. package/dist/gridstack-h5.js +1 -1
  74. package/dist/gridstack-h5.js.LICENSE.txt +1 -1
  75. package/dist/gridstack-h5.js.map +1 -1
  76. package/dist/gridstack-jq.d.ts +1 -1
  77. package/dist/gridstack-jq.js +1 -1
  78. package/dist/gridstack-jq.js.LICENSE.txt +1 -1
  79. package/dist/gridstack-jq.js.map +1 -1
  80. package/dist/gridstack-static.d.ts +1 -1
  81. package/dist/gridstack-static.js +1 -1
  82. package/dist/gridstack-static.js.LICENSE.txt +1 -1
  83. package/dist/gridstack-static.js.map +1 -1
  84. package/dist/gridstack.css +1 -2
  85. package/dist/gridstack.d.ts +1 -1
  86. package/dist/gridstack.js +13 -11
  87. package/dist/gridstack.js.map +1 -1
  88. package/dist/gridstack.min.css +1 -1
  89. package/dist/h5/dd-base-impl.d.ts +1 -1
  90. package/dist/h5/dd-base-impl.js +1 -1
  91. package/dist/h5/dd-base-impl.js.map +1 -1
  92. package/dist/h5/dd-draggable.d.ts +1 -1
  93. package/dist/h5/dd-draggable.js +1 -1
  94. package/dist/h5/dd-draggable.js.map +1 -1
  95. package/dist/h5/dd-droppable.d.ts +1 -1
  96. package/dist/h5/dd-droppable.js +1 -1
  97. package/dist/h5/dd-droppable.js.map +1 -1
  98. package/dist/h5/dd-element.d.ts +1 -1
  99. package/dist/h5/dd-element.js +1 -1
  100. package/dist/h5/dd-element.js.map +1 -1
  101. package/dist/h5/dd-manager.d.ts +1 -1
  102. package/dist/h5/dd-manager.js +1 -1
  103. package/dist/h5/dd-manager.js.map +1 -1
  104. package/dist/h5/dd-resizable-handle.d.ts +1 -1
  105. package/dist/h5/dd-resizable-handle.js +1 -1
  106. package/dist/h5/dd-resizable-handle.js.map +1 -1
  107. package/dist/h5/dd-resizable.d.ts +1 -1
  108. package/dist/h5/dd-resizable.js +1 -1
  109. package/dist/h5/dd-resizable.js.map +1 -1
  110. package/dist/h5/dd-utils.d.ts +1 -1
  111. package/dist/h5/dd-utils.js +1 -1
  112. package/dist/h5/dd-utils.js.map +1 -1
  113. package/dist/h5/gridstack-dd-native.d.ts +1 -1
  114. package/dist/h5/gridstack-dd-native.js +1 -1
  115. package/dist/h5/gridstack-dd-native.js.map +1 -1
  116. package/dist/jq/gridstack-dd-jqueryui.js.map +1 -1
  117. package/dist/src/gridstack.scss +2 -2
  118. package/dist/types.d.ts +3 -2
  119. package/dist/types.js +1 -1
  120. package/dist/types.js.map +1 -1
  121. package/dist/utils.d.ts +3 -1
  122. package/dist/utils.js +4 -4
  123. package/dist/utils.js.map +1 -1
  124. package/doc/CHANGES.md +7 -1
  125. package/package.json +5 -3
@@ -0,0 +1,955 @@
1
+ "use strict";
2
+ /**
3
+ * gridstack-engine.ts 4.4.0
4
+ * Copyright (c) 2021 Alain Dumesny - see GridStack root license
5
+ */
6
+ var __assign = (this && this.__assign) || function () {
7
+ __assign = Object.assign || function(t) {
8
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
9
+ s = arguments[i];
10
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
11
+ t[p] = s[p];
12
+ }
13
+ return t;
14
+ };
15
+ return __assign.apply(this, arguments);
16
+ };
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.GridStackEngine = void 0;
19
+ var utils_1 = require("./utils");
20
+ /**
21
+ * Defines the GridStack engine that does most no DOM grid manipulation.
22
+ * See GridStack methods and vars for descriptions.
23
+ *
24
+ * NOTE: values should not be modified directly - call the main GridStack API instead
25
+ */
26
+ var GridStackEngine = /** @class */ (function () {
27
+ function GridStackEngine(opts) {
28
+ if (opts === void 0) { opts = {}; }
29
+ this.addedNodes = [];
30
+ this.removedNodes = [];
31
+ this.column = opts.column || 12;
32
+ this.onChange = opts.onChange;
33
+ this._float = opts.float;
34
+ this.maxRow = opts.maxRow;
35
+ this.nodes = opts.nodes || [];
36
+ }
37
+ GridStackEngine.prototype.batchUpdate = function () {
38
+ if (this.batchMode)
39
+ return this;
40
+ this.batchMode = true;
41
+ this._prevFloat = this._float;
42
+ this._float = true; // let things go anywhere for now... commit() will restore and possibly reposition
43
+ this.saveInitial(); // since begin update (which is called multiple times) won't do this
44
+ return this;
45
+ };
46
+ GridStackEngine.prototype.commit = function () {
47
+ if (!this.batchMode)
48
+ return this;
49
+ this.batchMode = false;
50
+ this._float = this._prevFloat;
51
+ delete this._prevFloat;
52
+ return this._packNodes()
53
+ ._notify();
54
+ };
55
+ // use entire row for hitting area (will use bottom reverse sorted first) if we not actively moving DOWN and didn't already skip
56
+ GridStackEngine.prototype._useEntireRowArea = function (node, nn) {
57
+ return !this.float && !this._hasLocked && (!node._moving || node._skipDown || nn.y <= node.y);
58
+ };
59
+ /** @internal fix collision on given 'node', going to given new location 'nn', with optional 'collide' node already found.
60
+ * return true if we moved. */
61
+ GridStackEngine.prototype._fixCollisions = function (node, nn, collide, opt) {
62
+ if (nn === void 0) { nn = node; }
63
+ if (opt === void 0) { opt = {}; }
64
+ this._sortNodes(-1); // from last to first, so recursive collision move items in the right order
65
+ collide = collide || this.collide(node, nn); // REAL area collide for swap and skip if none...
66
+ if (!collide)
67
+ return false;
68
+ // swap check: if we're actively moving in gravity mode, see if we collide with an object the same size
69
+ if (node._moving && !opt.nested && !this.float) {
70
+ if (this.swap(node, collide))
71
+ return true;
72
+ }
73
+ // during while() collisions MAKE SURE to check entire row so larger items don't leap frog small ones (push them all down starting last in grid)
74
+ var area = nn;
75
+ if (this._useEntireRowArea(node, nn)) {
76
+ area = { x: 0, w: this.column, y: nn.y, h: nn.h };
77
+ collide = this.collide(node, area, opt.skip); // force new hit
78
+ }
79
+ var didMove = false;
80
+ var newOpt = { nested: true, pack: false };
81
+ while (collide = collide || this.collide(node, area, opt.skip)) { // could collide with more than 1 item... so repeat for each
82
+ var moved = void 0;
83
+ // if colliding with a locked item OR moving down with top gravity (and collide could move up) -> skip past the collide,
84
+ // but remember that skip down so we only do this once (and push others otherwise).
85
+ if (collide.locked || node._moving && !node._skipDown && nn.y > node.y && !this.float &&
86
+ // can take space we had, or before where we're going
87
+ (!this.collide(collide, __assign(__assign({}, collide), { y: node.y }), node) || !this.collide(collide, __assign(__assign({}, collide), { y: nn.y - collide.h }), node))) {
88
+ node._skipDown = (node._skipDown || nn.y > node.y);
89
+ moved = this.moveNode(node, __assign(__assign(__assign({}, nn), { y: collide.y + collide.h }), newOpt));
90
+ if (collide.locked && moved) {
91
+ utils_1.Utils.copyPos(nn, node); // moving after lock become our new desired location
92
+ }
93
+ else if (!collide.locked && moved && opt.pack) {
94
+ // we moved after and will pack: do it now and keep the original drop location, but past the old collide to see what else we might push way
95
+ this._packNodes();
96
+ nn.y = collide.y + collide.h;
97
+ utils_1.Utils.copyPos(node, nn);
98
+ }
99
+ didMove = didMove || moved;
100
+ }
101
+ else {
102
+ // move collide down *after* where we will be, ignoring where we are now (don't collide with us)
103
+ moved = this.moveNode(collide, __assign(__assign(__assign({}, collide), { y: nn.y + nn.h, skip: node }), newOpt));
104
+ }
105
+ if (!moved) {
106
+ return didMove;
107
+ } // break inf loop if we couldn't move after all (ex: maxRow, fixed)
108
+ collide = undefined;
109
+ }
110
+ return didMove;
111
+ };
112
+ /** return the nodes that intercept the given node. Optionally a different area can be used, as well as a second node to skip */
113
+ GridStackEngine.prototype.collide = function (skip, area, skip2) {
114
+ if (area === void 0) { area = skip; }
115
+ return this.nodes.find(function (n) { return n !== skip && n !== skip2 && utils_1.Utils.isIntercepted(n, area); });
116
+ };
117
+ GridStackEngine.prototype.collideAll = function (skip, area, skip2) {
118
+ if (area === void 0) { area = skip; }
119
+ return this.nodes.filter(function (n) { return n !== skip && n !== skip2 && utils_1.Utils.isIntercepted(n, area); });
120
+ };
121
+ /** does a pixel coverage collision, returning the node that has the most coverage that is >50% mid line */
122
+ GridStackEngine.prototype.collideCoverage = function (node, o, collides) {
123
+ if (!o.rect || !node._rect)
124
+ return;
125
+ var r0 = node._rect; // where started
126
+ var r = __assign({}, o.rect); // where we are
127
+ // update dragged rect to show where it's coming from (above or below, etc...)
128
+ if (r.y > r0.y) {
129
+ r.h += r.y - r0.y;
130
+ r.y = r0.y;
131
+ }
132
+ else {
133
+ r.h += r0.y - r.y;
134
+ }
135
+ if (r.x > r0.x) {
136
+ r.w += r.x - r0.x;
137
+ r.x = r0.x;
138
+ }
139
+ else {
140
+ r.w += r0.x - r.x;
141
+ }
142
+ var collide;
143
+ collides.forEach(function (n) {
144
+ if (n.locked || !n._rect)
145
+ return;
146
+ var r2 = n._rect; // overlapping target
147
+ var yOver = Number.MAX_VALUE, xOver = Number.MAX_VALUE, overMax = 0.5; // need >50%
148
+ // depending on which side we started from, compute the overlap % of coverage
149
+ // (ex: from above/below we only compute the max horizontal line coverage)
150
+ if (r0.y < r2.y) { // from above
151
+ yOver = ((r.y + r.h) - r2.y) / r2.h;
152
+ }
153
+ else if (r0.y + r0.h > r2.y + r2.h) { // from below
154
+ yOver = ((r2.y + r2.h) - r.y) / r2.h;
155
+ }
156
+ if (r0.x < r2.x) { // from the left
157
+ xOver = ((r.x + r.w) - r2.x) / r2.w;
158
+ }
159
+ else if (r0.x + r0.w > r2.x + r2.w) { // from the right
160
+ xOver = ((r2.x + r2.w) - r.x) / r2.w;
161
+ }
162
+ var over = Math.min(xOver, yOver);
163
+ if (over > overMax) {
164
+ overMax = over;
165
+ collide = n;
166
+ }
167
+ });
168
+ return collide;
169
+ };
170
+ /** called to cache the nodes pixel rectangles used for collision detection during drag */
171
+ GridStackEngine.prototype.cacheRects = function (w, h, top, right, bottom, left) {
172
+ this.nodes.forEach(function (n) {
173
+ return n._rect = {
174
+ y: n.y * h + top,
175
+ x: n.x * w + left,
176
+ w: n.w * w - left - right,
177
+ h: n.h * h - top - bottom
178
+ };
179
+ });
180
+ return this;
181
+ };
182
+ /** called to possibly swap between 2 nodes (same size or column, not locked, touching), returning true if successful */
183
+ GridStackEngine.prototype.swap = function (a, b) {
184
+ if (!b || b.locked || !a || a.locked)
185
+ return false;
186
+ function _doSwap() {
187
+ var x = b.x, y = b.y;
188
+ b.x = a.x;
189
+ b.y = a.y; // b -> a position
190
+ if (a.h != b.h) {
191
+ a.x = x;
192
+ a.y = b.y + b.h; // a -> goes after b
193
+ }
194
+ else if (a.w != b.w) {
195
+ a.x = b.x + b.w;
196
+ a.y = y; // a -> goes after b
197
+ }
198
+ else {
199
+ a.x = x;
200
+ a.y = y; // a -> old b position
201
+ }
202
+ a._dirty = b._dirty = true;
203
+ return true;
204
+ }
205
+ var touching; // remember if we called it (vs undefined)
206
+ // same size and same row or column, and touching
207
+ if (a.w === b.w && a.h === b.h && (a.x === b.x || a.y === b.y) && (touching = utils_1.Utils.isTouching(a, b)))
208
+ return _doSwap();
209
+ if (touching === false)
210
+ return; // IFF ran test and fail, bail out
211
+ // check for taking same columns (but different height) and touching
212
+ if (a.w === b.w && a.x === b.x && (touching || (touching = utils_1.Utils.isTouching(a, b)))) {
213
+ if (b.y < a.y) {
214
+ var t = a;
215
+ a = b;
216
+ b = t;
217
+ } // swap a <-> b vars so a is first
218
+ return _doSwap();
219
+ }
220
+ if (touching === false)
221
+ return;
222
+ // check if taking same row (but different width) and touching
223
+ if (a.h === b.h && a.y === b.y && (touching || (touching = utils_1.Utils.isTouching(a, b)))) {
224
+ if (b.x < a.x) {
225
+ var t = a;
226
+ a = b;
227
+ b = t;
228
+ } // swap a <-> b vars so a is first
229
+ return _doSwap();
230
+ }
231
+ return false;
232
+ };
233
+ GridStackEngine.prototype.isAreaEmpty = function (x, y, w, h) {
234
+ var nn = { x: x || 0, y: y || 0, w: w || 1, h: h || 1 };
235
+ return !this.collide(nn);
236
+ };
237
+ /** re-layout grid items to reclaim any empty space */
238
+ GridStackEngine.prototype.compact = function () {
239
+ var _this = this;
240
+ if (this.nodes.length === 0)
241
+ return this;
242
+ this.batchUpdate()
243
+ ._sortNodes();
244
+ var copyNodes = this.nodes;
245
+ this.nodes = []; // pretend we have no nodes to conflict layout to start with...
246
+ copyNodes.forEach(function (node) {
247
+ if (!node.locked) {
248
+ node.autoPosition = true;
249
+ }
250
+ _this.addNode(node, false); // 'false' for add event trigger
251
+ node._dirty = true; // will force attr update
252
+ });
253
+ return this.commit();
254
+ };
255
+ Object.defineProperty(GridStackEngine.prototype, "float", {
256
+ /** float getter method */
257
+ get: function () { return this._float || false; },
258
+ /** enable/disable floating widgets (default: `false`) See [example](http://gridstackjs.com/demo/float.html) */
259
+ set: function (val) {
260
+ if (this._float === val)
261
+ return;
262
+ this._float = val || false;
263
+ if (!val) {
264
+ this._packNodes()._notify();
265
+ }
266
+ },
267
+ enumerable: false,
268
+ configurable: true
269
+ });
270
+ /** @internal */
271
+ GridStackEngine.prototype._sortNodes = function (dir) {
272
+ this.nodes = utils_1.Utils.sort(this.nodes, dir, this.column);
273
+ return this;
274
+ };
275
+ /** @internal called to top gravity pack the items back OR revert back to original Y positions when floating */
276
+ GridStackEngine.prototype._packNodes = function () {
277
+ var _this = this;
278
+ if (this.batchMode) {
279
+ return;
280
+ }
281
+ this._sortNodes(); // first to last
282
+ if (this.float) {
283
+ // restore original Y pos
284
+ this.nodes.forEach(function (n) {
285
+ if (n._updating || n._orig === undefined || n.y === n._orig.y)
286
+ return;
287
+ var newY = n.y;
288
+ while (newY > n._orig.y) {
289
+ --newY;
290
+ var collide = _this.collide(n, { x: n.x, y: newY, w: n.w, h: n.h });
291
+ if (!collide) {
292
+ n._dirty = true;
293
+ n.y = newY;
294
+ }
295
+ }
296
+ });
297
+ }
298
+ else {
299
+ // top gravity pack
300
+ this.nodes.forEach(function (n, i) {
301
+ if (n.locked)
302
+ return;
303
+ while (n.y > 0) {
304
+ var newY = i === 0 ? 0 : n.y - 1;
305
+ var canBeMoved = i === 0 || !_this.collide(n, { x: n.x, y: newY, w: n.w, h: n.h });
306
+ if (!canBeMoved)
307
+ break;
308
+ // Note: must be dirty (from last position) for GridStack::OnChange CB to update positions
309
+ // and move items back. The user 'change' CB should detect changes from the original
310
+ // starting position instead.
311
+ n._dirty = (n.y !== newY);
312
+ n.y = newY;
313
+ }
314
+ });
315
+ }
316
+ return this;
317
+ };
318
+ /**
319
+ * given a random node, makes sure it's coordinates/values are valid in the current grid
320
+ * @param node to adjust
321
+ * @param resizing if out of bound, resize down or move into the grid to fit ?
322
+ */
323
+ GridStackEngine.prototype.prepareNode = function (node, resizing) {
324
+ node = node || {};
325
+ node._id = node._id || GridStackEngine._idSeq++;
326
+ // if we're missing position, have the grid position us automatically (before we set them to 0,0)
327
+ if (node.x === undefined || node.y === undefined || node.x === null || node.y === null) {
328
+ node.autoPosition = true;
329
+ }
330
+ // assign defaults for missing required fields
331
+ var defaults = { x: 0, y: 0, w: 1, h: 1 };
332
+ utils_1.Utils.defaults(node, defaults);
333
+ if (!node.autoPosition) {
334
+ delete node.autoPosition;
335
+ }
336
+ if (!node.noResize) {
337
+ delete node.noResize;
338
+ }
339
+ if (!node.noMove) {
340
+ delete node.noMove;
341
+ }
342
+ // check for NaN (in case messed up strings were passed. can't do parseInt() || defaults.x above as 0 is valid #)
343
+ if (typeof node.x == 'string') {
344
+ node.x = Number(node.x);
345
+ }
346
+ if (typeof node.y == 'string') {
347
+ node.y = Number(node.y);
348
+ }
349
+ if (typeof node.w == 'string') {
350
+ node.w = Number(node.w);
351
+ }
352
+ if (typeof node.h == 'string') {
353
+ node.h = Number(node.h);
354
+ }
355
+ if (isNaN(node.x)) {
356
+ node.x = defaults.x;
357
+ node.autoPosition = true;
358
+ }
359
+ if (isNaN(node.y)) {
360
+ node.y = defaults.y;
361
+ node.autoPosition = true;
362
+ }
363
+ if (isNaN(node.w)) {
364
+ node.w = defaults.w;
365
+ }
366
+ if (isNaN(node.h)) {
367
+ node.h = defaults.h;
368
+ }
369
+ return this.nodeBoundFix(node, resizing);
370
+ };
371
+ /** part2 of preparing a node to fit inside our grid - checks for x,y from grid dimensions */
372
+ GridStackEngine.prototype.nodeBoundFix = function (node, resizing) {
373
+ var before = node._orig || utils_1.Utils.copyPos({}, node);
374
+ if (node.maxW) {
375
+ node.w = Math.min(node.w, node.maxW);
376
+ }
377
+ if (node.maxH) {
378
+ node.h = Math.min(node.h, node.maxH);
379
+ }
380
+ if (node.minW && node.minW <= this.column) {
381
+ node.w = Math.max(node.w, node.minW);
382
+ }
383
+ if (node.minH) {
384
+ node.h = Math.max(node.h, node.minH);
385
+ }
386
+ if (node.w > this.column) {
387
+ // if user loaded a larger than allowed widget for current # of columns,
388
+ // remember it's full width so we can restore back (1 -> 12 column) #1655
389
+ // IFF we're not in the middle of column resizing!
390
+ if (this.column < 12 && !this._inColumnResize) {
391
+ node.w = Math.min(12, node.w);
392
+ this.cacheOneLayout(node, 12);
393
+ }
394
+ node.w = this.column;
395
+ }
396
+ else if (node.w < 1) {
397
+ node.w = 1;
398
+ }
399
+ if (this.maxRow && node.h > this.maxRow) {
400
+ node.h = this.maxRow;
401
+ }
402
+ else if (node.h < 1) {
403
+ node.h = 1;
404
+ }
405
+ if (node.x < 0) {
406
+ node.x = 0;
407
+ }
408
+ if (node.y < 0) {
409
+ node.y = 0;
410
+ }
411
+ if (node.x + node.w > this.column) {
412
+ if (resizing) {
413
+ node.w = this.column - node.x;
414
+ }
415
+ else {
416
+ node.x = this.column - node.w;
417
+ }
418
+ }
419
+ if (this.maxRow && node.y + node.h > this.maxRow) {
420
+ if (resizing) {
421
+ node.h = this.maxRow - node.y;
422
+ }
423
+ else {
424
+ node.y = this.maxRow - node.h;
425
+ }
426
+ }
427
+ if (!utils_1.Utils.samePos(node, before)) {
428
+ node._dirty = true;
429
+ }
430
+ return node;
431
+ };
432
+ GridStackEngine.prototype.getDirtyNodes = function (verify) {
433
+ // compare original x,y,w,h instead as _dirty can be a temporary state
434
+ if (verify) {
435
+ return this.nodes.filter(function (n) { return n._dirty && !utils_1.Utils.samePos(n, n._orig); });
436
+ }
437
+ return this.nodes.filter(function (n) { return n._dirty; });
438
+ };
439
+ /** @internal call this to call onChange CB with dirty nodes */
440
+ GridStackEngine.prototype._notify = function (nodes, removeDOM) {
441
+ if (removeDOM === void 0) { removeDOM = true; }
442
+ if (this.batchMode)
443
+ return this;
444
+ nodes = (nodes === undefined ? [] : (Array.isArray(nodes) ? nodes : [nodes]));
445
+ var dirtyNodes = nodes.concat(this.getDirtyNodes());
446
+ this.onChange && this.onChange(dirtyNodes, removeDOM);
447
+ return this;
448
+ };
449
+ /** @internal remove dirty and last tried info */
450
+ GridStackEngine.prototype.cleanNodes = function () {
451
+ if (this.batchMode)
452
+ return this;
453
+ this.nodes.forEach(function (n) {
454
+ delete n._dirty;
455
+ delete n._lastTried;
456
+ });
457
+ return this;
458
+ };
459
+ /** @internal called to save initial position/size to track real dirty state.
460
+ * Note: should be called right after we call change event (so next API is can detect changes)
461
+ * as well as right before we start move/resize/enter (so we can restore items to prev values) */
462
+ GridStackEngine.prototype.saveInitial = function () {
463
+ this.nodes.forEach(function (n) {
464
+ n._orig = utils_1.Utils.copyPos({}, n);
465
+ delete n._dirty;
466
+ });
467
+ this._hasLocked = this.nodes.some(function (n) { return n.locked; });
468
+ return this;
469
+ };
470
+ /** @internal restore all the nodes back to initial values (called when we leave) */
471
+ GridStackEngine.prototype.restoreInitial = function () {
472
+ this.nodes.forEach(function (n) {
473
+ if (utils_1.Utils.samePos(n, n._orig))
474
+ return;
475
+ utils_1.Utils.copyPos(n, n._orig);
476
+ n._dirty = true;
477
+ });
478
+ this._notify();
479
+ return this;
480
+ };
481
+ /** call to add the given node to our list, fixing collision and re-packing */
482
+ GridStackEngine.prototype.addNode = function (node, triggerAddEvent) {
483
+ if (triggerAddEvent === void 0) { triggerAddEvent = false; }
484
+ var dup = this.nodes.find(function (n) { return n._id === node._id; });
485
+ if (dup)
486
+ return dup; // prevent inserting twice! return it instead.
487
+ // skip prepareNode if we're in middle of column resize (not new) but do check for bounds!
488
+ node = this._inColumnResize ? this.nodeBoundFix(node) : this.prepareNode(node);
489
+ delete node._temporaryRemoved;
490
+ delete node._removeDOM;
491
+ if (node.autoPosition) {
492
+ this._sortNodes();
493
+ var _loop_1 = function (i) {
494
+ var x = i % this_1.column;
495
+ var y = Math.floor(i / this_1.column);
496
+ if (x + node.w > this_1.column) {
497
+ return "continue";
498
+ }
499
+ var box = { x: x, y: y, w: node.w, h: node.h };
500
+ if (!this_1.nodes.find(function (n) { return utils_1.Utils.isIntercepted(box, n); })) {
501
+ node.x = x;
502
+ node.y = y;
503
+ delete node.autoPosition; // found our slot
504
+ return "break";
505
+ }
506
+ };
507
+ var this_1 = this;
508
+ for (var i = 0;; ++i) {
509
+ var state_1 = _loop_1(i);
510
+ if (state_1 === "break")
511
+ break;
512
+ }
513
+ }
514
+ this.nodes.push(node);
515
+ if (triggerAddEvent) {
516
+ this.addedNodes.push(node);
517
+ }
518
+ this._fixCollisions(node);
519
+ if (!this.batchMode) {
520
+ this._packNodes()._notify();
521
+ }
522
+ return node;
523
+ };
524
+ GridStackEngine.prototype.removeNode = function (node, removeDOM, triggerEvent) {
525
+ if (removeDOM === void 0) { removeDOM = true; }
526
+ if (triggerEvent === void 0) { triggerEvent = false; }
527
+ if (!this.nodes.find(function (n) { return n === node; })) {
528
+ // TEST console.log(`Error: GridStackEngine.removeNode() node._id=${node._id} not found!`)
529
+ return this;
530
+ }
531
+ if (triggerEvent) { // we wait until final drop to manually track removed items (rather than during drag)
532
+ this.removedNodes.push(node);
533
+ }
534
+ if (removeDOM)
535
+ node._removeDOM = true; // let CB remove actual HTML (used to set _id to null, but then we loose layout info)
536
+ // don't use 'faster' .splice(findIndex(),1) in case node isn't in our list, or in multiple times.
537
+ this.nodes = this.nodes.filter(function (n) { return n !== node; });
538
+ return this._packNodes()
539
+ ._notify(node);
540
+ };
541
+ GridStackEngine.prototype.removeAll = function (removeDOM) {
542
+ if (removeDOM === void 0) { removeDOM = true; }
543
+ delete this._layouts;
544
+ if (this.nodes.length === 0)
545
+ return this;
546
+ removeDOM && this.nodes.forEach(function (n) { return n._removeDOM = true; }); // let CB remove actual HTML (used to set _id to null, but then we loose layout info)
547
+ this.removedNodes = this.nodes;
548
+ this.nodes = [];
549
+ return this._notify(this.removedNodes);
550
+ };
551
+ /** checks if item can be moved (layout constrain) vs moveNode(), returning true if was able to move.
552
+ * In more complicated cases (maxRow) it will attempt at moving the item and fixing
553
+ * others in a clone first, then apply those changes if still within specs. */
554
+ GridStackEngine.prototype.moveNodeCheck = function (node, o) {
555
+ var _this = this;
556
+ // if (node.locked) return false;
557
+ if (!this.changedPosConstrain(node, o))
558
+ return false;
559
+ o.pack = true;
560
+ // simpler case: move item directly...
561
+ if (!this.maxRow /* && !this._hasLocked*/) {
562
+ return this.moveNode(node, o);
563
+ }
564
+ // complex case: create a clone with NO maxRow (will check for out of bounds at the end)
565
+ var clonedNode;
566
+ var clone = new GridStackEngine({
567
+ column: this.column,
568
+ float: this.float,
569
+ nodes: this.nodes.map(function (n) {
570
+ if (n === node) {
571
+ clonedNode = __assign({}, n);
572
+ return clonedNode;
573
+ }
574
+ return __assign({}, n);
575
+ })
576
+ });
577
+ if (!clonedNode)
578
+ return false;
579
+ var canMove = clone.moveNode(clonedNode, o);
580
+ // if maxRow make sure we are still valid size
581
+ if (this.maxRow && canMove) {
582
+ canMove = (clone.getRow() <= this.maxRow);
583
+ // turns out we can't grow, then see if we can swap instead (ex: full grid) if we're not resizing
584
+ if (!canMove && !o.resizing) {
585
+ var collide = this.collide(node, o);
586
+ if (collide && this.swap(node, collide)) {
587
+ this._notify();
588
+ return true;
589
+ }
590
+ }
591
+ }
592
+ if (!canMove)
593
+ return false;
594
+ // if clone was able to move, copy those mods over to us now instead of caller trying to do this all over!
595
+ // Note: we can't use the list directly as elements and other parts point to actual node, so copy content
596
+ clone.nodes.filter(function (n) { return n._dirty; }).forEach(function (c) {
597
+ var n = _this.nodes.find(function (a) { return a._id === c._id; });
598
+ if (!n)
599
+ return;
600
+ utils_1.Utils.copyPos(n, c);
601
+ n._dirty = true;
602
+ });
603
+ this._notify();
604
+ return true;
605
+ };
606
+ /** return true if can fit in grid height constrain only (always true if no maxRow) */
607
+ GridStackEngine.prototype.willItFit = function (node) {
608
+ delete node._willFitPos;
609
+ if (!this.maxRow)
610
+ return true;
611
+ // create a clone with NO maxRow and check if still within size
612
+ var clone = new GridStackEngine({
613
+ column: this.column,
614
+ float: this.float,
615
+ nodes: this.nodes.map(function (n) { return __assign({}, n); })
616
+ });
617
+ var n = __assign({}, node); // clone node so we don't mod any settings on it but have full autoPosition and min/max as well! #1687
618
+ this.cleanupNode(n);
619
+ delete n.el;
620
+ delete n._id;
621
+ delete n.content;
622
+ delete n.grid;
623
+ clone.addNode(n);
624
+ if (clone.getRow() <= this.maxRow) {
625
+ node._willFitPos = utils_1.Utils.copyPos({}, n);
626
+ return true;
627
+ }
628
+ return false;
629
+ };
630
+ /** true if x,y or w,h are different after clamping to min/max */
631
+ GridStackEngine.prototype.changedPosConstrain = function (node, p) {
632
+ // make sure w,h are set
633
+ p.w = p.w || node.w;
634
+ p.h = p.h || node.h;
635
+ if (node.x !== p.x || node.y !== p.y)
636
+ return true;
637
+ // check constrained w,h
638
+ if (node.maxW) {
639
+ p.w = Math.min(p.w, node.maxW);
640
+ }
641
+ if (node.maxH) {
642
+ p.h = Math.min(p.h, node.maxH);
643
+ }
644
+ if (node.minW) {
645
+ p.w = Math.max(p.w, node.minW);
646
+ }
647
+ if (node.minH) {
648
+ p.h = Math.max(p.h, node.minH);
649
+ }
650
+ return (node.w !== p.w || node.h !== p.h);
651
+ };
652
+ /** return true if the passed in node was actually moved (checks for no-op and locked) */
653
+ GridStackEngine.prototype.moveNode = function (node, o) {
654
+ if (!node || /*node.locked ||*/ !o)
655
+ return false;
656
+ if (o.pack === undefined)
657
+ o.pack = true;
658
+ // constrain the passed in values and check if we're still changing our node
659
+ if (typeof o.x !== 'number') {
660
+ o.x = node.x;
661
+ }
662
+ if (typeof o.y !== 'number') {
663
+ o.y = node.y;
664
+ }
665
+ if (typeof o.w !== 'number') {
666
+ o.w = node.w;
667
+ }
668
+ if (typeof o.h !== 'number') {
669
+ o.h = node.h;
670
+ }
671
+ var resizing = (node.w !== o.w || node.h !== o.h);
672
+ var nn = utils_1.Utils.copyPos({}, node, true); // get min/max out first, then opt positions next
673
+ utils_1.Utils.copyPos(nn, o);
674
+ nn = this.nodeBoundFix(nn, resizing);
675
+ utils_1.Utils.copyPos(o, nn);
676
+ if (utils_1.Utils.samePos(node, o))
677
+ return false;
678
+ var prevPos = utils_1.Utils.copyPos({}, node);
679
+ // during while() collisions make sure to check entire row so larger items don't leap frog small ones (push them all down)
680
+ var area = nn;
681
+ // if (this._useEntireRowArea(node, nn)) {
682
+ // area = {x: 0, w: this.column, y: nn.y, h: nn.h};
683
+ // }
684
+ // check if we will need to fix collision at our new location
685
+ var collides = this.collideAll(node, area, o.skip);
686
+ var needToMove = true;
687
+ if (collides.length) {
688
+ // now check to make sure we actually collided over 50% surface area while dragging
689
+ var collide = node._moving && !o.nested ? this.collideCoverage(node, o, collides) : collides[0];
690
+ if (collide) {
691
+ needToMove = !this._fixCollisions(node, nn, collide, o); // check if already moved...
692
+ }
693
+ else {
694
+ needToMove = false; // we didn't cover >50% for a move, skip...
695
+ }
696
+ }
697
+ // now move (to the original ask vs the collision version which might differ) and repack things
698
+ if (needToMove) {
699
+ node._dirty = true;
700
+ utils_1.Utils.copyPos(node, nn);
701
+ }
702
+ if (o.pack) {
703
+ this._packNodes()
704
+ ._notify();
705
+ }
706
+ return !utils_1.Utils.samePos(node, prevPos); // pack might have moved things back
707
+ };
708
+ GridStackEngine.prototype.getRow = function () {
709
+ return this.nodes.reduce(function (row, n) { return Math.max(row, n.y + n.h); }, 0);
710
+ };
711
+ GridStackEngine.prototype.beginUpdate = function (node) {
712
+ if (!node._updating) {
713
+ node._updating = true;
714
+ delete node._skipDown;
715
+ if (!this.batchMode)
716
+ this.saveInitial();
717
+ }
718
+ return this;
719
+ };
720
+ GridStackEngine.prototype.endUpdate = function () {
721
+ var n = this.nodes.find(function (n) { return n._updating; });
722
+ if (n) {
723
+ delete n._updating;
724
+ delete n._skipDown;
725
+ }
726
+ return this;
727
+ };
728
+ /** saves a copy of the largest column layout (eg 12 even when rendering oneColumnMode, so we don't loose orig layout),
729
+ * returning a list of widgets for serialization */
730
+ GridStackEngine.prototype.save = function (saveElement) {
731
+ var _a;
732
+ if (saveElement === void 0) { saveElement = true; }
733
+ // use the highest layout for any saved info so we can have full detail on reload #1849
734
+ var len = (_a = this._layouts) === null || _a === void 0 ? void 0 : _a.length;
735
+ var layout = len && this.column !== (len - 1) ? this._layouts[len - 1] : null;
736
+ var list = [];
737
+ this._sortNodes();
738
+ this.nodes.forEach(function (n) {
739
+ var wl = layout === null || layout === void 0 ? void 0 : layout.find(function (l) { return l._id === n._id; });
740
+ var w = __assign({}, n);
741
+ // use layout info instead if set
742
+ if (wl) {
743
+ w.x = wl.x;
744
+ w.y = wl.y;
745
+ w.w = wl.w;
746
+ }
747
+ // delete internals
748
+ for (var key in w) {
749
+ if (key[0] === '_' || w[key] === null || w[key] === undefined)
750
+ delete w[key];
751
+ }
752
+ delete w.grid;
753
+ if (!saveElement)
754
+ delete w.el;
755
+ // delete default values (will be re-created on read)
756
+ if (!w.autoPosition)
757
+ delete w.autoPosition;
758
+ if (!w.noResize)
759
+ delete w.noResize;
760
+ if (!w.noMove)
761
+ delete w.noMove;
762
+ if (!w.locked)
763
+ delete w.locked;
764
+ list.push(w);
765
+ });
766
+ return list;
767
+ };
768
+ /** @internal called whenever a node is added or moved - updates the cached layouts */
769
+ GridStackEngine.prototype.layoutsNodesChange = function (nodes) {
770
+ var _this = this;
771
+ if (!this._layouts || this._inColumnResize)
772
+ return this;
773
+ // remove smaller layouts - we will re-generate those on the fly... larger ones need to update
774
+ this._layouts.forEach(function (layout, column) {
775
+ if (!layout || column === _this.column)
776
+ return _this;
777
+ if (column < _this.column) {
778
+ _this._layouts[column] = undefined;
779
+ }
780
+ else {
781
+ // we save the original x,y,w (h isn't cached) to see what actually changed to propagate better.
782
+ // NOTE: we don't need to check against out of bound scaling/moving as that will be done when using those cache values. #1785
783
+ var ratio_1 = column / _this.column;
784
+ nodes.forEach(function (node) {
785
+ if (!node._orig)
786
+ return; // didn't change (newly added ?)
787
+ var n = layout.find(function (l) { return l._id === node._id; });
788
+ if (!n)
789
+ return; // no cache for new nodes. Will use those values.
790
+ // Y changed, push down same amount
791
+ // TODO: detect doing item 'swaps' will help instead of move (especially in 1 column mode)
792
+ if (node.y !== node._orig.y) {
793
+ n.y += (node.y - node._orig.y);
794
+ }
795
+ // X changed, scale from new position
796
+ if (node.x !== node._orig.x) {
797
+ n.x = Math.round(node.x * ratio_1);
798
+ }
799
+ // width changed, scale from new width
800
+ if (node.w !== node._orig.w) {
801
+ n.w = Math.round(node.w * ratio_1);
802
+ }
803
+ // ...height always carries over from cache
804
+ });
805
+ }
806
+ });
807
+ return this;
808
+ };
809
+ /**
810
+ * @internal Called to scale the widget width & position up/down based on the column change.
811
+ * Note we store previous layouts (especially original ones) to make it possible to go
812
+ * from say 12 -> 1 -> 12 and get back to where we were.
813
+ *
814
+ * @param prevColumn previous number of columns
815
+ * @param column new column number
816
+ * @param nodes different sorted list (ex: DOM order) instead of current list
817
+ * @param layout specify the type of re-layout that will happen (position, size, etc...).
818
+ * Note: items will never be outside of the current column boundaries. default (moveScale). Ignored for 1 column
819
+ */
820
+ GridStackEngine.prototype.updateNodeWidths = function (prevColumn, column, nodes, layout) {
821
+ var _this = this;
822
+ var _a;
823
+ if (layout === void 0) { layout = 'moveScale'; }
824
+ if (!this.nodes.length || !column || prevColumn === column)
825
+ return this;
826
+ // cache the current layout in case they want to go back (like 12 -> 1 -> 12) as it requires original data
827
+ this.cacheLayout(this.nodes, prevColumn);
828
+ this.batchUpdate(); // do this EARLY as it will call saveInitial() so we can detect where we started for _dirty and collision
829
+ var newNodes = [];
830
+ // if we're going to 1 column and using DOM order rather than default sorting, then generate that layout
831
+ var domOrder = false;
832
+ if (column === 1 && (nodes === null || nodes === void 0 ? void 0 : nodes.length)) {
833
+ domOrder = true;
834
+ var top_1 = 0;
835
+ nodes.forEach(function (n) {
836
+ n.x = 0;
837
+ n.w = 1;
838
+ n.y = Math.max(n.y, top_1);
839
+ top_1 = n.y + n.h;
840
+ });
841
+ newNodes = nodes;
842
+ nodes = [];
843
+ }
844
+ else {
845
+ nodes = utils_1.Utils.sort(this.nodes, -1, prevColumn); // current column reverse sorting so we can insert last to front (limit collision)
846
+ }
847
+ // see if we have cached previous layout IFF we are going up in size (restore) otherwise always
848
+ // generate next size down from where we are (looks more natural as you gradually size down).
849
+ var cacheNodes = [];
850
+ if (column > prevColumn) {
851
+ cacheNodes = this._layouts[column] || [];
852
+ // ...if not, start with the largest layout (if not already there) as down-scaling is more accurate
853
+ // by pretending we came from that larger column by assigning those values as starting point
854
+ var lastIndex = this._layouts.length - 1;
855
+ if (!cacheNodes.length && prevColumn !== lastIndex && ((_a = this._layouts[lastIndex]) === null || _a === void 0 ? void 0 : _a.length)) {
856
+ prevColumn = lastIndex;
857
+ this._layouts[lastIndex].forEach(function (cacheNode) {
858
+ var n = nodes.find(function (n) { return n._id === cacheNode._id; });
859
+ if (n) {
860
+ // still current, use cache info positions
861
+ n.x = cacheNode.x;
862
+ n.y = cacheNode.y;
863
+ n.w = cacheNode.w;
864
+ }
865
+ });
866
+ }
867
+ }
868
+ // if we found cache re-use those nodes that are still current
869
+ cacheNodes.forEach(function (cacheNode) {
870
+ var j = nodes.findIndex(function (n) { return n._id === cacheNode._id; });
871
+ if (j !== -1) {
872
+ // still current, use cache info positions
873
+ nodes[j].x = cacheNode.x;
874
+ nodes[j].y = cacheNode.y;
875
+ nodes[j].w = cacheNode.w;
876
+ newNodes.push(nodes[j]);
877
+ nodes.splice(j, 1);
878
+ }
879
+ });
880
+ // ...and add any extra non-cached ones
881
+ if (nodes.length) {
882
+ if (typeof layout === 'function') {
883
+ layout(column, prevColumn, newNodes, nodes);
884
+ }
885
+ else if (!domOrder) {
886
+ var ratio_2 = column / prevColumn;
887
+ var move_1 = (layout === 'move' || layout === 'moveScale');
888
+ var scale_1 = (layout === 'scale' || layout === 'moveScale');
889
+ nodes.forEach(function (node) {
890
+ // NOTE: x + w could be outside of the grid, but addNode() below will handle that
891
+ node.x = (column === 1 ? 0 : (move_1 ? Math.round(node.x * ratio_2) : Math.min(node.x, column - 1)));
892
+ node.w = ((column === 1 || prevColumn === 1) ? 1 :
893
+ scale_1 ? (Math.round(node.w * ratio_2) || 1) : (Math.min(node.w, column)));
894
+ newNodes.push(node);
895
+ });
896
+ nodes = [];
897
+ }
898
+ }
899
+ // finally re-layout them in reverse order (to get correct placement)
900
+ newNodes = utils_1.Utils.sort(newNodes, -1, column);
901
+ this._inColumnResize = true; // prevent cache update
902
+ this.nodes = []; // pretend we have no nodes to start with (add() will use same structures) to simplify layout
903
+ newNodes.forEach(function (node) {
904
+ _this.addNode(node, false); // 'false' for add event trigger
905
+ delete node._orig; // make sure the commit doesn't try to restore things back to original
906
+ });
907
+ this.commit();
908
+ delete this._inColumnResize;
909
+ return this;
910
+ };
911
+ /**
912
+ * call to cache the given layout internally to the given location so we can restore back when column changes size
913
+ * @param nodes list of nodes
914
+ * @param column corresponding column index to save it under
915
+ * @param clear if true, will force other caches to be removed (default false)
916
+ */
917
+ GridStackEngine.prototype.cacheLayout = function (nodes, column, clear) {
918
+ if (clear === void 0) { clear = false; }
919
+ var copy = [];
920
+ nodes.forEach(function (n, i) {
921
+ n._id = n._id || GridStackEngine._idSeq++; // make sure we have an id in case this is new layout, else re-use id already set
922
+ copy[i] = { x: n.x, y: n.y, w: n.w, _id: n._id }; // only thing we change is x,y,w and id to find it back
923
+ });
924
+ this._layouts = clear ? [] : this._layouts || []; // use array to find larger quick
925
+ this._layouts[column] = copy;
926
+ return this;
927
+ };
928
+ /**
929
+ * call to cache the given node layout internally to the given location so we can restore back when column changes size
930
+ * @param node single node to cache
931
+ * @param column corresponding column index to save it under
932
+ */
933
+ GridStackEngine.prototype.cacheOneLayout = function (n, column) {
934
+ n._id = n._id || GridStackEngine._idSeq++;
935
+ var layout = { x: n.x, y: n.y, w: n.w, _id: n._id };
936
+ this._layouts = this._layouts || [];
937
+ this._layouts[column] = this._layouts[column] || [];
938
+ var index = this._layouts[column].findIndex(function (l) { return l._id === n._id; });
939
+ index === -1 ? this._layouts[column].push(layout) : this._layouts[column][index] = layout;
940
+ return this;
941
+ };
942
+ /** called to remove all internal values but the _id */
943
+ GridStackEngine.prototype.cleanupNode = function (node) {
944
+ for (var prop in node) {
945
+ if (prop[0] === '_' && prop !== '_id')
946
+ delete node[prop];
947
+ }
948
+ return this;
949
+ };
950
+ /** @internal unique global internal _id counter NOT starting at 0 */
951
+ GridStackEngine._idSeq = 1;
952
+ return GridStackEngine;
953
+ }());
954
+ exports.GridStackEngine = GridStackEngine;
955
+ //# sourceMappingURL=gridstack-engine.js.map