gridstack 12.4.1 → 12.5.0

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 (63) hide show
  1. package/dist/angular/esm2020/lib/base-widget.mjs +2 -2
  2. package/dist/angular/esm2020/lib/gridstack-item.component.mjs +2 -2
  3. package/dist/angular/esm2020/lib/gridstack.component.mjs +2 -2
  4. package/dist/angular/esm2020/lib/gridstack.module.mjs +2 -2
  5. package/dist/angular/esm2020/lib/types.mjs +2 -2
  6. package/dist/angular/fesm2015/gridstack-angular.mjs +4 -4
  7. package/dist/angular/fesm2015/gridstack-angular.mjs.map +1 -1
  8. package/dist/angular/fesm2020/gridstack-angular.mjs +5 -5
  9. package/dist/angular/fesm2020/gridstack-angular.mjs.map +1 -1
  10. package/dist/angular/lib/gridstack-item.component.d.ts +1 -1
  11. package/dist/angular/lib/gridstack.component.d.ts +1 -1
  12. package/dist/angular/lib/types.d.ts +1 -1
  13. package/dist/angular/package.json +1 -1
  14. package/dist/angular/src/base-widget.ts +1 -1
  15. package/dist/angular/src/gridstack-item.component.ts +1 -1
  16. package/dist/angular/src/gridstack.component.ts +1 -1
  17. package/dist/angular/src/gridstack.module.ts +1 -1
  18. package/dist/angular/src/types.ts +1 -1
  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 +3 -1
  23. package/dist/dd-draggable.js +74 -2
  24. package/dist/dd-draggable.js.map +1 -1
  25. package/dist/dd-droppable.d.ts +1 -1
  26. package/dist/dd-droppable.js +10 -8
  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 +1 -1
  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 +1 -1
  38. package/dist/dd-resizable-handle.js +1 -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 +2 -1
  42. package/dist/dd-resizable.js.map +1 -1
  43. package/dist/dd-touch.d.ts +6 -1
  44. package/dist/dd-touch.js +2 -2
  45. package/dist/dd-touch.js.map +1 -1
  46. package/dist/gridstack-all.js +1 -1
  47. package/dist/gridstack-all.js.LICENSE.txt +1 -1
  48. package/dist/gridstack-all.js.map +1 -1
  49. package/dist/gridstack-engine.d.ts +1 -1
  50. package/dist/gridstack-engine.js +1 -1
  51. package/dist/gridstack-engine.js.map +1 -1
  52. package/dist/gridstack.css +1 -1
  53. package/dist/gridstack.d.ts +1 -1
  54. package/dist/gridstack.js +22 -13
  55. package/dist/gridstack.js.map +1 -1
  56. package/dist/types.d.ts +4 -1
  57. package/dist/types.js +1 -1
  58. package/dist/types.js.map +1 -1
  59. package/dist/utils.d.ts +1 -1
  60. package/dist/utils.js +4 -36
  61. package/dist/utils.js.map +1 -1
  62. package/doc/API.md +367 -347
  63. package/package.json +2 -2
@@ -1,5 +1,5 @@
1
1
  /**
2
- * gridstack-engine.ts 12.4.1
2
+ * gridstack-engine.ts 12.5.0
3
3
  * Copyright (c) 2021-2025 Alain Dumesny - see GridStack root license
4
4
  */
5
5
  import { GridStackNode, GridStackPosition, GridStackMoveOpts, SaveFcn, CompactOptions } from './types';
@@ -1,5 +1,5 @@
1
1
  /**
2
- * gridstack-engine.ts 12.4.1
2
+ * gridstack-engine.ts 12.5.0
3
3
  * Copyright (c) 2021-2025 Alain Dumesny - see GridStack root license
4
4
  */
5
5
  import { Utils } from './utils';
