gridstack 7.2.3 → 7.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.
Files changed (93) hide show
  1. package/README.md +1 -1
  2. package/dist/angular/gridstack-item.component.ts +20 -4
  3. package/dist/angular/gridstack.component.ts +40 -27
  4. package/dist/dd-base-impl.d.ts +1 -1
  5. package/dist/dd-base-impl.js +1 -1
  6. package/dist/dd-base-impl.js.map +1 -1
  7. package/dist/dd-draggable.d.ts +1 -1
  8. package/dist/dd-draggable.js +4 -5
  9. package/dist/dd-draggable.js.map +1 -1
  10. package/dist/dd-droppable.d.ts +1 -1
  11. package/dist/dd-droppable.js +1 -1
  12. package/dist/dd-droppable.js.map +1 -1
  13. package/dist/dd-element.d.ts +1 -1
  14. package/dist/dd-element.js +1 -1
  15. package/dist/dd-element.js.map +1 -1
  16. package/dist/dd-gridstack.d.ts +1 -1
  17. package/dist/dd-gridstack.js +1 -1
  18. package/dist/dd-gridstack.js.map +1 -1
  19. package/dist/dd-manager.d.ts +1 -1
  20. package/dist/dd-manager.js +1 -1
  21. package/dist/dd-manager.js.map +1 -1
  22. package/dist/dd-resizable-handle.d.ts +1 -1
  23. package/dist/dd-resizable-handle.js +1 -1
  24. package/dist/dd-resizable-handle.js.map +1 -1
  25. package/dist/dd-resizable.d.ts +1 -1
  26. package/dist/dd-resizable.js +1 -1
  27. package/dist/dd-resizable.js.map +1 -1
  28. package/dist/dd-touch.d.ts +1 -1
  29. package/dist/dd-touch.js +2 -1
  30. package/dist/dd-touch.js.map +1 -1
  31. package/dist/es5/dd-base-impl.d.ts +1 -1
  32. package/dist/es5/dd-base-impl.js +1 -1
  33. package/dist/es5/dd-base-impl.js.map +1 -1
  34. package/dist/es5/dd-draggable.d.ts +1 -1
  35. package/dist/es5/dd-draggable.js +4 -5
  36. package/dist/es5/dd-draggable.js.map +1 -1
  37. package/dist/es5/dd-droppable.d.ts +1 -1
  38. package/dist/es5/dd-droppable.js +1 -1
  39. package/dist/es5/dd-droppable.js.map +1 -1
  40. package/dist/es5/dd-element.d.ts +1 -1
  41. package/dist/es5/dd-element.js +1 -1
  42. package/dist/es5/dd-element.js.map +1 -1
  43. package/dist/es5/dd-gridstack.d.ts +1 -1
  44. package/dist/es5/dd-gridstack.js +1 -1
  45. package/dist/es5/dd-gridstack.js.map +1 -1
  46. package/dist/es5/dd-manager.d.ts +1 -1
  47. package/dist/es5/dd-manager.js +1 -1
  48. package/dist/es5/dd-manager.js.map +1 -1
  49. package/dist/es5/dd-resizable-handle.d.ts +1 -1
  50. package/dist/es5/dd-resizable-handle.js +1 -1
  51. package/dist/es5/dd-resizable-handle.js.map +1 -1
  52. package/dist/es5/dd-resizable.d.ts +1 -1
  53. package/dist/es5/dd-resizable.js +1 -1
  54. package/dist/es5/dd-resizable.js.map +1 -1
  55. package/dist/es5/dd-touch.d.ts +1 -1
  56. package/dist/es5/dd-touch.js +2 -1
  57. package/dist/es5/dd-touch.js.map +1 -1
  58. package/dist/es5/gridstack-all.js +1 -1
  59. package/dist/es5/gridstack-all.js.LICENSE.txt +1 -1
  60. package/dist/es5/gridstack-all.js.map +1 -1
  61. package/dist/es5/gridstack-engine.d.ts +5 -3
  62. package/dist/es5/gridstack-engine.js +38 -19
  63. package/dist/es5/gridstack-engine.js.map +1 -1
  64. package/dist/es5/gridstack-poly.js +1 -1
  65. package/dist/es5/gridstack.d.ts +1 -1
  66. package/dist/es5/gridstack.js +39 -33
  67. package/dist/es5/gridstack.js.map +1 -1
  68. package/dist/es5/types.d.ts +12 -7
  69. package/dist/es5/types.js +1 -1
  70. package/dist/es5/types.js.map +1 -1
  71. package/dist/es5/utils.d.ts +4 -2
  72. package/dist/es5/utils.js +5 -2
  73. package/dist/es5/utils.js.map +1 -1
  74. package/dist/gridstack-all.js +1 -1
  75. package/dist/gridstack-all.js.LICENSE.txt +1 -1
  76. package/dist/gridstack-all.js.map +1 -1
  77. package/dist/gridstack-engine.d.ts +5 -3
  78. package/dist/gridstack-engine.js +36 -18
  79. package/dist/gridstack-engine.js.map +1 -1
  80. package/dist/gridstack.css +1 -1
  81. package/dist/gridstack.d.ts +1 -1
  82. package/dist/gridstack.js +39 -33
  83. package/dist/gridstack.js.map +1 -1
  84. package/dist/src/gridstack.scss +1 -1
  85. package/dist/types.d.ts +12 -7
  86. package/dist/types.js +1 -1
  87. package/dist/types.js.map +1 -1
  88. package/dist/utils.d.ts +4 -2
  89. package/dist/utils.js +5 -2
  90. package/dist/utils.js.map +1 -1
  91. package/doc/CHANGES.md +7 -0
  92. package/doc/README.md +2 -0
  93. package/package.json +1 -1
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 7.2.3
15
+ * GridStack 7.3.0
16
16
  * https://gridstackjs.com/
