gridstack 11.3.0 → 11.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 (112) hide show
  1. package/README.md +4 -4
  2. package/dist/angular/README.md +4 -4
  3. package/dist/angular/esm2020/index.mjs +3 -2
  4. package/dist/angular/esm2020/lib/base-widget.mjs +2 -2
  5. package/dist/angular/esm2020/lib/gridstack-item.component.mjs +2 -2
  6. package/dist/angular/esm2020/lib/gridstack.component.mjs +2 -2
  7. package/dist/angular/esm2020/lib/gridstack.module.mjs +10 -10
  8. package/dist/angular/esm2020/lib/types.mjs +6 -0
  9. package/dist/angular/fesm2015/gridstack-angular.mjs +40 -40
  10. package/dist/angular/fesm2015/gridstack-angular.mjs.map +1 -1
  11. package/dist/angular/fesm2020/gridstack-angular.mjs +45 -40
  12. package/dist/angular/fesm2020/gridstack-angular.mjs.map +1 -1
  13. package/dist/angular/index.d.ts +2 -1
  14. package/dist/angular/lib/base-widget.d.ts +1 -1
  15. package/dist/angular/lib/gridstack-item.component.d.ts +1 -1
  16. package/dist/angular/lib/gridstack.component.d.ts +3 -21
  17. package/dist/angular/lib/gridstack.module.d.ts +3 -3
  18. package/dist/angular/lib/types.d.ts +24 -0
  19. package/dist/angular/src/base-widget.ts +2 -2
  20. package/dist/angular/src/gridstack-item.component.ts +1 -1
  21. package/dist/angular/src/gridstack.component.ts +3 -21
  22. package/dist/angular/src/gridstack.module.ts +4 -4
  23. package/dist/dd-base-impl.d.ts +1 -1
  24. package/dist/dd-base-impl.js +1 -1
  25. package/dist/dd-base-impl.js.map +1 -1
  26. package/dist/dd-draggable.d.ts +1 -1
  27. package/dist/dd-draggable.js +2 -2
  28. package/dist/dd-draggable.js.map +1 -1
  29. package/dist/dd-droppable.d.ts +1 -1
  30. package/dist/dd-droppable.js +1 -1
  31. package/dist/dd-droppable.js.map +1 -1
  32. package/dist/dd-element.d.ts +1 -1
  33. package/dist/dd-element.js +1 -1
  34. package/dist/dd-element.js.map +1 -1
  35. package/dist/dd-gridstack.d.ts +1 -1
  36. package/dist/dd-gridstack.js +10 -13
  37. package/dist/dd-gridstack.js.map +1 -1
  38. package/dist/dd-manager.d.ts +1 -1
  39. package/dist/dd-manager.js +1 -1
  40. package/dist/dd-manager.js.map +1 -1
  41. package/dist/dd-resizable-handle.d.ts +1 -1
  42. package/dist/dd-resizable-handle.js +1 -1
  43. package/dist/dd-resizable-handle.js.map +1 -1
  44. package/dist/dd-resizable.d.ts +1 -1
  45. package/dist/dd-resizable.js +1 -1
  46. package/dist/dd-resizable.js.map +1 -1
  47. package/dist/dd-touch.d.ts +1 -1
  48. package/dist/dd-touch.js +4 -39
  49. package/dist/dd-touch.js.map +1 -1
  50. package/dist/es5/dd-base-impl.d.ts +1 -1
  51. package/dist/es5/dd-base-impl.js +1 -1
  52. package/dist/es5/dd-base-impl.js.map +1 -1
  53. package/dist/es5/dd-draggable.d.ts +1 -1
  54. package/dist/es5/dd-draggable.js +2 -2
  55. package/dist/es5/dd-draggable.js.map +1 -1
  56. package/dist/es5/dd-droppable.d.ts +1 -1
  57. package/dist/es5/dd-droppable.js +1 -1
  58. package/dist/es5/dd-droppable.js.map +1 -1
  59. package/dist/es5/dd-element.d.ts +1 -1
  60. package/dist/es5/dd-element.js +1 -1
  61. package/dist/es5/dd-element.js.map +1 -1
  62. package/dist/es5/dd-gridstack.d.ts +1 -1
  63. package/dist/es5/dd-gridstack.js +10 -14
  64. package/dist/es5/dd-gridstack.js.map +1 -1
  65. package/dist/es5/dd-manager.d.ts +1 -1
  66. package/dist/es5/dd-manager.js +1 -1
  67. package/dist/es5/dd-manager.js.map +1 -1
  68. package/dist/es5/dd-resizable-handle.d.ts +1 -1
  69. package/dist/es5/dd-resizable-handle.js +1 -1
  70. package/dist/es5/dd-resizable-handle.js.map +1 -1
  71. package/dist/es5/dd-resizable.d.ts +1 -1
  72. package/dist/es5/dd-resizable.js +1 -1
  73. package/dist/es5/dd-resizable.js.map +1 -1
  74. package/dist/es5/dd-touch.d.ts +1 -1
  75. package/dist/es5/dd-touch.js +4 -39
  76. package/dist/es5/dd-touch.js.map +1 -1
  77. package/dist/es5/gridstack-all.js +1 -1
  78. package/dist/es5/gridstack-all.js.LICENSE.txt +1 -1
  79. package/dist/es5/gridstack-all.js.map +1 -1
  80. package/dist/es5/gridstack-engine.d.ts +1 -1
  81. package/dist/es5/gridstack-engine.js +9 -9
  82. package/dist/es5/gridstack-engine.js.map +1 -1
  83. package/dist/es5/gridstack-poly.js +1 -1
  84. package/dist/es5/gridstack.d.ts +7 -3
  85. package/dist/es5/gridstack.js +41 -26
  86. package/dist/es5/gridstack.js.map +1 -1
  87. package/dist/es5/types.d.ts +2 -2
  88. package/dist/es5/types.js +1 -1
  89. package/dist/es5/types.js.map +1 -1
  90. package/dist/es5/utils.d.ts +5 -5
  91. package/dist/es5/utils.js +24 -42
  92. package/dist/es5/utils.js.map +1 -1
  93. package/dist/gridstack-all.js +1 -1
  94. package/dist/gridstack-all.js.LICENSE.txt +1 -1
  95. package/dist/gridstack-all.js.map +1 -1
  96. package/dist/gridstack-engine.d.ts +1 -1
  97. package/dist/gridstack-engine.js +9 -9
  98. package/dist/gridstack-engine.js.map +1 -1
  99. package/dist/gridstack.css +1 -1
  100. package/dist/gridstack.d.ts +7 -3
  101. package/dist/gridstack.js +39 -26
  102. package/dist/gridstack.js.map +1 -1
  103. package/dist/src/gridstack.scss +1 -1
  104. package/dist/types.d.ts +2 -2
  105. package/dist/types.js +1 -1
  106. package/dist/types.js.map +1 -1
  107. package/dist/utils.d.ts +5 -5
  108. package/dist/utils.js +23 -40
  109. package/dist/utils.js.map +1 -1
  110. package/doc/CHANGES.md +10 -0
  111. package/doc/README.md +4 -4
  112. package/package.json +1 -1
