gridstack 11.0.1 → 11.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.
Files changed (105) hide show
  1. package/README.md +4 -0
  2. package/dist/angular/README.md +6 -1
  3. package/dist/angular/esm2022/lib/base-widget.mjs +2 -2
  4. package/dist/angular/esm2022/lib/gridstack-item.component.mjs +2 -2
  5. package/dist/angular/esm2022/lib/gridstack.component.mjs +2 -2
  6. package/dist/angular/esm2022/lib/gridstack.module.mjs +2 -2
  7. package/dist/angular/fesm2022/gridstack-angular.mjs +4 -4
  8. package/dist/angular/fesm2022/gridstack-angular.mjs.map +1 -1
  9. package/dist/angular/lib/gridstack-item.component.d.ts +1 -1
  10. package/dist/angular/lib/gridstack.component.d.ts +1 -1
  11. package/dist/angular/package.json +1 -1
  12. package/dist/angular/src/base-widget.ts +1 -1
  13. package/dist/angular/src/gridstack-item.component.ts +1 -1
  14. package/dist/angular/src/gridstack.component.ts +1 -1
  15. package/dist/angular/src/gridstack.module.ts +1 -1
  16. package/dist/dd-base-impl.d.ts +1 -1
  17. package/dist/dd-base-impl.js +1 -1
  18. package/dist/dd-base-impl.js.map +1 -1
  19. package/dist/dd-draggable.d.ts +1 -1
  20. package/dist/dd-draggable.js +1 -1
  21. package/dist/dd-draggable.js.map +1 -1
  22. package/dist/dd-droppable.d.ts +1 -1
  23. package/dist/dd-droppable.js +1 -1
  24. package/dist/dd-droppable.js.map +1 -1
  25. package/dist/dd-element.d.ts +1 -1
  26. package/dist/dd-element.js +1 -1
  27. package/dist/dd-element.js.map +1 -1
  28. package/dist/dd-gridstack.d.ts +1 -1
  29. package/dist/dd-gridstack.js +1 -1
  30. package/dist/dd-gridstack.js.map +1 -1
  31. package/dist/dd-manager.d.ts +1 -1
  32. package/dist/dd-manager.js +1 -1
  33. package/dist/dd-manager.js.map +1 -1
  34. package/dist/dd-resizable-handle.d.ts +1 -1
  35. package/dist/dd-resizable-handle.js +1 -1
  36. package/dist/dd-resizable-handle.js.map +1 -1
  37. package/dist/dd-resizable.d.ts +1 -1
  38. package/dist/dd-resizable.js +1 -1
  39. package/dist/dd-resizable.js.map +1 -1
  40. package/dist/dd-touch.d.ts +1 -1
  41. package/dist/dd-touch.js +1 -1
  42. package/dist/dd-touch.js.map +1 -1
  43. package/dist/es5/dd-base-impl.d.ts +1 -1
  44. package/dist/es5/dd-base-impl.js +1 -1
  45. package/dist/es5/dd-base-impl.js.map +1 -1
  46. package/dist/es5/dd-draggable.d.ts +1 -1
  47. package/dist/es5/dd-draggable.js +1 -1
  48. package/dist/es5/dd-draggable.js.map +1 -1
  49. package/dist/es5/dd-droppable.d.ts +1 -1
  50. package/dist/es5/dd-droppable.js +1 -1
  51. package/dist/es5/dd-droppable.js.map +1 -1
  52. package/dist/es5/dd-element.d.ts +1 -1
  53. package/dist/es5/dd-element.js +1 -1
  54. package/dist/es5/dd-element.js.map +1 -1
  55. package/dist/es5/dd-gridstack.d.ts +1 -1
  56. package/dist/es5/dd-gridstack.js +1 -1
  57. package/dist/es5/dd-gridstack.js.map +1 -1
  58. package/dist/es5/dd-manager.d.ts +1 -1
  59. package/dist/es5/dd-manager.js +1 -1
  60. package/dist/es5/dd-manager.js.map +1 -1
  61. package/dist/es5/dd-resizable-handle.d.ts +1 -1
  62. package/dist/es5/dd-resizable-handle.js +1 -1
  63. package/dist/es5/dd-resizable-handle.js.map +1 -1
  64. package/dist/es5/dd-resizable.d.ts +1 -1
  65. package/dist/es5/dd-resizable.js +1 -1
  66. package/dist/es5/dd-resizable.js.map +1 -1
  67. package/dist/es5/dd-touch.d.ts +1 -1
  68. package/dist/es5/dd-touch.js +1 -1
  69. package/dist/es5/dd-touch.js.map +1 -1
  70. package/dist/es5/gridstack-all.js +1 -1
  71. package/dist/es5/gridstack-all.js.LICENSE.txt +1 -1
  72. package/dist/es5/gridstack-all.js.map +1 -1
  73. package/dist/es5/gridstack-engine.d.ts +2 -1
  74. package/dist/es5/gridstack-engine.js +23 -15
  75. package/dist/es5/gridstack-engine.js.map +1 -1
  76. package/dist/es5/gridstack-poly.js +1 -1
  77. package/dist/es5/gridstack.d.ts +5 -4
  78. package/dist/es5/gridstack.js +29 -16
  79. package/dist/es5/gridstack.js.map +1 -1
  80. package/dist/es5/types.d.ts +3 -1
  81. package/dist/es5/types.js +1 -1
  82. package/dist/es5/types.js.map +1 -1
  83. package/dist/es5/utils.d.ts +1 -1
  84. package/dist/es5/utils.js +1 -1
  85. package/dist/es5/utils.js.map +1 -1
  86. package/dist/gridstack-all.js +1 -1
  87. package/dist/gridstack-all.js.LICENSE.txt +1 -1
  88. package/dist/gridstack-all.js.map +1 -1
  89. package/dist/gridstack-engine.d.ts +2 -1
  90. package/dist/gridstack-engine.js +23 -15
  91. package/dist/gridstack-engine.js.map +1 -1
  92. package/dist/gridstack.css +1 -1
  93. package/dist/gridstack.d.ts +5 -4
  94. package/dist/gridstack.js +28 -16
  95. package/dist/gridstack.js.map +1 -1
  96. package/dist/src/gridstack.scss +1 -1
  97. package/dist/types.d.ts +3 -1
  98. package/dist/types.js +1 -1
  99. package/dist/types.js.map +1 -1
  100. package/dist/utils.d.ts +1 -1
  101. package/dist/utils.js +1 -1
  102. package/dist/utils.js.map +1 -1
  103. package/doc/CHANGES.md +7 -0
  104. package/doc/README.md +9 -8
  105. package/package.json +1 -1
