gridstack 9.1.1 → 9.2.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 (110) hide show
  1. package/angular/projects/lib/package.json +1 -1
  2. package/angular/projects/lib/src/lib/base-widget.ts +1 -1
  3. package/angular/projects/lib/src/lib/gridstack-item.component.ts +1 -1
  4. package/angular/projects/lib/src/lib/gridstack.component.ts +1 -1
  5. package/angular/projects/lib/src/lib/gridstack.module.ts +1 -1
  6. package/dist/angular/esm2020/lib/base-widget.mjs +2 -2
  7. package/dist/angular/esm2020/lib/gridstack-item.component.mjs +2 -2
  8. package/dist/angular/esm2020/lib/gridstack.component.mjs +2 -2
  9. package/dist/angular/esm2020/lib/gridstack.module.mjs +2 -2
  10. package/dist/angular/fesm2015/gridstack-angular.mjs +4 -4
  11. package/dist/angular/fesm2015/gridstack-angular.mjs.map +1 -1
  12. package/dist/angular/fesm2020/gridstack-angular.mjs +4 -4
  13. package/dist/angular/fesm2020/gridstack-angular.mjs.map +1 -1
  14. package/dist/angular/lib/gridstack-item.component.d.ts +1 -1
  15. package/dist/angular/lib/gridstack.component.d.ts +1 -1
  16. package/dist/angular/package.json +1 -1
  17. package/dist/angular/src/base-widget.ts +1 -1
  18. package/dist/angular/src/gridstack-item.component.ts +1 -1
  19. package/dist/angular/src/gridstack.component.ts +1 -1
  20. package/dist/angular/src/gridstack.module.ts +1 -1
  21. package/dist/dd-base-impl.d.ts +1 -1
  22. package/dist/dd-base-impl.js +1 -1
  23. package/dist/dd-base-impl.js.map +1 -1
  24. package/dist/dd-draggable.d.ts +1 -1
  25. package/dist/dd-draggable.js +1 -1
  26. package/dist/dd-draggable.js.map +1 -1
  27. package/dist/dd-droppable.d.ts +1 -1
  28. package/dist/dd-droppable.js +1 -1
  29. package/dist/dd-droppable.js.map +1 -1
  30. package/dist/dd-element.d.ts +1 -1
  31. package/dist/dd-element.js +1 -1
  32. package/dist/dd-element.js.map +1 -1
  33. package/dist/dd-gridstack.d.ts +1 -1
  34. package/dist/dd-gridstack.js +1 -1
  35. package/dist/dd-gridstack.js.map +1 -1
  36. package/dist/dd-manager.d.ts +1 -1
  37. package/dist/dd-manager.js +1 -1
  38. package/dist/dd-manager.js.map +1 -1
  39. package/dist/dd-resizable-handle.d.ts +1 -1
  40. package/dist/dd-resizable-handle.js +1 -1
  41. package/dist/dd-resizable-handle.js.map +1 -1
  42. package/dist/dd-resizable.d.ts +1 -1
  43. package/dist/dd-resizable.js +1 -1
  44. package/dist/dd-resizable.js.map +1 -1
  45. package/dist/dd-touch.d.ts +1 -1
  46. package/dist/dd-touch.js +1 -1
  47. package/dist/dd-touch.js.map +1 -1
  48. package/dist/es5/dd-base-impl.d.ts +1 -1
  49. package/dist/es5/dd-base-impl.js +1 -1
  50. package/dist/es5/dd-base-impl.js.map +1 -1
  51. package/dist/es5/dd-draggable.d.ts +1 -1
  52. package/dist/es5/dd-draggable.js +1 -1
  53. package/dist/es5/dd-draggable.js.map +1 -1
  54. package/dist/es5/dd-droppable.d.ts +1 -1
  55. package/dist/es5/dd-droppable.js +1 -1
  56. package/dist/es5/dd-droppable.js.map +1 -1
  57. package/dist/es5/dd-element.d.ts +1 -1
  58. package/dist/es5/dd-element.js +1 -1
  59. package/dist/es5/dd-element.js.map +1 -1
  60. package/dist/es5/dd-gridstack.d.ts +1 -1
  61. package/dist/es5/dd-gridstack.js +1 -1
  62. package/dist/es5/dd-gridstack.js.map +1 -1
  63. package/dist/es5/dd-manager.d.ts +1 -1
  64. package/dist/es5/dd-manager.js +1 -1
  65. package/dist/es5/dd-manager.js.map +1 -1
  66. package/dist/es5/dd-resizable-handle.d.ts +1 -1
  67. package/dist/es5/dd-resizable-handle.js +1 -1
  68. package/dist/es5/dd-resizable-handle.js.map +1 -1
  69. package/dist/es5/dd-resizable.d.ts +1 -1
  70. package/dist/es5/dd-resizable.js +1 -1
  71. package/dist/es5/dd-resizable.js.map +1 -1
  72. package/dist/es5/dd-touch.d.ts +1 -1
  73. package/dist/es5/dd-touch.js +1 -1
  74. package/dist/es5/dd-touch.js.map +1 -1
  75. package/dist/es5/gridstack-all.js +1 -1
  76. package/dist/es5/gridstack-all.js.LICENSE.txt +1 -1
  77. package/dist/es5/gridstack-all.js.map +1 -1
  78. package/dist/es5/gridstack-engine.d.ts +1 -1
  79. package/dist/es5/gridstack-engine.js +4 -3
  80. package/dist/es5/gridstack-engine.js.map +1 -1
  81. package/dist/es5/gridstack-poly.js +1 -1
  82. package/dist/es5/gridstack.d.ts +7 -6
  83. package/dist/es5/gridstack.js +61 -41
  84. package/dist/es5/gridstack.js.map +1 -1
  85. package/dist/es5/types.d.ts +5 -5
  86. package/dist/es5/types.js +1 -1
  87. package/dist/es5/types.js.map +1 -1
  88. package/dist/es5/utils.d.ts +1 -1
  89. package/dist/es5/utils.js +1 -1
  90. package/dist/es5/utils.js.map +1 -1
  91. package/dist/gridstack-all.js +1 -1
  92. package/dist/gridstack-all.js.LICENSE.txt +1 -1
  93. package/dist/gridstack-all.js.map +1 -1
  94. package/dist/gridstack-engine.d.ts +1 -1
  95. package/dist/gridstack-engine.js +4 -3
  96. package/dist/gridstack-engine.js.map +1 -1
  97. package/dist/gridstack.css +1 -1
  98. package/dist/gridstack.d.ts +7 -6
  99. package/dist/gridstack.js +63 -43
  100. package/dist/gridstack.js.map +1 -1
  101. package/dist/src/gridstack.scss +1 -1
  102. package/dist/types.d.ts +5 -5
  103. package/dist/types.js +1 -1
  104. package/dist/types.js.map +1 -1
  105. package/dist/utils.d.ts +1 -1
  106. package/dist/utils.js +1 -1
  107. package/dist/utils.js.map +1 -1
  108. package/doc/CHANGES.md +9 -0
  109. package/doc/README.md +7 -0
  110. package/package.json +1 -1