17
17
  *
18
18
  * Copyright (c) 2021-2022 Alain Dumesny
@@ -162,20 +162,7 @@ class GridStack {
162
162
  });
163
163
  if (this.opts.auto) {
164
164
  this.batchUpdate(); // prevent in between re-layout #1535 TODO: this only set float=true, need to prevent collision check...
165
- let elements = [];
166
- let column = this.getColumn();
167
- if (column === 1 && this._prevColumn)
168
- column = this._prevColumn; // do 12 column when reading into 1 column mode
169
- this.getGridItems().forEach(el => {
170
- let x = parseInt(el.getAttribute('gs-x'));
171
- let y = parseInt(el.getAttribute('gs-y'));
172
- elements.push({
173
- el,
174
- // if x,y are missing (autoPosition) add them to end of list - but keep their respective DOM order
175
- i: (Number.isNaN(x) ? 1000 : x) + (Number.isNaN(y) ? 1000 : y) * column
176
- });
177
- });
178
- elements.sort((a, b) => b.i - a.i).forEach(e => this._prepareElement(e.el)); // revert sort so lowest item wins
165
+ this.getGridItems().forEach(el => this._prepareElement(el));
179
166
  this.batchUpdate(false);
180
167
  }
181
168
  // load any passed in children as well, which overrides any DOM layout done above
