gridstack 9.0.2 → 9.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 (112) hide show
  1. package/README.md +1 -1
  2. package/angular/projects/lib/package.json +1 -1
  3. package/angular/projects/lib/src/lib/base-widget.ts +1 -1
  4. package/angular/projects/lib/src/lib/gridstack-item.component.ts +1 -1
  5. package/angular/projects/lib/src/lib/gridstack.component.ts +1 -1
  6. package/angular/projects/lib/src/lib/gridstack.module.ts +1 -1
  7. package/dist/angular/esm2020/lib/base-widget.mjs +2 -2
  8. package/dist/angular/esm2020/lib/gridstack-item.component.mjs +2 -2
  9. package/dist/angular/esm2020/lib/gridstack.component.mjs +2 -2
  10. package/dist/angular/esm2020/lib/gridstack.module.mjs +2 -2
  11. package/dist/angular/fesm2015/gridstack-angular.mjs +4 -4
  12. package/dist/angular/fesm2015/gridstack-angular.mjs.map +1 -1
  13. package/dist/angular/fesm2020/gridstack-angular.mjs +4 -4
  14. package/dist/angular/fesm2020/gridstack-angular.mjs.map +1 -1
  15. package/dist/angular/lib/gridstack-item.component.d.ts +1 -1
  16. package/dist/angular/lib/gridstack.component.d.ts +1 -1
  17. package/dist/angular/package.json +1 -1
  18. package/dist/angular/src/base-widget.ts +1 -1
  19. package/dist/angular/src/gridstack-item.component.ts +1 -1
  20. package/dist/angular/src/gridstack.component.ts +1 -1
  21. package/dist/angular/src/gridstack.module.ts +1 -1
  22. package/dist/dd-base-impl.d.ts +1 -1
  23. package/dist/dd-base-impl.js +1 -1
  24. package/dist/dd-base-impl.js.map +1 -1
  25. package/dist/dd-draggable.d.ts +1 -1
  26. package/dist/dd-draggable.js +2 -2
  27. package/dist/dd-draggable.js.map +1 -1
  28. package/dist/dd-droppable.d.ts +1 -1
  29. package/dist/dd-droppable.js +1 -1
  30. package/dist/dd-droppable.js.map +1 -1
  31. package/dist/dd-element.d.ts +1 -1
  32. package/dist/dd-element.js +1 -1
  33. package/dist/dd-element.js.map +1 -1
  34. package/dist/dd-gridstack.d.ts +1 -1
  35. package/dist/dd-gridstack.js +1 -1
  36. package/dist/dd-gridstack.js.map +1 -1
  37. package/dist/dd-manager.d.ts +1 -1
  38. package/dist/dd-manager.js +1 -1
  39. package/dist/dd-manager.js.map +1 -1
  40. package/dist/dd-resizable-handle.d.ts +1 -1
  41. package/dist/dd-resizable-handle.js +1 -1
  42. package/dist/dd-resizable-handle.js.map +1 -1
  43. package/dist/dd-resizable.d.ts +1 -1
  44. package/dist/dd-resizable.js +2 -2
  45. package/dist/dd-resizable.js.map +1 -1
  46. package/dist/dd-touch.d.ts +1 -1
  47. package/dist/dd-touch.js +1 -1
  48. package/dist/dd-touch.js.map +1 -1
  49. package/dist/es5/dd-base-impl.d.ts +1 -1
  50. package/dist/es5/dd-base-impl.js +1 -1
  51. package/dist/es5/dd-base-impl.js.map +1 -1
  52. package/dist/es5/dd-draggable.d.ts +1 -1
  53. package/dist/es5/dd-draggable.js +2 -2
  54. package/dist/es5/dd-draggable.js.map +1 -1
  55. package/dist/es5/dd-droppable.d.ts +1 -1
  56. package/dist/es5/dd-droppable.js +1 -1
  57. package/dist/es5/dd-droppable.js.map +1 -1
  58. package/dist/es5/dd-element.d.ts +1 -1
  59. package/dist/es5/dd-element.js +1 -1
  60. package/dist/es5/dd-element.js.map +1 -1
  61. package/dist/es5/dd-gridstack.d.ts +1 -1
  62. package/dist/es5/dd-gridstack.js +1 -1
  63. package/dist/es5/dd-gridstack.js.map +1 -1
  64. package/dist/es5/dd-manager.d.ts +1 -1
  65. package/dist/es5/dd-manager.js +1 -1
  66. package/dist/es5/dd-manager.js.map +1 -1
  67. package/dist/es5/dd-resizable-handle.d.ts +1 -1
  68. package/dist/es5/dd-resizable-handle.js +1 -1
  69. package/dist/es5/dd-resizable-handle.js.map +1 -1
  70. package/dist/es5/dd-resizable.d.ts +1 -1
  71. package/dist/es5/dd-resizable.js +2 -2
  72. package/dist/es5/dd-resizable.js.map +1 -1
  73. package/dist/es5/dd-touch.d.ts +1 -1
  74. package/dist/es5/dd-touch.js +1 -1
  75. package/dist/es5/dd-touch.js.map +1 -1
  76. package/dist/es5/gridstack-all.js +1 -1
  77. package/dist/es5/gridstack-all.js.LICENSE.txt +1 -1
  78. package/dist/es5/gridstack-all.js.map +1 -1
  79. package/dist/es5/gridstack-engine.d.ts +1 -1
  80. package/dist/es5/gridstack-engine.js +3 -2
  81. package/dist/es5/gridstack-engine.js.map +1 -1
  82. package/dist/es5/gridstack-poly.js +1 -1
  83. package/dist/es5/gridstack.d.ts +9 -6
  84. package/dist/es5/gridstack.js +83 -66
  85. package/dist/es5/gridstack.js.map +1 -1
  86. package/dist/es5/types.d.ts +10 -7
  87. package/dist/es5/types.js +1 -1
  88. package/dist/es5/types.js.map +1 -1
  89. package/dist/es5/utils.d.ts +2 -2
  90. package/dist/es5/utils.js +4 -4
  91. package/dist/es5/utils.js.map +1 -1
  92. package/dist/gridstack-all.js +1 -1
  93. package/dist/gridstack-all.js.LICENSE.txt +1 -1
  94. package/dist/gridstack-all.js.map +1 -1
  95. package/dist/gridstack-engine.d.ts +1 -1
  96. package/dist/gridstack-engine.js +3 -2
  97. package/dist/gridstack-engine.js.map +1 -1
  98. package/dist/gridstack.css +2 -2
  99. package/dist/gridstack.d.ts +9 -6
  100. package/dist/gridstack.js +80 -65
  101. package/dist/gridstack.js.map +1 -1
  102. package/dist/gridstack.min.css +1 -1
  103. package/dist/src/gridstack.scss +2 -2
  104. package/dist/types.d.ts +10 -7
  105. package/dist/types.js +1 -1
  106. package/dist/types.js.map +1 -1
  107. package/dist/utils.d.ts +2 -2
  108. package/dist/utils.js +4 -4
  109. package/dist/utils.js.map +1 -1
  110. package/doc/CHANGES.md +14 -3
  111. package/doc/README.md +3 -2
  112. package/package.json +1 -1