package/dist/gridstack.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * GridStack 9.1.1
2
+ * GridStack 9.2.1
3
3
  * https://gridstackjs.com/
4
4
  *
5
5
  * Copyright (c) 2021-2022 Alain Dumesny
@@ -540,7 +540,7 @@ class GridStack {
540
540
  *
541
541
  * @example
542
542
  * see http://gridstackjs.com/demo/serialization.html
543
- **/
543
+ */
544
544
  load(layout, addRemove = GridStack.addRemoveCB || true) {
545
545
  // if passed list has coordinates, use them (insert from end to beginning for conflict resolution) else force widget same order
546
546
  const haveCoord = layout.some(w => w.x !== undefined || w.y !== undefined);
@@ -696,7 +696,7 @@ class GridStack {
696
696
  * 'compact' might re-order items to fill any empty space
697
697
  *
698
698
  * doSort - 'false' to let you do your own sorting ahead in case you need to control a different order. (default to sort)
699
- **/
699
+ */
700
700
  compact(layout = 'compact', doSort = true) {
701
701
  this.engine.compact(layout, doSort);
702
702
  this._triggerChangeEvent();
@@ -1118,10 +1118,12 @@ class GridStack {
1118
1118
  * Updates widget height to match the content height to avoid v-scrollbar or dead space.
1119
1119
  * Note: this assumes only 1 child under resizeToContentParent='.grid-stack-item-content' (sized to gridItem minus padding) that is at the entire content size wanted.
1120
1120
  * useAttrSize set to true if GridStackNode.h should be used instead of actual container height when we don't need to wait for animation to finish to get actual DOM heights
1121
- **/
1121
+ */
1122
1122
  resizeToContent(el, useAttrSize = false) {
1123
- el?.classList.remove('size-to-content-max');
1124
- if (!el?.clientHeight)
1123
+ if (!el)
1124
+ return;
1125
+ el.classList.remove('size-to-content-max');
1126
+ if (!el.clientHeight)
1125
1127
  return; // 0 when hidden, skip
1126
1128
  let n = el.gridstackNode;
1127
1129
  if (!n)
@@ -1142,15 +1144,22 @@ class GridStack {
1142
1144
  item = el.querySelector(GridStack.resizeToContentParent);
1143
1145
  if (!item)
1144
1146
  return;
1145
- const child = item.firstElementChild;
1146
- // NOTE: clientHeight & getBoundingClientRect() is undefined for text and other leaf nodes. use <div> container!
1147
- if (!child) {
1148
- console.log(`Error: resizeToContent() '${GridStack.resizeToContentParent}'.firstElementChild is null, make sure to have a div like container. Skipping sizing.`);
1149
- return;
1150
- }
1151
1147
  const padding = el.clientHeight - item.clientHeight; // full - available height to our child (minus border, padding...)
1152
1148
  const itemH = useAttrSize && 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)
1153
- const wantedH = child.getBoundingClientRect().height || itemH;
1149
+ let wantedH;
1150
+ if (n.subGrid) {
1151
+ // sub-grid - use their actual row count * their cell height
1152
+ wantedH = n.subGrid.getRow() * n.subGrid.getCellHeight();
1153
+ }
1154
+ else {
1155
+ // NOTE: clientHeight & getBoundingClientRect() is undefined for text and other leaf nodes. use <div> container!
1156
+ const child = item.firstElementChild;
1157
+ if (!child) {
1158
+ console.log(`Error: resizeToContent() '${GridStack.resizeToContentParent}'.firstElementChild is null, make sure to have a div like container. Skipping sizing.`);
1159
+ return;
1160
+ }
1161
+ wantedH = child.getBoundingClientRect().height || itemH;
1162
+ }
1154
1163
  if (itemH === wantedH)
1155
1164
  return;
1156
1165
  height += wantedH - itemH;
@@ -1171,10 +1180,10 @@ class GridStack {
1171
1180
  delete grid._ignoreLayoutsNodeChange;
1172
1181
  }
1173
1182
  }
1174
- /** call the user resize (so we can do extra work) else our build in version */
1183
+ /** call the user resize (so they can do extra work) else our build in version */
1175
1184
  resizeToContentCheck(el, useAttr = false) {
1176
1185
  if (GridStack.resizeToContentCB)
1177
- GridStack.resizeToContentCB(el);
1186
+ GridStack.resizeToContentCB(el, useAttr);
1178
1187
  else
1179
1188
  this.resizeToContent(el, useAttr);
1180
1189
  }
@@ -1335,27 +1344,33 @@ class GridStack {
1335
1344
  _updateContainerHeight() {
1336
1345
  if (!this.engine || this.engine.batchMode)
1337
1346
  return this;
1338
- let row = this.getRow() + this._extraDragRow; // checks for minRow already
1339
- // check for css min height
1340
- // Note: we don't handle %,rem correctly so comment out, beside we don't need need to create un-necessary
1341
- // rows as the CSS will make us bigger than our set height if needed... not sure why we had this.
1342
- // let cssMinHeight = parseInt(getComputedStyle(this.el)['min-height']);
1343
- // if (cssMinHeight > 0) {
1344
- // let minRow = Math.round(cssMinHeight / this.getCellHeight(true));
1345
- // if (row < minRow) {
1346
- // row = minRow;
1347
- // }
1348
- // }
1349
- this.el.setAttribute('gs-current-row', String(row));
1350
- if (row === 0) {
1351
- this.el.style.removeProperty('min-height');
1352
- return this;
1353
- }
1354
- let cellHeight = this.opts.cellHeight;
1355
- let unit = this.opts.cellHeightUnit;
1347
+ const parent = this.parentGridItem;
1348
+ let row = this.getRow() + this._extraDragRow; // this checks for minRow already
1349
+ const cellHeight = this.opts.cellHeight;
1350
+ const unit = this.opts.cellHeightUnit;
1356
1351
  if (!cellHeight)
1357
1352
  return this;
1358
- this.el.style.minHeight = row * cellHeight + unit;
1353
+ // check for css min height (non nested grid). TODO: support mismatch, say: min % while unit is px.
1354
+ if (!parent) {
1355
+ const cssMinHeight = Utils.parseHeight(getComputedStyle(this.el)['minHeight']);
1356
+ if (cssMinHeight.h > 0 && cssMinHeight.unit === unit) {
1357
+ const minRow = Math.floor(cssMinHeight.h / cellHeight);
1358
+ if (row < minRow) {
1359
+ row = minRow;
1360
+ }
1361
+ }
1362
+ }
1363
+ this.el.setAttribute('gs-current-row', String(row));
1364
+ this.el.style.removeProperty('min-height');
1365
+ this.el.style.removeProperty('height');
1366
+ if (row) {
1367
+ // nested grids have 'insert:0' to fill the space of parent by default, but we may be taller so use min-height for possible scrollbars
1368
+ this.el.style[parent ? 'minHeight' : 'height'] = row * cellHeight + unit;
1369
+ }
1370
+ // if we're a nested grid inside an sizeToContent item, tell it to resize itself too
1371
+ if (parent && !parent.grid.engine.batchMode && Utils.shouldSizeToContent(parent)) {
1372
+ parent.grid.resizeToContentCheck(parent.el);
1373
+ }
1359
1374
  return this;
1360
1375
  }
1361
1376
  /** @internal */
@@ -1505,7 +1520,9 @@ class GridStack {
1505
1520
  if (n.subGrid)
1506
1521
  n.subGrid.onResize();
1507
1522
  });
1508
- this.doContentResize(columnChanged); // wait for anim of column changed (DOM reflow before we can size correctly)
1523
+ if (!this._skipInitialResize)
1524
+ this.doContentResize(columnChanged); // wait for anim of column changed (DOM reflow before we can size correctly)
1525
+ delete this._skipInitialResize;
1509
1526
  this.batchUpdate(false);
1510
1527
  return this;
1511
1528
  }
@@ -1517,7 +1534,7 @@ class GridStack {
1517
1534
  if (Utils.shouldSizeToContent(n))
1518
1535
  this.resizeToContentCheck(n.el, useAttr);
1519
1536
  }
1520
- else {
1537
+ else if (this.engine.nodes.some(n => Utils.shouldSizeToContent(n))) {
1521
1538
  const nodes = [...this.engine.nodes]; // in case order changes while resizing one
1522
1539
  this.batchUpdate();
1523
1540
  nodes.forEach(n => {
@@ -1526,6 +1543,7 @@ class GridStack {
1526
1543
  });
1527
1544
  this.batchUpdate(false);
1528
1545
  }
1546
+ // call this regardless of shouldSizeToContent because widget might need to stretch to take available space after a resize
1529
1547
  if (this._gsEventHandler['resizecontent'])
1530
1548
  this._gsEventHandler['resizecontent'](null, n ? [n] : this.engine.nodes);
1531
1549
  }, delay ? 300 + 10 : 0);
@@ -1534,11 +1552,13 @@ class GridStack {
1534
1552
  _updateResizeEvent(forceRemove = false) {
1535
1553
  // only add event if we're not nested (parent will call us) and we're auto sizing cells or supporting oneColumn (i.e. doing work)
1536
1554
  // or supporting new sizeToContent option.
1537
- const trackSize = !this.parentGridItem && (this._isAutoCellHeight || this.opts.sizeToContent || !this.opts.disableOneColumnMode || this.engine.nodes.find(n => n.sizeToContent));
1555
+ const trackSize = !this.parentGridItem && (this._isAutoCellHeight || this.opts.sizeToContent || !this.opts.disableOneColumnMode
1556
+ || this.engine.nodes.find(n => n.sizeToContent));
1538
1557
  if (!forceRemove && trackSize && !this.resizeObserver) {
1539
1558
  this._sizeThrottle = Utils.throttle(() => this.onResize(), this.opts.cellHeightThrottle);
1540
1559
  this.resizeObserver = new ResizeObserver(entries => this._sizeThrottle());
1541
1560
  this.resizeObserver.observe(this.el);
1561
+ this._skipInitialResize = true; // makeWidget will originally have called on startup
1542
1562
  }
1543
1563
  else if ((forceRemove || !trackSize) && this.resizeObserver) {
1544
1564
  this.resizeObserver.disconnect();
@@ -1634,7 +1654,7 @@ class GridStack {
1634
1654
  * @param dragIn string selector (ex: '.sidebar .grid-stack-item') or list of dom elements
1635
1655
  * @param dragInOptions options - see DDDragInOpt. (default: {handle: '.grid-stack-item-content', appendTo: 'body'}
1636
1656
  * @param root optional root which defaults to document (for shadow dom pas the parent HTMLDocument)
1637
- **/
1657
+ */
1638
1658
  static setupDragIn(dragIn, dragInOptions, root = document) {
1639
1659
  if (dragInOptions?.pause !== undefined) {
1640
1660
  DDManager.pauseDrag = dragInOptions.pause;
@@ -2011,7 +2031,7 @@ class GridStack {
2011
2031
  }
2012
2032
  return this;
2013
2033
  }
2014
- /** @internal prepares the element for drag&drop **/
2034
+ /** @internal prepares the element for drag&drop */
2015
2035
  _prepareDragDropByNode(node) {
2016
2036
  let el = node.el;
2017
2037
  const noMove = node.noMove || this.opts.disableDrag;
@@ -2105,7 +2125,7 @@ class GridStack {
2105
2125
  .resizable(el, noResize ? 'disable' : 'enable');
2106
2126
  return this;
2107
2127
  }
2108
- /** @internal handles actual drag/resize start **/
2128
+ /** @internal handles actual drag/resize start */
2109
2129
  _onStartMoving(el, event, ui, node, cellWidth, cellHeight) {
2110
2130
  this.engine.cleanNodes()
2111
2131
  .beginUpdate(node);
@@ -2136,7 +2156,7 @@ class GridStack {
2136
2156
  }
2137
2157
  }
2138
2158
  }
2139
- /** @internal handles actual drag/resize **/
2159
+ /** @internal handles actual drag/resize */
2140
2160
  _dragOrResize(el, event, ui, node, cellWidth, cellHeight) {
2141
2161
  let p = { ...node._orig }; // could be undefined (_isExternal) which is ok (drag only set x,y and w,h will default to node value)
2142
2162
  let resizing;
@@ -2224,7 +2244,7 @@ class GridStack {
2224
2244
  /** @internal called when item leaving our area by either cursor dropout event
2225
2245
  * or shape is outside our boundaries. remove it from us, and mark temporary if this was
2226
2246
  * our item to start with else restore prev node values from prev grid it came from.
2227
- **/
2247
+ */
2228
2248
  _leave(el, helper) {
2229
2249
  let node = el.gridstackNode;
2230
2250
  if (!node)
@@ -2263,6 +2283,6 @@ GridStack.resizeToContentParent = '.grid-stack-item-content';
2263
2283
  GridStack.Utils = Utils;
2264
2284
  /** scoping so users can call new GridStack.Engine(12) for example */
2265
2285
  GridStack.Engine = GridStackEngine;
2266
- GridStack.GDRev = '9.1.1';
2286
+ GridStack.GDRev = '9.2.1';
2267
2287
  export { GridStack };
2268
2288
  //# sourceMappingURL=gridstack.js.map