package/dist/gridstack.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * GridStack 11.3.0
2
+ * GridStack 11.4.0
3
3
  * https://gridstackjs.com/
4
4
  *
5
5
  * Copyright (c) 2021-2024 Alain Dumesny
@@ -355,7 +355,7 @@ class GridStack {
355
355
  el = GridStack.addRemoveCB(this.el, w, true, false);
356
356
  }
357
357
  else {
358
- el = Utils.createWidgetDivs(this.opts.itemClass, node);
358
+ el = this.createWidgetDivs(node);
359
359
  }
360
360
  if (!el)
361
361
  return;
@@ -374,6 +374,27 @@ class GridStack {
374
374
  this.makeWidget(el, w);
375
375
  return el;
376
376
  }
377
+ /** create the default grid item divs, and content (possibly lazy loaded) by using GridStack.renderCB() */
378
+ createWidgetDivs(n) {
379
+ const el = Utils.createDiv(['grid-stack-item', this.opts.itemClass]);
380
+ const cont = Utils.createDiv(['grid-stack-item-content'], el);
381
+ if (Utils.lazyLoad(n)) {
382
+ if (!n.visibleObservable) {
383
+ n.visibleObservable = new IntersectionObserver(([entry]) => {
384
+ if (entry.isIntersecting) {
385
+ n.visibleObservable?.disconnect();
386
+ delete n.visibleObservable;
387
+ GridStack.renderCB(cont, n);
388
+ n.grid?.prepareDragDrop(n.el);
389
+ }
390
+ });
391
+ window.setTimeout(() => n.visibleObservable?.observe(el)); // wait until callee sets position attributes
392
+ }
393
+ }
394
+ else
395
+ GridStack.renderCB(cont, n);
396
+ return el;
397
+ }
377
398
  /**
378
399
  * Convert an existing gridItem element into a sub-grid with the given (optional) options, else inherit them
379
400
  * from the parent's subGrid options.
@@ -433,7 +454,7 @@ class GridStack {
433
454
  newItem.appendChild(content);
434
455
  content = Utils.createDiv(['grid-stack-item-content'], node.el);
435
456
  }
436
- this._prepareDragDropByNode(node); // ... and restore original D&D
457
+ this.prepareDragDrop(node.el); // ... and restore original D&D
437
458
  }
438
459
  // if we're adding an additional item, make the container large enough to have them both
439
460
  if (nodeToAdd) {
@@ -562,8 +583,8 @@ class GridStack {
562
583
  /**
563
584
  * load the widgets from a list. This will call update() on each (matching by id) or add/remove widgets that are not there.
564
585
  *
565
- * @param layout list of widgets definition to update/create
566
- * @param addAndRemove boolean (default true) or callback method can be passed to control if and how missing widgets can be added/removed, giving
586
+ * @param items list of widgets definition to update/create
587
+ * @param addRemove boolean (default true) or callback method can be passed to control if and how missing widgets can be added/removed, giving
567
588
  * the user control of insertion.
568
589
  *
569
590
  * @example
@@ -1117,7 +1138,7 @@ class GridStack {
1117
1138
  this._setupRemoveDrop();
1118
1139
  this._setupAcceptWidget();
1119
1140
  this.engine.nodes.forEach(n => {
1120
- this._prepareDragDropByNode(n); // either delete or init Drag&drop
1141
+ this.prepareDragDrop(n.el); // either delete or init Drag&drop
1121
1142
  if (n.subGrid && recurse)
1122
1143
  n.subGrid.setStatic(val, updateClass, recurse);
1123
1144
  });
@@ -1132,20 +1153,11 @@ class GridStack {
1132
1153
  * @param opt new widget options (x,y,w,h, etc..). Only those set will be updated.
1133
1154
  */
