gridstack 10.1.2 → 10.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 (142) hide show
  1. package/angular/angular.json +3 -0
  2. package/angular/package.json +1 -1
  3. package/dist/angular/esm2020/gridstack-angular.mjs +4 -4
  4. package/dist/angular/esm2020/lib/base-widget.mjs +30 -30
  5. package/dist/angular/esm2020/lib/gridstack-item.component.mjs +52 -52
  6. package/dist/angular/esm2020/lib/gridstack.component.mjs +266 -264
  7. package/dist/angular/esm2020/lib/gridstack.module.mjs +39 -39
  8. package/dist/angular/esm2020/public-api.mjs +7 -7
  9. package/dist/angular/fesm2015/gridstack-angular.mjs +368 -366
  10. package/dist/angular/fesm2015/gridstack-angular.mjs.map +1 -1
  11. package/dist/angular/fesm2020/gridstack-angular.mjs +363 -361
  12. package/dist/angular/fesm2020/gridstack-angular.mjs.map +1 -1
  13. package/dist/angular/index.d.ts +5 -5
  14. package/dist/angular/lib/base-widget.d.ts +16 -16
  15. package/dist/angular/lib/gridstack-item.component.d.ts +37 -37
  16. package/dist/angular/lib/gridstack.component.d.ts +129 -129
  17. package/dist/angular/lib/gridstack.module.d.ts +10 -10
  18. package/dist/angular/public-api.d.ts +4 -4
  19. package/dist/dd-base-impl.d.ts +1 -1
  20. package/dist/dd-base-impl.js +1 -1
  21. package/dist/dd-base-impl.js.map +1 -1
  22. package/dist/dd-draggable.d.ts +4 -4
  23. package/dist/dd-draggable.js +63 -19
  24. package/dist/dd-draggable.js.map +1 -1
  25. package/dist/dd-droppable.d.ts +1 -1
  26. package/dist/dd-droppable.js +1 -1
  27. package/dist/dd-droppable.js.map +1 -1
  28. package/dist/dd-element.d.ts +1 -1
  29. package/dist/dd-element.js +1 -1
  30. package/dist/dd-element.js.map +1 -1
  31. package/dist/dd-gridstack.d.ts +1 -1
  32. package/dist/dd-gridstack.js +2 -2
  33. package/dist/dd-gridstack.js.map +1 -1
  34. package/dist/dd-manager.d.ts +1 -1
  35. package/dist/dd-manager.js +1 -1
  36. package/dist/dd-manager.js.map +1 -1
  37. package/dist/dd-resizable-handle.d.ts +4 -3
  38. package/dist/dd-resizable-handle.js +12 -1
  39. package/dist/dd-resizable-handle.js.map +1 -1
  40. package/dist/dd-resizable.d.ts +1 -1
  41. package/dist/dd-resizable.js +1 -1
  42. package/dist/dd-resizable.js.map +1 -1
  43. package/dist/dd-touch.d.ts +1 -1
  44. package/dist/dd-touch.js +1 -1
  45. package/dist/dd-touch.js.map +1 -1
  46. package/dist/es5/dd-base-impl.d.ts +1 -1
  47. package/dist/es5/dd-base-impl.js +1 -1
  48. package/dist/es5/dd-base-impl.js.map +1 -1
  49. package/dist/es5/dd-draggable.d.ts +4 -4
  50. package/dist/es5/dd-draggable.js +78 -21
  51. package/dist/es5/dd-draggable.js.map +1 -1
  52. package/dist/es5/dd-droppable.d.ts +1 -1
  53. package/dist/es5/dd-droppable.js +1 -1
  54. package/dist/es5/dd-droppable.js.map +1 -1
  55. package/dist/es5/dd-element.d.ts +1 -1
  56. package/dist/es5/dd-element.js +1 -1
  57. package/dist/es5/dd-element.js.map +1 -1
  58. package/dist/es5/dd-gridstack.d.ts +1 -1
  59. package/dist/es5/dd-gridstack.js +2 -2
  60. package/dist/es5/dd-gridstack.js.map +1 -1
  61. package/dist/es5/dd-manager.d.ts +1 -1
  62. package/dist/es5/dd-manager.js +1 -1
  63. package/dist/es5/dd-manager.js.map +1 -1
  64. package/dist/es5/dd-resizable-handle.d.ts +4 -3
  65. package/dist/es5/dd-resizable-handle.js +13 -1
  66. package/dist/es5/dd-resizable-handle.js.map +1 -1
  67. package/dist/es5/dd-resizable.d.ts +1 -1
  68. package/dist/es5/dd-resizable.js +1 -1
  69. package/dist/es5/dd-resizable.js.map +1 -1
  70. package/dist/es5/dd-touch.d.ts +1 -1
  71. package/dist/es5/dd-touch.js +1 -1
  72. package/dist/es5/dd-touch.js.map +1 -1
  73. package/dist/es5/gridstack-all.js +1 -1
  74. package/dist/es5/gridstack-all.js.LICENSE.txt +1 -1
  75. package/dist/es5/gridstack-all.js.map +1 -1
  76. package/dist/es5/gridstack-engine.d.ts +1 -1
  77. package/dist/es5/gridstack-engine.js +1 -1
  78. package/dist/es5/gridstack-engine.js.map +1 -1
  79. package/dist/es5/gridstack-poly.js +1 -1
  80. package/dist/es5/gridstack.d.ts +9 -3
  81. package/dist/es5/gridstack.js +61 -28
  82. package/dist/es5/gridstack.js.map +1 -1
  83. package/dist/es5/types.d.ts +8 -8
  84. package/dist/es5/types.js +1 -1
  85. package/dist/es5/types.js.map +1 -1
  86. package/dist/es5/utils.d.ts +6 -1
  87. package/dist/es5/utils.js +26 -10
  88. package/dist/es5/utils.js.map +1 -1
  89. package/dist/gridstack-all.js +1 -1
  90. package/dist/gridstack-all.js.LICENSE.txt +1 -1
  91. package/dist/gridstack-all.js.map +1 -1
  92. package/dist/gridstack-engine.d.ts +1 -1
  93. package/dist/gridstack-engine.js +1 -1
  94. package/dist/gridstack-engine.js.map +1 -1
  95. package/dist/gridstack.css +1 -1
  96. package/dist/gridstack.d.ts +9 -3
  97. package/dist/gridstack.js +56 -26
  98. package/dist/gridstack.js.map +1 -1
  99. package/dist/types.d.ts +8 -8
  100. package/dist/types.js +1 -1
  101. package/dist/types.js.map +1 -1
  102. package/dist/utils.d.ts +6 -1
  103. package/dist/utils.js +25 -10
  104. package/dist/utils.js.map +1 -1
  105. package/doc/CHANGES.md +15 -0
  106. package/doc/README.md +7 -1
  107. package/package.json +3 -2
  108. package/angular/.vscode/extensions.json +0 -4
  109. package/angular/.vscode/launch.json +0 -20
  110. package/angular/.vscode/tasks.json +0 -42
  111. package/angular/projects/demo/.browserslistrc +0 -16
  112. package/angular/projects/demo/src/app/app.component.css +0 -11
  113. package/angular/projects/demo/src/app/app.component.html +0 -110
  114. package/angular/projects/demo/src/app/app.component.spec.ts +0 -25
  115. package/angular/projects/demo/src/app/app.component.ts +0 -223
  116. package/angular/projects/demo/src/app/app.module.ts +0 -39
  117. package/angular/projects/demo/src/app/dummy.component.ts +0 -34
  118. package/angular/projects/demo/src/app/ngFor.ts +0 -131
  119. package/angular/projects/demo/src/app/ngFor_cmd.ts +0 -106
  120. package/angular/projects/demo/src/app/simple.ts +0 -46
  121. package/angular/projects/demo/src/assets/.gitkeep +0 -0
  122. package/angular/projects/demo/src/environments/environment.ts +0 -16
  123. package/angular/projects/demo/src/favicon.ico +0 -0
  124. package/angular/projects/demo/src/index.html +0 -13
  125. package/angular/projects/demo/src/main.ts +0 -12
  126. package/angular/projects/demo/src/polyfills.ts +0 -53
  127. package/angular/projects/demo/src/styles.css +0 -41
  128. package/angular/projects/demo/src/test.ts +0 -26
  129. package/angular/projects/demo/tsconfig.app.json +0 -15
  130. package/angular/projects/demo/tsconfig.spec.json +0 -18
  131. package/angular/projects/lib/src/lib/base-widget.ts +0 -28
  132. package/angular/projects/lib/src/lib/gridstack-item.component.ts +0 -78
  133. package/angular/projects/lib/src/lib/gridstack.component.ts +0 -287
  134. package/angular/projects/lib/src/lib/gridstack.module.ts +0 -32
  135. package/angular/projects/lib/src/public-api.ts +0 -8
  136. package/angular/projects/lib/src/test.ts +0 -27
  137. package/dist/angular/src/base-widget.ts +0 -28
  138. package/dist/angular/src/gridstack-item.component.ts +0 -78
  139. package/dist/angular/src/gridstack.component.ts +0 -287
  140. package/dist/angular/src/gridstack.module.ts +0 -32
  141. package/dist/src/gridstack-extra.scss +0 -25
  142. package/dist/src/gridstack.scss +0 -157