@@ -36,7 +36,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
36
36
  Object.defineProperty(exports, "__esModule", { value: true });
37
37
  exports.GridStack = void 0;
38
38
  /*!
39
- * GridStack 9.0.2
39
+ * GridStack 9.1.1
40
40
  * https://gridstackjs.com/
41
41
  *
42
42
  * Copyright (c) 2021-2022 Alain Dumesny
@@ -730,7 +730,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
730
730
  }
731
731
  this.opts.cellHeightUnit = data.unit;
732
732
  this.opts.cellHeight = data.h;
733
- this.doContentResize(false);
733
+ this.doContentResize(false, true); // no anim wait, but use attributes since we only change row height
734
734
  if (update) {
735
735
  this._updateStyles(true); // true = force re-create for current # of rows
736
736
  }
@@ -928,7 +928,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
928
928
  this._prepareElement(el, true, options);
929
929
  var node = el.gridstackNode;
930
930
  this._updateContainerHeight();
931
- this.doContentResize(false, node);
931
+ this.doContentResize(false, false, node);
932
932
  // see if there is a sub-grid to create
933
933
  if (node.subGridOpts) {
934
934
  this.makeSubGrid(el, node.subGridOpts, undefined, false); // node.subGrid will be used as option in method, no need to pass
@@ -1189,58 +1189,71 @@ var GridStack = exports.GridStack = /** @class */ (function () {
1189
1189
  this._triggerChangeEvent();
1190
1190
  this.engine.endUpdate();
1191
1191
  };
1192
- /** Updates widget height to match the content height to avoid v-scrollbar or dead space.
1193
- Note: this assumes only 1 child under '.grid-stack-item-content' (sized to gridItem minus padding) that is at the entire content size wanted */
1194
- GridStack.prototype.resizeToContent = function (els) {
1195
- var _this = this;
1196
- GridStack.getElements(els).forEach(function (el) {
1197
- var n = el === null || el === void 0 ? void 0 : el.gridstackNode;
1198
- if (!n)
1199
- return;
1200
- var grid = n.grid;
1201
- if (grid !== _this)
1202
- return grid === null || grid === void 0 ? void 0 : grid.resizeToContent(el);
1203
- if (el.parentElement !== _this.el)
1204
- return; // skip if we are not inside a grid
1205
- var cell = _this.getCellHeight();
1206
- if (!cell)
1207
- return;
1208
- var height = n.h ? n.h * cell : el.clientHeight; // getBoundingClientRect().height seem to flicker back and forth
1209
- if (!height)
1210
- return; // 0 when hidden, skip
1211
- var item = el.querySelector(GridStack.resizeToContentParent);
1212
- if (!item)
1213
- return;
1214
- var child = item.firstElementChild;
1215
- // NOTE: clientHeight & getBoundingClientRect() is undefined for text and other leaf nodes. use <div> container!
1216
- if (!child) {
1217
- console.log("Error: resizeToContent() '".concat(GridStack.resizeToContentParent, "'.firstElementChild is null, make sure to have a div like container. Skipping sizing."));
1218
- return;
1219
- }
1220
- var padding = el.clientHeight - item.clientHeight; // full - available height to our child (minus border, padding...)
1221
- var 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)
1222
- var wantedH = child.getBoundingClientRect().height || itemH;
1223
- if (itemH === wantedH)
1224
- return;
1225
- height += wantedH - itemH;
1226
- var h = Math.ceil(height / cell);
1227
- if (n.minH && h < n.minH)
1228
- h = n.minH;
1229
- else if (n.maxH && h > n.maxH)
1230
- h = n.maxH;
1231
- if (h !== n.h) {
1232
- _this._ignoreLayoutsNodeChange = true;
1233
- _this.moveNode(n, { h: h });
1234
- delete _this._ignoreLayoutsNodeChange;
1235
- }
1236
- });
1192
+ /**
1193
+ * Updates widget height to match the content height to avoid v-scrollbar or dead space.
1194
+ * 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.
1195
+ * 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
1196
+ **/
1197
+ GridStack.prototype.resizeToContent = function (el, useAttrSize) {
1198
+ if (useAttrSize === void 0) { useAttrSize = false; }
1199
+ el === null || el === void 0 ? void 0 : el.classList.remove('size-to-content-max');
1200
+ if (!(el === null || el === void 0 ? void 0 : el.clientHeight))
1201
+ return; // 0 when hidden, skip
1202
+ var n = el.gridstackNode;
1203
+ if (!n)
1204
+ return;
1205
+ var grid = n.grid;
1206
+ if (!grid)
1207
+ return;
1208
+ if (el.parentElement !== grid.el)
1209
+ return; // skip if we are not inside a grid
1210
+ var cell = grid.getCellHeight();
1211
+ if (!cell)
1212
+ return;
1213
+ var height = useAttrSize && n.h ? n.h * cell : el.clientHeight; // getBoundingClientRect().height seem to flicker back and forth
1214
+ var item;
1215
+ if (n.resizeToContentParent)
1216
+ item = el.querySelector(n.resizeToContentParent);
1217
+ if (!item)
1218
+ item = el.querySelector(GridStack.resizeToContentParent);
1219
+ if (!item)
1220
+ return;
1221
+ var child = item.firstElementChild;
1222
+ // NOTE: clientHeight & getBoundingClientRect() is undefined for text and other leaf nodes. use <div> container!
1223
+ if (!child) {
1224
+ console.log("Error: resizeToContent() '".concat(GridStack.resizeToContentParent, "'.firstElementChild is null, make sure to have a div like container. Skipping sizing."));
1225
+ return;
1226
+ }
1227
+ var padding = el.clientHeight - item.clientHeight; // full - available height to our child (minus border, padding...)
1228
+ var 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)
1229
+ var wantedH = child.getBoundingClientRect().height || itemH;
1230
+ if (itemH === wantedH)
1231
+ return;
1232
+ height += wantedH - itemH;
1233
+ var h = Math.ceil(height / cell);
1234
+ // check for min/max and special sizing
1235
+ var softMax = Number.isInteger(n.sizeToContent) ? n.sizeToContent : 0;
1236
+ if (softMax && h > softMax) {
1237
+ h = softMax;
1238
+ el.classList.add('size-to-content-max'); // get v-scroll back
1239
+ }
1240
+ if (n.minH && h < n.minH)
1241
+ h = n.minH;
1242
+ else if (n.maxH && h > n.maxH)
1243
+ h = n.maxH;
1244
+ if (h !== n.h) {
1245
+ grid._ignoreLayoutsNodeChange = true;
1246
+ grid.moveNode(n, { h: h });
1247
+ delete grid._ignoreLayoutsNodeChange;
1248
+ }
1237
1249
  };