@@ -271,11 +258,17 @@ class GridStack {
271
258
  return null;
272
259
  // create the grid element, but check if the passed 'parent' already has grid styling and should be used instead
273
260
  let el = parent;
274
- if (!parent.classList.contains('grid-stack')) {
275
- let doc = document.implementation.createHTMLDocument(''); // IE needs a param
276
- doc.body.innerHTML = `<div class="grid-stack ${opt.class || ''}"></div>`;
277
- el = doc.body.children[0];
278
- parent.appendChild(el);
261
+ const parentIsGrid = parent.classList.contains('grid-stack');
262
+ if (!parentIsGrid || opt.addRemoveCB) {
263
+ if (opt.addRemoveCB) {
264
+ el = opt.addRemoveCB(parent, opt, true, true);
265
+ }
266
+ else {
267
+ let doc = document.implementation.createHTMLDocument(''); // IE needs a param
268
+ doc.body.innerHTML = `<div class="grid-stack ${opt.class || ''}"></div>`;
269
+ el = doc.body.children[0];
270
+ parent.appendChild(el);
271
+ }
279
272
  }
280
273
  // create grid class and load any children
281
274
  let grid = GridStack.init(opt, el);
@@ -334,7 +327,7 @@ class GridStack {
334
327
  el = node.el; // re-use element stored in the node
335
328
  }
336
329
  else if (this.opts.addRemoveCB) {
337
- el = this.opts.addRemoveCB(this, options, true);
330
+ el = this.opts.addRemoveCB(this.el, options, true, false);
338
331
  }
339
332
  else {
340
333
  let content = (options === null || options === void 0 ? void 0 : options.content) || '';
@@ -367,7 +360,7 @@ class GridStack {
367
360
  this._updateContainerHeight();
368
361
  // see if there is a sub-grid to create
369
362
  if (node.subGrid) {
370
- this.makeSubGrid(node.el, undefined, undefined, false);
363
+ this.makeSubGrid(node.el, undefined, undefined, false); //node.subGrid will be used as option in method, no need to pass
371
364
  }
372
365
  // if we're adding an item into 1 column (_prevColumn is set only when going to 1) make sure
373
366
  // we don't override the larger 12 column layout that was already saved. #1985
@@ -413,16 +406,11 @@ class GridStack {
413
406
  ops.disableOneColumnMode = true; // driven by parent
414
407
  }
415
408
  // if we're converting an existing full item, move over the content to be the first sub item in the new grid
416
- // TODO: support this.opts.addRemoveCB for frameworks
417
409
  let content = node.el.querySelector('.grid-stack-item-content');
418
410
  let newItem;
419
411
  let newItemOpt;
420
412
  if (saveContent) {
421
413
  this._removeDD(node.el); // remove D&D since it's set on content div
422
- let doc = document.implementation.createHTMLDocument(''); // IE needs a param
423
- doc.body.innerHTML = `<div class="grid-stack-item"></div>`;
424
- newItem = doc.body.children[0];
425
- newItem.appendChild(content);
426
414
  newItemOpt = Object.assign(Object.assign({}, node), { x: 0, y: 0 });
427
415
  utils_1.Utils.removeInternalForSave(newItemOpt);
428
416
  delete newItemOpt.subGrid;
@@ -430,9 +418,18 @@ class GridStack {
430
418
  newItemOpt.content = node.content;
431
419
  delete node.content;
432
420
  }
433
- doc.body.innerHTML = `<div class="grid-stack-item-content"></div>`;
434
- content = doc.body.children[0];
435
- node.el.appendChild(content);
421
+ if (this.opts.addRemoveCB) {
422
+ newItem = this.opts.addRemoveCB(this.el, newItemOpt, true, false);
423
+ }
424
+ else {
425
+ let doc = document.implementation.createHTMLDocument(''); // IE needs a param
426
+ doc.body.innerHTML = `<div class="grid-stack-item"></div>`;
427
+ newItem = doc.body.children[0];
428
+ newItem.appendChild(content);
429
+ doc.body.innerHTML = `<div class="grid-stack-item-content"></div>`;
430
+ content = doc.body.children[0];
431
+ node.el.appendChild(content);
432
+ }
436
433
  this._prepareDragDropByNode(node); // ... and restore original D&D
437
434
  }
438
435
  // if we're adding an additional item, make the container large enough to have them both
@@ -444,6 +441,9 @@ class GridStack {
444
441
  this.update(node.el, { w, h });
445
442
  setTimeout(() => style.transition = null); // recover animation
446
443
  }
444
+ if (this.opts.addRemoveCB) {
445
+ ops.addRemoveCB = ops.addRemoveCB || this.opts.addRemoveCB;
446
+ }
447
447
  let subGrid = node.subGrid = GridStack.addGrid(content, ops);
448
448
  if (nodeToAdd === null || nodeToAdd === void 0 ? void 0 : nodeToAdd._moving)
449
449
  subGrid._isTemp = true; // prevent re-nesting as we add over
@@ -483,6 +483,8 @@ class GridStack {
483
483
  pGrid.addWidget(n.el, n);
484
484
  });
485
485
  pGrid.batchUpdate(false);
486
+ if (this.parentGridItem)
487
+ delete this.parentGridItem.subGrid;
486
488
  delete this.parentGridItem;
487
489
  // create an artificial event for the original grid now that this one is gone (got a leave, but won't get enter)
488
490
  if (nodeThatRemoved) {
@@ -589,7 +591,7 @@ class GridStack {
589
591
  let item = items.find(w => n.id === w.id);
590
592
  if (!item) {
591
593
  if (this.opts.addRemoveCB)
592
- this.opts.addRemoveCB(this, n, false);
594
+ this.opts.addRemoveCB(this.el, n, false, false);
593
595
  removed.push(n); // batch keep track
594
596
  this.removeWidget(n.el, true, false);
595
597
  }
@@ -785,6 +787,8 @@ class GridStack {
785
787
  }
786
788
  this._removeStylesheet();
787
789
  this.el.removeAttribute('gs-current-row');
790
+ if (this.parentGridItem)
791
+ delete this.parentGridItem.subGrid;
788
792
  delete this.parentGridItem;
789
793
  delete this.opts;
790
794
  delete this._placeholder;
@@ -1200,7 +1204,9 @@ class GridStack {
1200
1204
  if (!this._styles) {
1201
1205
  // insert style to parent (instead of 'head' by default) to support WebComponent
1202
1206
  let styleLocation = this.opts.styleInHead ? undefined : this.el.parentNode;
1203
- this._styles = utils_1.Utils.createStylesheet(this._styleSheetClass, styleLocation);
1207
+ this._styles = utils_1.Utils.createStylesheet(this._styleSheetClass, styleLocation, {
1208
+ nonce: this.opts.nonce,
1209
+ });
1204
1210
  if (!this._styles)
1205
1211
  return this;
1206
1212
  this._styles._max = 0;
@@ -2148,5 +2154,5 @@ exports.GridStack = GridStack;
2148
2154
  GridStack.Utils = utils_1.Utils;
2149
2155
  /** scoping so users can call new GridStack.Engine(12) for example */
2150
2156
  GridStack.Engine = gridstack_engine_1.GridStackEngine;
2151
- GridStack.GDRev = '7.2.3';
2157
+ GridStack.GDRev = '7.3.0';
2152
2158
  //# sourceMappingURL=gridstack.js.map