@@ -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 10.1.2
39
+ * GridStack 10.2.1
40
40
  * https://gridstackjs.com/
41
41
  *
42
42
  * Copyright (c) 2021-2022 Alain Dumesny
@@ -231,7 +231,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
231
231
  this.load(children); // don't load empty
232
232
  }
233
233
  // if (this.engine.nodes.length) this._updateStyles(); // update based on # of children. done in engine onChange CB
234
- this.setAnimation(opts.animate);
234
+ this.setAnimation();
235
235
  // dynamic grids require pausing during drag to detect over to nest vs push
236
236
  if (opts.subGridDynamic && !dd_manager_1.DDManager.pauseDrag)
237
237
  dd_manager_1.DDManager.pauseDrag = true;
@@ -638,6 +638,8 @@ var GridStack = exports.GridStack = /** @class */ (function () {
638
638
  if (addRemove === void 0) { addRemove = GridStack.addRemoveCB || true; }
639
639
  items = utils_1.Utils.cloneDeep(items); // so we can mod
640
640
  var column = this.getColumn();
641
+ // make sure size 1x1 (default) is present as it may need to override current sizes
642
+ items.forEach(function (n) { n.w = n.w || 1; n.h = n.h || 1; });
641
643
  // if we have a mix of new items without coordinates and existing items, separate them out so they can be added after #2639
642
644
  var addAfter = items.filter(function (n) { return (n.x === undefined || n.y === undefined) && !utils_1.Utils.find(_this.engine.nodes, n.id); });
643
645
  if (addAfter.length && addAfter.length !== items.length) {
@@ -733,10 +735,9 @@ var GridStack = exports.GridStack = /** @class */ (function () {
733
735
  delete this._ignoreLayoutsNodeChange;
734
736
  delete this._insertNotAppend;
735
737
  prevCB ? GridStack.addRemoveCB = prevCB : delete GridStack.addRemoveCB;
736
- // delay adding animation back, but check to make sure grid (opt) is still around
738
+ // delay adding animation back
737
739
  if (noAnim && ((_a = this.opts) === null || _a === void 0 ? void 0 : _a.animate))
738
- setTimeout(function () { if (_this.opts)
739
- _this.setAnimation(_this.opts.animate); });
740
+ this.setAnimation(this.opts.animate, true);
740
741
  return this;
741
742
  };
742
743
  /**
@@ -1169,9 +1170,17 @@ var GridStack = exports.GridStack = /** @class */ (function () {
1169
1170
  /**
1170
1171
  * Toggle the grid animation state. Toggles the `grid-stack-animate` class.
1171
1172
  * @param doAnimate if true the grid will animate.
1173
+ * @param delay if true setting will be set on next event loop.
1172
1174
  */
1173
- GridStack.prototype.setAnimation = function (doAnimate) {
1174
- if (doAnimate) {
1175
+ GridStack.prototype.setAnimation = function (doAnimate, delay) {
1176
+ var _this = this;
1177
+ if (doAnimate === void 0) { doAnimate = this.opts.animate; }
1178
+ if (delay) {
1179
+ // delay, but check to make sure grid (opt) is still around
1180
+ setTimeout(function () { if (_this.opts)
1181
+ _this.setAnimation(doAnimate); });
1182
+ }
1183
+ else if (doAnimate) {
1175
1184
  this.el.classList.add('grid-stack-animate');
1176
1185
  }
1177
1186
  else {
@@ -1275,6 +1284,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
1275
1284
  var widthChanged = (m.w !== undefined && m.w !== n.w);
1276
1285
  _this.moveNode(n, m);
1277
1286
  _this.resizeToContentCheck(widthChanged, n); // wait for animation if we changed width
1287
+ delete n._orig; // clear out original position now that we moved #2669
1278
1288
  }
1279
1289
  if (m || changed) {
1280
1290
  _this._writeAttr(el, n);
@@ -1286,12 +1296,15 @@ var GridStack = exports.GridStack = /** @class */ (function () {
1286
1296
  return this;
1287
1297
  };
1288
1298
  GridStack.prototype.moveNode = function (n, m) {
1289
- this.engine.cleanNodes()
1290
- .beginUpdate(n)
1291
- .moveNode(n, m);
1299
+ var wasUpdating = n._updating;
1300
+ if (!wasUpdating)
1301
+ this.engine.cleanNodes().beginUpdate(n);
1302
+ this.engine.moveNode(n, m);
1292
1303
  this._updateContainerHeight();
1293
- this._triggerChangeEvent();
1294
- this.engine.endUpdate();
1304
+ if (!wasUpdating) {
1305
+ this._triggerChangeEvent();
1306
+ this.engine.endUpdate();
1307
+ }
1295
1308
  };
1296
1309
  /**
1297
1310
  * Updates widget height to match the content height to avoid v-scrollbar or dead space.
@@ -1365,6 +1378,28 @@ var GridStack = exports.GridStack = /** @class */ (function () {
1365
1378
  else
1366
1379
  this.resizeToContent(el);
1367
1380
  };
1381
+ /** rotate (by swapping w & h) the passed in node - called when user press 'r' during dragging
1382
+ * @param els widget or selector of objects to modify
1383
+ * @param relative optional pixel coord relative to upper/left corner to rotate around (will keep that cell under cursor)
1384
+ */
1385
+ GridStack.prototype.rotate = function (els, relative) {
1386
+ var _this = this;
1387
+ GridStack.getElements(els).forEach(function (el) {
1388
+ var n = el.gridstackNode;
1389
+ if (!utils_1.Utils.canBeRotated(n))
1390
+ return;
1391
+ var rot = { w: n.h, h: n.w, minH: n.minW, minW: n.minH, maxH: n.maxW, maxW: n.maxH };
1392
+ // if given an offset, adjust x/y by column/row bounds when user presses 'r' during dragging
1393
+ if (relative) {
1394
+ var pivotX = relative.left > 0 ? Math.floor(relative.left / _this.cellWidth()) : 0;
1395
+ var pivotY = relative.top > 0 ? Math.floor(relative.top / _this.opts.cellHeight) : 0;
1396
+ rot.x = n.x + pivotX - (n.h - (pivotY + 1));
1397
+ rot.y = (n.y + pivotY) - pivotX;
1398
+ }
1399
+ _this.update(el, rot);
1400
+ });
1401
+ return this;
1402
+ };
1368
1403
  /**
1369
1404
  * 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).
1370
1405
  * @param value margin value
@@ -2153,7 +2188,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
2153
2188
  * end - releasing the mouse
2154
2189
  */
2155
2190
  .on(this.el, 'drop', function (event, el, helper) {
2156
- var _a, _b;
2191
+ var _a, _b, _c;
2157
2192
  var node = el.gridstackNode;
2158
2193
  // ignore drop on ourself from ourself that didn't come from the outside - dragend will handle the simple move instead
2159
2194
  if ((node === null || node === void 0 ? void 0 : node.grid) === _this && !node._isExternal)
@@ -2185,7 +2220,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
2185
2220
  _this.engine.cleanupNode(node); // removes all internal _xyz values
2186
2221
  node.grid = _this;
2187
2222
  }
2188
- delete node.grid._isTemp;
2223
+ (_a = node.grid) === null || _a === void 0 ? true : delete _a._isTemp;
2189
2224
  dd.off(el, 'drag');
2190
2225
  // if we made a copy ('helper' which is temp) of the original node then insert a copy, else we move the original node (#1102)
2191
2226
  // as the helper will be nuked by jquery-ui otherwise. TODO: update old code path
@@ -2204,7 +2239,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
2204
2239
  return false;
2205
2240
  el.gridstackNode = node;
2206
2241
  node.el = el;
2207
- var subGrid = (_b = (_a = node.subGrid) === null || _a === void 0 ? void 0 : _a.el) === null || _b === void 0 ? void 0 : _b.gridstack; // set when actual sub-grid present
2242
+ var subGrid = (_c = (_b = node.subGrid) === null || _b === void 0 ? void 0 : _b.el) === null || _c === void 0 ? void 0 : _c.gridstack; // set when actual sub-grid present
2208
2243
  // @ts-ignore
2209
2244
  utils_1.Utils.copyPos(node, _this._readAttr(_this.placeholder)); // placeholder values as moving VERY fast can throw things off #1578
2210
2245
  utils_1.Utils.removePositioningStyles(el); // @ts-ignore
@@ -2223,10 +2258,9 @@ var GridStack = exports.GridStack = /** @class */ (function () {
2223
2258
  if (_this._gsEventHandler['dropped']) {
2224
2259
  _this._gsEventHandler['dropped'](__assign(__assign({}, event), { type: 'dropped' }), origNode && origNode.grid ? origNode : undefined, node);
2225
2260
  }
2226
- // delay adding animation back, but check to make sure grid (opt) is still around
2261
+ // delay adding animation back
2227
2262
  if (noAnim)
2228
- setTimeout(function () { if (_this.opts)
2229
- _this.setAnimation(_this.opts.animate); });
2263
+ _this.setAnimation(_this.opts.animate, true);
2230
2264
  return false; // prevent parent from receiving msg (which may be grid as well)
2231
2265
  });
2232
2266
  return this;
@@ -2360,6 +2394,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
2360
2394
  // @ts-ignore
2361
2395
  this._writePosAttr(this.placeholder, node);
2362
2396
  this.el.appendChild(this.placeholder);
2397
+ this.placeholder.gridstackNode = node;
2363
2398
  // console.log('_onStartMoving placeholder') // TEST
2364
2399
  // if the element is inside a grid, it has already been scaled
2365
2400
  // we can use that as a scale reference
@@ -2391,17 +2426,15 @@ var GridStack = exports.GridStack = /** @class */ (function () {
2391
2426
  this.engine.addNode(node); // will add, fix collisions, update attr and clear _temporaryRemoved
2392
2427
  node._moving = true; // AFTER, mark as moving object (wanted fix location before)
2393
2428
  }
2394
- // set the min/max resize info
2429
+ // set the min/max resize info taking into account the column count and position (so we don't resize outside the grid)
2395
2430
  this.engine.cacheRects(cellWidth, cellHeight, this.opts.marginTop, this.opts.marginRight, this.opts.marginBottom, this.opts.marginLeft);
2396
2431
  if (event.type === 'resizestart') {
2397
- dd.resizable(el, 'option', 'minWidth', cellWidth * (node.minW || 1))
2398
- .resizable(el, 'option', 'minHeight', cellHeight * (node.minH || 1));
2399
- if (node.maxW) {
2400
- dd.resizable(el, 'option', 'maxWidth', cellWidth * node.maxW);
2401
- }
2402
- if (node.maxH) {
2403
- dd.resizable(el, 'option', 'maxHeight', cellHeight * node.maxH);
2404
- }
2432
+ var colLeft = this.getColumn() - node.x;
2433
+ var rowLeft = (this.opts.maxRow || Number.MAX_SAFE_INTEGER) - node.y;
2434
+ dd.resizable(el, 'option', 'minWidth', cellWidth * Math.min(node.minW || 1, colLeft))
2435
+ .resizable(el, 'option', 'minHeight', cellHeight * Math.min(node.minH || 1, rowLeft))
2436
+ .resizable(el, 'option', 'maxWidth', cellWidth * Math.min(node.maxW || Number.MAX_SAFE_INTEGER, colLeft))
2437
+ .resizable(el, 'option', 'maxHeight', cellHeight * Math.min(node.maxH || Number.MAX_SAFE_INTEGER, rowLeft));
2405
2438
  }
2406
2439
  };
2407
2440
  /** @internal handles actual drag/resize */
@@ -2533,7 +2566,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
2533
2566
  GridStack.Utils = utils_1.Utils;
2534
2567
  /** scoping so users can call new GridStack.Engine(12) for example */
2535
2568
  GridStack.Engine = gridstack_engine_1.GridStackEngine;
2536
- GridStack.GDRev = '10.1.2';
2569
+ GridStack.GDRev = '10.2.1';
2537
2570
  return GridStack;
2538
2571
  }());
2539
2572
  //# sourceMappingURL=gridstack.js.map