1238
1250
  /** call the user resize (so we can do extra work) else our build in version */
1239
- GridStack.prototype.resizeToContentCheck = function (el) {
1251
+ GridStack.prototype.resizeToContentCheck = function (el, useAttr) {
1252
+ if (useAttr === void 0) { useAttr = false; }
1240
1253
  if (GridStack.resizeToContentCB)
1241
1254
  GridStack.resizeToContentCB(el);
1242
1255
  else
1243
- this.resizeToContent(el);
1256
+ this.resizeToContent(el, useAttr);
1244
1257
  };
1245
1258
  /**
1246
1259
  * Updates the margins which will set all 4 sides at once - see `GridStackOptions.margin` for format options (CSS string format of 1,2,4 values or single number).
@@ -1439,8 +1452,8 @@ var GridStack = exports.GridStack = /** @class */ (function () {
1439
1452
  if (!utils_1.Utils.same(node, copy)) {
1440
1453
  this._writeAttr(el, node);
1441
1454
  }
1442
- if (utils_1.Utils.shouldFitToContent(node))
1443
- el.classList.add('fit-to-content');
1455
+ if (utils_1.Utils.shouldSizeToContent(node))
1456
+ el.classList.add('size-to-content');
1444
1457
  this._prepareDragDropByNode(node);
1445
1458
  return this;
1446
1459
  };
@@ -1538,7 +1551,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
1538
1551
  /**
1539
1552
  * called when we are being resized - check if the one Column Mode needs to be turned on/off
1540
1553
  * and remember the prev columns we used, or get our count from parent, as well as check for cellHeight==='auto' (square)
1541
- * or `fitToContent` gridItem options.
1554
+ * or `sizeToContent` gridItem options.
1542
1555
  */
1543
1556
  GridStack.prototype.onResize = function () {
1544
1557
  var _a;
@@ -1562,7 +1575,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
1562
1575
  var oneColumn = !this.opts.disableOneColumnMode && this.el.clientWidth <= this.opts.oneColumnSize ||
1563
1576
  (this.opts.column === 1 && !this._prevColumn);
1564
1577
  if ((this.opts.column === 1) !== oneColumn) {
1565
- // if (this.opts.animate) this.setAnimation(false); // 1 <-> 12 is too radical, turn off animation and we need it for fitToContent
1578
+ // if (this.opts.animate) this.setAnimation(false); // 1 <-> 12 is too radical, turn off animation and we need it for sizeToContent
1566
1579
  this.column(oneColumn ? 1 : this._prevColumn);
1567
1580
  // if (this.opts.animate) setTimeout(() => this.setAnimation(true));
1568
1581
  columnChanged = true;
@@ -1576,27 +1589,28 @@ var GridStack = exports.GridStack = /** @class */ (function () {
1576
1589
  if (n.subGrid)
1577
1590
  n.subGrid.onResize();
1578
1591
  });
1579
- this.doContentResize(columnChanged);
1592
+ this.doContentResize(columnChanged); // wait for anim of column changed (DOM reflow before we can size correctly)
1580
1593
  this.batchUpdate(false);
1581
1594
  return this;
1582
1595
  };
1583
- GridStack.prototype.doContentResize = function (delay, n) {
1596
+ GridStack.prototype.doContentResize = function (delay, useAttr, n) {
1584
1597
  var _this = this;
1585
1598
  if (delay === void 0) { delay = true; }
1599
+ if (useAttr === void 0) { useAttr = false; }
1586
1600
  if (n === void 0) { n = undefined; }
1587
- // update any gridItem height with fitToContent, but wait for DOM $animation_speed to settle if we changed column count
1601
+ // update any gridItem height with sizeToContent, but wait for DOM $animation_speed to settle if we changed column count
1588
1602
  // 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 ?
1589
1603
  setTimeout(function () {
1590
1604
  if (n) {
1591
- if (utils_1.Utils.shouldFitToContent(n))
1592
- _this.resizeToContentCheck(n.el);
1605
+ if (utils_1.Utils.shouldSizeToContent(n))
1606
+ _this.resizeToContentCheck(n.el, useAttr);
1593
1607
  }
1594
1608
  else {
1595
1609
  var nodes = __spreadArray([], _this.engine.nodes, true); // in case order changes while resizing one
1596
1610
  _this.batchUpdate();
1597
1611
  nodes.forEach(function (n) {
1598
- if (utils_1.Utils.shouldFitToContent(n))
1599
- _this.resizeToContentCheck(n.el);
1612
+ if (utils_1.Utils.shouldSizeToContent(n))
1613
+ _this.resizeToContentCheck(n.el, useAttr);
1600
1614
  });
1601
1615
  _this.batchUpdate(false);
1602
1616
  }
@@ -1609,8 +1623,8 @@ var GridStack = exports.GridStack = /** @class */ (function () {
1609
1623
  var _this = this;
1610
1624
  if (forceRemove === void 0) { forceRemove = false; }
1611
1625
  // 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)
1612
- // or supporting new fitToContent option.
1613
- var trackSize = !this.parentGridItem && (this._isAutoCellHeight || this.opts.fitToContent || !this.opts.disableOneColumnMode || this.engine.nodes.find(function (n) { return n.fitToContent; }));
1626
+ // or supporting new sizeToContent option.
1627
+ var trackSize = !this.parentGridItem && (this._isAutoCellHeight || this.opts.sizeToContent || !this.opts.disableOneColumnMode || this.engine.nodes.find(function (n) { return n.sizeToContent; }));
1614
1628
  if (!forceRemove && trackSize && !this.resizeObserver) {
1615
1629
  this._sizeThrottle = utils_1.Utils.throttle(function () { return _this.onResize(); }, this.opts.cellHeightThrottle);
1616
1630
  this.resizeObserver = new ResizeObserver(function (entries) { return _this._sizeThrottle(); });
@@ -2179,8 +2193,11 @@ var GridStack = exports.GridStack = /** @class */ (function () {
2179
2193
  _this._updateContainerHeight(); // @ts-ignore
2180
2194
  _this._triggerChangeEvent();
2181
2195
  _this.engine.endUpdate();
2182
- if (event.type === 'resizestop')
2183
- _this.doContentResize(false, node);
2196
+ if (event.type === 'resizestop') {
2197
+ if (Number.isInteger(node.sizeToContent))
2198
+ node.sizeToContent = node.h; // new soft limit
2199
+ _this.doContentResize(false, true, node); // no amin wait as will use the actual sized coordinate attr
2200
+ }
2184
2201
  };
2185
2202
  dd.draggable(el, {
2186
2203
  start: onStartMoving,
@@ -2355,7 +2372,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
2355
2372
  GridStack.Utils = utils_1.Utils;
2356
2373
  /** scoping so users can call new GridStack.Engine(12) for example */
2357
2374
  GridStack.Engine = gridstack_engine_1.GridStackEngine;
2358
- GridStack.GDRev = '9.0.2';
2375
+ GridStack.GDRev = '9.1.1';
2359
2376
  return GridStack;
2360
2377
  }());
2361
2378
  //# sourceMappingURL=gridstack.js.map