1134
1155
  update(els, opt) {
1135
- // support legacy call for now ?
1136
- if (arguments.length > 2) {
1137
- console.warn('gridstack.ts: `update(el, x, y, w, h)` is deprecated. Use `update(el, {x, w, content, ...})`. It will be removed soon');
1138
- // eslint-disable-next-line prefer-rest-params
1139
- const a = arguments;
1140
- let i = 1;
1141
- opt = { x: a[i++], y: a[i++], w: a[i++], h: a[i++] };
1142
- return this.update(els, opt);
1143
- }
1144
1156
  GridStack.getElements(els).forEach(el => {
1145
1157
  const n = el?.gridstackNode;
1146
1158
  if (!n)
1147
1159
  return;
1148
- const w = Utils.cloneDeep(opt); // make a copy we can modify in case they re-use it or multiple items
1160
+ const w = { ...Utils.copyPos({}, n), ...Utils.cloneDeep(opt) }; // make a copy we can modify in case they re-use it or multiple items
1149
1161
  this.engine.nodeBoundFix(w);
1150
1162
  delete w.autoPosition;
1151
1163
  // move/resize widget if anything changed
@@ -1205,7 +1217,7 @@ class GridStack {
1205
1217
  this._writeAttr(el, n);
1206
1218
  }
1207
1219
  if (ddChanged) {
1208
- this._prepareDragDropByNode(n);
1220
+ this.prepareDragDrop(n.el);
1209
1221
  }
1210
1222
  });
1211
1223
  return this;
@@ -1531,7 +1543,8 @@ class GridStack {
1531
1543
  sizeToContent ? el.classList.add('size-to-content') : el.classList.remove('size-to-content');
1532
1544
  if (sizeToContent)
1533
1545
  this.resizeToContentCheck(false, node);
1534
- this._prepareDragDropByNode(node);
1546
+ if (!Utils.lazyLoad(node))
1547
+ this.prepareDragDrop(node.el);
1535
1548
  return this;
1536
1549
  }
1537
1550
  /** @internal call to write position x,y,w,h attributes back to element */
@@ -1824,7 +1837,7 @@ class GridStack {
1824
1837
  if (!n)
1825
1838
  return;
1826
1839
  val ? delete n.noMove : n.noMove = true;
1827
- this._prepareDragDropByNode(n); // init DD if need be, and adjust
1840
+ this.prepareDragDrop(n.el); // init DD if need be, and adjust
1828
1841
  });