package/dist/gridstack.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * GridStack 11.0.1
2
+ * GridStack 11.1.0
3
3
  * https://gridstackjs.com/
4
4
  *
5
5
  * Copyright (c) 2021-2024 Alain Dumesny
@@ -154,6 +154,8 @@ class GridStack {
154
154
  constructor(el, opts = {}) {
155
155
  this.el = el;
156
156
  this.opts = opts;
157
+ /** time to wait for animation (if enabled) to be done so content sizing can happen */
158
+ this.animationDelay = 300 + 10;
157
159
  /** @internal */
158
160
  this._gsEventHandler = {};
159
161
  /** @internal extra row added when dragging at the bottom of the grid */
@@ -161,7 +163,7 @@ class GridStack {
161
163
  /** @internal meant to store the scale of the active grid */
162
164
  this.dragTransform = { xScale: 1, yScale: 1, xOffset: 0, yOffset: 0 };
163
165
  el.gridstack = this;
164
- opts = opts || {}; // handles null/undefined/0
166
+ this.opts = opts = opts || {}; // handles null/undefined/0
165
167
  if (!el.classList.contains('grid-stack')) {
166
168
  this.el.classList.add('grid-stack');
167
169
  }
@@ -370,7 +372,7 @@ class GridStack {
370
372
  const domAttr = this._readAttr(el);
371
373
  Utils.defaults(w, domAttr);
372
374
  this.engine.prepareNode(w);
373
- this._writeAttr(el, w);
375
+ // this._writeAttr(el, w); why write possibly incorrect values back when makeWidget() will ?
374
376
  this.el.appendChild(el);
375
377
  this.makeWidget(el, w);
376
378
  return el;
@@ -459,6 +461,8 @@ class GridStack {
459
461
  subGrid.makeWidget(node.el, node);
460
462
  }
461
463
  }
464
+ // if sizedToContent, we need to re-calc the size of ourself
465
+ this.resizeToContentCheck(false, node);
462
466
  return subGrid;
463
467
  }
464
468
  /**
@@ -574,6 +578,8 @@ class GridStack {
574
578
  // the original wanted layout so we can scale back up correctly #1471
575
579
  let maxColumn = 0;
576
580
  items.forEach(n => { maxColumn = Math.max(maxColumn, (n.x || 0) + n.w); });
581
+ if (maxColumn > this.engine.defaultColumn)
582
+ this.engine.defaultColumn = maxColumn;
577
583
  if (maxColumn > column) {
578
584
  this._ignoreLayoutsNodeChange = true; // skip layout update
579
585
  this.engine.cacheLayout(items, maxColumn, true);
@@ -629,8 +635,9 @@ class GridStack {
629
635
  }
630
636
  // add back to current list BUT force a collision check if it 'appears' we didn't change to make sure we don't overlap others now
631
637
  this.engine.nodes.push(item);
632
- if (Utils.samePos(item, w)) {
638
+ if (Utils.samePos(item, w) && this.engine.nodes.length > 1) {
633
639
  this.moveNode(item, { ...w, forceCollide: true });
640
+ Utils.copyPos(w, item); // use possily updated values before update() is called next (no-op since already moved)
634
641
  }
635
642
  this.update(item.el, w);
636
643
  if (w.subGridOpts?.children) { // update any sub grid as well
@@ -929,8 +936,7 @@ class GridStack {
929
936
  *
930
937
  * @example
931
938
  * const grid = GridStack.init();
932
- * grid.el.appendChild('<div id="1" gs-w="3"></div>');
933
- * grid.el.appendChild('<div id="2"></div>');
939
+ * grid.el.innerHtml = '<div id="1" gs-w="3"></div><div id="2"></div>';
934
940
  * grid.makeWidget('1');
935
941
  * grid.makeWidget('2', {w:2, content: 'hello'});
936
942
  */
@@ -1136,7 +1142,6 @@ class GridStack {
1136
1142
  const w = Utils.cloneDeep(opt); // make a copy we can modify in case they re-use it or multiple items
1137
1143
  this.engine.nodeBoundFix(w);
1138
1144
  delete w.autoPosition;
1139
- delete w.id;
1140
1145
  // move/resize widget if anything changed
1141
1146
  const keys = ['x', 'y', 'w', 'h'];
1142
1147
  let m;
@@ -1155,6 +1160,7 @@ class GridStack {
1155
1160
  if (w.content !== undefined) {
1156
1161
  const itemContent = el.querySelector('.grid-stack-item-content');
1157
1162
  if (itemContent && itemContent.textContent !== w.content) {
1163
+ n.content = w.content;
1158
1164
  GridStack.renderCB(itemContent, w);
1159
1165
  // restore any sub-grid back
1160
1166
  if (n.subGrid?.el) {
@@ -1180,7 +1186,13 @@ class GridStack {
1180
1186
  if (m) {
1181
1187
  const widthChanged = (m.w !== undefined && m.w !== n.w);
1182
1188
  this.moveNode(n, m);
1183
- this.resizeToContentCheck(widthChanged, n); // wait for animation if we changed width
1189
+ if (widthChanged && n.subGrid) {
1190
+ // if we're animating the client size hasn't changed yet, so force a change (not exact size)
1191
+ n.subGrid.onResize(this.hasAnimationCSS() ? n.w : undefined);
1192
+ }
1193
+ else {
1194
+ this.resizeToContentCheck(widthChanged, n);
1195
+ }
1184
1196
  delete n._orig; // clear out original position now that we moved #2669
1185
1197
  }
1186
1198
  if (m || changed) {
@@ -1607,19 +1619,19 @@ class GridStack {
1607
1619
  * and remember the prev columns we used, or get our count from parent, as well as check for cellHeight==='auto' (square)
1608
1620
  * or `sizeToContent` gridItem options.
1609
1621
  */
1610
- onResize() {
1611
- if (!this.el?.clientWidth)
1622
+ onResize(clientWidth = this.el?.clientWidth) {
1623
+ if (!clientWidth)
1612
1624
  return; // return if we're gone or no size yet (will get called again)
1613
- if (this.prevWidth === this.el.clientWidth)
1625
+ if (this.prevWidth === clientWidth)
1614
1626
  return; // no-op
1615
- this.prevWidth = this.el.clientWidth;
1616
- // console.log('onResize ', this.el.clientWidth);
1627
+ this.prevWidth = clientWidth;
1628
+ // console.log('onResize ', clientWidth);
1617
1629
  this.batchUpdate();
1618
1630
  // see if we're nested and take our column count from our parent....
1619
1631
  let columnChanged = false;
1620
1632
  if (this._autoColumn && this.parentGridNode) {
1621
1633
  if (this.opts.column !== this.parentGridNode.w) {
1622
- this.column(this.parentGridNode.w, 'none');
1634
+ this.column(this.parentGridNode.w, this.opts.layout || 'list');
1623
1635
  columnChanged = true;
1624
1636
  }
1625
1637
  }
@@ -1648,7 +1660,7 @@ class GridStack {
1648
1660
  // update any gridItem height with sizeToContent, but wait for DOM $animation_speed to settle if we changed column count
1649
1661
  // TODO: is there a way to know what the final (post animation) size of the content will be so we can animate the column width and height together rather than sequentially ?
1650
1662
  if (delay && this.hasAnimationCSS())
1651
- return setTimeout(() => this.resizeToContentCheck(false, n), 300 + 10);
1663
+ return setTimeout(() => this.resizeToContentCheck(false, n), this.animationDelay);
1652
1664
  if (n) {
1653
1665
  if (Utils.shouldSizeToContent(n))
1654
1666
  this.resizeToContentCBCheck(n.el);
@@ -2465,6 +2477,6 @@ GridStack.resizeToContentParent = '.grid-stack-item-content';
2465
2477
  GridStack.Utils = Utils;
2466
2478
  /** scoping so users can call new GridStack.Engine(12) for example */
2467
2479
  GridStack.Engine = GridStackEngine;
2468
- GridStack.GDRev = '11.0.1';
2480
+ GridStack.GDRev = '11.1.0';
2469
2481
  export { GridStack };
2470
2482
  //# sourceMappingURL=gridstack.js.map