gridstack 11.0.1 → 11.1.1

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 +34 -18
  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 +38 -18
  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 +12 -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.1
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;
@@ -399,7 +401,12 @@ class GridStack {
399
401
  grid = grid.parentGridNode?.grid;
400
402
  }
401
403
  //... and set the create options
402
- ops = Utils.cloneDeep({ ...(subGridTemplate || {}), children: undefined, ...(ops || node.subGridOpts || {}) });
404
+ ops = Utils.cloneDeep({
405
+ // by default sub-grid inherit from us | parent, other than id, children, etc...
406
+ ...this.opts, id: undefined, children: undefined, column: 'auto', columnOpts: undefined, layout: 'list', subGridOpts: undefined,
407
+ ...(subGridTemplate || {}),
408
+ ...(ops || node.subGridOpts || {})
409
+ });
403
410
  node.subGridOpts = ops;
404
411
  // if column special case it set, remember that flag and set default
405
412
  let autoColumn;
@@ -459,6 +466,8 @@ class GridStack {
459
466
  subGrid.makeWidget(node.el, node);
460
467
  }
461
468
  }
469
+ // if sizedToContent, we need to re-calc the size of ourself
470
+ this.resizeToContentCheck(false, node);
462
471
  return subGrid;
463
472
  }
464
473
  /**
@@ -574,6 +583,8 @@ class GridStack {
574
583
  // the original wanted layout so we can scale back up correctly #1471
575
584
  let maxColumn = 0;
576
585
  items.forEach(n => { maxColumn = Math.max(maxColumn, (n.x || 0) + n.w); });
586
+ if (maxColumn > this.engine.defaultColumn)
587
+ this.engine.defaultColumn = maxColumn;
577
588
  if (maxColumn > column) {
578
589
  this._ignoreLayoutsNodeChange = true; // skip layout update
579
590
  this.engine.cacheLayout(items, maxColumn, true);
@@ -629,8 +640,9 @@ class GridStack {
629
640
  }
630
641
  // 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
642
  this.engine.nodes.push(item);
632
- if (Utils.samePos(item, w)) {
643
+ if (Utils.samePos(item, w) && this.engine.nodes.length > 1) {
633
644
  this.moveNode(item, { ...w, forceCollide: true });
645
+ Utils.copyPos(w, item); // use possily updated values before update() is called next (no-op since already moved)
634
646
  }
635
647
  this.update(item.el, w);
636
648
  if (w.subGridOpts?.children) { // update any sub grid as well
@@ -929,8 +941,7 @@ class GridStack {
929
941
  *
930
942
  * @example
931
943
  * const grid = GridStack.init();
932
- * grid.el.appendChild('<div id="1" gs-w="3"></div>');
933
- * grid.el.appendChild('<div id="2"></div>');
944
+ * grid.el.innerHtml = '<div id="1" gs-w="3"></div><div id="2"></div>';
934
945
  * grid.makeWidget('1');
935
946
  * grid.makeWidget('2', {w:2, content: 'hello'});
936
947
  */