1829
1842
  return this;
1830
1843
  }
@@ -1841,7 +1854,7 @@ class GridStack {
1841
1854
  if (!n)
1842
1855
  return;
1843
1856
  val ? delete n.noResize : n.noResize = true;
1844
- this._prepareDragDropByNode(n); // init DD if need be, and adjust
1857
+ this.prepareDragDrop(n.el); // init DD if need be, and adjust
1845
1858
  });
1846
1859
  return this;
1847
1860
  }
@@ -1889,7 +1902,7 @@ class GridStack {
1889
1902
  return this; // can't move a static grid!
1890
1903
  doEnable ? delete this.opts.disableDrag : this.opts.disableDrag = true; // FIRST before we update children as grid overrides #1658
1891
1904
  this.engine.nodes.forEach(n => {
1892
- this._prepareDragDropByNode(n);
1905
+ this.prepareDragDrop(n.el);
1893
1906
  if (n.subGrid && recurse)
1894
1907
  n.subGrid.enableMove(doEnable, recurse);
1895
1908
  });
@@ -1904,7 +1917,7 @@ class GridStack {
1904
1917
  return this; // can't size a static grid!
1905
1918
  doEnable ? delete this.opts.disableResize : this.opts.disableResize = true; // FIRST before we update children as grid overrides #1658
1906
1919
  this.engine.nodes.forEach(n => {
1907
- this._prepareDragDropByNode(n);
1920
+ this.prepareDragDrop(n.el);
1908
1921
  if (n.subGrid && recurse)
1909
1922
  n.subGrid.enableResize(doEnable, recurse);
1910
1923
  });
@@ -2225,9 +2238,9 @@ class GridStack {
2225
2238
  }
2226
2239
  return this;
2227
2240
  }
2228
- /** @internal prepares the element for drag&drop */
2229
- _prepareDragDropByNode(node) {
2230
- const el = node.el;
2241
+ /** prepares the element for drag&drop - this is normally called by makeWiget() unless are are delay loading */
2242
+ prepareDragDrop(el) {
2243
+ const node = el.gridstackNode;
2231
2244
  const noMove = node.noMove || this.opts.disableDrag;
2232
2245
  const noResize = node.noResize || this.opts.disableResize;
2233
2246
  // check for disabled grid first
@@ -2508,6 +2521,6 @@ GridStack.resizeToContentParent = '.grid-stack-item-content';
2508
2521
  GridStack.Utils = Utils;
2509
2522
  /** scoping so users can call new GridStack.Engine(12) for example */
2510
2523
  GridStack.Engine = GridStackEngine;
2511
- GridStack.GDRev = '11.3.0';
2524
+ GridStack.GDRev = '11.4.0';
2512
2525
  export { GridStack };
2513
2526
  //# sourceMappingURL=gridstack.js.map