gridstack 9.1.0 → 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 (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 +2 -2
  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 +2 -2
  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 +2 -2
  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 +2 -2
  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 +3 -2
  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 +8 -5
  83. package/dist/es5/gridstack.js +70 -70
  84. package/dist/es5/gridstack.js.map +1 -1
  85. package/dist/es5/types.d.ts +4 -4
  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 +2 -2
  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 +3 -2
  96. package/dist/gridstack-engine.js.map +1 -1
  97. package/dist/gridstack.css +2 -2
  98. package/dist/gridstack.d.ts +8 -5
  99. package/dist/gridstack.js +67 -69
  100. package/dist/gridstack.js.map +1 -1
  101. package/dist/gridstack.min.css +1 -1
  102. package/dist/src/gridstack.scss +2 -2
  103. package/dist/types.d.ts +4 -4
  104. package/dist/types.js +1 -1
  105. package/dist/types.js.map +1 -1
  106. package/dist/utils.d.ts +1 -1
  107. package/dist/utils.js +2 -2
  108. package/dist/utils.js.map +1 -1
  109. package/doc/CHANGES.md +5 -0
  110. package/package.json +1 -1
package/dist/gridstack.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * GridStack 9.1.0
2
+ * GridStack 9.1.1
3
3
  * https://gridstackjs.com/
4
4
  *
5
5
  * Copyright (c) 2021-2022 Alain Dumesny
@@ -674,7 +674,7 @@ class GridStack {
674
674
  }
675
675
  this.opts.cellHeightUnit = data.unit;
676
676
  this.opts.cellHeight = data.h;
677
- this.doContentResize(false);
677
+ this.doContentResize(false, true); // no anim wait, but use attributes since we only change row height
678
678
  if (update) {
679
679
  this._updateStyles(true); // true = force re-create for current # of rows
680
680
  }
@@ -866,7 +866,7 @@ class GridStack {
866
866
  this._prepareElement(el, true, options);
867
867
  const node = el.gridstackNode;
868
868
  this._updateContainerHeight();
869
- this.doContentResize(false, node);
869
+ this.doContentResize(false, false, node);
870
870
  // see if there is a sub-grid to create
871
871
  if (node.subGridOpts) {
872
872
  this.makeSubGrid(el, node.subGridOpts, undefined, false); // node.subGrid will be used as option in method, no need to pass
@@ -1114,71 +1114,69 @@ class GridStack {
1114
1114
  this._triggerChangeEvent();
1115
1115
  this.engine.endUpdate();
1116
1116
  }
1117
- /** Updates widget height to match the content height to avoid v-scrollbar or dead space.
1118
- Note: this assumes only 1 child under '.grid-stack-item-content' (sized to gridItem minus padding) that is at the entire content size wanted */
1119
- resizeToContent(els) {
1120
- GridStack.getElements(els).forEach(el => {
1121
- if (!el.clientHeight)
1122
- return; // 0 when hidden, skip
1123
- let n = el?.gridstackNode;
1124
- if (!n)
1125
- return;
1126
- const grid = n.grid;
1127
- if (grid !== this)
1128
- return grid?.resizeToContent(el);
1129
- if (el.parentElement !== this.el)
1130
- return; // skip if we are not inside a grid
1131
- const cell = this.getCellHeight();
1132
- if (!cell)
1133
- return;
1134
- let height = n.h ? n.h * cell : el.clientHeight; // getBoundingClientRect().height seem to flicker back and forth
1135
- let item;
1136
- if (n.resizeToContentParent)
1137
- item = el.querySelector(n.resizeToContentParent);
1138
- if (!item)
1139
- item = el.querySelector(GridStack.resizeToContentParent);
1140
- if (!item)
1141
- return;
1142
- const child = item.firstElementChild;
1143
- // NOTE: clientHeight & getBoundingClientRect() is undefined for text and other leaf nodes. use <div> container!
1144
- if (!child) {
1145
- console.log(`Error: resizeToContent() '${GridStack.resizeToContentParent}'.firstElementChild is null, make sure to have a div like container. Skipping sizing.`);
1146
- return;
1147
- }
1148
- const padding = el.clientHeight - item.clientHeight; // full - available height to our child (minus border, padding...)
1149
- 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)
1150
- const wantedH = child.getBoundingClientRect().height || itemH;
1151
- if (itemH === wantedH)
1152
- return;
1153
- height += wantedH - itemH;
1154
- let h = Math.ceil(height / cell);
1155
- // check for min/max and special sizing
1156
- const softMax = Number.isInteger(n.sizeToContent) ? n.sizeToContent : 0;
1157
- if (softMax) {
1158
- if (h > softMax) {
1159
- h = softMax;
1160
- el.classList.remove('size-to-content'); // get v-scroll back
1161
- }
1162
- else
1163
- el.classList.add('size-to-content');
1164
- }
1165
- if (n.minH && h < n.minH)
1166
- h = n.minH;
1167
- else if (n.maxH && h > n.maxH)
1168
- h = n.maxH;
1169
- if (h !== n.h) {
1170
- this._ignoreLayoutsNodeChange = true;
1171
- this.moveNode(n, { h });
1172
- delete this._ignoreLayoutsNodeChange;
1173
- }
1174
- });
1117
+ /**
1118
+ * Updates widget height to match the content height to avoid v-scrollbar or dead space.
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
+ * 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
+ **/
1122
+ resizeToContent(el, useAttrSize = false) {
1123
+ el?.classList.remove('size-to-content-max');
1124
+ if (!el?.clientHeight)
1125
+ return; // 0 when hidden, skip
1126
+ let n = el.gridstackNode;
1127
+ if (!n)
1128
+ return;
1129
+ const grid = n.grid;
1130
+ if (!grid)
1131
+ return;
1132
+ if (el.parentElement !== grid.el)
1133
+ return; // skip if we are not inside a grid
1134
+ const cell = grid.getCellHeight();
1135
+ if (!cell)
1136
+ return;
1137
+ let height = useAttrSize && n.h ? n.h * cell : el.clientHeight; // getBoundingClientRect().height seem to flicker back and forth
1138
+ let item;
1139
+ if (n.resizeToContentParent)
1140
+ item = el.querySelector(n.resizeToContentParent);
1141
+ if (!item)
1142
+ item = el.querySelector(GridStack.resizeToContentParent);
1143
+ if (!item)
1144
+ 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
+ const padding = el.clientHeight - item.clientHeight; // full - available height to our child (minus border, padding...)
1152
+ 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;
1154
+ if (itemH === wantedH)
1155
+ return;
1156
+ height += wantedH - itemH;
1157
+ let h = Math.ceil(height / cell);
1158
+ // check for min/max and special sizing
1159
+ const softMax = Number.isInteger(n.sizeToContent) ? n.sizeToContent : 0;
1160
+ if (softMax && h > softMax) {
1161
+ h = softMax;
1162
+ el.classList.add('size-to-content-max'); // get v-scroll back
1163
+ }
1164
+ if (n.minH && h < n.minH)
1165
+ h = n.minH;
1166
+ else if (n.maxH && h > n.maxH)
1167
+ h = n.maxH;
1168
+ if (h !== n.h) {
1169
+ grid._ignoreLayoutsNodeChange = true;
1170
+ grid.moveNode(n, { h });
1171
+ delete grid._ignoreLayoutsNodeChange;
1172
+ }
1175
1173
  }
1176
1174
  /** call the user resize (so we can do extra work) else our build in version */
1177
- resizeToContentCheck(el) {
1175
+ resizeToContentCheck(el, useAttr = false) {
1178
1176
  if (GridStack.resizeToContentCB)
1179
1177
  GridStack.resizeToContentCB(el);
1180
1178
  else
1181
- this.resizeToContent(el);
1179
+ this.resizeToContent(el, useAttr);
1182
1180
  }
1183
1181
  /**
1184
1182
  * 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).
@@ -1507,24 +1505,24 @@ class GridStack {
1507
1505
  if (n.subGrid)
1508
1506
  n.subGrid.onResize();
1509
1507
  });
1510
- this.doContentResize(columnChanged);
1508
+ this.doContentResize(columnChanged); // wait for anim of column changed (DOM reflow before we can size correctly)
1511
1509
  this.batchUpdate(false);
1512
1510
  return this;
1513
1511
  }
1514
- doContentResize(delay = true, n = undefined) {
1512
+ doContentResize(delay = true, useAttr = false, n = undefined) {
1515
1513
  // update any gridItem height with sizeToContent, but wait for DOM $animation_speed to settle if we changed column count
1516
1514
  // 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 ?
1517
1515
  setTimeout(() => {
1518
1516
  if (n) {
1519
1517
  if (Utils.shouldSizeToContent(n))
1520
- this.resizeToContentCheck(n.el);
1518
+ this.resizeToContentCheck(n.el, useAttr);
1521
1519
  }
1522
1520
  else {
1523
1521
  const nodes = [...this.engine.nodes]; // in case order changes while resizing one
1524
1522
  this.batchUpdate();
1525
1523
  nodes.forEach(n => {
1526
1524
  if (Utils.shouldSizeToContent(n))
1527
- this.resizeToContentCheck(n.el);
1525
+ this.resizeToContentCheck(n.el, useAttr);
1528
1526
  });
1529
1527
  this.batchUpdate(false);
1530
1528
  }
@@ -2088,7 +2086,7 @@ class GridStack {
2088
2086
  if (event.type === 'resizestop') {
2089
2087
  if (Number.isInteger(node.sizeToContent))
2090
2088
  node.sizeToContent = node.h; // new soft limit
2091
- this.doContentResize(false, node);
2089
+ this.doContentResize(false, true, node); // no amin wait as will use the actual sized coordinate attr
2092
2090
  }
2093
2091
  };
2094
2092
  dd.draggable(el, {
@@ -2265,6 +2263,6 @@ GridStack.resizeToContentParent = '.grid-stack-item-content';
2265
2263
  GridStack.Utils = Utils;
2266
2264
  /** scoping so users can call new GridStack.Engine(12) for example */
2267
2265
  GridStack.Engine = GridStackEngine;
2268
- GridStack.GDRev = '9.1.0';
2266
+ GridStack.GDRev = '9.1.1';
2269
2267
  export { GridStack };
2270
2268
  //# sourceMappingURL=gridstack.js.map