@@ -1136,7 +1147,6 @@ class GridStack {
1136
1147
  const w = Utils.cloneDeep(opt); // make a copy we can modify in case they re-use it or multiple items
1137
1148
  this.engine.nodeBoundFix(w);
1138
1149
  delete w.autoPosition;
1139
- delete w.id;
1140
1150
  // move/resize widget if anything changed
1141
1151
  const keys = ['x', 'y', 'w', 'h'];
1142
1152
  let m;
@@ -1155,6 +1165,7 @@ class GridStack {
1155
1165
  if (w.content !== undefined) {
1156
1166
  const itemContent = el.querySelector('.grid-stack-item-content');
1157
1167
  if (itemContent && itemContent.textContent !== w.content) {
1168
+ n.content = w.content;
1158
1169
  GridStack.renderCB(itemContent, w);
1159
1170
  // restore any sub-grid back
1160
1171
  if (n.subGrid?.el) {
@@ -1180,7 +1191,13 @@ class GridStack {
1180
1191
  if (m) {
1181
1192
  const widthChanged = (m.w !== undefined && m.w !== n.w);
1182
1193
  this.moveNode(n, m);
1183
- this.resizeToContentCheck(widthChanged, n); // wait for animation if we changed width
1194
+ if (widthChanged && n.subGrid) {
1195
+ // if we're animating the client size hasn't changed yet, so force a change (not exact size)
1196
+ n.subGrid.onResize(this.hasAnimationCSS() ? n.w : undefined);
1197
+ }
1198
+ else {
1199
+ this.resizeToContentCheck(widthChanged, n);
1200
+ }
1184
1201
  delete n._orig; // clear out original position now that we moved #2669
1185
1202
  }
1186
1203
  if (m || changed) {
@@ -1236,8 +1253,11 @@ class GridStack {
1236
1253
  const itemH = n.h ? n.h * cell - padding : item.clientHeight; // calculated to what cellHeight is or will become (rather than actual to prevent waiting for animation to finish)
1237
1254
  let wantedH;
1238
1255
  if (n.subGrid) {
1239
- // sub-grid - use their actual row count * their cell height
1256
+ // sub-grid - use their actual row count * their cell height, BUT append any content outside of the grid (eg: above text)
1240
1257
  wantedH = n.subGrid.getRow() * n.subGrid.getCellHeight(true);
1258
+ const subRec = n.subGrid.el.getBoundingClientRect();
1259
+ const parentRec = n.subGrid.el.parentElement.getBoundingClientRect();
1260
+ wantedH += subRec.top - parentRec.top;
1241
1261
  }
1242
1262
  else if (n.subGridOpts?.children?.length) {
1243
1263
  // not sub-grid just yet (case above) wait until we do
@@ -1607,19 +1627,19 @@ class GridStack {
1607
1627
  * and remember the prev columns we used, or get our count from parent, as well as check for cellHeight==='auto' (square)
1608
1628
  * or `sizeToContent` gridItem options.
1609
1629
  */
1610
- onResize() {
1611
- if (!this.el?.clientWidth)
1630
+ onResize(clientWidth = this.el?.clientWidth) {
1631
+ if (!clientWidth)
1612
1632
  return; // return if we're gone or no size yet (will get called again)
1613
- if (this.prevWidth === this.el.clientWidth)
1633
+ if (this.prevWidth === clientWidth)
1614
1634
  return; // no-op
1615
- this.prevWidth = this.el.clientWidth;
1616
- // console.log('onResize ', this.el.clientWidth);
1635
+ this.prevWidth = clientWidth;
1636
+ // console.log('onResize ', clientWidth);
1617
1637
  this.batchUpdate();
1618
1638
  // see if we're nested and take our column count from our parent....
1619
1639
  let columnChanged = false;
1620
1640
  if (this._autoColumn && this.parentGridNode) {
1621
1641
  if (this.opts.column !== this.parentGridNode.w) {
1622
- this.column(this.parentGridNode.w, 'none');
1642
+ this.column(this.parentGridNode.w, this.opts.layout || 'list');
1623
1643
  columnChanged = true;
1624
1644
  }
1625
1645
  }
@@ -1648,7 +1668,7 @@ class GridStack {
1648
1668
  // update any gridItem height with sizeToContent, but wait for DOM $animation_speed to settle if we changed column count
1649
1669
  // 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
1670
  if (delay && this.hasAnimationCSS())
1651
- return setTimeout(() => this.resizeToContentCheck(false, n), 300 + 10);
1671
+ return setTimeout(() => this.resizeToContentCheck(false, n), this.animationDelay);
1652
1672
  if (n) {
1653
1673
  if (Utils.shouldSizeToContent(n))
1654
1674
  this.resizeToContentCBCheck(n.el);
@@ -2465,6 +2485,6 @@ GridStack.resizeToContentParent = '.grid-stack-item-content';
2465
2485
  GridStack.Utils = Utils;
2466
2486
  /** scoping so users can call new GridStack.Engine(12) for example */
2467
2487
  GridStack.Engine = GridStackEngine;
2468
- GridStack.GDRev = '11.0.1';
2488
+ GridStack.GDRev = '11.1.1';
2469
2489
  export { GridStack };
2470
2490
  //# sourceMappingURL=gridstack.js.map