@@ -1 +1 @@
1
- {"version":3,"file":"gridstack-engine.js","sourceRoot":"","sources":["../src/gridstack-engine.ts"],"names":[],"mappings":"AAAA;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AAC,CAAgB;QAC/C,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YAClB,OAAO;SACR;QACD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC7C,MAAM,KAAK,GAAG,IAAI,CAAC,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YACzC,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE;gBAChB,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;aACnC;SACF;IACH,CAAC;IAED,uDAAuD;IAChD,WAAW,CAAC,IAAmB;QACpC,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE;YACvB,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,IAAI,KAAK,KAAK;gBAAE,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC;SAC1D;QACD,OAAO,IAAI,CAAC;IACd,CAAC;;AA7qCD,mDAAmD;AACrC,sBAAM,GAAG,CAAC,AAAJ,CAAK;SAzBd,eAAe","sourcesContent":["/**\n * gridstack-engine.ts 12.4.1\n * Copyright (c) 2021-2025 Alain Dumesny - see GridStack root license\n */\n\nimport { Utils } from './utils';\nimport { GridStackNode, ColumnOptions, GridStackPosition, GridStackMoveOpts, SaveFcn, CompactOptions } from './types';\n\n/** callback to update the DOM attributes since this class is generic (no HTML or other info) for items that changed - see _notify() */\ntype OnChangeCB = (nodes: GridStackNode[]) => void;\n\n/** options used during creation - similar to GridStackOptions */\nexport interface GridStackEngineOptions {\n column?: number;\n maxRow?: number;\n float?: boolean;\n nodes?: GridStackNode[];\n onChange?: OnChangeCB;\n}\n\n/**\n * Defines the GridStack engine that handles all grid layout calculations and node positioning.\n * This is the core engine that performs grid manipulation without any DOM operations.\n *\n * The engine manages:\n * - Node positioning and collision detection\n * - Layout algorithms (compact, float, etc.)\n * - Grid resizing and column changes\n * - Widget movement and resizing logic\n *\n * NOTE: Values should not be modified directly - use the main GridStack API instead\n * to ensure proper DOM updates and event triggers.\n */\nexport class GridStackEngine {\n public column: number;\n public maxRow: number;\n public nodes: GridStackNode[];\n public addedNodes: GridStackNode[] = [];\n public removedNodes: GridStackNode[] = [];\n public batchMode: boolean;\n public defaultColumn = 12;\n /** @internal callback to update the DOM attributes */\n protected onChange: OnChangeCB;\n /** @internal */\n protected _float: boolean;\n /** @internal */\n protected _prevFloat: boolean;\n /** @internal cached layouts of difference column count so we can restore back (eg 12 -> 1 -> 12) */\n protected _layouts?: GridStackNode[][]; // maps column # to array of values nodes\n /** @internal set during loading (which is sorted) so item gets added AFTER collision nodes */\n public _loading?: boolean\n /** @internal true while we are resizing widgets during column resize to skip certain parts */\n protected _inColumnResize?: boolean;\n /** true when grid.load() already cached the layout and can skip out of bound caching info */\n public skipCacheUpdate?: boolean;\n /** @internal true if we have some items locked */\n protected _hasLocked: boolean;\n /** @internal unique global internal _id counter */\n public static _idSeq = 0;\n\n public constructor(opts: GridStackEngineOptions = {}) {\n this.column = opts.column || this.defaultColumn;\n if (this.column > this.defaultColumn) this.defaultColumn = this.column;\n this.maxRow = opts.maxRow;\n this._float = opts.float;\n this.nodes = opts.nodes || [];\n this.onChange = opts.onChange;\n }\n\n /**\n * Enable/disable batch mode for multiple operations to optimize performance.\n * When enabled, layout updates are deferred until batch mode is disabled.\n *\n * @param flag true to enable batch mode, false to disable and apply changes\n * @param doPack if true (default), pack/compact nodes when disabling batch mode\n * @returns the engine instance for chaining\n *\n * @example\n * // Start batch mode for multiple operations\n * engine.batchUpdate(true);\n * engine.addNode(node1);\n * engine.addNode(node2);\n * engine.batchUpdate(false); // Apply all changes at once\n */\n public batchUpdate(flag = true, doPack = true): GridStackEngine {\n if (!!this.batchMode === flag) return this;\n this.batchMode = flag;\n if (flag) {\n this._prevFloat = this._float;\n this._float = true; // let things go anywhere for now... will restore and possibly reposition later\n this.cleanNodes();\n this.saveInitial(); // since begin update (which is called multiple times) won't do this\n } else {\n this._float = this._prevFloat;\n delete this._prevFloat;\n if (doPack) this._packNodes();\n this._notify();\n }\n return this;\n }\n\n // use entire row for hitting area (will use bottom reverse sorted first) if we not actively moving DOWN and didn't already skip\n protected _useEntireRowArea(node: GridStackNode, nn: GridStackPosition): boolean {\n return (!this.float || this.batchMode && !this._prevFloat) && !this._hasLocked && (!node._moving || node._skipDown || nn.y <= node.y);\n }\n\n /** @internal fix collision on given 'node', going to given new location 'nn', with optional 'collide' node already found.\n * return true if we moved. */\n protected _fixCollisions(node: GridStackNode, nn = node, collide?: GridStackNode, opt: GridStackMoveOpts = {}): boolean {\n this.sortNodes(-1); // from last to first, so recursive collision move items in the right order\n\n collide = collide || this.collide(node, nn); // REAL area collide for swap and skip if none...\n if (!collide) return false;\n\n // swap check: if we're actively moving in gravity mode, see if we collide with an object the same size\n if (node._moving && !opt.nested && !this.float) {\n if (this.swap(node, collide)) return true;\n }\n\n // during while() collisions MAKE SURE to check entire row so larger items don't leap frog small ones (push them all down starting last in grid)\n let area = nn;\n if (!this._loading && this._useEntireRowArea(node, nn)) {\n area = {x: 0, w: this.column, y: nn.y, h: nn.h};\n collide = this.collide(node, area, opt.skip); // force new hit\n }\n\n let didMove = false;\n const newOpt: GridStackMoveOpts = {nested: true, pack: false};\n let counter = 0;\n while (collide = collide || this.collide(node, area, opt.skip)) { // could collide with more than 1 item... so repeat for each\n if (counter++ > this.nodes.length * 2) {\n throw new Error(\"Infinite collide check\");\n }\n let moved: boolean;\n // if colliding with a locked item OR loading (move after) OR moving down with top gravity (and collide could move up) -> skip past the collide,\n // but remember that skip down so we only do this once (and push others otherwise).\n if (collide.locked || this._loading || node._moving && !node._skipDown && nn.y > node.y && !this.float &&\n // can take space we had, or before where we're going\n (!this.collide(collide, {...collide, y: node.y}, node) || !this.collide(collide, {...collide, y: nn.y - collide.h}, node))) {\n\n node._skipDown = (node._skipDown || nn.y > node.y);\n const newNN = {...nn, y: collide.y + collide.h, ...newOpt};\n // pretent we moved to where we are now so we can continue any collision checks #2492\n moved = this._loading && Utils.samePos(node, newNN) ? true : this.moveNode(node, newNN);\n\n if ((collide.locked || this._loading) && moved) {\n Utils.copyPos(nn, node); // moving after lock become our new desired location\n } else if (!collide.locked && moved && opt.pack) {\n // we moved after and will pack: do it now and keep the original drop location, but past the old collide to see what else we might push way\n this._packNodes();\n nn.y = collide.y + collide.h;\n Utils.copyPos(node, nn);\n }\n didMove = didMove || moved;\n } else {\n // move collide down *after* where we will be, ignoring where we are now (don't collide with us)\n moved = this.moveNode(collide, {...collide, y: nn.y + nn.h, skip: node, ...newOpt});\n }\n\n if (!moved) return didMove; // break inf loop if we couldn't move after all (ex: maxRow, fixed)\n\n collide = undefined;\n }\n return didMove;\n }\n\n /**\n * Return the first node that intercepts/collides with the given node or area.\n * Used for collision detection during drag and drop operations.\n *\n * @param skip the node to skip in collision detection (usually the node being moved)\n * @param area the area to check for collisions (defaults to skip node's area)\n * @param skip2 optional second node to skip in collision detection\n * @returns the first colliding node, or undefined if no collision\n *\n * @example\n * const colliding = engine.collide(draggedNode, {x: 2, y: 1, w: 2, h: 1});\n * if (colliding) {\n * console.log('Would collide with:', colliding.id);\n * }\n */\n public collide(skip: GridStackNode, area = skip, skip2?: GridStackNode): GridStackNode | undefined {\n const skipId = skip._id;\n const skip2Id = skip2?._id;\n return this.nodes.find(n => n._id !== skipId && n._id !== skip2Id && Utils.isIntercepted(n, area));\n }\n /**\n * Return all nodes that intercept/collide with the given node or area.\n * Similar to collide() but returns all colliding nodes instead of just the first.\n *\n * @param skip the node to skip in collision detection\n * @param area the area to check for collisions (defaults to skip node's area)\n * @param skip2 optional second node to skip in collision detection\n * @returns array of all colliding nodes\n *\n * @example\n * const allCollisions = engine.collideAll(draggedNode);\n * console.log('Colliding with', allCollisions.length, 'nodes');\n */\n public collideAll(skip: GridStackNode, area = skip, skip2?: GridStackNode): GridStackNode[] {\n const skipId = skip._id;\n const skip2Id = skip2?._id;\n return this.nodes.filter(n => n._id !== skipId && n._id !== skip2Id && Utils.isIntercepted(n, area));\n }\n\n /** does a pixel coverage collision based on where we started, returning the node that has the most coverage that is >50% mid line */\n protected directionCollideCoverage(node: GridStackNode, o: GridStackMoveOpts, collides: GridStackNode[]): GridStackNode | undefined {\n if (!o.rect || !node._rect) return;\n const r0 = node._rect; // where started\n const r = {...o.rect}; // where we are\n\n // update dragged rect to show where it's coming from (above or below, etc...)\n if (r.y > r0.y) {\n r.h += r.y - r0.y;\n r.y = r0.y;\n } else {\n r.h += r0.y - r.y;\n }\n if (r.x > r0.x) {\n r.w += r.x - r0.x;\n r.x = r0.x;\n } else {\n r.w += r0.x - r.x;\n }\n\n let collide: GridStackNode;\n let overMax = 0.5; // need >50%\n for (let n of collides) {\n if (n.locked || !n._rect) {\n break;\n }\n const r2 = n._rect; // overlapping target\n let yOver = Number.MAX_VALUE, xOver = Number.MAX_VALUE;\n // depending on which side we started from, compute the overlap % of coverage\n // (ex: from above/below we only compute the max horizontal line coverage)\n if (r0.y < r2.y) { // from above\n yOver = ((r.y + r.h) - r2.y) / r2.h;\n } else if (r0.y + r0.h > r2.y + r2.h) { // from below\n yOver = ((r2.y + r2.h) - r.y) / r2.h;\n }\n if (r0.x < r2.x) { // from the left\n xOver = ((r.x + r.w) - r2.x) / r2.w;\n } else if (r0.x + r0.w > r2.x + r2.w) { // from the right\n xOver = ((r2.x + r2.w) - r.x) / r2.w;\n }\n const over = Math.min(xOver, yOver);\n if (over > overMax) {\n overMax = over;\n collide = n;\n }\n }\n o.collide = collide; // save it so we don't have to find it again\n return collide;\n }\n\n /** does a pixel coverage returning the node that has the most coverage by area */\n /*\n protected collideCoverage(r: GridStackPosition, collides: GridStackNode[]): {collide: GridStackNode, over: number} {\n const collide: GridStackNode;\n const overMax = 0;\n collides.forEach(n => {\n if (n.locked || !n._rect) return;\n const over = Utils.areaIntercept(r, n._rect);\n if (over > overMax) {\n overMax = over;\n collide = n;\n }\n });\n return {collide, over: overMax};\n }\n */\n\n /**\n * Cache the pixel rectangles for all nodes used for collision detection during drag operations.\n * This optimization converts grid coordinates to pixel coordinates for faster collision detection.\n *\n * @param w width of a single grid cell in pixels\n * @param h height of a single grid cell in pixels\n * @param top top margin/padding in pixels\n * @param right right margin/padding in pixels\n * @param bottom bottom margin/padding in pixels\n * @param left left margin/padding in pixels\n * @returns the engine instance for chaining\n *\n * @internal This is typically called by GridStack during resize events\n */\n public cacheRects(w: number, h: number, top: number, right: number, bottom: number, left: number): GridStackEngine\n {\n this.nodes.forEach(n =>\n n._rect = {\n y: n.y * h + top,\n x: n.x * w + left,\n w: n.w * w - left - right,\n h: n.h * h - top - bottom\n }\n );\n return this;\n }\n\n /**\n * Attempt to swap the positions of two nodes if they meet swapping criteria.\n * Nodes can swap if they are the same size or in the same column/row, not locked, and touching.\n *\n * @param a first node to swap\n * @param b second node to swap\n * @returns true if swap was successful, false if not possible, undefined if not applicable\n *\n * @example\n * const swapped = engine.swap(nodeA, nodeB);\n * if (swapped) {\n * console.log('Nodes swapped successfully');\n * }\n */\n public swap(a: GridStackNode, b: GridStackNode): boolean | undefined {\n if (!b || b.locked || !a || a.locked) return false;\n\n function _doSwap(): true { // assumes a is before b IFF they have different height (put after rather than exact swap)\n const x = b.x, y = b.y;\n b.x = a.x; b.y = a.y; // b -> a position\n if (a.h != b.h) {\n a.x = x; a.y = b.y + b.h; // a -> goes after b\n } else if (a.w != b.w) {\n a.x = b.x + b.w; a.y = y; // a -> goes after b\n } else {\n a.x = x; a.y = y; // a -> old b position\n }\n a._dirty = b._dirty = true;\n return true;\n }\n let touching: boolean; // remember if we called it (vs undefined)\n\n // same size and same row or column, and touching\n if (a.w === b.w && a.h === b.h && (a.x === b.x || a.y === b.y) && (touching = Utils.isTouching(a, b)))\n return _doSwap();\n if (touching === false) return; // IFF ran test and fail, bail out\n\n // check for taking same columns (but different height) and touching\n if (a.w === b.w && a.x === b.x && (touching || (touching = Utils.isTouching(a, b)))) {\n if (b.y < a.y) { const t = a; a = b; b = t; } // swap a <-> b vars so a is first\n return _doSwap();\n }\n if (touching === false) return;\n\n // check if taking same row (but different width) and touching\n if (a.h === b.h && a.y === b.y && (touching || (touching = Utils.isTouching(a, b)))) {\n if (b.x < a.x) { const t = a; a = b; b = t; } // swap a <-> b vars so a is first\n return _doSwap();\n }\n return false;\n }\n\n /**\n * Check if the specified rectangular area is empty (no nodes occupy any part of it).\n *\n * @param x the x coordinate (column) of the area to check\n * @param y the y coordinate (row) of the area to check\n * @param w the width in columns of the area to check\n * @param h the height in rows of the area to check\n * @returns true if the area is completely empty, false if any node overlaps\n *\n * @example\n * if (engine.isAreaEmpty(2, 1, 3, 2)) {\n * console.log('Area is available for placement');\n * }\n */\n public isAreaEmpty(x: number, y: number, w: number, h: number): boolean {\n const nn: GridStackNode = {x: x || 0, y: y || 0, w: w || 1, h: h || 1};\n return !this.collide(nn);\n }\n\n /**\n * Re-layout grid items to reclaim any empty space.\n * This optimizes the grid layout by moving items to fill gaps.\n *\n * @param layout layout algorithm to use:\n * - 'compact' (default): find truly empty spaces, may reorder items\n * - 'list': keep the sort order exactly the same, move items up sequentially\n * @param doSort if true (default), sort nodes by position before compacting\n * @returns the engine instance for chaining\n *\n * @example\n * // Compact to fill empty spaces\n * engine.compact();\n *\n * // Compact preserving item order\n * engine.compact('list');\n */\n public compact(layout: CompactOptions = 'compact', doSort = true): GridStackEngine {\n if (this.nodes.length === 0) return this;\n if (doSort) this.sortNodes();\n const wasBatch = this.batchMode;\n if (!wasBatch) this.batchUpdate();\n const wasColumnResize = this._inColumnResize;\n if (!wasColumnResize) this._inColumnResize = true; // faster addNode()\n const copyNodes = this.nodes;\n this.nodes = []; // pretend we have no nodes to conflict layout to start with...\n copyNodes.forEach((n, index, list) => {\n let after: GridStackNode;\n if (!n.locked) {\n n.autoPosition = true;\n if (layout === 'list' && index) after = list[index - 1];\n }\n this.addNode(n, false, after); // 'false' for add event trigger\n });\n if (!wasColumnResize) delete this._inColumnResize;\n if (!wasBatch) this.batchUpdate(false);\n return this;\n }\n\n /**\n * Enable/disable floating widgets (default: `false`).\n * When floating is enabled, widgets can move up to fill empty spaces.\n * See [example](http://gridstackjs.com/demo/float.html)\n *\n * @param val true to enable floating, false to disable\n *\n * @example\n * engine.float = true; // Enable floating\n * engine.float = false; // Disable floating (default)\n */\n public set float(val: boolean) {\n if (this._float === val) return;\n this._float = val || false;\n if (!val) {\n this._packNodes()._notify();\n }\n }\n\n /**\n * Get the current floating mode setting.\n *\n * @returns true if floating is enabled, false otherwise\n *\n * @example\n * const isFloating = engine.float;\n * console.log('Floating enabled:', isFloating);\n */\n public get float(): boolean { return this._float || false; }\n\n /**\n * Sort the nodes array from first to last, or reverse.\n * This is called during collision/placement operations to enforce a specific order.\n *\n * @param dir sort direction: 1 for ascending (first to last), -1 for descending (last to first)\n * @returns the engine instance for chaining\n *\n * @example\n * engine.sortNodes(); // Sort ascending (default)\n * engine.sortNodes(-1); // Sort descending\n */\n public sortNodes(dir: 1 | -1 = 1): GridStackEngine {\n this.nodes = Utils.sort(this.nodes, dir);\n return this;\n }\n\n /** @internal called to top gravity pack the items back OR revert back to original Y positions when floating */\n protected _packNodes(): GridStackEngine {\n if (this.batchMode) { return this; }\n this.sortNodes(); // first to last\n\n if (this.float) {\n // restore original Y pos\n this.nodes.forEach(n => {\n if (n._updating || n._orig === undefined || n.y === n._orig.y) return;\n let newY = n.y;\n while (newY > n._orig.y) {\n --newY;\n const collide = this.collide(n, {x: n.x, y: newY, w: n.w, h: n.h});\n if (!collide) {\n n._dirty = true;\n n.y = newY;\n }\n }\n });\n } else {\n // top gravity pack\n this.nodes.forEach((n, i) => {\n if (n.locked) return;\n while (n.y > 0) {\n const newY = i === 0 ? 0 : n.y - 1;\n const canBeMoved = i === 0 || !this.collide(n, {x: n.x, y: newY, w: n.w, h: n.h});\n if (!canBeMoved) break;\n // Note: must be dirty (from last position) for GridStack::OnChange CB to update positions\n // and move items back. The user 'change' CB should detect changes from the original\n // starting position instead.\n n._dirty = (n.y !== newY);\n n.y = newY;\n }\n });\n }\n return this;\n }\n\n /**\n * Prepare and validate a node's coordinates and values for the current grid.\n * This ensures the node has valid position, size, and properties before being added to the grid.\n *\n * @param node the node to prepare and validate\n * @param resizing if true, resize the node down if it's out of bounds; if false, move it to fit\n * @returns the prepared node with valid coordinates\n *\n * @example\n * const node = { w: 3, h: 2, content: 'Hello' };\n * const prepared = engine.prepareNode(node);\n * console.log('Node prepared at:', prepared.x, prepared.y);\n */\n public prepareNode(node: GridStackNode, resizing?: boolean): GridStackNode {\n node._id = node._id ?? GridStackEngine._idSeq++;\n\n // make sure USER supplied id are unique in our list, else assign a new one as it will create issues during load/update/etc...\n const id = node.id;\n if (id) {\n let count = 1; // append nice _n rather than some random number\n while (this.nodes.find(n => n.id === node.id && n !== node)) {\n node.id = id + '_' + (count++);\n }\n }\n\n // if we're missing position, have the grid position us automatically (before we set them to 0,0)\n if (node.x === undefined || node.y === undefined || node.x === null || node.y === null) {\n node.autoPosition = true;\n }\n\n // assign defaults for missing required fields\n const defaults: GridStackNode = { x: 0, y: 0, w: 1, h: 1};\n Utils.defaults(node, defaults);\n\n if (!node.autoPosition) { delete node.autoPosition; }\n if (!node.noResize) { delete node.noResize; }\n if (!node.noMove) { delete node.noMove; }\n Utils.sanitizeMinMax(node);\n\n // check for NaN (in case messed up strings were passed. can't do parseInt() || defaults.x above as 0 is valid #)\n if (typeof node.x == 'string') { node.x = Number(node.x); }\n if (typeof node.y == 'string') { node.y = Number(node.y); }\n if (typeof node.w == 'string') { node.w = Number(node.w); }\n if (typeof node.h == 'string') { node.h = Number(node.h); }\n if (isNaN(node.x)) { node.x = defaults.x; node.autoPosition = true; }\n if (isNaN(node.y)) { node.y = defaults.y; node.autoPosition = true; }\n if (isNaN(node.w)) { node.w = defaults.w; }\n if (isNaN(node.h)) { node.h = defaults.h; }\n\n this.nodeBoundFix(node, resizing);\n return node;\n }\n\n /**\n * Part 2 of preparing a node to fit inside the grid - validates and fixes coordinates and dimensions.\n * This ensures the node fits within grid boundaries and respects min/max constraints.\n *\n * @param node the node to validate and fix\n * @param resizing if true, resize the node to fit; if false, move the node to fit\n * @returns the engine instance for chaining\n *\n * @example\n * // Fix a node that might be out of bounds\n * engine.nodeBoundFix(node, true); // Resize to fit\n * engine.nodeBoundFix(node, false); // Move to fit\n */\n public nodeBoundFix(node: GridStackNode, resizing?: boolean): GridStackEngine {\n\n const before = node._orig || Utils.copyPos({}, node);\n\n if (node.maxW) { node.w = Math.min(node.w || 1, node.maxW); }\n if (node.maxH) { node.h = Math.min(node.h || 1, node.maxH); }\n if (node.minW) { node.w = Math.max(node.w || 1, node.minW); }\n if (node.minH) { node.h = Math.max(node.h || 1, node.minH); }\n\n // if user loaded a larger than allowed widget for current # of columns,\n // remember it's position & width so we can restore back (1 -> 12 column) #1655 #1985\n // IFF we're not in the middle of column resizing!\n const saveOrig = (node.x || 0) + (node.w || 1) > this.column;\n if (saveOrig && this.column < this.defaultColumn && !this._inColumnResize && !this.skipCacheUpdate && node._id != null && this.findCacheLayout(node, this.defaultColumn) === -1) {\n const copy = {...node}; // need _id + positions\n if (copy.autoPosition || copy.x === undefined) { delete copy.x; delete copy.y; }\n else copy.x = Math.min(this.defaultColumn - 1, copy.x);\n copy.w = Math.min(this.defaultColumn, copy.w || 1);\n this.cacheOneLayout(copy, this.defaultColumn);\n }\n\n if (node.w > this.column) {\n node.w = this.column;\n } else if (node.w < 1) {\n node.w = 1;\n }\n\n if (this.maxRow && node.h > this.maxRow) {\n node.h = this.maxRow;\n } else if (node.h < 1) {\n node.h = 1;\n }\n\n if (node.x < 0) {\n node.x = 0;\n }\n if (node.y < 0) {\n node.y = 0;\n }\n\n if (node.x + node.w > this.column) {\n if (resizing) {\n node.w = this.column - node.x;\n } else {\n node.x = this.column - node.w;\n }\n }\n if (this.maxRow && node.y + node.h > this.maxRow) {\n if (resizing) {\n node.h = this.maxRow - node.y;\n } else {\n node.y = this.maxRow - node.h;\n }\n }\n\n if (!Utils.samePos(node, before)) {\n node._dirty = true;\n }\n\n return this;\n }\n\n /**\n * Returns a list of nodes that have been modified from their original values.\n * This is used to track which nodes need DOM updates.\n *\n * @param verify if true, performs additional verification by comparing current vs original positions\n * @returns array of nodes that have been modified\n *\n * @example\n * const changed = engine.getDirtyNodes();\n * console.log('Modified nodes:', changed.length);\n *\n * // Get verified dirty nodes\n * const verified = engine.getDirtyNodes(true);\n */\n public getDirtyNodes(verify?: boolean): GridStackNode[] {\n // compare original x,y,w,h instead as _dirty can be a temporary state\n if (verify) {\n return this.nodes.filter(n => n._dirty && !Utils.samePos(n, n._orig));\n }\n return this.nodes.filter(n => n._dirty);\n }\n\n /** @internal call this to call onChange callback with dirty nodes so DOM can be updated */\n protected _notify(removedNodes?: GridStackNode[]): GridStackEngine {\n if (this.batchMode || !this.onChange) return this;\n const dirtyNodes = (removedNodes || []).concat(this.getDirtyNodes());\n this.onChange(dirtyNodes);\n return this;\n }\n\n /**\n * Clean all dirty and last tried information from nodes.\n * This resets the dirty state tracking for all nodes.\n *\n * @returns the engine instance for chaining\n *\n * @internal\n */\n public cleanNodes(): GridStackEngine {\n if (this.batchMode) return this;\n this.nodes.forEach(n => {\n delete n._dirty;\n delete n._lastTried;\n });\n return this;\n }\n\n /**\n * Save the initial position/size of all nodes to track real dirty state.\n * This creates a snapshot of current positions that can be restored later.\n *\n * Note: Should be called right after change events and before move/resize operations.\n *\n * @returns the engine instance for chaining\n *\n * @internal\n */\n public saveInitial(): GridStackEngine {\n this.nodes.forEach(n => {\n n._orig = Utils.copyPos({}, n);\n delete n._dirty;\n });\n this._hasLocked = this.nodes.some(n => n.locked);\n return this;\n }\n\n /**\n * Restore all nodes back to their initial values.\n * This is typically called when canceling an operation (e.g., Esc key during drag).\n *\n * @returns the engine instance for chaining\n *\n * @internal\n */\n public restoreInitial(): GridStackEngine {\n this.nodes.forEach(n => {\n if (!n._orig || Utils.samePos(n, n._orig)) return;\n Utils.copyPos(n, n._orig);\n n._dirty = true;\n });\n this._notify();\n return this;\n }\n\n /**\n * Find the first available empty spot for the given node dimensions.\n * Updates the node's x,y attributes with the found position.\n *\n * @param node the node to find a position for (w,h must be set)\n * @param nodeList optional list of nodes to check against (defaults to engine nodes)\n * @param column optional column count (defaults to engine column count)\n * @param after optional node to start search after (maintains order)\n * @returns true if an empty position was found and node was updated\n *\n * @example\n * const node = { w: 2, h: 1 };\n * if (engine.findEmptyPosition(node)) {\n * console.log('Found position at:', node.x, node.y);\n * }\n */\n public findEmptyPosition(node: GridStackNode, nodeList = this.nodes, column = this.column, after?: GridStackNode): boolean {\n const start = after ? after.y * column + (after.x + after.w) : 0;\n let found = false;\n for (let i = start; !found; ++i) {\n const x = i % column;\n const y = Math.floor(i / column);\n if (x + node.w > column) {\n continue;\n }\n const box = {x, y, w: node.w, h: node.h};\n if (!nodeList.find(n => Utils.isIntercepted(box, n))) {\n if (node.x !== x || node.y !== y) node._dirty = true;\n node.x = x;\n node.y = y;\n delete node.autoPosition;\n found = true;\n }\n }\n return found;\n }\n\n /**\n * Add the given node to the grid, handling collision detection and re-packing.\n * This is the main method for adding new widgets to the engine.\n *\n * @param node the node to add to the grid\n * @param triggerAddEvent if true, adds node to addedNodes list for event triggering\n * @param after optional node to place this node after (for ordering)\n * @returns the added node (or existing node if duplicate)\n *\n * @example\n * const node = { x: 0, y: 0, w: 2, h: 1, content: 'Hello' };\n * const added = engine.addNode(node, true);\n */\n public addNode(node: GridStackNode, triggerAddEvent = false, after?: GridStackNode): GridStackNode {\n const dup = this.nodes.find(n => n._id === node._id);\n if (dup) return dup; // prevent inserting twice! return it instead.\n\n // skip prepareNode if we're in middle of column resize (not new) but do check for bounds!\n this._inColumnResize ? this.nodeBoundFix(node) : this.prepareNode(node);\n delete node._temporaryRemoved;\n delete node._removeDOM;\n\n let skipCollision: boolean;\n if (node.autoPosition && this.findEmptyPosition(node, this.nodes, this.column, after)) {\n delete node.autoPosition; // found our slot\n skipCollision = true;\n }\n\n this.nodes.push(node);\n if (triggerAddEvent) { this.addedNodes.push(node); }\n\n if (!skipCollision) this._fixCollisions(node);\n if (!this.batchMode) { this._packNodes()._notify(); }\n return node;\n }\n\n /**\n * Remove the given node from the grid.\n *\n * @param node the node to remove\n * @param removeDOM if true (default), marks node for DOM removal\n * @param triggerEvent if true, adds node to removedNodes list for event triggering\n * @returns the engine instance for chaining\n *\n * @example\n * engine.removeNode(node, true, true);\n */\n public removeNode(node: GridStackNode, removeDOM = true, triggerEvent = false): GridStackEngine {\n if (!this.nodes.find(n => n._id === node._id)) {\n // TEST console.log(`Error: GridStackEngine.removeNode() node._id=${node._id} not found!`)\n return this;\n }\n if (triggerEvent) { // we wait until final drop to manually track removed items (rather than during drag)\n this.removedNodes.push(node);\n }\n if (removeDOM) node._removeDOM = true; // let CB remove actual HTML (used to set _id to null, but then we loose layout info)\n // don't use 'faster' .splice(findIndex(),1) in case node isn't in our list, or in multiple times.\n this.nodes = this.nodes.filter(n => n._id !== node._id);\n if (!node._isAboutToRemove) this._packNodes(); // if dragged out, no need to relayout as already done...\n this._notify([node]);\n return this;\n }\n\n /**\n * Remove all nodes from the grid.\n *\n * @param removeDOM if true (default), marks all nodes for DOM removal\n * @param triggerEvent if true (default), triggers removal events\n * @returns the engine instance for chaining\n *\n * @example\n * engine.removeAll(); // Remove all nodes\n */\n public removeAll(removeDOM = true, triggerEvent = true): GridStackEngine {\n delete this._layouts;\n if (!this.nodes.length) return this;\n removeDOM && this.nodes.forEach(n => n._removeDOM = true); // let CB remove actual HTML (used to set _id to null, but then we loose layout info)\n const removedNodes = this.nodes;\n this.removedNodes = triggerEvent ? removedNodes : [];\n this.nodes = [];\n return this._notify(removedNodes);\n }\n\n /**\n * Check if a node can be moved to a new position, considering layout constraints.\n * This is a safer version of moveNode() that validates the move first.\n *\n * For complex cases (like maxRow constraints), it simulates the move in a clone first,\n * then applies the changes only if they meet all specifications.\n *\n * @param node the node to move\n * @param o move options including target position\n * @returns true if the node was successfully moved\n *\n * @example\n * const canMove = engine.moveNodeCheck(node, { x: 2, y: 1 });\n * if (canMove) {\n * console.log('Node moved successfully');\n * }\n */\n public moveNodeCheck(node: GridStackNode, o: GridStackMoveOpts): boolean {\n // if (node.locked) return false;\n if (!this.changedPosConstrain(node, o)) return false;\n o.pack = true;\n\n // simpler case: move item directly...\n if (!this.maxRow) {\n return this.moveNode(node, o);\n }\n\n // complex case: create a clone with NO maxRow (will check for out of bounds at the end)\n let clonedNode: GridStackNode;\n const clone = new GridStackEngine({\n column: this.column,\n float: this.float,\n nodes: this.nodes.map(n => {\n if (n._id === node._id) {\n clonedNode = {...n};\n return clonedNode;\n }\n return {...n};\n })\n });\n if (!clonedNode) return false;\n\n // check if we're covering 50% collision and could move, while still being under maxRow or at least not making it worse\n // (case where widget was somehow added past our max #2449)\n const canMove = clone.moveNode(clonedNode, o) && clone.getRow() <= Math.max(this.getRow(), this.maxRow);\n // else check if we can force a swap (float=true, or different shapes) on non-resize\n if (!canMove && !o.resizing && o.collide) {\n const collide = o.collide.el.gridstackNode; // find the source node the clone collided with at 50%\n if (this.swap(node, collide)) { // swaps and mark dirty\n this._notify();\n return true;\n }\n }\n if (!canMove) return false;\n\n // if clone was able to move, copy those mods over to us now instead of caller trying to do this all over!\n // Note: we can't use the list directly as elements and other parts point to actual node, so copy content\n clone.nodes.filter(n => n._dirty).forEach(c => {\n const n = this.nodes.find(a => a._id === c._id);\n if (!n) return;\n Utils.copyPos(n, c);\n n._dirty = true;\n });\n this._notify();\n return true;\n }\n\n /** return true if can fit in grid height constrain only (always true if no maxRow) */\n public willItFit(node: GridStackNode): boolean {\n delete node._willFitPos;\n if (!this.maxRow) return true;\n // create a clone with NO maxRow and check if still within size\n const clone = new GridStackEngine({\n column: this.column,\n float: this.float,\n nodes: this.nodes.map(n => {return {...n}})\n });\n const n = {...node}; // clone node so we don't mod any settings on it but have full autoPosition and min/max as well! #1687\n this.cleanupNode(n);\n delete n.el; delete n._id; delete n.content; delete n.grid;\n clone.addNode(n);\n if (clone.getRow() <= this.maxRow) {\n node._willFitPos = Utils.copyPos({}, n);\n return true;\n }\n return false;\n }\n\n /** true if x,y or w,h are different after clamping to min/max */\n public changedPosConstrain(node: GridStackNode, p: GridStackPosition): boolean {\n // first make sure w,h are set for caller\n p.w = p.w || node.w;\n p.h = p.h || node.h;\n if (node.x !== p.x || node.y !== p.y) return true;\n // check constrained w,h\n if (node.maxW) { p.w = Math.min(p.w, node.maxW); }\n if (node.maxH) { p.h = Math.min(p.h, node.maxH); }\n if (node.minW) { p.w = Math.max(p.w, node.minW); }\n if (node.minH) { p.h = Math.max(p.h, node.minH); }\n return (node.w !== p.w || node.h !== p.h);\n }\n\n /** return true if the passed in node was actually moved (checks for no-op and locked) */\n public moveNode(node: GridStackNode, o: GridStackMoveOpts): boolean {\n if (!node || /*node.locked ||*/ !o) return false;\n let wasUndefinedPack: boolean;\n if (o.pack === undefined && !this.batchMode) {\n wasUndefinedPack = o.pack = true;\n }\n\n // constrain the passed in values and check if we're still changing our node\n if (typeof o.x !== 'number') { o.x = node.x; }\n if (typeof o.y !== 'number') { o.y = node.y; }\n if (typeof o.w !== 'number') { o.w = node.w; }\n if (typeof o.h !== 'number') { o.h = node.h; }\n const resizing = (node.w !== o.w || node.h !== o.h);\n const nn: GridStackNode = Utils.copyPos({}, node, true); // get min/max out first, then opt positions next\n Utils.copyPos(nn, o);\n this.nodeBoundFix(nn, resizing);\n Utils.copyPos(o, nn);\n\n if (!o.forceCollide && Utils.samePos(node, o)) return false;\n const prevPos: GridStackPosition = Utils.copyPos({}, node);\n\n // check if we will need to fix collision at our new location\n const collides = this.collideAll(node, nn, o.skip);\n let needToMove = true;\n if (collides.length) {\n const activeDrag = node._moving && !o.nested;\n // check to make sure we actually collided over 50% surface area while dragging\n let collide = activeDrag ? this.directionCollideCoverage(node, o, collides) : collides[0];\n // if we're enabling creation of sub-grids on the fly, see if we're covering 80% of either one, if we didn't already do that\n if (activeDrag && collide && node.grid?.opts?.subGridDynamic && !node.grid._isTemp) {\n const over = Utils.areaIntercept(o.rect, collide._rect);\n const a1 = Utils.area(o.rect);\n const a2 = Utils.area(collide._rect);\n const perc = over / (a1 < a2 ? a1 : a2);\n if (perc > .8) {\n collide.grid.makeSubGrid(collide.el, undefined, node);\n collide = undefined;\n }\n }\n\n if (collide) {\n needToMove = !this._fixCollisions(node, nn, collide, o); // check if already moved...\n } else {\n needToMove = false; // we didn't cover >50% for a move, skip...\n if (wasUndefinedPack) delete o.pack;\n }\n }\n\n // now move (to the original ask vs the collision version which might differ) and repack things\n if (needToMove && !Utils.samePos(node, nn)) {\n node._dirty = true;\n Utils.copyPos(node, nn);\n }\n if (o.pack) {\n this._packNodes()\n ._notify();\n }\n return !Utils.samePos(node, prevPos); // pack might have moved things back\n }\n\n public getRow(): number {\n return this.nodes.reduce((row, n) => Math.max(row, n.y + n.h), 0);\n }\n\n public beginUpdate(node: GridStackNode): GridStackEngine {\n if (!node._updating) {\n node._updating = true;\n delete node._skipDown;\n if (!this.batchMode) this.saveInitial();\n }\n return this;\n }\n\n public endUpdate(): GridStackEngine {\n const n = this.nodes.find(n => n._updating);\n if (n) {\n delete n._updating;\n delete n._skipDown;\n }\n return this;\n }\n\n /** saves a copy of the largest column layout (eg 12 even when rendering 1 column) so we don't loose orig layout, unless explicity column\n * count to use is given. returning a list of widgets for serialization\n * @param saveElement if true (default), the element will be saved to GridStackWidget.el field, else it will be removed.\n * @param saveCB callback for each node -> widget, so application can insert additional data to be saved into the widget data structure.\n * @param column if provided, the grid will be saved for the given column count (IFF we have matching internal saved layout, or current layout).\n * Note: nested grids will ALWAYS save the container w to match overall layouts (parent + child) to be consistent.\n */\n public save(saveElement = true, saveCB?: SaveFcn, column?: number): GridStackNode[] {\n // use the highest layout for any saved info so we can have full detail on reload #1849\n // unless we're given a column to match (always set for nested grids)\n const len = this._layouts?.length || 0;\n let layout: GridStackNode[];\n if (len) {\n if (column) {\n if (column !== this.column) layout = this._layouts[column];\n } else if (this.column !== len - 1) {\n layout = this._layouts[len - 1];\n }\n }\n const list: GridStackNode[] = [];\n this.sortNodes();\n this.nodes.forEach(n => {\n const wl = layout?.find(l => l._id === n._id);\n // use layout info fields instead if set\n const w: GridStackNode = {...n, ...(wl || {})};\n Utils.removeInternalForSave(w, !saveElement);\n if (saveCB) saveCB(n, w);\n list.push(w);\n });\n return list;\n }\n\n /** @internal called whenever a node is added or moved - updates the cached layouts */\n public layoutsNodesChange(nodes: GridStackNode[]): GridStackEngine {\n if (!this._layouts || this._inColumnResize) return this;\n // remove smaller layouts - we will re-generate those on the fly... larger ones need to update\n this._layouts.forEach((layout, column) => {\n if (!layout || column === this.column) return this;\n if (column < this.column) {\n this._layouts[column] = undefined;\n }\n else {\n // we save the original x,y,w (h isn't cached) to see what actually changed to propagate better.\n // NOTE: we don't need to check against out of bound scaling/moving as that will be done when using those cache values. #1785\n const ratio = column / this.column;\n nodes.forEach(node => {\n if (!node._orig) return; // didn't change (newly added ?)\n const n = layout.find(l => l._id === node._id);\n if (!n) return; // no cache for new nodes. Will use those values.\n // Y changed, push down same amount\n // TODO: detect doing item 'swaps' will help instead of move (especially in 1 column mode)\n if (n.y >= 0 && node.y !== node._orig.y) {\n n.y += (node.y - node._orig.y);\n if (n.y < 0) n.y = 0;\n }\n // X changed, scale from new position\n if (node.x !== node._orig.x) {\n n.x = Math.round(node.x * ratio);\n if (n.x < 0) n.x = 0;\n }\n // width changed, scale from new width\n if (node.w !== node._orig.w) {\n n.w = Math.round(node.w * ratio);\n if (n.w < 1) n.w = 1;\n }\n // ...height always carries over from cache\n });\n }\n });\n return this;\n }\n\n /**\n * @internal Called to scale the widget width & position up/down based on the column change.\n * Note we store previous layouts (especially original ones) to make it possible to go\n * from say 12 -> 1 -> 12 and get back to where we were.\n *\n * @param prevColumn previous number of columns\n * @param column new column number\n * @param layout specify the type of re-layout that will happen (position, size, etc...).\n * Note: items will never be outside of the current column boundaries. default (moveScale). Ignored for 1 column\n */\n public columnChanged(prevColumn: number, column: number, layout: ColumnOptions = 'moveScale'): GridStackEngine {\n if (!this.nodes.length || !column || prevColumn === column) return this;\n\n // simpler shortcuts layouts\n const doCompact = layout === 'compact' || layout === 'list';\n if (doCompact) {\n this.sortNodes(1); // sort with original layout once and only once (new column will affect order otherwise)\n }\n\n // cache the current layout in case they want to go back (like 12 -> 1 -> 12) as it requires original data IFF we're sizing down (see below)\n if (column < prevColumn) this.cacheLayout(this.nodes, prevColumn);\n this.batchUpdate(); // do this EARLY as it will call saveInitial() so we can detect where we started for _dirty and collision\n let newNodes: GridStackNode[] = [];\n let nodes = doCompact ? this.nodes : Utils.sort(this.nodes, -1); // current column reverse sorting so we can insert last to front (limit collision)\n\n // see if we have cached previous layout IFF we are going up in size (restore) otherwise always\n // generate next size down from where we are (looks more natural as you gradually size down).\n if (column > prevColumn && this._layouts) {\n const cacheNodes = this._layouts[column] || [];\n // ...if not, start with the largest layout (if not already there) as down-scaling is more accurate\n // by pretending we came from that larger column by assigning those values as starting point\n const lastIndex = this._layouts.length - 1;\n if (!cacheNodes.length && prevColumn !== lastIndex && this._layouts[lastIndex]?.length) {\n prevColumn = lastIndex;\n this._layouts[lastIndex].forEach(cacheNode => {\n const n = nodes.find(n => n._id === cacheNode._id);\n if (n) {\n // still current, use cache info positions\n if (!doCompact && !cacheNode.autoPosition) {\n n.x = cacheNode.x ?? n.x;\n n.y = cacheNode.y ?? n.y;\n }\n n.w = cacheNode.w ?? n.w;\n if (cacheNode.x == undefined || cacheNode.y === undefined) n.autoPosition = true;\n }\n });\n }\n\n // if we found cache re-use those nodes that are still current\n cacheNodes.forEach(cacheNode => {\n const j = nodes.findIndex(n => n._id === cacheNode._id);\n if (j !== -1) {\n const n = nodes[j];\n // still current, use cache info positions\n if (doCompact) {\n n.w = cacheNode.w; // only w is used, and don't trim the list\n return;\n }\n if (cacheNode.autoPosition || isNaN(cacheNode.x) || isNaN(cacheNode.y)) {\n this.findEmptyPosition(cacheNode, newNodes);\n }\n if (!cacheNode.autoPosition) {\n n.x = cacheNode.x ?? n.x;\n n.y = cacheNode.y ?? n.y;\n n.w = cacheNode.w ?? n.w;\n newNodes.push(n);\n }\n nodes.splice(j, 1);\n }\n });\n }\n\n // much simpler layout that just compacts\n if (doCompact) {\n this.compact(layout, false);\n } else {\n // ...and add any extra non-cached ones\n if (nodes.length) {\n if (typeof layout === 'function') {\n layout(column, prevColumn, newNodes, nodes);\n } else {\n const ratio = (doCompact || layout === 'none') ? 1 : column / prevColumn;\n const move = (layout === 'move' || layout === 'moveScale');\n const scale = (layout === 'scale' || layout === 'moveScale');\n nodes.forEach(node => {\n // NOTE: x + w could be outside of the grid, but addNode() below will handle that\n node.x = (column === 1 ? 0 : (move ? Math.round(node.x * ratio) : Math.min(node.x, column - 1)));\n node.w = ((column === 1 || prevColumn === 1) ? 1 : scale ? (Math.round(node.w * ratio) || 1) : (Math.min(node.w, column)));\n newNodes.push(node);\n });\n nodes = [];\n }\n }\n\n // finally re-layout them in reverse order (to get correct placement)\n newNodes = Utils.sort(newNodes, -1);\n this._inColumnResize = true; // prevent cache update\n this.nodes = []; // pretend we have no nodes to start with (add() will use same structures) to simplify layout\n newNodes.forEach(node => {\n this.addNode(node, false); // 'false' for add event trigger\n delete node._orig; // make sure the commit doesn't try to restore things back to original\n });\n }\n\n this.nodes.forEach(n => delete n._orig); // clear _orig before batch=false so it doesn't handle float=true restore\n this.batchUpdate(false, !doCompact);\n delete this._inColumnResize;\n return this;\n }\n\n /**\n * call to cache the given layout internally to the given location so we can restore back when column changes size\n * @param nodes list of nodes\n * @param column corresponding column index to save it under\n * @param clear if true, will force other caches to be removed (default false)\n */\n public cacheLayout(nodes: GridStackNode[], column: number, clear = false): GridStackEngine {\n const copy: GridStackNode[] = [];\n nodes.forEach((n, i) => {\n // make sure we have an id in case this is new layout, else re-use id already set\n if (n._id === undefined) {\n const existing = n.id ? this.nodes.find(n2 => n2.id === n.id) : undefined; // find existing node using users id\n n._id = existing?._id ?? GridStackEngine._idSeq++;\n }\n copy[i] = {x: n.x, y: n.y, w: n.w, _id: n._id} // only thing we change is x,y,w and id to find it back\n });\n this._layouts = clear ? [] : this._layouts || []; // use array to find larger quick\n this._layouts[column] = copy;\n return this;\n }\n\n /**\n * call to cache the given node layout internally to the given location so we can restore back when column changes size\n * @param node single node to cache\n * @param column corresponding column index to save it under\n */\n public cacheOneLayout(n: GridStackNode, column: number): GridStackEngine {\n n._id = n._id ?? GridStackEngine._idSeq++;\n const l: GridStackNode = {x: n.x, y: n.y, w: n.w, _id: n._id}\n if (n.autoPosition || n.x === undefined) { delete l.x; delete l.y; if (n.autoPosition) l.autoPosition = true; }\n this._layouts = this._layouts || [];\n this._layouts[column] = this._layouts[column] || [];\n const index = this.findCacheLayout(n, column);\n if (index === -1)\n this._layouts[column].push(l);\n else\n this._layouts[column][index] = l;\n return this;\n }\n\n protected findCacheLayout(n: GridStackNode, column: number): number | undefined {\n return this._layouts?.[column]?.findIndex(l => l._id === n._id) ?? -1;\n }\n\n public removeNodeFromLayoutCache(n: GridStackNode) {\n if (!this._layouts) {\n return;\n }\n for (let i = 0; i < this._layouts.length; i++) {\n const index = this.findCacheLayout(n, i);\n if (index !== -1) {\n this._layouts[i].splice(index, 1);\n }\n }\n }\n\n /** called to remove all internal values but the _id */\n public cleanupNode(node: GridStackNode): GridStackEngine {\n for (const prop in node) {\n if (prop[0] === '_' && prop !== '_id') delete node[prop];\n }\n return this;\n }\n}\n"]}
1
+ {"version":3,"file":"gridstack-engine.js","sourceRoot":"","sources":["../src/gridstack-engine.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAehC;;;;;;;;;;;;GAYG;AACH,MAAa,eAAe;IA2B1B,YAAmB,OAA+B,EAAE;QAvB7C,eAAU,GAAoB,EAAE,CAAC;QACjC,iBAAY,GAAoB,EAAE,CAAC;QAEnC,kBAAa,GAAG,EAAE,CAAC;QAqBxB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,aAAa,CAAC;QA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,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;aACnC;SACF;IACH,CAAC;IAED,uDAAuD;IAChD,WAAW,CAAC,IAAmB;QACpC,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE;YACvB,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,IAAI,KAAK,KAAK;gBAAE,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC;SAC1D;QACD,OAAO,IAAI,CAAC;IACd,CAAC;;AA7qCD,mDAAmD;AACrC,sBAAM,GAAG,CAAC,AAAJ,CAAK;SAzBd,eAAe","sourcesContent":["/**\n * gridstack-engine.ts 12.5.0\n * Copyright (c) 2021-2025 Alain Dumesny - see GridStack root license\n */\n\nimport { Utils } from './utils';\nimport { GridStackNode, ColumnOptions, GridStackPosition, GridStackMoveOpts, SaveFcn, CompactOptions } from './types';\n\n/** callback to update the DOM attributes since this class is generic (no HTML or other info) for items that changed - see _notify() */\ntype OnChangeCB = (nodes: GridStackNode[]) => void;\n\n/** options used during creation - similar to GridStackOptions */\nexport interface GridStackEngineOptions {\n column?: number;\n maxRow?: number;\n float?: boolean;\n nodes?: GridStackNode[];\n onChange?: OnChangeCB;\n}\n\n/**\n * Defines the GridStack engine that handles all grid layout calculations and node positioning.\n * This is the core engine that performs grid manipulation without any DOM operations.\n *\n * The engine manages:\n * - Node positioning and collision detection\n * - Layout algorithms (compact, float, etc.)\n * - Grid resizing and column changes\n * - Widget movement and resizing logic\n *\n * NOTE: Values should not be modified directly - use the main GridStack API instead\n * to ensure proper DOM updates and event triggers.\n */\nexport class GridStackEngine {\n public column: number;\n public maxRow: number;\n public nodes: GridStackNode[];\n public addedNodes: GridStackNode[] = [];\n public removedNodes: GridStackNode[] = [];\n public batchMode: boolean;\n public defaultColumn = 12;\n /** @internal callback to update the DOM attributes */\n protected onChange: OnChangeCB;\n /** @internal */\n protected _float: boolean;\n /** @internal */\n protected _prevFloat: boolean;\n /** @internal cached layouts of difference column count so we can restore back (eg 12 -> 1 -> 12) */\n protected _layouts?: GridStackNode[][]; // maps column # to array of values nodes\n /** @internal set during loading (which is sorted) so item gets added AFTER collision nodes */\n public _loading?: boolean\n /** @internal true while we are resizing widgets during column resize to skip certain parts */\n protected _inColumnResize?: boolean;\n /** true when grid.load() already cached the layout and can skip out of bound caching info */\n public skipCacheUpdate?: boolean;\n /** @internal true if we have some items locked */\n protected _hasLocked: boolean;\n /** @internal unique global internal _id counter */\n public static _idSeq = 0;\n\n public constructor(opts: GridStackEngineOptions = {}) {\n this.column = opts.column || this.defaultColumn;\n if (this.column > this.defaultColumn) this.defaultColumn = this.column;\n this.maxRow = opts.maxRow;\n this._float = opts.float;\n this.nodes = opts.nodes || [];\n this.onChange = opts.onChange;\n }\n\n /**\n * Enable/disable batch mode for multiple operations to optimize performance.\n * When enabled, layout updates are deferred until batch mode is disabled.\n *\n * @param flag true to enable batch mode, false to disable and apply changes\n * @param doPack if true (default), pack/compact nodes when disabling batch mode\n * @returns the engine instance for chaining\n *\n * @example\n * // Start batch mode for multiple operations\n * engine.batchUpdate(true);\n * engine.addNode(node1);\n * engine.addNode(node2);\n * engine.batchUpdate(false); // Apply all changes at once\n */\n public batchUpdate(flag = true, doPack = true): GridStackEngine {\n if (!!this.batchMode === flag) return this;\n this.batchMode = flag;\n if (flag) {\n this._prevFloat = this._float;\n this._float = true; // let things go anywhere for now... will restore and possibly reposition later\n this.cleanNodes();\n this.saveInitial(); // since begin update (which is called multiple times) won't do this\n } else {\n this._float = this._prevFloat;\n delete this._prevFloat;\n if (doPack) this._packNodes();\n this._notify();\n }\n return this;\n }\n\n // use entire row for hitting area (will use bottom reverse sorted first) if we not actively moving DOWN and didn't already skip\n protected _useEntireRowArea(node: GridStackNode, nn: GridStackPosition): boolean {\n return (!this.float || this.batchMode && !this._prevFloat) && !this._hasLocked && (!node._moving || node._skipDown || nn.y <= node.y);\n }\n\n /** @internal fix collision on given 'node', going to given new location 'nn', with optional 'collide' node already found.\n * return true if we moved. */\n protected _fixCollisions(node: GridStackNode, nn = node, collide?: GridStackNode, opt: GridStackMoveOpts = {}): boolean {\n this.sortNodes(-1); // from last to first, so recursive collision move items in the right order\n\n collide = collide || this.collide(node, nn); // REAL area collide for swap and skip if none...\n if (!collide) return false;\n\n // swap check: if we're actively moving in gravity mode, see if we collide with an object the same size\n if (node._moving && !opt.nested && !this.float) {\n if (this.swap(node, collide)) return true;\n }\n\n // during while() collisions MAKE SURE to check entire row so larger items don't leap frog small ones (push them all down starting last in grid)\n let area = nn;\n if (!this._loading && this._useEntireRowArea(node, nn)) {\n area = {x: 0, w: this.column, y: nn.y, h: nn.h};\n collide = this.collide(node, area, opt.skip); // force new hit\n }\n\n let didMove = false;\n const newOpt: GridStackMoveOpts = {nested: true, pack: false};\n let counter = 0;\n while (collide = collide || this.collide(node, area, opt.skip)) { // could collide with more than 1 item... so repeat for each\n if (counter++ > this.nodes.length * 2) {\n throw new Error(\"Infinite collide check\");\n }\n let moved: boolean;\n // if colliding with a locked item OR loading (move after) OR moving down with top gravity (and collide could move up) -> skip past the collide,\n // but remember that skip down so we only do this once (and push others otherwise).\n if (collide.locked || this._loading || node._moving && !node._skipDown && nn.y > node.y && !this.float &&\n // can take space we had, or before where we're going\n (!this.collide(collide, {...collide, y: node.y}, node) || !this.collide(collide, {...collide, y: nn.y - collide.h}, node))) {\n\n node._skipDown = (node._skipDown || nn.y > node.y);\n const newNN = {...nn, y: collide.y + collide.h, ...newOpt};\n // pretent we moved to where we are now so we can continue any collision checks #2492\n moved = this._loading && Utils.samePos(node, newNN) ? true : this.moveNode(node, newNN);\n\n if ((collide.locked || this._loading) && moved) {\n Utils.copyPos(nn, node); // moving after lock become our new desired location\n } else if (!collide.locked && moved && opt.pack) {\n // we moved after and will pack: do it now and keep the original drop location, but past the old collide to see what else we might push way\n this._packNodes();\n nn.y = collide.y + collide.h;\n Utils.copyPos(node, nn);\n }\n didMove = didMove || moved;\n } else {\n // move collide down *after* where we will be, ignoring where we are now (don't collide with us)\n moved = this.moveNode(collide, {...collide, y: nn.y + nn.h, skip: node, ...newOpt});\n }\n\n if (!moved) return didMove; // break inf loop if we couldn't move after all (ex: maxRow, fixed)\n\n collide = undefined;\n }\n return didMove;\n }\n\n /**\n * Return the first node that intercepts/collides with the given node or area.\n * Used for collision detection during drag and drop operations.\n *\n * @param skip the node to skip in collision detection (usually the node being moved)\n * @param area the area to check for collisions (defaults to skip node's area)\n * @param skip2 optional second node to skip in collision detection\n * @returns the first colliding node, or undefined if no collision\n *\n * @example\n * const colliding = engine.collide(draggedNode, {x: 2, y: 1, w: 2, h: 1});\n * if (colliding) {\n * console.log('Would collide with:', colliding.id);\n * }\n */\n public collide(skip: GridStackNode, area = skip, skip2?: GridStackNode): GridStackNode | undefined {\n const skipId = skip._id;\n const skip2Id = skip2?._id;\n return this.nodes.find(n => n._id !== skipId && n._id !== skip2Id && Utils.isIntercepted(n, area));\n }\n /**\n * Return all nodes that intercept/collide with the given node or area.\n * Similar to collide() but returns all colliding nodes instead of just the first.\n *\n * @param skip the node to skip in collision detection\n * @param area the area to check for collisions (defaults to skip node's area)\n * @param skip2 optional second node to skip in collision detection\n * @returns array of all colliding nodes\n *\n * @example\n * const allCollisions = engine.collideAll(draggedNode);\n * console.log('Colliding with', allCollisions.length, 'nodes');\n */\n public collideAll(skip: GridStackNode, area = skip, skip2?: GridStackNode): GridStackNode[] {\n const skipId = skip._id;\n const skip2Id = skip2?._id;\n return this.nodes.filter(n => n._id !== skipId && n._id !== skip2Id && Utils.isIntercepted(n, area));\n }\n\n /** does a pixel coverage collision based on where we started, returning the node that has the most coverage that is >50% mid line */\n protected directionCollideCoverage(node: GridStackNode, o: GridStackMoveOpts, collides: GridStackNode[]): GridStackNode | undefined {\n if (!o.rect || !node._rect) return;\n const r0 = node._rect; // where started\n const r = {...o.rect}; // where we are\n\n // update dragged rect to show where it's coming from (above or below, etc...)\n if (r.y > r0.y) {\n r.h += r.y - r0.y;\n r.y = r0.y;\n } else {\n r.h += r0.y - r.y;\n }\n if (r.x > r0.x) {\n r.w += r.x - r0.x;\n r.x = r0.x;\n } else {\n r.w += r0.x - r.x;\n }\n\n let collide: GridStackNode;\n let overMax = 0.5; // need >50%\n for (let n of collides) {\n if (n.locked || !n._rect) {\n break;\n }\n const r2 = n._rect; // overlapping target\n let yOver = Number.MAX_VALUE, xOver = Number.MAX_VALUE;\n // depending on which side we started from, compute the overlap % of coverage\n // (ex: from above/below we only compute the max horizontal line coverage)\n if (r0.y < r2.y) { // from above\n yOver = ((r.y + r.h) - r2.y) / r2.h;\n } else if (r0.y + r0.h > r2.y + r2.h) { // from below\n yOver = ((r2.y + r2.h) - r.y) / r2.h;\n }\n if (r0.x < r2.x) { // from the left\n xOver = ((r.x + r.w) - r2.x) / r2.w;\n } else if (r0.x + r0.w > r2.x + r2.w) { // from the right\n xOver = ((r2.x + r2.w) - r.x) / r2.w;\n }\n const over = Math.min(xOver, yOver);\n if (over > overMax) {\n overMax = over;\n collide = n;\n }\n }\n o.collide = collide; // save it so we don't have to find it again\n return collide;\n }\n\n /** does a pixel coverage returning the node that has the most coverage by area */\n /*\n protected collideCoverage(r: GridStackPosition, collides: GridStackNode[]): {collide: GridStackNode, over: number} {\n const collide: GridStackNode;\n const overMax = 0;\n collides.forEach(n => {\n if (n.locked || !n._rect) return;\n const over = Utils.areaIntercept(r, n._rect);\n if (over > overMax) {\n overMax = over;\n collide = n;\n }\n });\n return {collide, over: overMax};\n }\n */\n\n /**\n * Cache the pixel rectangles for all nodes used for collision detection during drag operations.\n * This optimization converts grid coordinates to pixel coordinates for faster collision detection.\n *\n * @param w width of a single grid cell in pixels\n * @param h height of a single grid cell in pixels\n * @param top top margin/padding in pixels\n * @param right right margin/padding in pixels\n * @param bottom bottom margin/padding in pixels\n * @param left left margin/padding in pixels\n * @returns the engine instance for chaining\n *\n * @internal This is typically called by GridStack during resize events\n */\n public cacheRects(w: number, h: number, top: number, right: number, bottom: number, left: number): GridStackEngine\n {\n this.nodes.forEach(n =>\n n._rect = {\n y: n.y * h + top,\n x: n.x * w + left,\n w: n.w * w - left - right,\n h: n.h * h - top - bottom\n }\n );\n return this;\n }\n\n /**\n * Attempt to swap the positions of two nodes if they meet swapping criteria.\n * Nodes can swap if they are the same size or in the same column/row, not locked, and touching.\n *\n * @param a first node to swap\n * @param b second node to swap\n * @returns true if swap was successful, false if not possible, undefined if not applicable\n *\n * @example\n * const swapped = engine.swap(nodeA, nodeB);\n * if (swapped) {\n * console.log('Nodes swapped successfully');\n * }\n */\n public swap(a: GridStackNode, b: GridStackNode): boolean | undefined {\n if (!b || b.locked || !a || a.locked) return false;\n\n function _doSwap(): true { // assumes a is before b IFF they have different height (put after rather than exact swap)\n const x = b.x, y = b.y;\n b.x = a.x; b.y = a.y; // b -> a position\n if (a.h != b.h) {\n a.x = x; a.y = b.y + b.h; // a -> goes after b\n } else if (a.w != b.w) {\n a.x = b.x + b.w; a.y = y; // a -> goes after b\n } else {\n a.x = x; a.y = y; // a -> old b position\n }\n a._dirty = b._dirty = true;\n return true;\n }\n let touching: boolean; // remember if we called it (vs undefined)\n\n // same size and same row or column, and touching\n if (a.w === b.w && a.h === b.h && (a.x === b.x || a.y === b.y) && (touching = Utils.isTouching(a, b)))\n return _doSwap();\n if (touching === false) return; // IFF ran test and fail, bail out\n\n // check for taking same columns (but different height) and touching\n if (a.w === b.w && a.x === b.x && (touching || (touching = Utils.isTouching(a, b)))) {\n if (b.y < a.y) { const t = a; a = b; b = t; } // swap a <-> b vars so a is first\n return _doSwap();\n }\n if (touching === false) return;\n\n // check if taking same row (but different width) and touching\n if (a.h === b.h && a.y === b.y && (touching || (touching = Utils.isTouching(a, b)))) {\n if (b.x < a.x) { const t = a; a = b; b = t; } // swap a <-> b vars so a is first\n return _doSwap();\n }\n return false;\n }\n\n /**\n * Check if the specified rectangular area is empty (no nodes occupy any part of it).\n *\n * @param x the x coordinate (column) of the area to check\n * @param y the y coordinate (row) of the area to check\n * @param w the width in columns of the area to check\n * @param h the height in rows of the area to check\n * @returns true if the area is completely empty, false if any node overlaps\n *\n * @example\n * if (engine.isAreaEmpty(2, 1, 3, 2)) {\n * console.log('Area is available for placement');\n * }\n */\n public isAreaEmpty(x: number, y: number, w: number, h: number): boolean {\n const nn: GridStackNode = {x: x || 0, y: y || 0, w: w || 1, h: h || 1};\n return !this.collide(nn);\n }\n\n /**\n * Re-layout grid items to reclaim any empty space.\n * This optimizes the grid layout by moving items to fill gaps.\n *\n * @param layout layout algorithm to use:\n * - 'compact' (default): find truly empty spaces, may reorder items\n * - 'list': keep the sort order exactly the same, move items up sequentially\n * @param doSort if true (default), sort nodes by position before compacting\n * @returns the engine instance for chaining\n *\n * @example\n * // Compact to fill empty spaces\n * engine.compact();\n *\n * // Compact preserving item order\n * engine.compact('list');\n */\n public compact(layout: CompactOptions = 'compact', doSort = true): GridStackEngine {\n if (this.nodes.length === 0) return this;\n if (doSort) this.sortNodes();\n const wasBatch = this.batchMode;\n if (!wasBatch) this.batchUpdate();\n const wasColumnResize = this._inColumnResize;\n if (!wasColumnResize) this._inColumnResize = true; // faster addNode()\n const copyNodes = this.nodes;\n this.nodes = []; // pretend we have no nodes to conflict layout to start with...\n copyNodes.forEach((n, index, list) => {\n let after: GridStackNode;\n if (!n.locked) {\n n.autoPosition = true;\n if (layout === 'list' && index) after = list[index - 1];\n }\n this.addNode(n, false, after); // 'false' for add event trigger\n });\n if (!wasColumnResize) delete this._inColumnResize;\n if (!wasBatch) this.batchUpdate(false);\n return this;\n }\n\n /**\n * Enable/disable floating widgets (default: `false`).\n * When floating is enabled, widgets can move up to fill empty spaces.\n * See [example](http://gridstackjs.com/demo/float.html)\n *\n * @param val true to enable floating, false to disable\n *\n * @example\n * engine.float = true; // Enable floating\n * engine.float = false; // Disable floating (default)\n */\n public set float(val: boolean) {\n if (this._float === val) return;\n this._float = val || false;\n if (!val) {\n this._packNodes()._notify();\n }\n }\n\n /**\n * Get the current floating mode setting.\n *\n * @returns true if floating is enabled, false otherwise\n *\n * @example\n * const isFloating = engine.float;\n * console.log('Floating enabled:', isFloating);\n */\n public get float(): boolean { return this._float || false; }\n\n /**\n * Sort the nodes array from first to last, or reverse.\n * This is called during collision/placement operations to enforce a specific order.\n *\n * @param dir sort direction: 1 for ascending (first to last), -1 for descending (last to first)\n * @returns the engine instance for chaining\n *\n * @example\n * engine.sortNodes(); // Sort ascending (default)\n * engine.sortNodes(-1); // Sort descending\n */\n public sortNodes(dir: 1 | -1 = 1): GridStackEngine {\n this.nodes = Utils.sort(this.nodes, dir);\n return this;\n }\n\n /** @internal called to top gravity pack the items back OR revert back to original Y positions when floating */\n protected _packNodes(): GridStackEngine {\n if (this.batchMode) { return this; }\n this.sortNodes(); // first to last\n\n if (this.float) {\n // restore original Y pos\n this.nodes.forEach(n => {\n if (n._updating || n._orig === undefined || n.y === n._orig.y) return;\n let newY = n.y;\n while (newY > n._orig.y) {\n --newY;\n const collide = this.collide(n, {x: n.x, y: newY, w: n.w, h: n.h});\n if (!collide) {\n n._dirty = true;\n n.y = newY;\n }\n }\n });\n } else {\n // top gravity pack\n this.nodes.forEach((n, i) => {\n if (n.locked) return;\n while (n.y > 0) {\n const newY = i === 0 ? 0 : n.y - 1;\n const canBeMoved = i === 0 || !this.collide(n, {x: n.x, y: newY, w: n.w, h: n.h});\n if (!canBeMoved) break;\n // Note: must be dirty (from last position) for GridStack::OnChange CB to update positions\n // and move items back. The user 'change' CB should detect changes from the original\n // starting position instead.\n n._dirty = (n.y !== newY);\n n.y = newY;\n }\n });\n }\n return this;\n }\n\n /**\n * Prepare and validate a node's coordinates and values for the current grid.\n * This ensures the node has valid position, size, and properties before being added to the grid.\n *\n * @param node the node to prepare and validate\n * @param resizing if true, resize the node down if it's out of bounds; if false, move it to fit\n * @returns the prepared node with valid coordinates\n *\n * @example\n * const node = { w: 3, h: 2, content: 'Hello' };\n * const prepared = engine.prepareNode(node);\n * console.log('Node prepared at:', prepared.x, prepared.y);\n */\n public prepareNode(node: GridStackNode, resizing?: boolean): GridStackNode {\n node._id = node._id ?? GridStackEngine._idSeq++;\n\n // make sure USER supplied id are unique in our list, else assign a new one as it will create issues during load/update/etc...\n const id = node.id;\n if (id) {\n let count = 1; // append nice _n rather than some random number\n while (this.nodes.find(n => n.id === node.id && n !== node)) {\n node.id = id + '_' + (count++);\n }\n }\n\n // if we're missing position, have the grid position us automatically (before we set them to 0,0)\n if (node.x === undefined || node.y === undefined || node.x === null || node.y === null) {\n node.autoPosition = true;\n }\n\n // assign defaults for missing required fields\n const defaults: GridStackNode = { x: 0, y: 0, w: 1, h: 1};\n Utils.defaults(node, defaults);\n\n if (!node.autoPosition) { delete node.autoPosition; }\n if (!node.noResize) { delete node.noResize; }\n if (!node.noMove) { delete node.noMove; }\n Utils.sanitizeMinMax(node);\n\n // check for NaN (in case messed up strings were passed. can't do parseInt() || defaults.x above as 0 is valid #)\n if (typeof node.x == 'string') { node.x = Number(node.x); }\n if (typeof node.y == 'string') { node.y = Number(node.y); }\n if (typeof node.w == 'string') { node.w = Number(node.w); }\n if (typeof node.h == 'string') { node.h = Number(node.h); }\n if (isNaN(node.x)) { node.x = defaults.x; node.autoPosition = true; }\n if (isNaN(node.y)) { node.y = defaults.y; node.autoPosition = true; }\n if (isNaN(node.w)) { node.w = defaults.w; }\n if (isNaN(node.h)) { node.h = defaults.h; }\n\n this.nodeBoundFix(node, resizing);\n return node;\n }\n\n /**\n * Part 2 of preparing a node to fit inside the grid - validates and fixes coordinates and dimensions.\n * This ensures the node fits within grid boundaries and respects min/max constraints.\n *\n * @param node the node to validate and fix\n * @param resizing if true, resize the node to fit; if false, move the node to fit\n * @returns the engine instance for chaining\n *\n * @example\n * // Fix a node that might be out of bounds\n * engine.nodeBoundFix(node, true); // Resize to fit\n * engine.nodeBoundFix(node, false); // Move to fit\n */\n public nodeBoundFix(node: GridStackNode, resizing?: boolean): GridStackEngine {\n\n const before = node._orig || Utils.copyPos({}, node);\n\n if (node.maxW) { node.w = Math.min(node.w || 1, node.maxW); }\n if (node.maxH) { node.h = Math.min(node.h || 1, node.maxH); }\n if (node.minW) { node.w = Math.max(node.w || 1, node.minW); }\n if (node.minH) { node.h = Math.max(node.h || 1, node.minH); }\n\n // if user loaded a larger than allowed widget for current # of columns,\n // remember it's position & width so we can restore back (1 -> 12 column) #1655 #1985\n // IFF we're not in the middle of column resizing!\n const saveOrig = (node.x || 0) + (node.w || 1) > this.column;\n if (saveOrig && this.column < this.defaultColumn && !this._inColumnResize && !this.skipCacheUpdate && node._id != null && this.findCacheLayout(node, this.defaultColumn) === -1) {\n const copy = {...node}; // need _id + positions\n if (copy.autoPosition || copy.x === undefined) { delete copy.x; delete copy.y; }\n else copy.x = Math.min(this.defaultColumn - 1, copy.x);\n copy.w = Math.min(this.defaultColumn, copy.w || 1);\n this.cacheOneLayout(copy, this.defaultColumn);\n }\n\n if (node.w > this.column) {\n node.w = this.column;\n } else if (node.w < 1) {\n node.w = 1;\n }\n\n if (this.maxRow && node.h > this.maxRow) {\n node.h = this.maxRow;\n } else if (node.h < 1) {\n node.h = 1;\n }\n\n if (node.x < 0) {\n node.x = 0;\n }\n if (node.y < 0) {\n node.y = 0;\n }\n\n if (node.x + node.w > this.column) {\n if (resizing) {\n node.w = this.column - node.x;\n } else {\n node.x = this.column - node.w;\n }\n }\n if (this.maxRow && node.y + node.h > this.maxRow) {\n if (resizing) {\n node.h = this.maxRow - node.y;\n } else {\n node.y = this.maxRow - node.h;\n }\n }\n\n if (!Utils.samePos(node, before)) {\n node._dirty = true;\n }\n\n return this;\n }\n\n /**\n * Returns a list of nodes that have been modified from their original values.\n * This is used to track which nodes need DOM updates.\n *\n * @param verify if true, performs additional verification by comparing current vs original positions\n * @returns array of nodes that have been modified\n *\n * @example\n * const changed = engine.getDirtyNodes();\n * console.log('Modified nodes:', changed.length);\n *\n * // Get verified dirty nodes\n * const verified = engine.getDirtyNodes(true);\n */\n public getDirtyNodes(verify?: boolean): GridStackNode[] {\n // compare original x,y,w,h instead as _dirty can be a temporary state\n if (verify) {\n return this.nodes.filter(n => n._dirty && !Utils.samePos(n, n._orig));\n }\n return this.nodes.filter(n => n._dirty);\n }\n\n /** @internal call this to call onChange callback with dirty nodes so DOM can be updated */\n protected _notify(removedNodes?: GridStackNode[]): GridStackEngine {\n if (this.batchMode || !this.onChange) return this;\n const dirtyNodes = (removedNodes || []).concat(this.getDirtyNodes());\n this.onChange(dirtyNodes);\n return this;\n }\n\n /**\n * Clean all dirty and last tried information from nodes.\n * This resets the dirty state tracking for all nodes.\n *\n * @returns the engine instance for chaining\n *\n * @internal\n */\n public cleanNodes(): GridStackEngine {\n if (this.batchMode) return this;\n this.nodes.forEach(n => {\n delete n._dirty;\n delete n._lastTried;\n });\n return this;\n }\n\n /**\n * Save the initial position/size of all nodes to track real dirty state.\n * This creates a snapshot of current positions that can be restored later.\n *\n * Note: Should be called right after change events and before move/resize operations.\n *\n * @returns the engine instance for chaining\n *\n * @internal\n */\n public saveInitial(): GridStackEngine {\n this.nodes.forEach(n => {\n n._orig = Utils.copyPos({}, n);\n delete n._dirty;\n });\n this._hasLocked = this.nodes.some(n => n.locked);\n return this;\n }\n\n /**\n * Restore all nodes back to their initial values.\n * This is typically called when canceling an operation (e.g., Esc key during drag).\n *\n * @returns the engine instance for chaining\n *\n * @internal\n */\n public restoreInitial(): GridStackEngine {\n this.nodes.forEach(n => {\n if (!n._orig || Utils.samePos(n, n._orig)) return;\n Utils.copyPos(n, n._orig);\n n._dirty = true;\n });\n this._notify();\n return this;\n }\n\n /**\n * Find the first available empty spot for the given node dimensions.\n * Updates the node's x,y attributes with the found position.\n *\n * @param node the node to find a position for (w,h must be set)\n * @param nodeList optional list of nodes to check against (defaults to engine nodes)\n * @param column optional column count (defaults to engine column count)\n * @param after optional node to start search after (maintains order)\n * @returns true if an empty position was found and node was updated\n *\n * @example\n * const node = { w: 2, h: 1 };\n * if (engine.findEmptyPosition(node)) {\n * console.log('Found position at:', node.x, node.y);\n * }\n */\n public findEmptyPosition(node: GridStackNode, nodeList = this.nodes, column = this.column, after?: GridStackNode): boolean {\n const start = after ? after.y * column + (after.x + after.w) : 0;\n let found = false;\n for (let i = start; !found; ++i) {\n const x = i % column;\n const y = Math.floor(i / column);\n if (x + node.w > column) {\n continue;\n }\n const box = {x, y, w: node.w, h: node.h};\n if (!nodeList.find(n => Utils.isIntercepted(box, n))) {\n if (node.x !== x || node.y !== y) node._dirty = true;\n node.x = x;\n node.y = y;\n delete node.autoPosition;\n found = true;\n }\n }\n return found;\n }\n\n /**\n * Add the given node to the grid, handling collision detection and re-packing.\n * This is the main method for adding new widgets to the engine.\n *\n * @param node the node to add to the grid\n * @param triggerAddEvent if true, adds node to addedNodes list for event triggering\n * @param after optional node to place this node after (for ordering)\n * @returns the added node (or existing node if duplicate)\n *\n * @example\n * const node = { x: 0, y: 0, w: 2, h: 1, content: 'Hello' };\n * const added = engine.addNode(node, true);\n */\n public addNode(node: GridStackNode, triggerAddEvent = false, after?: GridStackNode): GridStackNode {\n const dup = this.nodes.find(n => n._id === node._id);\n if (dup) return dup; // prevent inserting twice! return it instead.\n\n // skip prepareNode if we're in middle of column resize (not new) but do check for bounds!\n this._inColumnResize ? this.nodeBoundFix(node) : this.prepareNode(node);\n delete node._temporaryRemoved;\n delete node._removeDOM;\n\n let skipCollision: boolean;\n if (node.autoPosition && this.findEmptyPosition(node, this.nodes, this.column, after)) {\n delete node.autoPosition; // found our slot\n skipCollision = true;\n }\n\n this.nodes.push(node);\n if (triggerAddEvent) { this.addedNodes.push(node); }\n\n if (!skipCollision) this._fixCollisions(node);\n if (!this.batchMode) { this._packNodes()._notify(); }\n return node;\n }\n\n /**\n * Remove the given node from the grid.\n *\n * @param node the node to remove\n * @param removeDOM if true (default), marks node for DOM removal\n * @param triggerEvent if true, adds node to removedNodes list for event triggering\n * @returns the engine instance for chaining\n *\n * @example\n * engine.removeNode(node, true, true);\n */\n public removeNode(node: GridStackNode, removeDOM = true, triggerEvent = false): GridStackEngine {\n if (!this.nodes.find(n => n._id === node._id)) {\n // TEST console.log(`Error: GridStackEngine.removeNode() node._id=${node._id} not found!`)\n return this;\n }\n if (triggerEvent) { // we wait until final drop to manually track removed items (rather than during drag)\n this.removedNodes.push(node);\n }\n if (removeDOM) node._removeDOM = true; // let CB remove actual HTML (used to set _id to null, but then we loose layout info)\n // don't use 'faster' .splice(findIndex(),1) in case node isn't in our list, or in multiple times.\n this.nodes = this.nodes.filter(n => n._id !== node._id);\n if (!node._isAboutToRemove) this._packNodes(); // if dragged out, no need to relayout as already done...\n this._notify([node]);\n return this;\n }\n\n /**\n * Remove all nodes from the grid.\n *\n * @param removeDOM if true (default), marks all nodes for DOM removal\n * @param triggerEvent if true (default), triggers removal events\n * @returns the engine instance for chaining\n *\n * @example\n * engine.removeAll(); // Remove all nodes\n */\n public removeAll(removeDOM = true, triggerEvent = true): GridStackEngine {\n delete this._layouts;\n if (!this.nodes.length) return this;\n removeDOM && this.nodes.forEach(n => n._removeDOM = true); // let CB remove actual HTML (used to set _id to null, but then we loose layout info)\n const removedNodes = this.nodes;\n this.removedNodes = triggerEvent ? removedNodes : [];\n this.nodes = [];\n return this._notify(removedNodes);\n }\n\n /**\n * Check if a node can be moved to a new position, considering layout constraints.\n * This is a safer version of moveNode() that validates the move first.\n *\n * For complex cases (like maxRow constraints), it simulates the move in a clone first,\n * then applies the changes only if they meet all specifications.\n *\n * @param node the node to move\n * @param o move options including target position\n * @returns true if the node was successfully moved\n *\n * @example\n * const canMove = engine.moveNodeCheck(node, { x: 2, y: 1 });\n * if (canMove) {\n * console.log('Node moved successfully');\n * }\n */\n public moveNodeCheck(node: GridStackNode, o: GridStackMoveOpts): boolean {\n // if (node.locked) return false;\n if (!this.changedPosConstrain(node, o)) return false;\n o.pack = true;\n\n // simpler case: move item directly...\n if (!this.maxRow) {\n return this.moveNode(node, o);\n }\n\n // complex case: create a clone with NO maxRow (will check for out of bounds at the end)\n let clonedNode: GridStackNode;\n const clone = new GridStackEngine({\n column: this.column,\n float: this.float,\n nodes: this.nodes.map(n => {\n if (n._id === node._id) {\n clonedNode = {...n};\n return clonedNode;\n }\n return {...n};\n })\n });\n if (!clonedNode) return false;\n\n // check if we're covering 50% collision and could move, while still being under maxRow or at least not making it worse\n // (case where widget was somehow added past our max #2449)\n const canMove = clone.moveNode(clonedNode, o) && clone.getRow() <= Math.max(this.getRow(), this.maxRow);\n // else check if we can force a swap (float=true, or different shapes) on non-resize\n if (!canMove && !o.resizing && o.collide) {\n const collide = o.collide.el.gridstackNode; // find the source node the clone collided with at 50%\n if (this.swap(node, collide)) { // swaps and mark dirty\n this._notify();\n return true;\n }\n }\n if (!canMove) return false;\n\n // if clone was able to move, copy those mods over to us now instead of caller trying to do this all over!\n // Note: we can't use the list directly as elements and other parts point to actual node, so copy content\n clone.nodes.filter(n => n._dirty).forEach(c => {\n const n = this.nodes.find(a => a._id === c._id);\n if (!n) return;\n Utils.copyPos(n, c);\n n._dirty = true;\n });\n this._notify();\n return true;\n }\n\n /** return true if can fit in grid height constrain only (always true if no maxRow) */\n public willItFit(node: GridStackNode): boolean {\n delete node._willFitPos;\n if (!this.maxRow) return true;\n // create a clone with NO maxRow and check if still within size\n const clone = new GridStackEngine({\n column: this.column,\n float: this.float,\n nodes: this.nodes.map(n => {return {...n}})\n });\n const n = {...node}; // clone node so we don't mod any settings on it but have full autoPosition and min/max as well! #1687\n this.cleanupNode(n);\n delete n.el; delete n._id; delete n.content; delete n.grid;\n clone.addNode(n);\n if (clone.getRow() <= this.maxRow) {\n node._willFitPos = Utils.copyPos({}, n);\n return true;\n }\n return false;\n }\n\n /** true if x,y or w,h are different after clamping to min/max */\n public changedPosConstrain(node: GridStackNode, p: GridStackPosition): boolean {\n // first make sure w,h are set for caller\n p.w = p.w || node.w;\n p.h = p.h || node.h;\n if (node.x !== p.x || node.y !== p.y) return true;\n // check constrained w,h\n if (node.maxW) { p.w = Math.min(p.w, node.maxW); }\n if (node.maxH) { p.h = Math.min(p.h, node.maxH); }\n if (node.minW) { p.w = Math.max(p.w, node.minW); }\n if (node.minH) { p.h = Math.max(p.h, node.minH); }\n return (node.w !== p.w || node.h !== p.h);\n }\n\n /** return true if the passed in node was actually moved (checks for no-op and locked) */\n public moveNode(node: GridStackNode, o: GridStackMoveOpts): boolean {\n if (!node || /*node.locked ||*/ !o) return false;\n let wasUndefinedPack: boolean;\n if (o.pack === undefined && !this.batchMode) {\n wasUndefinedPack = o.pack = true;\n }\n\n // constrain the passed in values and check if we're still changing our node\n if (typeof o.x !== 'number') { o.x = node.x; }\n if (typeof o.y !== 'number') { o.y = node.y; }\n if (typeof o.w !== 'number') { o.w = node.w; }\n if (typeof o.h !== 'number') { o.h = node.h; }\n const resizing = (node.w !== o.w || node.h !== o.h);\n const nn: GridStackNode = Utils.copyPos({}, node, true); // get min/max out first, then opt positions next\n Utils.copyPos(nn, o);\n this.nodeBoundFix(nn, resizing);\n Utils.copyPos(o, nn);\n\n if (!o.forceCollide && Utils.samePos(node, o)) return false;\n const prevPos: GridStackPosition = Utils.copyPos({}, node);\n\n // check if we will need to fix collision at our new location\n const collides = this.collideAll(node, nn, o.skip);\n let needToMove = true;\n if (collides.length) {\n const activeDrag = node._moving && !o.nested;\n // check to make sure we actually collided over 50% surface area while dragging\n let collide = activeDrag ? this.directionCollideCoverage(node, o, collides) : collides[0];\n // if we're enabling creation of sub-grids on the fly, see if we're covering 80% of either one, if we didn't already do that\n if (activeDrag && collide && node.grid?.opts?.subGridDynamic && !node.grid._isTemp) {\n const over = Utils.areaIntercept(o.rect, collide._rect);\n const a1 = Utils.area(o.rect);\n const a2 = Utils.area(collide._rect);\n const perc = over / (a1 < a2 ? a1 : a2);\n if (perc > .8) {\n collide.grid.makeSubGrid(collide.el, undefined, node);\n collide = undefined;\n }\n }\n\n if (collide) {\n needToMove = !this._fixCollisions(node, nn, collide, o); // check if already moved...\n } else {\n needToMove = false; // we didn't cover >50% for a move, skip...\n if (wasUndefinedPack) delete o.pack;\n }\n }\n\n // now move (to the original ask vs the collision version which might differ) and repack things\n if (needToMove && !Utils.samePos(node, nn)) {\n node._dirty = true;\n Utils.copyPos(node, nn);\n }\n if (o.pack) {\n this._packNodes()\n ._notify();\n }\n return !Utils.samePos(node, prevPos); // pack might have moved things back\n }\n\n public getRow(): number {\n return this.nodes.reduce((row, n) => Math.max(row, n.y + n.h), 0);\n }\n\n public beginUpdate(node: GridStackNode): GridStackEngine {\n if (!node._updating) {\n node._updating = true;\n delete node._skipDown;\n if (!this.batchMode) this.saveInitial();\n }\n return this;\n }\n\n public endUpdate(): GridStackEngine {\n const n = this.nodes.find(n => n._updating);\n if (n) {\n delete n._updating;\n delete n._skipDown;\n }\n return this;\n }\n\n /** saves a copy of the largest column layout (eg 12 even when rendering 1 column) so we don't loose orig layout, unless explicity column\n * count to use is given. returning a list of widgets for serialization\n * @param saveElement if true (default), the element will be saved to GridStackWidget.el field, else it will be removed.\n * @param saveCB callback for each node -> widget, so application can insert additional data to be saved into the widget data structure.\n * @param column if provided, the grid will be saved for the given column count (IFF we have matching internal saved layout, or current layout).\n * Note: nested grids will ALWAYS save the container w to match overall layouts (parent + child) to be consistent.\n */\n public save(saveElement = true, saveCB?: SaveFcn, column?: number): GridStackNode[] {\n // use the highest layout for any saved info so we can have full detail on reload #1849\n // unless we're given a column to match (always set for nested grids)\n const len = this._layouts?.length || 0;\n let layout: GridStackNode[];\n if (len) {\n if (column) {\n if (column !== this.column) layout = this._layouts[column];\n } else if (this.column !== len - 1) {\n layout = this._layouts[len - 1];\n }\n }\n const list: GridStackNode[] = [];\n this.sortNodes();\n this.nodes.forEach(n => {\n const wl = layout?.find(l => l._id === n._id);\n // use layout info fields instead if set\n const w: GridStackNode = {...n, ...(wl || {})};\n Utils.removeInternalForSave(w, !saveElement);\n if (saveCB) saveCB(n, w);\n list.push(w);\n });\n return list;\n }\n\n /** @internal called whenever a node is added or moved - updates the cached layouts */\n public layoutsNodesChange(nodes: GridStackNode[]): GridStackEngine {\n if (!this._layouts || this._inColumnResize) return this;\n // remove smaller layouts - we will re-generate those on the fly... larger ones need to update\n this._layouts.forEach((layout, column) => {\n if (!layout || column === this.column) return this;\n if (column < this.column) {\n this._layouts[column] = undefined;\n }\n else {\n // we save the original x,y,w (h isn't cached) to see what actually changed to propagate better.\n // NOTE: we don't need to check against out of bound scaling/moving as that will be done when using those cache values. #1785\n const ratio = column / this.column;\n nodes.forEach(node => {\n if (!node._orig) return; // didn't change (newly added ?)\n const n = layout.find(l => l._id === node._id);\n if (!n) return; // no cache for new nodes. Will use those values.\n // Y changed, push down same amount\n // TODO: detect doing item 'swaps' will help instead of move (especially in 1 column mode)\n if (n.y >= 0 && node.y !== node._orig.y) {\n n.y += (node.y - node._orig.y);\n if (n.y < 0) n.y = 0;\n }\n // X changed, scale from new position\n if (node.x !== node._orig.x) {\n n.x = Math.round(node.x * ratio);\n if (n.x < 0) n.x = 0;\n }\n // width changed, scale from new width\n if (node.w !== node._orig.w) {\n n.w = Math.round(node.w * ratio);\n if (n.w < 1) n.w = 1;\n }\n // ...height always carries over from cache\n });\n }\n });\n return this;\n }\n\n /**\n * @internal Called to scale the widget width & position up/down based on the column change.\n * Note we store previous layouts (especially original ones) to make it possible to go\n * from say 12 -> 1 -> 12 and get back to where we were.\n *\n * @param prevColumn previous number of columns\n * @param column new column number\n * @param layout specify the type of re-layout that will happen (position, size, etc...).\n * Note: items will never be outside of the current column boundaries. default (moveScale). Ignored for 1 column\n */\n public columnChanged(prevColumn: number, column: number, layout: ColumnOptions = 'moveScale'): GridStackEngine {\n if (!this.nodes.length || !column || prevColumn === column) return this;\n\n // simpler shortcuts layouts\n const doCompact = layout === 'compact' || layout === 'list';\n if (doCompact) {\n this.sortNodes(1); // sort with original layout once and only once (new column will affect order otherwise)\n }\n\n // cache the current layout in case they want to go back (like 12 -> 1 -> 12) as it requires original data IFF we're sizing down (see below)\n if (column < prevColumn) this.cacheLayout(this.nodes, prevColumn);\n this.batchUpdate(); // do this EARLY as it will call saveInitial() so we can detect where we started for _dirty and collision\n let newNodes: GridStackNode[] = [];\n let nodes = doCompact ? this.nodes : Utils.sort(this.nodes, -1); // current column reverse sorting so we can insert last to front (limit collision)\n\n // see if we have cached previous layout IFF we are going up in size (restore) otherwise always\n // generate next size down from where we are (looks more natural as you gradually size down).\n if (column > prevColumn && this._layouts) {\n const cacheNodes = this._layouts[column] || [];\n // ...if not, start with the largest layout (if not already there) as down-scaling is more accurate\n // by pretending we came from that larger column by assigning those values as starting point\n const lastIndex = this._layouts.length - 1;\n if (!cacheNodes.length && prevColumn !== lastIndex && this._layouts[lastIndex]?.length) {\n prevColumn = lastIndex;\n this._layouts[lastIndex].forEach(cacheNode => {\n const n = nodes.find(n => n._id === cacheNode._id);\n if (n) {\n // still current, use cache info positions\n if (!doCompact && !cacheNode.autoPosition) {\n n.x = cacheNode.x ?? n.x;\n n.y = cacheNode.y ?? n.y;\n }\n n.w = cacheNode.w ?? n.w;\n if (cacheNode.x == undefined || cacheNode.y === undefined) n.autoPosition = true;\n }\n });\n }\n\n // if we found cache re-use those nodes that are still current\n cacheNodes.forEach(cacheNode => {\n const j = nodes.findIndex(n => n._id === cacheNode._id);\n if (j !== -1) {\n const n = nodes[j];\n // still current, use cache info positions\n if (doCompact) {\n n.w = cacheNode.w; // only w is used, and don't trim the list\n return;\n }\n if (cacheNode.autoPosition || isNaN(cacheNode.x) || isNaN(cacheNode.y)) {\n this.findEmptyPosition(cacheNode, newNodes);\n }\n if (!cacheNode.autoPosition) {\n n.x = cacheNode.x ?? n.x;\n n.y = cacheNode.y ?? n.y;\n n.w = cacheNode.w ?? n.w;\n newNodes.push(n);\n }\n nodes.splice(j, 1);\n }\n });\n }\n\n // much simpler layout that just compacts\n if (doCompact) {\n this.compact(layout, false);\n } else {\n // ...and add any extra non-cached ones\n if (nodes.length) {\n if (typeof layout === 'function') {\n layout(column, prevColumn, newNodes, nodes);\n } else {\n const ratio = (doCompact || layout === 'none') ? 1 : column / prevColumn;\n const move = (layout === 'move' || layout === 'moveScale');\n const scale = (layout === 'scale' || layout === 'moveScale');\n nodes.forEach(node => {\n // NOTE: x + w could be outside of the grid, but addNode() below will handle that\n node.x = (column === 1 ? 0 : (move ? Math.round(node.x * ratio) : Math.min(node.x, column - 1)));\n node.w = ((column === 1 || prevColumn === 1) ? 1 : scale ? (Math.round(node.w * ratio) || 1) : (Math.min(node.w, column)));\n newNodes.push(node);\n });\n nodes = [];\n }\n }\n\n // finally re-layout them in reverse order (to get correct placement)\n newNodes = Utils.sort(newNodes, -1);\n this._inColumnResize = true; // prevent cache update\n this.nodes = []; // pretend we have no nodes to start with (add() will use same structures) to simplify layout\n newNodes.forEach(node => {\n this.addNode(node, false); // 'false' for add event trigger\n delete node._orig; // make sure the commit doesn't try to restore things back to original\n });\n }\n\n this.nodes.forEach(n => delete n._orig); // clear _orig before batch=false so it doesn't handle float=true restore\n this.batchUpdate(false, !doCompact);\n delete this._inColumnResize;\n return this;\n }\n\n /**\n * call to cache the given layout internally to the given location so we can restore back when column changes size\n * @param nodes list of nodes\n * @param column corresponding column index to save it under\n * @param clear if true, will force other caches to be removed (default false)\n */\n public cacheLayout(nodes: GridStackNode[], column: number, clear = false): GridStackEngine {\n const copy: GridStackNode[] = [];\n nodes.forEach((n, i) => {\n // make sure we have an id in case this is new layout, else re-use id already set\n if (n._id === undefined) {\n const existing = n.id ? this.nodes.find(n2 => n2.id === n.id) : undefined; // find existing node using users id\n n._id = existing?._id ?? GridStackEngine._idSeq++;\n }\n copy[i] = {x: n.x, y: n.y, w: n.w, _id: n._id} // only thing we change is x,y,w and id to find it back\n });\n this._layouts = clear ? [] : this._layouts || []; // use array to find larger quick\n this._layouts[column] = copy;\n return this;\n }\n\n /**\n * call to cache the given node layout internally to the given location so we can restore back when column changes size\n * @param node single node to cache\n * @param column corresponding column index to save it under\n */\n public cacheOneLayout(n: GridStackNode, column: number): GridStackEngine {\n n._id = n._id ?? GridStackEngine._idSeq++;\n const l: GridStackNode = {x: n.x, y: n.y, w: n.w, _id: n._id}\n if (n.autoPosition || n.x === undefined) { delete l.x; delete l.y; if (n.autoPosition) l.autoPosition = true; }\n this._layouts = this._layouts || [];\n this._layouts[column] = this._layouts[column] || [];\n const index = this.findCacheLayout(n, column);\n if (index === -1)\n this._layouts[column].push(l);\n else\n this._layouts[column][index] = l;\n return this;\n }\n\n protected findCacheLayout(n: GridStackNode, column: number): number | undefined {\n return this._layouts?.[column]?.findIndex(l => l._id === n._id) ?? -1;\n }\n\n public removeNodeFromLayoutCache(n: GridStackNode) {\n if (!this._layouts) {\n return;\n }\n for (let i = 0; i < this._layouts.length; i++) {\n const index = this.findCacheLayout(n, i);\n if (index !== -1) {\n this._layouts[i].splice(index, 1);\n }\n }\n }\n\n /** called to remove all internal values but the _id */\n public cleanupNode(node: GridStackNode): GridStackEngine {\n for (const prop in node) {\n if (prop[0] === '_' && prop !== '_id') delete node[prop];\n }\n return this;\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * gridstack SASS styles 12.4.1
2
+ * gridstack SASS styles 12.5.0
3
3
  * Copyright (c) 2021-2025 Alain Dumesny - see GridStack root license
4
4
  */
5
5
  .grid-stack {
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * GridStack 12.4.1
2
+ * GridStack 12.5.0
3
3
  * https://gridstackjs.com/
4
4
  *
5
5
  * Copyright (c) 2021-2025 Alain Dumesny
package/dist/gridstack.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * GridStack 12.4.1
2
+ * GridStack 12.5.0
3
3
  * https://gridstackjs.com/
4
4
  *
5
5
  * Copyright (c) 2021-2025 Alain Dumesny
@@ -619,8 +619,7 @@ class GridStack {
619
619
  * @see {@link http://gridstackjs.com/demo/serialization.html} for complete example
620
620
  */
621
621
  load(items, addRemove = GridStack.addRemoveCB || true) {
622
- items = Utils.cloneDeep(items); // so we can mod
623
- const column = this.getColumn();
622
+ // items = Utils.cloneDeep(items); // TODO: let callee decide by using directly instead of copy we can modify ?
624
623
  // make sure size 1x1 (default) is present as it may need to override current sizes
625
624
  items.forEach(n => { n.w = n.w || n.minW || 1; n.h = n.h || n.minH || 1; });
626
625
  // sort items. those without coord will be appended last
@@ -632,6 +631,7 @@ class GridStack {
632
631
  items.forEach(n => { maxColumn = Math.max(maxColumn, (n.x || 0) + n.w); });
633
632
  if (maxColumn > this.engine.defaultColumn)
634
633
  this.engine.defaultColumn = maxColumn;
634
+ const column = this.getColumn();
635
635
  if (maxColumn > column) {
636
636
  // if we're loading (from empty) into a smaller column, check for special responsive layout
637
637
  if (this.engine.nodes.length === 0 && this.responseLayout) {
@@ -1345,10 +1345,13 @@ class GridStack {
1345
1345
  }
1346
1346
  // responsive column take over actual count (keep what we have now)
1347
1347
  if (o.columnOpts) {
1348
+ const hadColumnOpts = !!this.opts.columnOpts;
1348
1349
  this.opts.columnOpts = o.columnOpts;
1350
+ if (hadColumnOpts !== !!this.opts.columnOpts)
1351
+ this._updateResizeEvent();
1349
1352
  this.checkDynamicColumn();
1350
1353
  }
1351
- else if (o.columnOpts === null && this.opts.columnOpts) {
1354
+ else if (o.columnOpts === null && this.opts.columnOpts) { // delete update cmd
1352
1355
  delete this.opts.columnOpts;
1353
1356
  this._updateResizeEvent();
1354
1357
  }
@@ -1374,7 +1377,7 @@ class GridStack {
1374
1377
  this._updateContainerHeight();
1375
1378
  }
1376
1379
  if (o.maxRow !== undefined)
1377
- opts.maxRow = o.maxRow;
1380
+ opts.maxRow = this.engine.maxRow = o.maxRow;
1378
1381
  }
1379
1382
  if (o.lazyLoad !== undefined)
1380
1383
  opts.lazyLoad = o.lazyLoad;
@@ -2724,10 +2727,9 @@ class GridStack {
2724
2727
  if (event.type === 'drag') {
2725
2728
  if (node._temporaryRemoved)
2726
2729
  return; // handled by dropover
2727
- const distance = ui.position.top - node._prevYPix;
2728
2730
  node._prevYPix = ui.position.top;
2729
2731
  if (this.opts.draggable.scroll !== false) {
2730
- Utils.updateScrollPosition(el, ui.position, distance);
2732
+ DDManager.dragElement?.updateScrollPosition(this.el);
2731
2733
  }
2732
2734
  // get new position taking into account the margin in the direction we are moving! (need to pass mid point by margin)
2733
2735
  const left = ui.position.left + (ui.position.left > node._lastUiPosition.left ? -mRight : mLeft);
@@ -2765,11 +2767,18 @@ class GridStack {
2765
2767
  return;
2766
2768
  if (node._lastTried && node._lastTried.w === p.w && node._lastTried.h === p.h)
2767
2769
  return; // skip one we tried (but failed)
2768
- // if we size on left/top side this might move us, so get possible new position as well
2769
- const left = ui.position.left + mLeft;
2770
- const top = ui.position.top + mTop;
2771
- p.x = Math.round(left / cellWidth);
2772
- p.y = Math.round(top / cellHeight);
2770
+ // only recalculate position for handles that move the top-left corner (N/W).
2771
+ // for SE/S/E handles the top-left is anchored — recalculating from pixels causes
2772
+ // rounding drift on fine grids where cellWidth/cellHeight are only a few pixels. #385 #1356
2773
+ const dir = event.resizeDir;
2774
+ if (dir && (dir.includes('w') || dir.includes('n'))) {
2775
+ const left = ui.position.left + mLeft;
2776
+ const top = ui.position.top + mTop;
2777
+ if (dir.includes('w'))
2778
+ p.x = Math.round(left / cellWidth);
2779
+ if (dir.includes('n'))
2780
+ p.y = Math.round(top / cellHeight);
2781
+ }
2773
2782
  resizing = true;
2774
2783
  }
2775
2784
  node._event = event;
@@ -2858,6 +2867,6 @@ GridStack.Utils = Utils;
2858
2867
  /** scoping so users can call new GridStack.Engine(12) for example */
2859
2868
  GridStack.Engine = GridStackEngine;
2860
2869
  /** @internal current version compiled in code */
2861
- GridStack.GDRev = '12.4.1';
2870
+ GridStack.GDRev = '12.5.0';
2862
2871
  export { GridStack };
2863
2872
  //# sourceMappingURL=gridstack.js.map