This repository has been archived by the owner on Aug 13, 2022. It is now read-only.
/
gridstack-h5.js.map
1 lines (1 loc) · 277 KB
/
gridstack-h5.js.map
1
{"version":3,"sources":["webpack://GridStack/webpack/universalModuleDefinition","webpack://GridStack/./src/gridstack-dd.ts","webpack://GridStack/./src/gridstack-ddi.ts","webpack://GridStack/./src/gridstack-engine.ts","webpack://GridStack/./src/gridstack-h5.ts","webpack://GridStack/./src/gridstack.ts","webpack://GridStack/./src/h5/dd-base-impl.ts","webpack://GridStack/./src/h5/dd-draggable.ts","webpack://GridStack/./src/h5/dd-droppable.ts","webpack://GridStack/./src/h5/dd-element.ts","webpack://GridStack/./src/h5/dd-manager.ts","webpack://GridStack/./src/h5/dd-resizable-handle.ts","webpack://GridStack/./src/h5/dd-resizable.ts","webpack://GridStack/./src/h5/dd-utils.ts","webpack://GridStack/./src/h5/gridstack-dd-native.ts","webpack://GridStack/./src/utils.ts","webpack://GridStack/webpack/bootstrap","webpack://GridStack/webpack/startup"],"names":["root","factory","exports","module","define","amd","self","GridStackDD","GridStackDDI","get","el","this","draggable","resizable","gridstackNode","_initDD","_itemRemoving","remove","node","undefined","grid","_isAboutToRemove","classList","add","GridStack","prototype","_setupAcceptWidget","opts","staticGrid","acceptWidgets","removable","droppable","gridPos","cellHeight","cellWidth","onDrag","event","helper","rec","getBoundingClientRect","left","top","ui","position","_temporaryRemoved","x","Math","max","round","y","autoPosition","engine","nodeBoundFix","willItFit","off","_willFitPos","Utils","copyPos","_onStartMoving","_dragOrResize","accept","canAccept","selector","matches","maxRow","n","w","h","minW","minH","on","_leave","box","getCellHeight","_readAttr","_isExternal","offsetWidth","offsetHeight","_gridstackNodeOrig","cleanupNode","wasAdded","placeholder","parentElement","origNode","oGrid","removedNodes","push","_triggerRemoveEvent","cloneNode","removePositioningStyles","_writeAttr","appendChild","_updateContainerHeight","addedNodes","_triggerAddEvent","_triggerChangeEvent","endUpdate","_gsEventHandler","type","window","setTimeout","_prepareDragDropByNode","removeNode","_setupRemoveDrop","trashEl","document","querySelector","isDroppable","removableOptions","setupDragIn","_dragIn","_dragInOptions","dragIn","dragInOptions","revert","handle","scroll","appendTo","dd","getElements","forEach","isDraggable","noMove","disableDrag","noResize","disableResize","onStartMoving","target","dragOrResize","onEndMoving","_moving","_lastTried","gridToNotify","_orig","_writePosAttr","addNode","_extraDragRow","start","stop","drag","resize","cleanNodes","beginUpdate","_lastUiPosition","_prevYPix","cacheRects","marginTop","marginRight","marginBottom","marginLeft","maxW","maxH","restoreInitial","resizing","p","mLeft","mRight","mTop","mBottom","distance","updateScrollPosition","prev","collide","row","getRow","extra","updateScrollResize","size","width","height","rect","moveNodeCheck","_skipDown","subGrid","onParentResize","movable","els","val","disable","enableMove","enableResize","_triggerEvent","enable","doEnable","nodes","pluginClass","ddi","registerPlugin","GridStackEngine","column","onChange","_float","float","batchMode","_prevFloat","saveInitial","_packNodes","_notify","nn","_hasLocked","opt","_sortNodes","nested","swap","area","_useEntireRowArea","skip","didMove","newOpt","pack","moved","locked","moveNode","skip2","find","isIntercepted","filter","o","collides","_rect","r0","r","r2","yOver","Number","MAX_VALUE","xOver","overMax","over","min","right","bottom","a","b","_doSwap","_dirty","touching","isTouching","t","length","batchUpdate","copyNodes","commit","dir","sort","_updating","newY","i","_id","_idSeq","defaults","isNaN","cacheOneLayout","verify","samePos","removeDOM","dirtyNodes","Array","isArray","concat","getDirtyNodes","some","triggerAddEvent","dup","prepareNode","_removeDOM","floor","_fixCollisions","triggerEvent","_layouts","changedPosConstrain","clonedNode","clone","map","canMove","c","content","prevPos","collideAll","needToMove","collideCoverage","reduce","saveElement","list","key","_ignoreLayoutsNodeChange","layout","l","ratio","oldColumn","cacheLayout","cacheNodes","lastIndex","cacheNode","j","findIndex","newNodes","splice","move","scale","clear","copy","index","prop","GridDefaults","minRow","itemClass","placeholderClass","placeholderText","handleClass","styleInHead","cellHeightThrottle","margin","auto","minWidth","animate","alwaysShowResizeHandle","autoHide","handles","rtl","marginUnit","cellHeightUnit","disableOneColumnMode","oneColumnModeDomSort","rowAttr","toNumber","getAttribute","cloneDeep","toBool","_styleSheetClass","random","toFixed","initMargin","_widthOrContainer","_prevColumn","style","direction","parentGridItemEl","closestByClass","_isNested","_isAutoCellHeight","_setStaticClass","cbNodes","_updateStyles","elements","getGridItems","parseInt","e","_prepareElement","setAnimation","_updateWindowResizeEvent","options","elOrString","getGridElement","gridstack","console","error","grids","getGridElements","parent","contains","doc","implementation","createHTMLDocument","body","innerHTML","class","children","init","load","_placeholder","placeholderChild","createElement","className","arguments","warn","id","addWidget","domAttr","_insertNotAppend","prepend","addGrid","saveContent","saveGridOpt","save","sub","removeInternalAndSame","addAndRemove","items","removed","removeWidget","item","update","forcePixel","marginDiff","data","parseHeight","unit","clientWidth","innerWidth","compact","domNodes","updateNodeWidths","from","setStatic","parentNode","removeChild","removeAll","_removeStylesheet","removeAttribute","useDocRelative","containerPos","documentElement","scrollTop","offsetTop","offsetLeft","relativeLeft","relativeTop","columnWidth","rowHeight","isAreaEmpty","getElement","name","callback","indexOf","split","noData","detail","addEventListener","log","removeEventListener","doAnimate","updateClass","m","keys","k","changed","ddChanged","value","layoutsNodesChange","CustomEvent","bubbles","Event","dispatchEvent","_styles","removeStylesheet","forceUpdate","prefix","styleLocation","createStylesheet","_max","addCSSRule","getHeight","rows","cssMinHeight","getComputedStyle","setAttribute","String","removeProperty","same","attrs","resizeHandles","hasOwnProperty","classes","oneColumn","changedOneColumn","_cellHeightThrottle","throttle","forceRemove","workTodo","_windowResizeBind","bind","margins","Engine","_disabled","_eventRegister","eventName","disabled","DDDraggable","DDBaseImplement","option","super","dragging","containmentRect","offset","substring","dragEl","_dragStart","_drag","_dragEnd","forDestroy","destroy","Object","DDManager","dragElement","_createHelper","_setupHelperContainmentStyle","dragOffset","_getDragOffset","helperContainment","ev","DDUtils","initEvent","_setupDragFollowNodeNotifyStart","_dragFollow","dragFollowTimer","_cancelDragGhost","_setupHelperStyle","dragEventListenerOption","preventDefault","clearTimeout","paintTimer","cancelAnimationFrame","parentOriginStylePosition","_removeHelperStyle","dragElementOriginStyle","originStyleProp","pointerEvents","willChange","transition","basePosition","zIndex","requestAnimationFrame","clientX","clientY","match","img","dataTransfer","setDragImage","stopPropagation","xformOffsetX","xformOffsetY","testEl","addElStyles","opacity","testElPosition","targetOffset","DDDroppable","_dragEnter","_dragOver","_dragLeave","_drop","_setupAccept","moving","_removeLeaveCallbacks","_canDrop","_ui","relatedTarget","out","drop","DDElement","ddElement","ddDraggable","ddDroppable","ddResizable","updateOption","DDResizable","DDResizableHandle","host","_mouseDown","_mouseMove","_mouseUp","_init","userSelect","mouseDownEvent","s","abs","_showHandlers","_hideHandlers","newRect","originalRect","scrolled","temporalRect","_setupAutoHide","_setupHandlers","_removeHandlers","updateHandles","updateAutoHide","handlerDirection","handlers","trim","_resizeStart","_resizeStop","_resizing","scrollEl","getScrollElement","scrollY","startEvent","_setupHelper","_applyChange","_getChange","_cleanHelper","elOriginStyleVal","_originStyleProp","oEvent","offsetX","offsetY","constrain","_constrainSize","oWidth","oHeight","maxWidth","MAX_SAFE_INTEGER","maxHeight","minHeight","containmentEl","test","styles","info","evt","obj","button","which","buttons","cancelable","isEventSupportPassiveOption","supportsPassive","passiveTest","GridStackDDNative","_getDDElements","dEl","cleanResizable","setupResizable","cleanDraggable","setupDraggable","containment","dragOut","_accept","cleanDroppable","setupDroppable","create","hosts","d","f","oldName","newName","rev","wrapper","args","apply","oldAttr","querySelectorAll","getElementById","col","styleSheet","cssText","createTextNode","insertBefore","firstChild","getElementsByTagName","sheet","rules","addRule","insertRule","v","toLowerCase","Boolean","Error","parseFloat","sources","source","minMax","func","delay","isWaiting","scrollingElement","overflow","overflowY","innerHeightOrClientHeight","innerHeight","clientHeight","offsetDiffDown","offsetDiffUp","prevScroll","pointerPosY","scrollBy","behavior","ret","__webpack_module_cache__","__webpack_exports__","__webpack_require__","moduleId","cachedModule","__webpack_modules__","call"],"mappings":";CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C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AWA,EAAWggB,GAIjEpnB,EAASF,KAAO+hB,EAAS3K,UAAYoQ,IAY3C,0BAA0B7nB,EAAmB1B,EAAiBqJ,GAC5D,MAAMya,EAAW7jB,KAAK8jB,iBAAiB/jB,GACjC+J,EAAS+Z,EAASsF,aAKlBhQ,EAAa0K,IAAa7jB,KAAK8jB,mBAAsB,EAAID,EAASjiB,wBAAwBE,IAC1FynB,EAAc9nB,EAAMwe,QAAU9G,EAE9BvL,EAAS2b,EAAczf,EAASV,EAD1BmgB,EAAcngB,EAMxBya,EAAS2F,SAAS,CAAEC,SAAU,SAAU3nB,IAAKynB,EAAcngB,IAClDwE,GACTiW,EAAS2F,SAAS,CAAEC,SAAU,SAAU3nB,IAAKsH,GAAYU,EAASyf,KAKtE,aAAgBhE,GACd,OAAIA,SAAqD,iBAAV,EACtCA,EAGLA,aAAejW,MAEV,IAAIiW,GAEN,OAAP,UAAWA,GAOb,iBAAoBA,GAElB,MAAMmE,EAAM7mB,EAAMwN,MAAMkV,GACxB,IAAK,MAAMtU,KAAOyY,EAEZA,EAAIvN,eAAelL,IAA6B,iBAAdyY,EAAIzY,IAA8C,OAAxBA,EAAIyM,UAAU,EAAG,KAC/EgM,EAAIzY,GAAOpO,EAAM+Q,UAAU2R,EAAItU,KAGnC,OAAOyY,GA1VX,YCpDIC,EAA2B,GCE3BC,EDCJ,SAASC,EAAoBC,GAE5B,IAAIC,EAAeJ,EAAyBG,GAC5C,QAAqBtpB,IAAjBupB,EACH,OAAOA,EAAaxqB,QAGrB,IAAIC,EAASmqB,EAAyBG,GAAY,CAGjDvqB,QAAS,IAOV,OAHAyqB,EAAoBF,GAAUG,KAAKzqB,EAAOD,QAASC,EAAQA,EAAOD,QAASsqB,GAGpErqB,EAAOD,QClBWsqB,CAAoB,K","file":"gridstack-h5.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"GridStack\"] = factory();\n\telse\n\t\troot[\"GridStack\"] = factory();\n})(self, function() {\nreturn ","/**\r\n * gridstack-dd.ts 4.2.6\r\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\r\n */\r\n\r\n/* eslint-disable @typescript-eslint/no-unused-vars */\r\nimport { GridStackDDI } from './gridstack-ddi';\r\nimport { GridItemHTMLElement, GridStackNode, GridStackElement, DDUIData, DDDragInOpt, GridStackPosition } from './types';\r\nimport { GridStack, MousePosition } from './gridstack';\r\nimport { Utils } from './utils';\r\n\r\n/** Drag&Drop drop options */\r\nexport type DDDropOpt = {\r\n /** function or class type that this grid will accept as dropped items (see GridStackOptions.acceptWidgets) */\r\n accept?: (el: GridItemHTMLElement) => boolean;\r\n}\r\n\r\n/** drag&drop options currently called from the main code, but others can be passed in grid options */\r\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\r\nexport type DDOpts = 'enable' | 'disable' | 'destroy' | 'option' | string | any;\r\nexport type DDKey = 'minWidth' | 'minHeight' | 'maxWidth' | 'maxHeight';\r\nexport type DDValue = number | string;\r\n\r\n/** drag&drop events callbacks */\r\nexport type DDCallback = (event: Event, arg2: GridItemHTMLElement, helper?: GridItemHTMLElement) => void;\r\n\r\n/**\r\n * Base class implementing common Grid drag'n'drop functionality, with domain specific subclass (h5 vs jq subclasses)\r\n */\r\nexport abstract class GridStackDD extends GridStackDDI {\r\n\r\n /** override to cast to correct type */\r\n static get(): GridStackDD {\r\n return GridStackDDI.get() as GridStackDD;\r\n }\r\n\r\n /** removes any drag&drop present (called during destroy) */\r\n public remove(el: GridItemHTMLElement): GridStackDD {\r\n this.draggable(el, 'destroy').resizable(el, 'destroy');\r\n if (el.gridstackNode) {\r\n delete el.gridstackNode._initDD; // reset our DD init flag\r\n }\r\n return this;\r\n }\r\n\r\n // APIs that must be implemented by subclasses to do actual darg/drop/resize called by GridStack code below\r\n\r\n public abstract resizable(el: GridItemHTMLElement, opts: DDOpts, key?: DDKey, value?: DDValue): GridStackDD;\r\n\r\n public abstract isResizable(el: HTMLElement): boolean;\r\n\r\n public abstract draggable(el: GridItemHTMLElement, opts: DDOpts, key?: DDKey, value?: DDValue): GridStackDD;\r\n\r\n public abstract dragIn(el: GridStackElement, opts: DDDragInOpt): GridStackDD;\r\n\r\n public abstract isDraggable(el: HTMLElement): boolean;\r\n\r\n public abstract droppable(el: GridItemHTMLElement, opts: DDOpts | DDDropOpt, key?: DDKey, value?: DDValue): GridStackDD;\r\n\r\n public abstract isDroppable(el: HTMLElement): boolean;\r\n\r\n public abstract on(el: GridItemHTMLElement, eventName: string, callback: DDCallback): GridStackDD;\r\n\r\n public abstract off(el: GridItemHTMLElement, eventName: string): GridStackDD;\r\n}\r\n\r\n/********************************************************************************\r\n * GridStack code that is doing drag&drop extracted here so main class is smaller\r\n * for static grid that don't do any of this work anyway. Saves about 10k.\r\n * TODO: no code hint in code below as this is <any> so look at alternatives ?\r\n * https://www.typescriptlang.org/docs/handbook/declaration-merging.html\r\n * https://www.typescriptlang.org/docs/handbook/mixins.html\r\n ********************************************************************************/\r\n\r\n/** @internal called to add drag over to support widgets being added externally */\r\nGridStack.prototype._setupAcceptWidget = function(this: GridStack): GridStack {\r\n\r\n // check if we need to disable things\r\n if (this.opts.staticGrid || (!this.opts.acceptWidgets && !this.opts.removable)) {\r\n GridStackDD.get().droppable(this.el, 'destroy');\r\n return this;\r\n }\r\n\r\n // vars shared across all methods\r\n let gridPos: MousePosition;\r\n let cellHeight: number, cellWidth: number;\r\n\r\n let onDrag = (event: DragEvent, el: GridItemHTMLElement, helper: GridItemHTMLElement) => {\r\n let node = el.gridstackNode;\r\n if (!node) return;\r\n\r\n helper = helper || el;\r\n let rec = helper.getBoundingClientRect();\r\n let left = rec.left - gridPos.left;\r\n let top = rec.top - gridPos.top;\r\n let ui: DDUIData = {position: {top, left}};\r\n\r\n if (node._temporaryRemoved) {\r\n node.x = Math.max(0, Math.round(left / cellWidth));\r\n node.y = Math.max(0, Math.round(top / cellHeight));\r\n delete node.autoPosition;\r\n this.engine.nodeBoundFix(node);\r\n\r\n // don't accept *initial* location if doesn't fit #1419 (locked drop region, or can't grow), but maybe try if it will go somewhere\r\n if (!this.engine.willItFit(node)) {\r\n node.autoPosition = true; // ignore x,y and try for any slot...\r\n if (!this.engine.willItFit(node)) {\r\n GridStackDD.get().off(el, 'drag'); // stop calling us\r\n return; // full grid or can't grow\r\n }\r\n if (node._willFitPos) {\r\n // use the auto position instead #1687\r\n Utils.copyPos(node, node._willFitPos);\r\n delete node._willFitPos;\r\n }\r\n }\r\n\r\n // re-use the existing node dragging method\r\n this._onStartMoving(helper, event, ui, node, cellWidth, cellHeight);\r\n } else {\r\n // re-use the existing node dragging that does so much of the collision detection\r\n this._dragOrResize(helper, event, ui, node, cellWidth, cellHeight);\r\n }\r\n }\r\n\r\n GridStackDD.get()\r\n .droppable(this.el, {\r\n accept: (el: GridItemHTMLElement) => {\r\n let node: GridStackNode = el.gridstackNode;\r\n // set accept drop to true on ourself (which we ignore) so we don't get \"can't drop\" icon in HTML5 mode while moving\r\n if (node && node.grid === this) return true;\r\n if (!this.opts.acceptWidgets) return false;\r\n // check for accept method or class matching\r\n let canAccept = true;\r\n if (typeof this.opts.acceptWidgets === 'function') {\r\n canAccept = this.opts.acceptWidgets(el);\r\n } else {\r\n let selector = (this.opts.acceptWidgets === true ? '.grid-stack-item' : this.opts.acceptWidgets as string);\r\n canAccept = el.matches(selector);\r\n }\r\n // finally check to make sure we actually have space left #1571\r\n if (canAccept && node && this.opts.maxRow) {\r\n let n = {w: node.w, h: node.h, minW: node.minW, minH: node.minH}; // only width/height matters and autoPosition\r\n canAccept = this.engine.willItFit(n);\r\n }\r\n return canAccept;\r\n }\r\n })\r\n /**\r\n * entering our grid area\r\n */\r\n .on(this.el, 'dropover', (event: Event, el: GridItemHTMLElement, helper: GridItemHTMLElement) => {\r\n let node = el.gridstackNode;\r\n // ignore drop enter on ourself (unless we temporarily removed) which happens on a simple drag of our item\r\n if (node && node.grid === this && !node._temporaryRemoved) {\r\n // delete node._added; // reset this to track placeholder again in case we were over other grid #1484 (dropout doesn't always clear)\r\n return false; // prevent parent from receiving msg (which may be a grid as well)\r\n }\r\n\r\n // fix #1578 when dragging fast, we may not get a leave on the previous grid so force one now\r\n if (node && node.grid && node.grid !== this && !node._temporaryRemoved) {\r\n // TEST console.log('dropover without leave');\r\n let otherGrid = node.grid;\r\n otherGrid._leave(el, helper);\r\n }\r\n\r\n // get grid screen coordinates and cell dimensions\r\n let box = this.el.getBoundingClientRect();\r\n gridPos = {top: box.top, left: box.left};\r\n cellWidth = this.cellWidth();\r\n cellHeight = this.getCellHeight(true);\r\n\r\n // load any element attributes if we don't have a node\r\n if (!node) {// @ts-ignore\r\n node = this._readAttr(el);\r\n }\r\n if (!node.grid) {\r\n node._isExternal = true;\r\n el.gridstackNode = node;\r\n }\r\n\r\n // calculate the grid size based on element outer size\r\n helper = helper || el;\r\n let w = node.w || Math.round(helper.offsetWidth / cellWidth) || 1;\r\n let h = node.h || Math.round(helper.offsetHeight / cellHeight) || 1;\r\n\r\n // if the item came from another grid, make a copy and save the original info in case we go back there\r\n if (node.grid && node.grid !== this) {\r\n // copy the node original values (min/max/id/etc...) but override width/height/other flags which are this grid specific\r\n // TEST console.log('dropover cloning node');\r\n if (!el._gridstackNodeOrig) el._gridstackNodeOrig = node; // shouldn't have multiple nested!\r\n el.gridstackNode = node = {...node, w, h, grid: this};\r\n this.engine.cleanupNode(node)\r\n .nodeBoundFix(node);\r\n // restore some internal fields we need after clearing them all\r\n node._initDD =\r\n node._isExternal = // DOM needs to be re-parented on a drop\r\n node._temporaryRemoved = true; // so it can be inserted onDrag below\r\n } else {\r\n node.w = w; node.h = h;\r\n node._temporaryRemoved = true; // so we can insert it\r\n }\r\n\r\n // clear any marked for complete removal (Note: don't check _isAboutToRemove as that is cleared above - just do it)\r\n _itemRemoving(node.el, false);\r\n\r\n GridStackDD.get().on(el, 'drag', onDrag);\r\n // make sure this is called at least once when going fast #1578\r\n onDrag(event as DragEvent, el, helper);\r\n return false; // prevent parent from receiving msg (which may be a grid as well)\r\n })\r\n /**\r\n * Leaving our grid area...\r\n */\r\n .on(this.el, 'dropout', (event, el: GridItemHTMLElement, helper: GridItemHTMLElement) => {\r\n let node = el.gridstackNode;\r\n // fix #1578 when dragging fast, we might get leave after other grid gets enter (which calls us to clean)\r\n // so skip this one if we're not the active grid really..\r\n if (!node.grid || node.grid === this) {\r\n this._leave(el, helper);\r\n }\r\n return false; // prevent parent from receiving msg (which may be grid as well)\r\n })\r\n /**\r\n * end - releasing the mouse\r\n */\r\n .on(this.el, 'drop', (event, el: GridItemHTMLElement, helper: GridItemHTMLElement) => {\r\n let node = el.gridstackNode;\r\n // ignore drop on ourself from ourself that didn't come from the outside - dragend will handle the simple move instead\r\n if (node && node.grid === this && !node._isExternal) return false;\r\n\r\n let wasAdded = !!this.placeholder.parentElement; // skip items not actually added to us because of constrains, but do cleanup #1419\r\n this.placeholder.remove();\r\n\r\n // notify previous grid of removal\r\n // TEST console.log('drop delete _gridstackNodeOrig')\r\n let origNode = el._gridstackNodeOrig;\r\n delete el._gridstackNodeOrig;\r\n if (wasAdded && origNode && origNode.grid && origNode.grid !== this) {\r\n let oGrid = origNode.grid;\r\n oGrid.engine.removedNodes.push(origNode);\r\n oGrid._triggerRemoveEvent();\r\n }\r\n\r\n if (!node) return false;\r\n\r\n // use existing placeholder node as it's already in our list with drop location\r\n if (wasAdded) {\r\n this.engine.cleanupNode(node); // removes all internal _xyz values\r\n node.grid = this;\r\n }\r\n GridStackDD.get().off(el, 'drag');\r\n // if we made a copy ('helper' which is temp) of the original node then insert a copy, else we move the original node (#1102)\r\n // as the helper will be nuked by jquery-ui otherwise\r\n if (helper !== el) {\r\n helper.remove();\r\n el.gridstackNode = origNode; // original item (left behind) is re-stored to pre dragging as the node now has drop info\r\n if (wasAdded) {\r\n el = el.cloneNode(true) as GridItemHTMLElement;\r\n }\r\n } else {\r\n el.remove(); // reduce flicker as we change depth here, and size further down\r\n GridStackDD.get().remove(el);\r\n }\r\n if (!wasAdded) return false;\r\n el.gridstackNode = node;\r\n node.el = el;\r\n // @ts-ignore\r\n Utils.copyPos(node, this._readAttr(this.placeholder)); // placeholder values as moving VERY fast can throw things off #1578\r\n Utils.removePositioningStyles(el);// @ts-ignore\r\n this._writeAttr(el, node);\r\n this.el.appendChild(el);// @ts-ignore\r\n this._updateContainerHeight();\r\n this.engine.addedNodes.push(node);// @ts-ignore\r\n this._triggerAddEvent();// @ts-ignore\r\n this._triggerChangeEvent();\r\n\r\n this.engine.endUpdate();\r\n if (this._gsEventHandler['dropped']) {\r\n this._gsEventHandler['dropped']({type: 'dropped'}, origNode && origNode.grid ? origNode : undefined, node);\r\n }\r\n\r\n // wait till we return out of the drag callback to set the new drag&resize handler or they may get messed up\r\n window.setTimeout(() => {\r\n // IFF we are still there (some application will use as placeholder and insert their real widget instead and better call makeWidget())\r\n if (node.el && node.el.parentElement) {\r\n this._prepareDragDropByNode(node);\r\n } else {\r\n this.engine.removeNode(node);\r\n }\r\n });\r\n\r\n return false; // prevent parent from receiving msg (which may be grid as well)\r\n });\r\n return this;\r\n}\r\n\r\n/** @internal mark item for removal */\r\nfunction _itemRemoving(el: GridItemHTMLElement, remove: boolean) {\r\n let node = el ? el.gridstackNode : undefined;\r\n if (!node || !node.grid) return;\r\n remove ? node._isAboutToRemove = true : delete node._isAboutToRemove;\r\n remove ? el.classList.add('grid-stack-item-removing') : el.classList.remove('grid-stack-item-removing');\r\n}\r\n\r\n/** @internal called to setup a trash drop zone if the user specifies it */\r\nGridStack.prototype._setupRemoveDrop = function(this: GridStack): GridStack {\r\n if (!this.opts.staticGrid && typeof this.opts.removable === 'string') {\r\n let trashEl = document.querySelector(this.opts.removable) as HTMLElement;\r\n if (!trashEl) return this;\r\n // only register ONE drop-over/dropout callback for the 'trash', and it will\r\n // update the passed in item and parent grid because the 'trash' is a shared resource anyway,\r\n // and Native DD only has 1 event CB (having a list and technically a per grid removableOptions complicates things greatly)\r\n if (!GridStackDD.get().isDroppable(trashEl)) {\r\n GridStackDD.get().droppable(trashEl, this.opts.removableOptions)\r\n .on(trashEl, 'dropover', (event, el) => _itemRemoving(el, true))\r\n .on(trashEl, 'dropout', (event, el) => _itemRemoving(el, false));\r\n }\r\n }\r\n return this;\r\n}\r\n\r\n/**\r\n * call to setup dragging in from the outside (say toolbar), by specifying the class selection and options.\r\n * Called during GridStack.init() as options, but can also be called directly (last param are cached) in case the toolbar\r\n * is dynamically create and needs to change later.\r\n **/\r\nGridStack.setupDragIn = function(this: GridStack, _dragIn?: string, _dragInOptions?: DDDragInOpt) {\r\n let dragIn: string;\r\n let dragInOptions: DDDragInOpt;\r\n const dragInDefaultOptions: DDDragInOpt = {\r\n revert: 'invalid',\r\n handle: '.grid-stack-item-content',\r\n scroll: false,\r\n appendTo: 'body'\r\n };\r\n\r\n // cache in the passed in values (form grid init?) so they don't have to resend them each time\r\n if (_dragIn) {\r\n dragIn = _dragIn;\r\n dragInOptions = {...dragInDefaultOptions, ...(_dragInOptions || {})};\r\n }\r\n if (typeof dragIn !== 'string') return;\r\n let dd = GridStackDD.get();\r\n Utils.getElements(dragIn).forEach(el => {\r\n if (!dd.isDraggable(el)) dd.dragIn(el, dragInOptions);\r\n });\r\n}\r\n\r\n/** @internal prepares the element for drag&drop **/\r\nGridStack.prototype._prepareDragDropByNode = function(this: GridStack, node: GridStackNode): GridStack {\r\n let el = node.el;\r\n let dd = GridStackDD.get();\r\n\r\n // check for disabled grid first\r\n if (this.opts.staticGrid || ((node.noMove || this.opts.disableDrag) && (node.noResize || this.opts.disableResize))) {\r\n if (node._initDD) {\r\n dd.remove(el); // nukes everything instead of just disable, will add some styles back next\r\n delete node._initDD;\r\n }\r\n el.classList.add('ui-draggable-disabled', 'ui-resizable-disabled'); // add styles one might depend on #1435\r\n return this;\r\n }\r\n\r\n if (!node._initDD) {\r\n // variables used/cashed between the 3 start/move/end methods, in addition to node passed above\r\n let cellWidth: number;\r\n let cellHeight: number;\r\n\r\n /** called when item starts moving/resizing */\r\n let onStartMoving = (event: Event, ui: DDUIData) => {\r\n // trigger any 'dragstart' / 'resizestart' manually\r\n if (this._gsEventHandler[event.type]) {\r\n this._gsEventHandler[event.type](event, event.target);\r\n }\r\n cellWidth = this.cellWidth();\r\n cellHeight = this.getCellHeight(true); // force pixels for calculations\r\n\r\n this._onStartMoving(el, event, ui, node, cellWidth, cellHeight);\r\n }\r\n\r\n /** called when item is being dragged/resized */\r\n let dragOrResize = (event: Event, ui: DDUIData) => {\r\n this._dragOrResize(el, event, ui, node, cellWidth, cellHeight);\r\n }\r\n\r\n /** called when the item stops moving/resizing */\r\n let onEndMoving = (event: Event) => {\r\n this.placeholder.remove();\r\n delete node._moving;\r\n delete node._lastTried;\r\n\r\n // if the item has moved to another grid, we're done here\r\n let target: GridItemHTMLElement = event.target as GridItemHTMLElement;\r\n if (!target.gridstackNode || target.gridstackNode.grid !== this) return;\r\n\r\n node.el = target;\r\n\r\n if (node._isAboutToRemove) {\r\n let gridToNotify = el.gridstackNode.grid;\r\n if (gridToNotify._gsEventHandler[event.type]) {\r\n gridToNotify._gsEventHandler[event.type](event, target);\r\n }\r\n dd.remove(el);\r\n gridToNotify.engine.removedNodes.push(node);\r\n gridToNotify._triggerRemoveEvent();\r\n // break circular links and remove DOM\r\n delete el.gridstackNode;\r\n delete node.el;\r\n el.remove();\r\n } else {\r\n if (!node._temporaryRemoved) {\r\n // move to new placeholder location\r\n Utils.removePositioningStyles(target);// @ts-ignore\r\n this._writePosAttr(target, node);\r\n } else {\r\n // got removed - restore item back to before dragging position\r\n Utils.removePositioningStyles(target);\r\n Utils.copyPos(node, node._orig);// @ts-ignore\r\n this._writePosAttr(target, node);\r\n this.engine.addNode(node);\r\n }\r\n if (this._gsEventHandler[event.type]) {\r\n this._gsEventHandler[event.type](event, target);\r\n }\r\n }\r\n // @ts-ignore\r\n this._extraDragRow = 0;// @ts-ignore\r\n this._updateContainerHeight();// @ts-ignore\r\n this._triggerChangeEvent();\r\n\r\n this.engine.endUpdate();\r\n }\r\n\r\n dd.draggable(el, {\r\n start: onStartMoving,\r\n stop: onEndMoving,\r\n drag: dragOrResize\r\n }).resizable(el, {\r\n start: onStartMoving,\r\n stop: onEndMoving,\r\n resize: dragOrResize\r\n });\r\n node._initDD = true; // we've set DD support now\r\n }\r\n\r\n // finally fine tune move vs resize by disabling any part...\r\n if (node.noMove || this.opts.disableDrag) {\r\n dd.draggable(el, 'disable');\r\n el.classList.add('ui-draggable-disabled');\r\n } else {\r\n dd.draggable(el, 'enable');\r\n el.classList.remove('ui-draggable-disabled');\r\n }\r\n if (node.noResize || this.opts.disableResize) {\r\n dd.resizable(el, 'disable');\r\n el.classList.add('ui-resizable-disabled');\r\n } else {\r\n dd.resizable(el, 'enable');\r\n el.classList.remove('ui-resizable-disabled');\r\n }\r\n\r\n return this;\r\n}\r\n\r\n/** @internal called when item is starting a drag/resize */\r\nGridStack.prototype._onStartMoving = function(this: GridStack, el: GridItemHTMLElement, event: Event, ui: DDUIData, node: GridStackNode, cellWidth: number, cellHeight: number) {\r\n this.engine.cleanNodes()\r\n .beginUpdate(node);\r\n // @ts-ignore\r\n this._writePosAttr(this.placeholder, node)\r\n this.el.appendChild(this.placeholder);\r\n // TEST console.log('_onStartMoving placeholder')\r\n\r\n node.el = this.placeholder;\r\n node._lastUiPosition = ui.position;\r\n node._prevYPix = ui.position.top;\r\n node._moving = (event.type === 'dragstart'); // 'dropover' are not initially moving so they can go exactly where they enter (will push stuff out of the way)\r\n delete node._lastTried;\r\n\r\n if (event.type === 'dropover' && node._temporaryRemoved) {\r\n // TEST console.log('engine.addNode x=' + node.x);\r\n this.engine.addNode(node); // will add, fix collisions, update attr and clear _temporaryRemoved\r\n node._moving = true; // AFTER, mark as moving object (wanted fix location before)\r\n }\r\n\r\n // set the min/max resize info\r\n this.engine.cacheRects(cellWidth, cellHeight, this.opts.marginTop as number, this.opts.marginRight as number, this.opts.marginBottom as number, this.opts.marginLeft as number);\r\n if (event.type === 'resizestart') {\r\n let dd = GridStackDD.get()\r\n .resizable(el, 'option', 'minWidth', cellWidth * (node.minW || 1))\r\n .resizable(el, 'option', 'minHeight', cellHeight * (node.minH || 1));\r\n if (node.maxW) { dd.resizable(el, 'option', 'maxWidth', cellWidth * node.maxW); }\r\n if (node.maxH) { dd.resizable(el, 'option', 'maxHeight', cellHeight * node.maxH); }\r\n }\r\n}\r\n\r\n/** @internal called when item leaving our area by either cursor dropout event\r\n * or shape is outside our boundaries. remove it from us, and mark temporary if this was\r\n * our item to start with else restore prev node values from prev grid it came from.\r\n **/\r\nGridStack.prototype._leave = function(this: GridStack, el: GridItemHTMLElement, helper?: GridItemHTMLElement) {\r\n let node = el.gridstackNode;\r\n if (!node) return;\r\n\r\n GridStackDD.get().off(el, 'drag'); // no need to track while being outside\r\n\r\n // this gets called when cursor leaves and shape is outside, so only do this once\r\n if (node._temporaryRemoved) return;\r\n node._temporaryRemoved = true;\r\n\r\n this.engine.removeNode(node); // remove placeholder as well, otherwise it's a sign node is not in our list, which is a bigger issue\r\n node.el = node._isExternal && helper ? helper : el; // point back to real item being dragged\r\n\r\n if (this.opts.removable === true) { // boolean vs a class string\r\n // item leaving us and we are supposed to remove on leave (no need to drag onto trash) mark it so\r\n _itemRemoving(el, true);\r\n }\r\n\r\n // finally if item originally came from another grid, but left us, restore things back to prev info\r\n if (el._gridstackNodeOrig) {\r\n // TEST console.log('leave delete _gridstackNodeOrig')\r\n el.gridstackNode = el._gridstackNodeOrig;\r\n delete el._gridstackNodeOrig;\r\n } else if (node._isExternal) {\r\n // item came from outside (like a toolbar) so nuke any node info\r\n delete node.el;\r\n delete el.gridstackNode;\r\n // and restore all nodes back to original\r\n this.engine.restoreInitial();\r\n }\r\n}\r\n\r\n/** @internal called when item is being dragged/resized */\r\nGridStack.prototype._dragOrResize = function(this: GridStack, el: GridItemHTMLElement, event: Event, ui: DDUIData, node: GridStackNode, cellWidth: number, cellHeight: number) {\r\n let p = {...node._orig}; // could be undefined (_isExternal) which is ok (drag only set x,y and w,h will default to node value)\r\n let resizing: boolean;\r\n const mLeft = this.opts.marginLeft as number,\r\n mRight = this.opts.marginRight as number,\r\n mTop = this.opts.marginTop as number,\r\n mBottom = this.opts.marginBottom as number;\r\n\r\n if (event.type === 'drag') {\r\n if (node._temporaryRemoved) return; // handled by dropover\r\n let distance = ui.position.top - node._prevYPix;\r\n node._prevYPix = ui.position.top;\r\n Utils.updateScrollPosition(el, ui.position, distance);\r\n\r\n // get new position taking into account the margin in the direction we are moving! (need to pass mid point by margin)\r\n let left = ui.position.left + (ui.position.left > node._lastUiPosition.left ? -mRight : mLeft);\r\n let top = ui.position.top + (ui.position.top > node._lastUiPosition.top ? -mBottom : mTop);\r\n p.x = Math.round(left / cellWidth);\r\n p.y = Math.round(top / cellHeight);\r\n\r\n // @ts-ignore// if we're at the bottom hitting something else, grow the grid so cursor doesn't leave when trying to place below others\r\n let prev = this._extraDragRow;\r\n if (this.engine.collide(node, p)) {\r\n let row = this.getRow();\r\n let extra = Math.max(0, (p.y + node.h) - row);\r\n if (this.opts.maxRow && row + extra > this.opts.maxRow) {\r\n extra = Math.max(0, this.opts.maxRow - row);\r\n }// @ts-ignore\r\n this._extraDragRow = extra;// @ts-ignore\r\n } else this._extraDragRow = 0;// @ts-ignore\r\n if (this._extraDragRow !== prev) this._updateContainerHeight();\r\n\r\n if (node.x === p.x && node.y === p.y) return; // skip same\r\n // DON'T skip one we tried as we might have failed because of coverage <50% before\r\n // if (node._lastTried && node._lastTried.x === x && node._lastTried.y === y) return;\r\n } else if (event.type === 'resize') {\r\n if (p.x < 0) return;\r\n // Scrolling page if needed\r\n Utils.updateScrollResize(event as MouseEvent, el, cellHeight);\r\n\r\n // get new size\r\n p.w = Math.round((ui.size.width - mLeft) / cellWidth);\r\n p.h = Math.round((ui.size.height - mTop) / cellHeight);\r\n if (node.w === p.w && node.h === p.h) return;\r\n if (node._lastTried && node._lastTried.w === p.w && node._lastTried.h === p.h) return; // skip one we tried (but failed)\r\n\r\n // if we size on left/top side this might move us, so get possible new position as well\r\n let left = ui.position.left + mLeft;\r\n let top = ui.position.top + mTop;\r\n p.x = Math.round(left / cellWidth);\r\n p.y = Math.round(top / cellHeight);\r\n\r\n resizing = true;\r\n }\r\n\r\n node._lastTried = p; // set as last tried (will nuke if we go there)\r\n let rect: GridStackPosition = { // screen pix of the dragged box\r\n x: ui.position.left + mLeft,\r\n y: ui.position.top + mTop,\r\n w: (ui.size ? ui.size.width : node.w * cellWidth) - mLeft - mRight,\r\n h: (ui.size ? ui.size.height : node.h * cellHeight) - mTop - mBottom\r\n };\r\n if (this.engine.moveNodeCheck(node, {...p, cellWidth, cellHeight, rect})) {\r\n node._lastUiPosition = ui.position;\r\n this.engine.cacheRects(cellWidth, cellHeight, mTop, mRight, mBottom, mLeft);\r\n delete node._skipDown;\r\n if (resizing && node.subGrid) { (node.subGrid as GridStack).onParentResize(); }// @ts-ignore\r\n this._extraDragRow = 0;// @ts-ignore\r\n this._updateContainerHeight();\r\n\r\n let target = event.target as GridItemHTMLElement;// @ts-ignore\r\n this._writePosAttr(target, node);\r\n if (this._gsEventHandler[event.type]) {\r\n this._gsEventHandler[event.type](event, target);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Enables/Disables moving.\r\n * @param els widget or selector to modify.\r\n * @param val if true widget will be draggable.\r\n */\r\nGridStack.prototype.movable = function(this: GridStack, els: GridStackElement, val: boolean): GridStack {\r\n if (this.opts.staticGrid) return this; // can't move a static grid!\r\n GridStack.getElements(els).forEach(el => {\r\n let node = el.gridstackNode;\r\n if (!node) return;\r\n if (val) delete node.noMove; else node.noMove = true;\r\n this._prepareDragDropByNode(node); // init DD if need be, and adjust\r\n });\r\n return this;\r\n}\r\n\r\n/**\r\n * Enables/Disables resizing.\r\n * @param els widget or selector to modify\r\n * @param val if true widget will be resizable.\r\n */\r\nGridStack.prototype.resizable = function(this: GridStack, els: GridStackElement, val: boolean): GridStack {\r\n if (this.opts.staticGrid) return this; // can't resize a static grid!\r\n GridStack.getElements(els).forEach(el => {\r\n let node = el.gridstackNode;\r\n if (!node) return;\r\n if (val) delete node.noResize; else node.noResize = true;\r\n this._prepareDragDropByNode(node); // init DD if need be, and adjust\r\n });\r\n return this;\r\n}\r\n\r\n\r\n/**\r\n * Temporarily disables widgets moving/resizing.\r\n * If you want a more permanent way (which freezes up resources) use `setStatic(true)` instead.\r\n * Note: no-op for static grid\r\n * This is a shortcut for:\r\n * @example\r\n * grid.enableMove(false);\r\n * grid.enableResize(false);\r\n */\r\nGridStack.prototype.disable = function(this: GridStack): GridStack {\r\n if (this.opts.staticGrid) return;\r\n this.enableMove(false);\r\n this.enableResize(false);// @ts-ignore\r\n this._triggerEvent('disable');\r\n return this;\r\n}\r\n\r\n/**\r\n * Re-enables widgets moving/resizing - see disable().\r\n * Note: no-op for static grid.\r\n * This is a shortcut for:\r\n * @example\r\n * grid.enableMove(true);\r\n * grid.enableResize(true);\r\n */\r\nGridStack.prototype.enable = function(this: GridStack): GridStack {\r\n if (this.opts.staticGrid) return;\r\n this.enableMove(true);\r\n this.enableResize(true);// @ts-ignore\r\n this._triggerEvent('enable');\r\n return this;\r\n}\r\n\r\n/** Enables/disables widget moving. No-op for static grids. */\r\nGridStack.prototype.enableMove = function(this: GridStack, doEnable: boolean): GridStack {\r\n if (this.opts.staticGrid) return this; // can't move a static grid!\r\n this.opts.disableDrag = !doEnable; // FIRST before we update children as grid overrides #1658\r\n this.engine.nodes.forEach(n => this.movable(n.el, doEnable));\r\n return this;\r\n}\r\n\r\n/** Enables/disables widget resizing. No-op for static grids. */\r\nGridStack.prototype.enableResize = function(this: GridStack, doEnable: boolean): GridStack {\r\n if (this.opts.staticGrid) return this; // can't size a static grid!\r\n this.opts.disableResize = !doEnable; // FIRST before we update children as grid overrides #1658\r\n this.engine.nodes.forEach(n => this.resizable(n.el, doEnable));\r\n return this;\r\n}\r\n","/**\r\n * gridstack-ddi.ts 4.2.6\r\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\r\n */\r\n\r\nimport { GridItemHTMLElement } from './types';\r\n\r\n/**\r\n * Abstract Partial Interface API for drag'n'drop plugin - look at GridStackDD and HTML5 / Jquery implementation versions\r\n */\r\nexport class GridStackDDI {\r\n\r\n protected static ddi: GridStackDDI;\r\n\r\n /** call this method to register your plugin instead of the default no-op one */\r\n static registerPlugin(pluginClass: typeof GridStackDDI): GridStackDDI {\r\n GridStackDDI.ddi = new pluginClass();\r\n return GridStackDDI.ddi;\r\n }\r\n\r\n /** get the current registered plugin to use */\r\n static get(): GridStackDDI {\r\n return GridStackDDI.ddi || GridStackDDI.registerPlugin(GridStackDDI);\r\n }\r\n\r\n /** removes any drag&drop present (called during destroy) */\r\n /* eslint-disable-next-line @typescript-eslint/no-unused-vars */\r\n public remove(el: GridItemHTMLElement): GridStackDDI {\r\n return this; // no-op for static grids\r\n }\r\n}\r\n","/**\r\n * gridstack-engine.ts 4.2.6\r\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\r\n */\r\n\r\nimport { Utils } from './utils';\r\nimport { GridStackNode, ColumnOptions, GridStackPosition, GridStackMoveOpts } from './types';\r\n\r\nexport type onChangeCB = (nodes: GridStackNode[], removeDOM?: boolean) => void;\r\n/** options used for creations - similar to GridStackOptions */\r\nexport interface GridStackEngineOptions {\r\n column?: number;\r\n maxRow?: number;\r\n float?: boolean;\r\n nodes?: GridStackNode[];\r\n onChange?: onChangeCB;\r\n}\r\n\r\n/**\r\n * Defines the GridStack engine that does most no DOM grid manipulation.\r\n * See GridStack methods and vars for descriptions.\r\n *\r\n * NOTE: values should not be modified directly - call the main GridStack API instead\r\n */\r\nexport class GridStackEngine {\r\n public column: number;\r\n public maxRow: number;\r\n public nodes: GridStackNode[];\r\n public onChange: onChangeCB;\r\n public addedNodes: GridStackNode[] = [];\r\n public removedNodes: GridStackNode[] = [];\r\n public batchMode: boolean;\r\n /** @internal */\r\n private _float: boolean;\r\n /** @internal */\r\n private _prevFloat: boolean;\r\n /** @internal */\r\n private _layouts?: Layout[][]; // maps column # to array of values nodes\r\n /** @internal */\r\n private _ignoreLayoutsNodeChange: boolean;\r\n /** @internal true if we have some items locked */\r\n private _hasLocked: boolean;\r\n /** @internal unique global internal _id counter NOT starting at 0 */\r\n private static _idSeq = 1;\r\n\r\n public constructor(opts: GridStackEngineOptions = {}) {\r\n this.column = opts.column || 12;\r\n this.onChange = opts.onChange;\r\n this._float = opts.float;\r\n this.maxRow = opts.maxRow;\r\n this.nodes = opts.nodes || [];\r\n }\r\n\r\n public batchUpdate(): GridStackEngine {\r\n if (this.batchMode) return this;\r\n this.batchMode = true;\r\n this._prevFloat = this._float;\r\n this._float = true; // let things go anywhere for now... commit() will restore and possibly reposition\r\n this.saveInitial(); // since begin update (which is called multiple times) won't do this\r\n return this;\r\n }\r\n\r\n public commit(): GridStackEngine {\r\n if (!this.batchMode) return this;\r\n this.batchMode = false;\r\n this._float = this._prevFloat;\r\n delete this._prevFloat;\r\n return this._packNodes()\r\n ._notify();\r\n }\r\n\r\n // use entire row for hitting area (will use bottom reverse sorted first) if we not actively moving DOWN and didn't already skip\r\n private _useEntireRowArea(node: GridStackNode, nn: GridStackPosition): boolean {\r\n return !this.float && !this._hasLocked && (!node._moving || node._skipDown || nn.y <= node.y);\r\n }\r\n\r\n /** @internal fix collision on given 'node', going to given new location 'nn', with optional 'collide' node already found.\r\n * return true if we moved. */\r\n private _fixCollisions(node: GridStackNode, nn = node, collide?: GridStackNode, opt: GridStackMoveOpts = {}): boolean {\r\n this._sortNodes(-1); // from last to first, so recursive collision move items in the right order\r\n\r\n collide = collide || this.collide(node, nn); // REAL area collide for swap and skip if none...\r\n if (!collide) return false;\r\n\r\n // swap check: if we're actively moving in gravity mode, see if we collide with an object the same size\r\n if (node._moving && !opt.nested && !this.float) {\r\n if (this.swap(node, collide)) return true;\r\n }\r\n\r\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)\r\n let area = nn;\r\n if (this._useEntireRowArea(node, nn)) {\r\n area = {x: 0, w: this.column, y: nn.y, h: nn.h};\r\n collide = this.collide(node, area, opt.skip); // force new hit\r\n }\r\n\r\n let didMove = false;\r\n let newOpt: GridStackMoveOpts = {nested: true, pack: false};\r\n while (collide = collide || this.collide(node, area, opt.skip)) { // could collide with more than 1 item... so repeat for each\r\n let moved: boolean;\r\n // if colliding with a locked item OR moving down with top gravity (and collide could move up) -> skip past the collide,\r\n // but remember that skip down so we only do this once (and push others otherwise).\r\n if (collide.locked || node._moving && !node._skipDown && nn.y > node.y && !this.float &&\r\n // can take space we had, or before where we're going\r\n (!this.collide(collide, {...collide, y: node.y}, node) || !this.collide(collide, {...collide, y: nn.y - collide.h}, node))) {\r\n node._skipDown = (node._skipDown || nn.y > node.y);\r\n moved = this.moveNode(node, {...nn, y: collide.y + collide.h, ...newOpt});\r\n if (collide.locked && moved) {\r\n Utils.copyPos(nn, node); // moving after lock become our new desired location\r\n } else if (!collide.locked && moved && opt.pack) {\r\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\r\n this._packNodes();\r\n nn.y = collide.y + collide.h;\r\n Utils.copyPos(node, nn);\r\n }\r\n didMove = didMove || moved;\r\n } else {\r\n // move collide down *after* where we will be, ignoring where we are now (don't collide with us)\r\n moved = this.moveNode(collide, {...collide, y: nn.y + nn.h, skip: node, ...newOpt});\r\n }\r\n if (!moved) { return didMove; } // break inf loop if we couldn't move after all (ex: maxRow, fixed)\r\n collide = undefined;\r\n }\r\n return didMove;\r\n }\r\n\r\n /** return the nodes that intercept the given node. Optionally a different area can be used, as well as a second node to skip */\r\n public collide(skip: GridStackNode, area = skip, skip2?: GridStackNode): GridStackNode {\r\n return this.nodes.find(n => n !== skip && n !== skip2 && Utils.isIntercepted(n, area));\r\n }\r\n public collideAll(skip: GridStackNode, area = skip, skip2?: GridStackNode): GridStackNode[] {\r\n return this.nodes.filter(n => n !== skip && n !== skip2 && Utils.isIntercepted(n, area));\r\n }\r\n\r\n /** does a pixel coverage collision, returning the node that has the most coverage that is >50% mid line */\r\n public collideCoverage(node: GridStackNode, o: GridStackMoveOpts, collides: GridStackNode[]): GridStackNode {\r\n if (!o.rect || !node._rect) return;\r\n let r0 = node._rect; // where started\r\n let r = {...o.rect}; // where we are\r\n\r\n // update dragged rect to show where it's coming from (above or below, etc...)\r\n if (r.y > r0.y) {\r\n r.h += r.y - r0.y;\r\n r.y = r0.y;\r\n } else {\r\n r.h += r0.y - r.y;\r\n }\r\n if (r.x > r0.x) {\r\n r.w += r.x - r0.x;\r\n r.x = r0.x;\r\n } else {\r\n r.w += r0.x - r.x;\r\n }\r\n\r\n let collide: GridStackNode;\r\n collides.forEach(n => {\r\n if (n.locked || !n._rect) return;\r\n let r2 = n._rect; // overlapping target\r\n let yOver = Number.MAX_VALUE, xOver = Number.MAX_VALUE, overMax = 0.5; // need >50%\r\n // depending on which side we started from, compute the overlap % of coverage\r\n // (ex: from above/below we only compute the max horizontal line coverage)\r\n if (r0.y < r2.y) { // from above\r\n yOver = ((r.y + r.h) - r2.y) / r2.h;\r\n } else if (r0.y+r0.h > r2.y+r2.h) { // from below\r\n yOver = ((r2.y + r2.h) - r.y) / r2.h;\r\n }\r\n if (r0.x < r2.x) { // from the left\r\n xOver = ((r.x + r.w) - r2.x) / r2.w;\r\n } else if (r0.x+r0.w > r2.x+r2.w) { // from the right\r\n xOver = ((r2.x + r2.w) - r.x) / r2.w;\r\n }\r\n let over = Math.min(xOver, yOver);\r\n if (over > overMax) {\r\n overMax = over;\r\n collide = n;\r\n }\r\n });\r\n return collide;\r\n }\r\n\r\n /** called to cache the nodes pixel rectangles used for collision detection during drag */\r\n public cacheRects(w: number, h: number, top: number, right: number, bottom: number, left: number): GridStackEngine\r\n {\r\n this.nodes.forEach(n =>\r\n n._rect = {\r\n y: n.y * h + top,\r\n x: n.x * w + left,\r\n w: n.w * w - left - right,\r\n h: n.h * h - top - bottom\r\n }\r\n );\r\n return this;\r\n }\r\n\r\n /** called to possibly swap between 2 nodes (same size or column, not locked, touching), returning true if successful */\r\n public swap(a: GridStackNode, b: GridStackNode): boolean {\r\n if (!b || b.locked || !a || a.locked) return false;\r\n\r\n function _doSwap(): true { // assumes a is before b IFF they have different height (put after rather than exact swap)\r\n let x = b.x, y = b.y;\r\n b.x = a.x; b.y = a.y; // b -> a position\r\n if (a.h != b.h) {\r\n a.x = x; a.y = b.y + b.h; // a -> goes after b\r\n } else {\r\n a.x = x; a.y = y; // a -> old b position\r\n }\r\n a._dirty = b._dirty = true;\r\n return true;\r\n }\r\n let touching: boolean; // remember if we called it (vs undefined)\r\n\r\n // same size and same row or column, and touching\r\n if (a.w === b.w && a.h === b.h && (a.x === b.x || a.y === b.y) && (touching = Utils.isTouching(a, b)))\r\n return _doSwap();\r\n if (touching === false) return; // ran test and fail, bail out\r\n\r\n // check for taking same columns (but different height) and touching\r\n if (a.w === b.w && a.x === b.x && (touching || Utils.isTouching(a, b))) {\r\n if (b.y < a.y) { let t = a; a = b; b = t; } // swap a <-> b vars so a is first\r\n return _doSwap();\r\n }\r\n\r\n /* different X will be weird (expect vertical swap) and different height overlap, so too complex. user regular layout instead\r\n // else check if swapping would not collide with anything else (requiring a re-layout)\r\n if (!this.collide(a, {x: a.x, y: a.y, w: b.w, h: b.h}, b) &&\r\n !this.collide(a, {x: b.x, y: b.y, w: a.w, h: a.h}, b))\r\n return _doSwap(); */\r\n return false;\r\n }\r\n\r\n public isAreaEmpty(x: number, y: number, w: number, h: number): boolean {\r\n let nn: GridStackNode = {x: x || 0, y: y || 0, w: w || 1, h: h || 1};\r\n return !this.collide(nn);\r\n }\r\n\r\n /** re-layout grid items to reclaim any empty space */\r\n public compact(): GridStackEngine {\r\n if (this.nodes.length === 0) return this;\r\n this.batchUpdate()\r\n ._sortNodes();\r\n let copyNodes = this.nodes;\r\n this.nodes = []; // pretend we have no nodes to conflict layout to start with...\r\n copyNodes.forEach(node => {\r\n if (!node.locked) {\r\n node.autoPosition = true;\r\n }\r\n this.addNode(node, false); // 'false' for add event trigger\r\n node._dirty = true; // will force attr update\r\n });\r\n return this.commit();\r\n }\r\n\r\n /** enable/disable floating widgets (default: `false`) See [example](http://gridstackjs.com/demo/float.html) */\r\n public set float(val: boolean) {\r\n if (this._float === val) return;\r\n this._float = val || false;\r\n if (!val) {\r\n this._packNodes()._notify();\r\n }\r\n }\r\n\r\n /** float getter method */\r\n public get float(): boolean { return this._float || false; }\r\n\r\n /** @internal */\r\n private _sortNodes(dir?: -1 | 1): GridStackEngine {\r\n this.nodes = Utils.sort(this.nodes, dir, this.column);\r\n return this;\r\n }\r\n\r\n /** @internal called to top gravity pack the items back OR revert back to original Y positions when floating */\r\n private _packNodes(): GridStackEngine {\r\n this._sortNodes(); // first to last\r\n\r\n if (this.float) {\r\n // restore original Y pos\r\n this.nodes.forEach(n => {\r\n if (n._updating || n._orig === undefined || n.y === n._orig.y) return;\r\n let newY = n.y;\r\n while (newY > n._orig.y) {\r\n --newY;\r\n let collide = this.collide(n, {x: n.x, y: newY, w: n.w, h: n.h});\r\n if (!collide) {\r\n n._dirty = true;\r\n n.y = newY;\r\n }\r\n }\r\n });\r\n } else {\r\n // top gravity pack\r\n this.nodes.forEach((n, i) => {\r\n if (n.locked) return;\r\n while (n.y > 0) {\r\n let newY = i === 0 ? 0 : n.y - 1;\r\n let canBeMoved = i === 0 || !this.collide(n, {x: n.x, y: newY, w: n.w, h: n.h});\r\n if (!canBeMoved) break;\r\n // Note: must be dirty (from last position) for GridStack::OnChange CB to update positions\r\n // and move items back. The user 'change' CB should detect changes from the original\r\n // starting position instead.\r\n n._dirty = (n.y !== newY);\r\n n.y = newY;\r\n }\r\n });\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * given a random node, makes sure it's coordinates/values are valid in the current grid\r\n * @param node to adjust\r\n * @param resizing if out of bound, resize down or move into the grid to fit ?\r\n */\r\n public prepareNode(node: GridStackNode, resizing?: boolean): GridStackNode {\r\n node = node || {};\r\n node._id = node._id || GridStackEngine._idSeq++;\r\n\r\n // if we're missing position, have the grid position us automatically (before we set them to 0,0)\r\n if (node.x === undefined || node.y === undefined || node.x === null || node.y === null) {\r\n node.autoPosition = true;\r\n }\r\n\r\n // assign defaults for missing required fields\r\n let defaults: GridStackNode = { x: 0, y: 0, w: 1, h: 1};\r\n Utils.defaults(node, defaults);\r\n\r\n if (!node.autoPosition) { delete node.autoPosition; }\r\n if (!node.noResize) { delete node.noResize; }\r\n if (!node.noMove) { delete node.noMove; }\r\n\r\n // check for NaN (in case messed up strings were passed. can't do parseInt() || defaults.x above as 0 is valid #)\r\n if (typeof node.x == 'string') { node.x = Number(node.x); }\r\n if (typeof node.y == 'string') { node.y = Number(node.y); }\r\n if (typeof node.w == 'string') { node.w = Number(node.w); }\r\n if (typeof node.h == 'string') { node.h = Number(node.h); }\r\n if (isNaN(node.x)) { node.x = defaults.x; node.autoPosition = true; }\r\n if (isNaN(node.y)) { node.y = defaults.y; node.autoPosition = true; }\r\n if (isNaN(node.w)) { node.w = defaults.w; }\r\n if (isNaN(node.h)) { node.h = defaults.h; }\r\n\r\n return this.nodeBoundFix(node, resizing);\r\n }\r\n\r\n /** part2 of preparing a node to fit inside our grid - checks for x,y from grid dimensions */\r\n public nodeBoundFix(node: GridStackNode, resizing?: boolean): GridStackNode {\r\n\r\n if (node.maxW) { node.w = Math.min(node.w, node.maxW); }\r\n if (node.maxH) { node.h = Math.min(node.h, node.maxH); }\r\n if (node.minW) { node.w = Math.max(node.w, node.minW); }\r\n if (node.minH) { node.h = Math.max(node.h, node.minH); }\r\n\r\n if (node.w > this.column) {\r\n // if user loaded a larger than allowed widget for current # of columns,\r\n // remember it's full width so we can restore back (1 -> 12 column) #1655\r\n if (this.column < 12) {\r\n node.w = Math.min(12, node.w);\r\n this.cacheOneLayout(node, 12);\r\n }\r\n node.w = this.column;\r\n } else if (node.w < 1) {\r\n node.w = 1;\r\n }\r\n\r\n if (this.maxRow && node.h > this.maxRow) {\r\n node.h = this.maxRow;\r\n } else if (node.h < 1) {\r\n node.h = 1;\r\n }\r\n\r\n if (node.x < 0) {\r\n node.x = 0;\r\n }\r\n if (node.y < 0) {\r\n node.y = 0;\r\n }\r\n\r\n if (node.x + node.w > this.column) {\r\n if (resizing) {\r\n node.w = this.column - node.x;\r\n } else {\r\n node.x = this.column - node.w;\r\n }\r\n }\r\n if (this.maxRow && node.y + node.h > this.maxRow) {\r\n if (resizing) {\r\n node.h = this.maxRow - node.y;\r\n } else {\r\n node.y = this.maxRow - node.h;\r\n }\r\n }\r\n\r\n return node;\r\n }\r\n\r\n public getDirtyNodes(verify?: boolean): GridStackNode[] {\r\n // compare original x,y,w,h instead as _dirty can be a temporary state\r\n if (verify) {\r\n return this.nodes.filter(n => n._dirty && !Utils.samePos(n, n._orig));\r\n }\r\n return this.nodes.filter(n => n._dirty);\r\n }\r\n\r\n /** @internal call this to call onChange CB with dirty nodes */\r\n private _notify(nodes?: GridStackNode | GridStackNode[], removeDOM = true): GridStackEngine {\r\n if (this.batchMode) return this;\r\n nodes = (nodes === undefined ? [] : (Array.isArray(nodes) ? nodes : [nodes]) );\r\n let dirtyNodes = nodes.concat(this.getDirtyNodes());\r\n this.onChange && this.onChange(dirtyNodes, removeDOM);\r\n return this;\r\n }\r\n\r\n /** @internal remove dirty and last tried info */\r\n public cleanNodes(): GridStackEngine {\r\n if (this.batchMode) return this;\r\n this.nodes.forEach(n => {\r\n delete n._dirty;\r\n delete n._lastTried;\r\n });\r\n return this;\r\n }\r\n\r\n /** @internal called to save initial position/size to track real dirty state.\r\n * Note: should be called right after we call change event (so next API is can detect changes)\r\n * as well as right before we start move/resize/enter (so we can restore items to prev values) */\r\n public saveInitial(): GridStackEngine {\r\n this.nodes.forEach(n => {\r\n n._orig = Utils.copyPos({}, n);\r\n delete n._dirty;\r\n });\r\n this._hasLocked = this.nodes.some(n => n.locked);\r\n return this;\r\n }\r\n\r\n /** @internal restore all the nodes back to initial values (called when we leave) */\r\n public restoreInitial(): GridStackEngine {\r\n this.nodes.forEach(n => {\r\n if (Utils.samePos(n, n._orig)) return;\r\n Utils.copyPos(n, n._orig);\r\n n._dirty = true;\r\n });\r\n this._notify();\r\n return this;\r\n }\r\n\r\n /** call to add the given node to our list, fixing collision and re-packing */\r\n public addNode(node: GridStackNode, triggerAddEvent = false): GridStackNode {\r\n let dup: GridStackNode;\r\n if (dup = this.nodes.find(n => n._id === node._id)) return dup; // prevent inserting twice! return it instead.\r\n\r\n node = this.prepareNode(node);\r\n delete node._temporaryRemoved;\r\n delete node._removeDOM;\r\n\r\n if (node.autoPosition) {\r\n this._sortNodes();\r\n\r\n for (let i = 0;; ++i) {\r\n let x = i % this.column;\r\n let y = Math.floor(i / this.column);\r\n if (x + node.w > this.column) {\r\n continue;\r\n }\r\n let box = {x, y, w: node.w, h: node.h};\r\n if (!this.nodes.find(n => Utils.isIntercepted(box, n))) {\r\n node.x = x;\r\n node.y = y;\r\n delete node.autoPosition; // found our slot\r\n break;\r\n }\r\n }\r\n }\r\n\r\n this.nodes.push(node);\r\n triggerAddEvent && this.addedNodes.push(node);\r\n\r\n this._fixCollisions(node);\r\n this._packNodes()\r\n ._notify();\r\n return node;\r\n }\r\n\r\n public removeNode(node: GridStackNode, removeDOM = true, triggerEvent = false): GridStackEngine {\r\n if (!this.nodes.find(n => n === node)) {\r\n // TEST console.log(`Error: GridStackEngine.removeNode() node._id=${node._id} not found!`)\r\n return this;\r\n }\r\n if (triggerEvent) { // we wait until final drop to manually track removed items (rather than during drag)\r\n this.removedNodes.push(node);\r\n }\r\n if (removeDOM) node._removeDOM = true; // let CB remove actual HTML (used to set _id to null, but then we loose layout info)\r\n // don't use 'faster' .splice(findIndex(),1) in case node isn't in our list, or in multiple times.\r\n this.nodes = this.nodes.filter(n => n !== node);\r\n return this._packNodes()\r\n ._notify(node);\r\n }\r\n\r\n public removeAll(removeDOM = true): GridStackEngine {\r\n delete this._layouts;\r\n if (this.nodes.length === 0) return this;\r\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)\r\n this.removedNodes = this.nodes;\r\n this.nodes = [];\r\n return this._notify(this.removedNodes);\r\n }\r\n\r\n /** checks if item can be moved (layout constrain) vs moveNode(), returning true if was able to move.\r\n * In more complicated cases (maxRow) it will attempt at moving the item and fixing\r\n * others in a clone first, then apply those changes if still within specs. */\r\n public moveNodeCheck(node: GridStackNode, o: GridStackMoveOpts): boolean {\r\n // if (node.locked) return false;\r\n if (!this.changedPosConstrain(node, o)) return false;\r\n o.pack = true;\r\n\r\n // simpler case: move item directly...\r\n if (!this.maxRow/* && !this._hasLocked*/) {\r\n return this.moveNode(node, o);\r\n }\r\n\r\n // complex case: create a clone with NO maxRow (will check for out of bounds at the end)\r\n let clonedNode: GridStackNode;\r\n let clone = new GridStackEngine({\r\n column: this.column,\r\n float: this.float,\r\n nodes: this.nodes.map(n => {\r\n if (n === node) {\r\n clonedNode = {...n};\r\n return clonedNode;\r\n }\r\n return {...n};\r\n })\r\n });\r\n if (!clonedNode) return false;\r\n\r\n let canMove = clone.moveNode(clonedNode, o);\r\n // if maxRow make sure we are still valid size\r\n if (this.maxRow && canMove) {\r\n canMove = (clone.getRow() <= this.maxRow);\r\n // turns out we can't grow, then see if we can swap instead (ex: full grid)\r\n if (!canMove) {\r\n let collide = this.collide(node, o);\r\n if (collide && this.swap(node, collide)) {\r\n this._notify();\r\n return true;\r\n }\r\n }\r\n }\r\n if (!canMove) return false;\r\n\r\n // if clone was able to move, copy those mods over to us now instead of caller trying to do this all over!\r\n // Note: we can't use the list directly as elements and other parts point to actual node, so copy content\r\n clone.nodes.filter(n => n._dirty).forEach(c => {\r\n let n = this.nodes.find(a => a._id === c._id);\r\n if (!n) return;\r\n Utils.copyPos(n, c);\r\n n._dirty = true;\r\n });\r\n this._notify();\r\n return true;\r\n }\r\n\r\n /** return true if can fit in grid height constrain only (always true if no maxRow) */\r\n public willItFit(node: GridStackNode): boolean {\r\n delete node._willFitPos;\r\n if (!this.maxRow) return true;\r\n // create a clone with NO maxRow and check if still within size\r\n let clone = new GridStackEngine({\r\n column: this.column,\r\n float: this.float,\r\n nodes: this.nodes.map(n => {return {...n}})\r\n });\r\n let n = {...node}; // clone node so we don't mod any settings on it but have full autoPosition and min/max as well! #1687\r\n this.cleanupNode(n);\r\n delete n.el; delete n._id; delete n.content; delete n.grid;\r\n clone.addNode(n);\r\n if (clone.getRow() <= this.maxRow) {\r\n node._willFitPos = Utils.copyPos({}, n);\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n /** true if x,y or w,h are different after clamping to min/max */\r\n public changedPosConstrain(node: GridStackNode, p: GridStackPosition): boolean {\r\n // make sure w,h are set\r\n p.w = p.w || node.w;\r\n p.h = p.h || node.h;\r\n if (node.x !== p.x || node.y !== p.y) return true;\r\n // check constrained w,h\r\n if (node.maxW) { p.w = Math.min(p.w, node.maxW); }\r\n if (node.maxH) { p.h = Math.min(p.h, node.maxH); }\r\n if (node.minW) { p.w = Math.max(p.w, node.minW); }\r\n if (node.minH) { p.h = Math.max(p.h, node.minH); }\r\n return (node.w !== p.w || node.h !== p.h);\r\n }\r\n\r\n /** return true if the passed in node was actually moved (checks for no-op and locked) */\r\n public moveNode(node: GridStackNode, o: GridStackMoveOpts): boolean {\r\n if (!node || /*node.locked ||*/ !o) return false;\r\n if (o.pack === undefined) o.pack = true;\r\n\r\n // constrain the passed in values and check if we're still changing our node\r\n if (typeof o.x !== 'number') { o.x = node.x; }\r\n if (typeof o.y !== 'number') { o.y = node.y; }\r\n if (typeof o.w !== 'number') { o.w = node.w; }\r\n if (typeof o.h !== 'number') { o.h = node.h; }\r\n let resizing = (node.w !== o.w || node.h !== o.h);\r\n let nn: GridStackNode = Utils.copyPos({}, node, true); // get min/max out first, then opt positions next\r\n Utils.copyPos(nn, o);\r\n nn = this.nodeBoundFix(nn, resizing);\r\n Utils.copyPos(o, nn);\r\n\r\n if (Utils.samePos(node, o)) return false;\r\n let prevPos: GridStackPosition = Utils.copyPos({}, node);\r\n\r\n // during while() collisions make sure to check entire row so larger items don't leap frog small ones (push them all down)\r\n let area = nn;\r\n // if (this._useEntireRowArea(node, nn)) {\r\n // area = {x: 0, w: this.column, y: nn.y, h: nn.h};\r\n // }\r\n\r\n // check if we will need to fix collision at our new location\r\n let collides = this.collideAll(node, area, o.skip);\r\n let needToMove = true;\r\n if (collides.length) {\r\n // now check to make sure we actually collided over 50% surface area while dragging\r\n let collide = node._moving && !o.nested ? this.collideCoverage(node, o, collides) : collides[0];\r\n if (collide) {\r\n needToMove = !this._fixCollisions(node, nn, collide, o); // check if already moved...\r\n } else {\r\n needToMove = false; // we didn't cover >50% for a move, skip...\r\n }\r\n }\r\n\r\n // now move (to the original ask vs the collision version which might differ) and repack things\r\n if (needToMove) {\r\n node._dirty = true;\r\n Utils.copyPos(node, nn);\r\n }\r\n if (o.pack) {\r\n this._packNodes()\r\n ._notify();\r\n }\r\n return !Utils.samePos(node, prevPos); // pack might have moved things back\r\n }\r\n\r\n public getRow(): number {\r\n return this.nodes.reduce((row, n) => Math.max(row, n.y + n.h), 0);\r\n }\r\n\r\n public beginUpdate(node: GridStackNode): GridStackEngine {\r\n if (!node._updating) {\r\n node._updating = true;\r\n delete node._skipDown;\r\n if (!this.batchMode) this.saveInitial();\r\n }\r\n return this;\r\n }\r\n\r\n public endUpdate(): GridStackEngine {\r\n let n = this.nodes.find(n => n._updating);\r\n if (n) {\r\n delete n._updating;\r\n delete n._skipDown;\r\n }\r\n return this;\r\n }\r\n\r\n /** saves a copy of the current layout returning a list of widgets for serialization */\r\n public save(saveElement = true): GridStackNode[] {\r\n let list: GridStackNode[] = [];\r\n this._sortNodes();\r\n this.nodes.forEach(n => {\r\n let w: GridStackNode = {};\r\n for (let key in n) { if (key[0] !== '_' && n[key] !== null && n[key] !== undefined ) w[key] = n[key]; }\r\n // delete other internals\r\n delete w.grid;\r\n if (!saveElement) delete w.el;\r\n // delete default values (will be re-created on read)\r\n if (!w.autoPosition) delete w.autoPosition;\r\n if (!w.noResize) delete w.noResize;\r\n if (!w.noMove) delete w.noMove;\r\n if (!w.locked) delete w.locked;\r\n list.push(w);\r\n });\r\n return list;\r\n }\r\n\r\n /** @internal called whenever a node is added or moved - updates the cached layouts */\r\n public layoutsNodesChange(nodes: GridStackNode[]): GridStackEngine {\r\n if (!this._layouts || this._ignoreLayoutsNodeChange) return this;\r\n // remove smaller layouts - we will re-generate those on the fly... larger ones need to update\r\n this._layouts.forEach((layout, column) => {\r\n if (!layout || column === this.column) return this;\r\n if (column < this.column) {\r\n this._layouts[column] = undefined;\r\n }\r\n else {\r\n // we save the original x,y,w (h isn't cached) to see what actually changed to propagate better.\r\n // Note: we don't need to check against out of bound scaling/moving as that will be done when using those cache values.\r\n nodes.forEach(node => {\r\n if (!node._orig) return; // didn't change (newly added ?)\r\n let n = layout.find(l => l._id === node._id);\r\n if (!n) return; // no cache for new nodes. Will use those values.\r\n let ratio = column / this.column;\r\n // Y changed, push down same amount\r\n // TODO: detect doing item 'swaps' will help instead of move (especially in 1 column mode)\r\n if (node.y !== node._orig.y) {\r\n n.y += (node.y - node._orig.y);\r\n }\r\n // X changed, scale from new position\r\n if (node.x !== node._orig.x) {\r\n n.x = Math.round(node.x * ratio);\r\n }\r\n // width changed, scale from new width\r\n if (node.w !== node._orig.w) {\r\n n.w = Math.round(node.w * ratio);\r\n }\r\n // ...height always carries over from cache\r\n });\r\n }\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * @internal Called to scale the widget width & position up/down based on the column change.\r\n * Note we store previous layouts (especially original ones) to make it possible to go\r\n * from say 12 -> 1 -> 12 and get back to where we were.\r\n *\r\n * @param oldColumn previous number of columns\r\n * @param column new column number\r\n * @param nodes different sorted list (ex: DOM order) instead of current list\r\n * @param layout specify the type of re-layout that will happen (position, size, etc...).\r\n * Note: items will never be outside of the current column boundaries. default (moveScale). Ignored for 1 column\r\n */\r\n public updateNodeWidths(oldColumn: number, column: number, nodes: GridStackNode[], layout: ColumnOptions = 'moveScale'): GridStackEngine {\r\n if (!this.nodes.length || oldColumn === column) return this;\r\n\r\n // cache the current layout in case they want to go back (like 12 -> 1 -> 12) as it requires original data\r\n this.cacheLayout(this.nodes, oldColumn);\r\n\r\n // if we're going to 1 column and using DOM order rather than default sorting, then generate that layout\r\n if (column === 1 && nodes && nodes.length) {\r\n let top = 0;\r\n nodes.forEach(n => {\r\n n.x = 0;\r\n n.w = 1;\r\n n.y = Math.max(n.y, top);\r\n top = n.y + n.h;\r\n });\r\n } else {\r\n nodes = Utils.sort(this.nodes, -1, oldColumn); // current column reverse sorting so we can insert last to front (limit collision)\r\n }\r\n\r\n // see if we have cached previous layout.\r\n let cacheNodes = this._layouts[column] || [];\r\n // if not AND we are going up in size start with the largest layout as down-scaling is more accurate\r\n let lastIndex = this._layouts.length - 1;\r\n if (cacheNodes.length === 0 && column > oldColumn && column < lastIndex) {\r\n cacheNodes = this._layouts[lastIndex] || [];\r\n if (cacheNodes.length) {\r\n // pretend we came from that larger column by assigning those values as starting point\r\n oldColumn = lastIndex;\r\n cacheNodes.forEach(cacheNode => {\r\n let j = nodes.findIndex(n => n._id === cacheNode._id);\r\n if (j !== -1) {\r\n // still current, use cache info positions\r\n nodes[j].x = cacheNode.x;\r\n nodes[j].y = cacheNode.y;\r\n nodes[j].w = cacheNode.w;\r\n }\r\n });\r\n cacheNodes = []; // we still don't have new column cached data... will generate from larger one.\r\n }\r\n }\r\n\r\n // if we found cache re-use those nodes that are still current\r\n let newNodes: GridStackNode[] = [];\r\n cacheNodes.forEach(cacheNode => {\r\n let j = nodes.findIndex(n => n._id === cacheNode._id);\r\n if (j !== -1) {\r\n // still current, use cache info positions\r\n nodes[j].x = cacheNode.x;\r\n nodes[j].y = cacheNode.y;\r\n nodes[j].w = cacheNode.w;\r\n newNodes.push(nodes[j]);\r\n nodes.splice(j, 1);\r\n }\r\n });\r\n // ...and add any extra non-cached ones\r\n if (nodes.length) {\r\n if (typeof layout === 'function') {\r\n layout(column, oldColumn, newNodes, nodes);\r\n } else {\r\n let ratio = column / oldColumn;\r\n let move = (layout === 'move' || layout === 'moveScale');\r\n let scale = (layout === 'scale' || layout === 'moveScale');\r\n nodes.forEach(node => {\r\n node.x = (column === 1 ? 0 : (move ? Math.round(node.x * ratio) : Math.min(node.x, column - 1)));\r\n node.w = ((column === 1 || oldColumn === 1) ? 1 :\r\n scale ? (Math.round(node.w * ratio) || 1) : (Math.min(node.w, column)));\r\n newNodes.push(node);\r\n });\r\n nodes = [];\r\n }\r\n }\r\n\r\n // finally re-layout them in reverse order (to get correct placement)\r\n newNodes = Utils.sort(newNodes, -1, column);\r\n this._ignoreLayoutsNodeChange = true;\r\n this.batchUpdate();\r\n this.nodes = []; // pretend we have no nodes to start with (we use same structures) to simplify layout\r\n newNodes.forEach(node => {\r\n this.addNode(node, false); // 'false' for add event trigger\r\n node._dirty = true; // force attr update\r\n }, this);\r\n this.commit();\r\n delete this._ignoreLayoutsNodeChange;\r\n return this;\r\n }\r\n\r\n /**\r\n * call to cache the given layout internally to the given location so we can restore back when column changes size\r\n * @param nodes list of nodes\r\n * @param column corresponding column index to save it under\r\n * @param clear if true, will force other caches to be removed (default false)\r\n */\r\n public cacheLayout(nodes: GridStackNode[], column: number, clear = false): GridStackEngine {\r\n let copy: Layout[] = [];\r\n nodes.forEach((n, i) => {\r\n n._id = n._id || GridStackEngine._idSeq++; // make sure we have an id in case this is new layout, else re-use id already set\r\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\r\n });\r\n this._layouts = clear ? [] : this._layouts || []; // use array to find larger quick\r\n this._layouts[column] = copy;\r\n return this;\r\n }\r\n\r\n /**\r\n * call to cache the given node layout internally to the given location so we can restore back when column changes size\r\n * @param node single node to cache\r\n * @param column corresponding column index to save it under\r\n */\r\n public cacheOneLayout(n: GridStackNode, column: number): GridStackEngine {\r\n n._id = n._id || GridStackEngine._idSeq++;\r\n let layout: Layout = {x: n.x, y: n.y, w: n.w, _id: n._id}\r\n this._layouts = this._layouts || [];\r\n this._layouts[column] = this._layouts[column] || [];\r\n let index = this._layouts[column].findIndex(l => l._id === n._id);\r\n index === -1 ? this._layouts[column].push(layout) : this._layouts[column][index] = layout;\r\n return this;\r\n }\r\n\r\n\r\n /** called to remove all internal values but the _id */\r\n public cleanupNode(node: GridStackNode): GridStackEngine {\r\n for (let prop in node) {\r\n if (prop[0] === '_' && prop !== '_id') delete node[prop];\r\n }\r\n return this;\r\n }\r\n}\r\n\r\n/** @internal class to store per column layout bare minimal info (subset of GridStackWidget) */\r\ninterface Layout {\r\n x: number;\r\n y: number;\r\n w: number;\r\n _id: number; // so we can find full node back\r\n}\r\n","/**\r\n * index-h5.ts 4.2.6 - everything you need for a Grid that uses HTML5 native drag&drop\r\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\r\n */\r\n\r\nexport * from './types';\r\nexport * from './utils';\r\nexport * from './gridstack-engine';\r\nexport * from './gridstack-ddi';\r\nexport * from './gridstack';\r\n\r\nexport * from './h5/gridstack-dd-native';\r\n\r\n// declare module 'gridstack'; for umd ?\r\n","/*!\r\n * GridStack 4.2.6\r\n * https://gridstackjs.com/\r\n *\r\n * Copyright (c) 2021 Alain Dumesny\r\n * see root license https://github.com/gridstack/gridstack.js/tree/master/LICENSE\r\n */\r\n\r\nimport { GridStackEngine } from './gridstack-engine';\r\nimport { Utils, HeightData } from './utils';\r\nimport { ColumnOptions, GridItemHTMLElement, GridStackElement, GridStackEventHandlerCallback,\r\n GridStackNode, GridStackOptions, GridStackWidget, numberOrString, DDUIData, DDDragInOpt, GridStackPosition } from './types';\r\nimport { GridStackDDI } from './gridstack-ddi';\r\n\r\n// export all dependent file as well to make it easier for users to just import the main file\r\nexport * from './types';\r\nexport * from './utils';\r\nexport * from './gridstack-engine';\r\nexport * from './gridstack-ddi';\r\n\r\nexport interface GridHTMLElement extends HTMLElement {\r\n gridstack?: GridStack; // grid's parent DOM element points back to grid class\r\n}\r\n/** list of possible events, or space separated list of them */\r\nexport type GridStackEvent = 'added' | 'change' | 'disable' | 'drag' | 'dragstart' | 'dragstop' | 'dropped' |\r\n 'enable' | 'removed' | 'resize' | 'resizestart' | 'resizestop' | string;\r\n\r\n/** Defines the coordinates of an object */\r\nexport interface MousePosition {\r\n top: number;\r\n left: number;\r\n}\r\n\r\n/** Defines the position of a cell inside the grid*/\r\nexport interface CellPosition {\r\n x: number;\r\n y: number;\r\n}\r\n\r\ninterface GridCSSStyleSheet extends CSSStyleSheet {\r\n _id?: string; // random id we will use to style us\r\n _max?: number; // internal tracker of the max # of rows we created\\\r\n}\r\n\r\n// default values for grid options - used during init and when saving out\r\nconst GridDefaults: GridStackOptions = {\r\n column: 12,\r\n minRow: 0,\r\n maxRow: 0,\r\n itemClass: 'grid-stack-item',\r\n placeholderClass: 'grid-stack-placeholder',\r\n placeholderText: '',\r\n handle: '.grid-stack-item-content',\r\n handleClass: null,\r\n styleInHead: false,\r\n cellHeight: 'auto',\r\n cellHeightThrottle: 100,\r\n margin: 10,\r\n auto: true,\r\n minWidth: 768,\r\n float: false,\r\n staticGrid: false,\r\n animate: true,\r\n alwaysShowResizeHandle: false,\r\n resizable: {\r\n autoHide: true,\r\n handles: 'se'\r\n },\r\n draggable: {\r\n handle: '.grid-stack-item-content',\r\n scroll: false,\r\n appendTo: 'body'\r\n },\r\n disableDrag: false,\r\n disableResize: false,\r\n rtl: 'auto',\r\n removable: false,\r\n removableOptions: {\r\n accept: '.grid-stack-item'\r\n },\r\n marginUnit: 'px',\r\n cellHeightUnit: 'px',\r\n disableOneColumnMode: false,\r\n oneColumnModeDomSort: false\r\n};\r\n\r\n/**\r\n * Main gridstack class - you will need to call `GridStack.init()` first to initialize your grid.\r\n * Note: your grid elements MUST have the following classes for the CSS layout to work:\r\n * @example\r\n * <div class=\"grid-stack\">\r\n * <div class=\"grid-stack-item\">\r\n * <div class=\"grid-stack-item-content\">Item 1</div>\r\n * </div>\r\n * </div>\r\n */\r\nexport class GridStack {\r\n\r\n /**\r\n * initializing the HTML element, or selector string, into a grid will return the grid. Calling it again will\r\n * simply return the existing instance (ignore any passed options). There is also an initAll() version that support\r\n * multiple grids initialization at once. Or you can use addGrid() to create the entire grid from JSON.\r\n * @param options grid options (optional)\r\n * @param elOrString element or CSS selector (first one used) to convert to a grid (default to '.grid-stack' class selector)\r\n *\r\n * @example\r\n * let grid = GridStack.init();\r\n *\r\n * Note: the HTMLElement (of type GridHTMLElement) will store a `gridstack: GridStack` value that can be retrieve later\r\n * let grid = document.querySelector('.grid-stack').gridstack;\r\n */\r\n public static init(options: GridStackOptions = {}, elOrString: GridStackElement = '.grid-stack'): GridStack {\r\n let el = GridStack.getGridElement(elOrString);\r\n if (!el) {\r\n if (typeof elOrString === 'string') {\r\n console.error('GridStack.initAll() no grid was found with selector \"' + elOrString + '\" - element missing or wrong selector ?' +\r\n '\\nNote: \".grid-stack\" is required for proper CSS styling and drag/drop, and is the default selector.');\r\n } else {\r\n console.error('GridStack.init() no grid element was passed.');\r\n }\r\n return null;\r\n }\r\n if (!el.gridstack) {\r\n el.gridstack = new GridStack(el, Utils.cloneDeep(options));\r\n }\r\n return el.gridstack\r\n }\r\n\r\n /**\r\n * Will initialize a list of elements (given a selector) and return an array of grids.\r\n * @param options grid options (optional)\r\n * @param selector elements selector to convert to grids (default to '.grid-stack' class selector)\r\n *\r\n * @example\r\n * let grids = GridStack.initAll();\r\n * grids.forEach(...)\r\n */\r\n public static initAll(options: GridStackOptions = {}, selector = '.grid-stack'): GridStack[] {\r\n let grids: GridStack[] = [];\r\n GridStack.getGridElements(selector).forEach(el => {\r\n if (!el.gridstack) {\r\n el.gridstack = new GridStack(el, Utils.cloneDeep(options));\r\n delete options.dragIn; delete options.dragInOptions; // only need to be done once (really a static global thing, not per grid)\r\n }\r\n grids.push(el.gridstack);\r\n });\r\n if (grids.length === 0) {\r\n console.error('GridStack.initAll() no grid was found with selector \"' + selector + '\" - element missing or wrong selector ?' +\r\n '\\nNote: \".grid-stack\" is required for proper CSS styling and drag/drop, and is the default selector.');\r\n }\r\n return grids;\r\n }\r\n\r\n /**\r\n * call to create a grid with the given options, including loading any children from JSON structure. This will call GridStack.init(), then\r\n * grid.load() on any passed children (recursively). Great alternative to calling init() if you want entire grid to come from\r\n * JSON serialized data, including options.\r\n * @param parent HTML element parent to the grid\r\n * @param opt grids options used to initialize the grid, and list of children\r\n */\r\n public static addGrid(parent: HTMLElement, opt: GridStackOptions = {}): GridStack {\r\n if (!parent) return null;\r\n\r\n // create the grid element, but check if the passed 'parent' already has grid styling and should be used instead\r\n let el = parent;\r\n if (!parent.classList.contains('grid-stack')) {\r\n let doc = document.implementation.createHTMLDocument();\r\n doc.body.innerHTML = `<div class=\"grid-stack ${opt.class || ''}\"></div>`;\r\n el = doc.body.children[0] as HTMLElement;\r\n parent.appendChild(el);\r\n }\r\n\r\n // create grid class and load any children\r\n let grid = GridStack.init(opt, el);\r\n if (grid.opts.children) {\r\n let children = grid.opts.children;\r\n delete grid.opts.children;\r\n grid.load(children);\r\n }\r\n return grid;\r\n }\r\n\r\n /** scoping so users can call GridStack.Utils.sort() for example */\r\n public static Utils = Utils;\r\n\r\n /** scoping so users can call new GridStack.Engine(12) for example */\r\n public static Engine = GridStackEngine;\r\n\r\n /** the HTML element tied to this grid after it's been initialized */\r\n public el: GridHTMLElement;\r\n\r\n /** engine used to implement non DOM grid functionality */\r\n public engine: GridStackEngine;\r\n\r\n /** grid options - public for classes to access, but use methods to modify! */\r\n public opts: GridStackOptions;\r\n\r\n /** @internal create placeholder DIV as needed */\r\n public get placeholder(): HTMLElement {\r\n if (!this._placeholder) {\r\n let placeholderChild = document.createElement('div'); // child so padding match item-content\r\n placeholderChild.className = 'placeholder-content';\r\n if (this.opts.placeholderText) {\r\n placeholderChild.innerHTML = this.opts.placeholderText;\r\n }\r\n this._placeholder = document.createElement('div');\r\n this._placeholder.classList.add(this.opts.placeholderClass, GridDefaults.itemClass, this.opts.itemClass);\r\n this.placeholder.appendChild(placeholderChild);\r\n }\r\n return this._placeholder;\r\n }\r\n /** @internal */\r\n private _placeholder: HTMLElement;\r\n /** @internal */\r\n private _prevColumn: number;\r\n /** @internal */\r\n private _ignoreLayoutsNodeChange: boolean;\r\n /** @internal */\r\n public _gsEventHandler = {};\r\n /** @internal */\r\n private _styles: GridCSSStyleSheet;\r\n /** @internal flag to keep cells square during resize */\r\n private _isAutoCellHeight: boolean;\r\n /** @internal track event binding to window resize so we can remove */\r\n private _windowResizeBind: () => void;\r\n /** @internal limit auto cell resizing method */\r\n private _cellHeightThrottle: () => void;\r\n /** @internal true when loading items to insert first rather than append */\r\n private _insertNotAppend: boolean;\r\n /** @internal extra row added when dragging at the bottom of the grid */\r\n private _extraDragRow = 0;\r\n\r\n /**\r\n * Construct a grid item from the given element and options\r\n * @param el\r\n * @param opts\r\n */\r\n public constructor(el: GridHTMLElement, opts: GridStackOptions = {}) {\r\n this.el = el; // exposed HTML element to the user\r\n opts = opts || {}; // handles null/undefined/0\r\n\r\n // if row property exists, replace minRow and maxRow instead\r\n if (opts.row) {\r\n opts.minRow = opts.maxRow = opts.row;\r\n delete opts.row;\r\n }\r\n let rowAttr = Utils.toNumber(el.getAttribute('gs-row'));\r\n\r\n // elements attributes override any passed options (like CSS style) - merge the two together\r\n let defaults: GridStackOptions = {...Utils.cloneDeep(GridDefaults),\r\n column: Utils.toNumber(el.getAttribute('gs-column')) || 12,\r\n minRow: rowAttr ? rowAttr : Utils.toNumber(el.getAttribute('gs-min-row')) || 0,\r\n maxRow: rowAttr ? rowAttr : Utils.toNumber(el.getAttribute('gs-max-row')) || 0,\r\n staticGrid: Utils.toBool(el.getAttribute('gs-static')) || false,\r\n _styleSheetClass: 'grid-stack-instance-' + (Math.random() * 10000).toFixed(0),\r\n alwaysShowResizeHandle: opts.alwaysShowResizeHandle || false,\r\n resizable: {\r\n autoHide: !(opts.alwaysShowResizeHandle || false),\r\n handles: 'se'\r\n },\r\n draggable: {\r\n handle: (opts.handleClass ? '.' + opts.handleClass : (opts.handle ? opts.handle : '')) || '.grid-stack-item-content',\r\n scroll: false,\r\n appendTo: 'body'\r\n },\r\n removableOptions: {\r\n accept: '.' + (opts.itemClass || 'grid-stack-item')\r\n },\r\n };\r\n if (el.getAttribute('gs-animate')) { // default to true, but if set to false use that instead\r\n defaults.animate = Utils.toBool(el.getAttribute('gs-animate'))\r\n }\r\n\r\n this.opts = Utils.defaults(opts, defaults);\r\n opts = null; // make sure we use this.opts instead\r\n this.initMargin(); // part of settings defaults...\r\n\r\n // Now check if we're loading into 1 column mode FIRST so we don't do un-necessary work (like cellHeight = width / 12 then go 1 column)\r\n if (this.opts.column !== 1 && !this.opts.disableOneColumnMode && this._widthOrContainer() <= this.opts.minWidth) {\r\n this._prevColumn = this.opts.column;\r\n this.opts.column = 1;\r\n }\r\n\r\n if (this.opts.rtl === 'auto') {\r\n this.opts.rtl = (el.style.direction === 'rtl');\r\n }\r\n\r\n if (this.opts.rtl) {\r\n this.el.classList.add('grid-stack-rtl');\r\n }\r\n\r\n // check if we're been nested, and if so update our style and keep pointer around (used during save)\r\n let parentGridItemEl = Utils.closestByClass(this.el, GridDefaults.itemClass) as GridItemHTMLElement;\r\n if (parentGridItemEl && parentGridItemEl.gridstackNode) {\r\n this.opts._isNested = parentGridItemEl.gridstackNode;\r\n this.opts._isNested.subGrid = this;\r\n this.el.classList.add('grid-stack-nested');\r\n }\r\n\r\n this._isAutoCellHeight = (this.opts.cellHeight === 'auto');\r\n if (this._isAutoCellHeight || this.opts.cellHeight === 'initial') {\r\n // make the cell content square initially (will use resize/column event to keep it square)\r\n this.cellHeight(undefined, false);\r\n } else {\r\n this.cellHeight(this.opts.cellHeight, false);\r\n }\r\n\r\n this.el.classList.add(this.opts._styleSheetClass);\r\n\r\n this._setStaticClass();\r\n\r\n this.engine = new GridStackEngine({\r\n column: this.opts.column,\r\n float: this.opts.float,\r\n maxRow: this.opts.maxRow,\r\n onChange: (cbNodes) => {\r\n let maxH = 0;\r\n this.engine.nodes.forEach(n => { maxH = Math.max(maxH, n.y + n.h) });\r\n cbNodes.forEach(n => {\r\n let el = n.el;\r\n if (n._removeDOM) {\r\n if (el) el.remove();\r\n delete n._removeDOM;\r\n } else {\r\n this._writePosAttr(el, n);\r\n }\r\n });\r\n this._updateStyles(false, maxH); // false = don't recreate, just append if need be\r\n }\r\n });\r\n\r\n if (this.opts.auto) {\r\n this.batchUpdate(); // prevent in between re-layout #1535 TODO: this only set float=true, need to prevent collision check...\r\n let elements: {el: HTMLElement; i: number}[] = [];\r\n this.getGridItems().forEach(el => { // get dom elements (not nodes yet)\r\n let x = parseInt(el.getAttribute('gs-x'));\r\n let y = parseInt(el.getAttribute('gs-y'));\r\n elements.push({\r\n el,\r\n // if x,y are missing (autoPosition) add them to end of list - but keep their respective DOM order\r\n i: (Number.isNaN(x) ? 1000 : x) + (Number.isNaN(y) ? 1000 : y) * this.opts.column\r\n });\r\n });\r\n elements.sort((a, b) => a.i - b.i).forEach(e => this._prepareElement(e.el));\r\n this.commit();\r\n }\r\n\r\n this.setAnimation(this.opts.animate);\r\n\r\n this._updateStyles();\r\n if (this.opts.column != 12) {\r\n this.el.classList.add('grid-stack-' + this.opts.column);\r\n }\r\n\r\n // legacy support to appear 'per grid` options when really global.\r\n if (this.opts.dragIn) GridStack.setupDragIn(this.opts.dragIn, this.opts.dragInOptions);\r\n delete this.opts.dragIn;\r\n delete this.opts.dragInOptions;\r\n\r\n this._setupRemoveDrop();\r\n this._setupAcceptWidget();\r\n this._updateWindowResizeEvent();\r\n }\r\n\r\n /**\r\n * add a new widget and returns it.\r\n *\r\n * Widget will be always placed even if result height is more than actual grid height.\r\n * You need to use `willItFit()` before calling addWidget for additional check.\r\n * See also `makeWidget()`.\r\n *\r\n * @example\r\n * let grid = GridStack.init();\r\n * grid.addWidget({w: 3, content: 'hello'});\r\n * grid.addWidget('<div class=\"grid-stack-item\"><div class=\"grid-stack-item-content\">hello</div></div>', {w: 3});\r\n *\r\n * @param el GridStackWidget (which can have content string as well), html element, or string definition to add\r\n * @param options widget position/size options (optional, and ignore if first param is already option) - see GridStackWidget\r\n */\r\n public addWidget(els?: GridStackWidget | GridStackElement, options?: GridStackWidget): GridItemHTMLElement {\r\n\r\n // support legacy call for now ?\r\n if (arguments.length > 2) {\r\n console.warn('gridstack.ts: `addWidget(el, x, y, width...)` is deprecated. Use `addWidget({x, y, w, content, ...})`. It will be removed soon');\r\n // eslint-disable-next-line prefer-rest-params\r\n let a = arguments, i = 1,\r\n opt: GridStackWidget = { x:a[i++], y:a[i++], w:a[i++], h:a[i++], autoPosition:a[i++],\r\n minW:a[i++], maxW:a[i++], minH:a[i++], maxH:a[i++], id:a[i++] };\r\n return this.addWidget(els, opt);\r\n }\r\n\r\n function isGridStackWidget(w: GridStackWidget): w is GridStackWidget { // https://medium.com/ovrsea/checking-the-type-of-an-object-in-typescript-the-type-guards-24d98d9119b0\r\n return w.x !== undefined || w.y !== undefined || w.w !== undefined || w.h !== undefined || w.content !== undefined ? true : false;\r\n }\r\n\r\n let el: HTMLElement;\r\n if (typeof els === 'string') {\r\n let doc = document.implementation.createHTMLDocument();\r\n doc.body.innerHTML = els;\r\n el = doc.body.children[0] as HTMLElement;\r\n } else if (arguments.length === 0 || arguments.length === 1 && isGridStackWidget(els)) {\r\n let content = els ? (els as GridStackWidget).content || '' : '';\r\n options = els;\r\n let doc = document.implementation.createHTMLDocument();\r\n doc.body.innerHTML = `<div class=\"grid-stack-item ${this.opts.itemClass || ''}\"><div class=\"grid-stack-item-content\">${content}</div></div>`;\r\n el = doc.body.children[0] as HTMLElement;\r\n } else {\r\n el = els as HTMLElement;\r\n }\r\n\r\n // Tempting to initialize the passed in opt with default and valid values, but this break knockout demos\r\n // as the actual value are filled in when _prepareElement() calls el.getAttribute('gs-xyz) before adding the node.\r\n // So make sure we load any DOM attributes that are not specified in passed in options (which override)\r\n let domAttr = this._readAttr(el);\r\n options = Utils.cloneDeep(options) || {}; // make a copy before we modify in case caller re-uses it\r\n Utils.defaults(options, domAttr);\r\n let node = this.engine.prepareNode(options);\r\n this._writeAttr(el, options);\r\n\r\n if (this._insertNotAppend) {\r\n this.el.prepend(el);\r\n } else {\r\n this.el.appendChild(el);\r\n }\r\n\r\n // similar to makeWidget() that doesn't read attr again and worse re-create a new node and loose any _id\r\n this._prepareElement(el, true, options);\r\n this._updateContainerHeight();\r\n\r\n // check if nested grid definition is present\r\n if (node.subGrid && !(node.subGrid as GridStack).el) { // see if there is a sub-grid to create too\r\n let content = node.el.querySelector('.grid-stack-item-content') as HTMLElement;\r\n node.subGrid = GridStack.addGrid(content, node.subGrid as GridStackOptions);\r\n }\r\n\r\n this._triggerAddEvent();\r\n this._triggerChangeEvent();\r\n\r\n return el;\r\n }\r\n\r\n /**\r\n /**\r\n * saves the current layout returning a list of widgets for serialization which might include any nested grids.\r\n * @param saveContent if true (default) the latest html inside .grid-stack-content will be saved to GridStackWidget.content field, else it will\r\n * be removed.\r\n * @param saveGridOpt if true (default false), save the grid options itself, so you can call the new GridStack.addGrid()\r\n * to recreate everything from scratch. GridStackOptions.children would then contain the widget list instead.\r\n * @returns list of widgets or full grid option, including .children list of widgets\r\n */\r\n public save(saveContent = true, saveGridOpt = false): GridStackWidget[] | GridStackOptions {\r\n // return copied nodes we can modify at will...\r\n let list = this.engine.save(saveContent);\r\n\r\n // check for HTML content and nested grids\r\n list.forEach(n => {\r\n if (saveContent && n.el && !n.subGrid) { // sub-grid are saved differently, not plain content\r\n let sub = n.el.querySelector('.grid-stack-item-content');\r\n n.content = sub ? sub.innerHTML : undefined;\r\n if (!n.content) delete n.content;\r\n } else {\r\n if (!saveContent) { delete n.content; }\r\n // check for nested grid\r\n if (n.subGrid) {\r\n n.subGrid = (n.subGrid as GridStack).save(saveContent, true) as GridStackOptions;\r\n }\r\n }\r\n delete n.el;\r\n });\r\n\r\n // check if save entire grid options (needed for recursive) + children...\r\n if (saveGridOpt) {\r\n let o: GridStackOptions = Utils.cloneDeep(this.opts);\r\n // delete default values that will be recreated on launch\r\n if (o.marginBottom === o.marginTop && o.marginRight === o.marginLeft && o.marginTop === o.marginRight) {\r\n o.margin = o.marginTop;\r\n delete o.marginTop; delete o.marginRight; delete o.marginBottom; delete o.marginLeft;\r\n }\r\n if (o.rtl === (this.el.style.direction === 'rtl')) { o.rtl = 'auto' }\r\n if (this._isAutoCellHeight) { o.cellHeight = 'auto' }\r\n Utils.removeInternalAndSame(o, GridDefaults);\r\n o.children = list;\r\n return o;\r\n }\r\n\r\n return list;\r\n }\r\n\r\n /**\r\n * load the widgets from a list. This will call update() on each (matching by id) or add/remove widgets that are not there.\r\n *\r\n * @param layout list of widgets definition to update/create\r\n * @param addAndRemove boolean (default true) or callback method can be passed to control if and how missing widgets can be added/removed, giving\r\n * the user control of insertion.\r\n *\r\n * @example\r\n * see http://gridstackjs.com/demo/serialization.html\r\n **/\r\n public load(layout: GridStackWidget[], addAndRemove: boolean | ((g: GridStack, w: GridStackWidget, add: boolean) => GridItemHTMLElement) = true): GridStack {\r\n let items = GridStack.Utils.sort([...layout], -1, this._prevColumn || this.opts.column); // make copy before we mod/sort\r\n this._insertNotAppend = true; // since create in reverse order...\r\n\r\n // if we're loading a layout into 1 column (_prevColumn is set only when going to 1) and items don't fit, make sure to save\r\n // the original wanted layout so we can scale back up correctly #1471\r\n if (this._prevColumn && this._prevColumn !== this.opts.column && items.some(n => (n.x + n.w) > this.opts.column)) {\r\n this._ignoreLayoutsNodeChange = true; // skip layout update\r\n this.engine.cacheLayout(items, this._prevColumn, true);\r\n }\r\n\r\n let removed: GridStackNode[] = [];\r\n this.batchUpdate();\r\n\r\n // see if any items are missing from new layout and need to be removed first\r\n if (addAndRemove) {\r\n let copyNodes = [...this.engine.nodes]; // don't loop through array you modify\r\n copyNodes.forEach(n => {\r\n let item = items.find(w => n.id === w.id);\r\n if (!item) {\r\n if (typeof(addAndRemove) === 'function') {\r\n addAndRemove(this, n, false);\r\n } else {\r\n removed.push(n); // batch keep track\r\n this.removeWidget(n.el, true, false);\r\n }\r\n }\r\n });\r\n }\r\n\r\n // now add/update the widgets\r\n items.forEach(w => {\r\n let item = (w.id || w.id === 0) ? this.engine.nodes.find(n => n.id === w.id) : undefined;\r\n if (item) {\r\n this.update(item.el, w);\r\n if (w.subGrid && (w.subGrid as GridStackOptions).children) { // update any sub grid as well\r\n let sub = item.el.querySelector('.grid-stack') as GridHTMLElement;\r\n if (sub && sub.gridstack) {\r\n sub.gridstack.load((w.subGrid as GridStackOptions).children); // TODO: support updating grid options ?\r\n this._insertNotAppend = true; // got reset by above call\r\n }\r\n }\r\n } else if (addAndRemove) {\r\n if (typeof(addAndRemove) === 'function') {\r\n w = addAndRemove(this, w, true).gridstackNode;\r\n } else {\r\n w = this.addWidget(w).gridstackNode;\r\n }\r\n }\r\n });\r\n\r\n this.engine.removedNodes = removed;\r\n this.commit();\r\n\r\n // after commit, clear that flag\r\n delete this._ignoreLayoutsNodeChange;\r\n delete this._insertNotAppend;\r\n return this;\r\n }\r\n\r\n /**\r\n * Initializes batch updates. You will see no changes until `commit()` method is called.\r\n */\r\n public batchUpdate(): GridStack {\r\n this.engine.batchUpdate();\r\n return this;\r\n }\r\n\r\n /**\r\n * Gets current cell height.\r\n */\r\n public getCellHeight(forcePixel = false): number {\r\n if (this.opts.cellHeight && this.opts.cellHeight !== 'auto' &&\r\n (!forcePixel || !this.opts.cellHeightUnit || this.opts.cellHeightUnit === 'px')) {\r\n return this.opts.cellHeight as number;\r\n }\r\n // else do entire grid and # of rows\r\n // or get first cell height ?\r\n // let el = this.el.querySelector('.' + this.opts.itemClass) as HTMLElement;\r\n // let height = Utils.toNumber(el.getAttribute('gs-h'));\r\n // return Math.round(el.offsetHeight / height);\r\n return Math.round(this.el.getBoundingClientRect().height) / parseInt(this.el.getAttribute('gs-current-row'));\r\n }\r\n\r\n /**\r\n * Update current cell height - see `GridStackOptions.cellHeight` for format.\r\n * This method rebuilds an internal CSS style sheet.\r\n * Note: You can expect performance issues if call this method too often.\r\n *\r\n * @param val the cell height. If not passed (undefined), cells content will be made square (match width minus margin),\r\n * if pass 0 the CSS will be generated by the application instead.\r\n * @param update (Optional) if false, styles will not be updated\r\n *\r\n * @example\r\n * grid.cellHeight(100); // same as 100px\r\n * grid.cellHeight('70px');\r\n * grid.cellHeight(grid.cellWidth() * 1.2);\r\n */\r\n public cellHeight(val?: numberOrString, update = true): GridStack {\r\n\r\n // if not called internally, check if we're changing mode\r\n if (update && val !== undefined) {\r\n if (this._isAutoCellHeight !== (val === 'auto')) {\r\n this._isAutoCellHeight = (val === 'auto');\r\n this._updateWindowResizeEvent();\r\n }\r\n }\r\n if (val === 'initial' || val === 'auto') { val = undefined; }\r\n\r\n // make item content be square\r\n if (val === undefined) {\r\n let marginDiff = - (this.opts.marginRight as number) - (this.opts.marginLeft as number)\r\n + (this.opts.marginTop as number) + (this.opts.marginBottom as number);\r\n val = this.cellWidth() + marginDiff;\r\n }\r\n\r\n let data = Utils.parseHeight(val);\r\n if (this.opts.cellHeightUnit === data.unit && this.opts.cellHeight === data.h) {\r\n return this;\r\n }\r\n this.opts.cellHeightUnit = data.unit;\r\n this.opts.cellHeight = data.h;\r\n\r\n if (update) {\r\n this._updateStyles(true, this.getRow()); // true = force re-create, for that # of rows\r\n }\r\n return this;\r\n }\r\n\r\n /** Gets current cell width. */\r\n public cellWidth(): number {\r\n return this._widthOrContainer() / this.opts.column;\r\n }\r\n /** return our expected width (or parent) for 1 column check */\r\n private _widthOrContainer(): number {\r\n // use `offsetWidth` or `clientWidth` (no scrollbar) ?\r\n // https://stackoverflow.com/questions/21064101/understanding-offsetwidth-clientwidth-scrollwidth-and-height-respectively\r\n return (this.el.clientWidth || this.el.parentElement.clientWidth || window.innerWidth);\r\n }\r\n\r\n /**\r\n * Finishes batch updates. Updates DOM nodes. You must call it after batchUpdate.\r\n */\r\n public commit(): GridStack {\r\n this.engine.commit();\r\n this._triggerRemoveEvent();\r\n this._triggerAddEvent();\r\n this._triggerChangeEvent();\r\n return this;\r\n }\r\n\r\n /** re-layout grid items to reclaim any empty space */\r\n public compact(): GridStack {\r\n this.engine.compact();\r\n this._triggerChangeEvent();\r\n return this;\r\n }\r\n\r\n /**\r\n * set the number of columns in the grid. Will update existing widgets to conform to new number of columns,\r\n * as well as cache the original layout so you can revert back to previous positions without loss.\r\n * Requires `gridstack-extra.css` or `gridstack-extra.min.css` for [2-11],\r\n * else you will need to generate correct CSS (see https://github.com/gridstack/gridstack.js#change-grid-columns)\r\n * @param column - Integer > 0 (default 12).\r\n * @param layout specify the type of re-layout that will happen (position, size, etc...).\r\n * Note: items will never be outside of the current column boundaries. default (moveScale). Ignored for 1 column\r\n */\r\n public column(column: number, layout: ColumnOptions = 'moveScale'): GridStack {\r\n if (this.opts.column === column) return this;\r\n let oldColumn = this.opts.column;\r\n\r\n // if we go into 1 column mode (which happens if we're sized less than minW unless disableOneColumnMode is on)\r\n // then remember the original columns so we can restore.\r\n if (column === 1) {\r\n this._prevColumn = oldColumn;\r\n } else {\r\n delete this._prevColumn;\r\n }\r\n\r\n this.el.classList.remove('grid-stack-' + oldColumn);\r\n this.el.classList.add('grid-stack-' + column);\r\n this.opts.column = this.engine.column = column;\r\n\r\n // update the items now - see if the dom order nodes should be passed instead (else default to current list)\r\n let domNodes: GridStackNode[];\r\n if (column === 1 && this.opts.oneColumnModeDomSort) {\r\n domNodes = [];\r\n this.getGridItems().forEach(el => { // get dom elements in order\r\n if (el.gridstackNode) { domNodes.push(el.gridstackNode); }\r\n });\r\n if (!domNodes.length) { domNodes = undefined; }\r\n }\r\n this.engine.updateNodeWidths(oldColumn, column, domNodes, layout);\r\n if (this._isAutoCellHeight) this.cellHeight();\r\n\r\n // and trigger our event last...\r\n this._ignoreLayoutsNodeChange = true; // skip layout update\r\n this._triggerChangeEvent();\r\n delete this._ignoreLayoutsNodeChange;\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * get the number of columns in the grid (default 12)\r\n */\r\n public getColumn(): number {\r\n return this.opts.column;\r\n }\r\n\r\n /** returns an array of grid HTML elements (no placeholder) - used to iterate through our children in DOM order */\r\n public getGridItems(): GridItemHTMLElement[] {\r\n return Array.from(this.el.children)\r\n .filter((el: HTMLElement) => el.matches('.' + this.opts.itemClass) && !el.matches('.' + this.opts.placeholderClass)) as GridItemHTMLElement[];\r\n }\r\n\r\n /**\r\n * Destroys a grid instance. DO NOT CALL any methods or access any vars after this as it will free up members.\r\n * @param removeDOM if `false` grid and items HTML elements will not be removed from the DOM (Optional. Default `true`).\r\n */\r\n public destroy(removeDOM = true): GridStack {\r\n if (!this.el) return; // prevent multiple calls\r\n this._updateWindowResizeEvent(true);\r\n this.setStatic(true, false); // permanently removes DD but don't set CSS class (we're going away)\r\n this.setAnimation(false);\r\n if (!removeDOM) {\r\n this.removeAll(removeDOM);\r\n this.el.classList.remove(this.opts._styleSheetClass);\r\n } else {\r\n this.el.parentNode.removeChild(this.el);\r\n }\r\n this._removeStylesheet();\r\n this.el.removeAttribute('gs-current-row');\r\n delete this.opts._isNested;\r\n delete this.opts;\r\n delete this._placeholder;\r\n delete this.engine;\r\n delete this.el.gridstack; // remove circular dependency that would prevent a freeing\r\n delete this.el;\r\n return this;\r\n }\r\n\r\n /**\r\n * enable/disable floating widgets (default: `false`) See [example](http://gridstackjs.com/demo/float.html)\r\n */\r\n public float(val: boolean): GridStack {\r\n this.engine.float = val;\r\n this._triggerChangeEvent();\r\n return this;\r\n }\r\n\r\n /**\r\n * get the current float mode\r\n */\r\n public getFloat(): boolean {\r\n return this.engine.float;\r\n }\r\n\r\n /**\r\n * Get the position of the cell under a pixel on screen.\r\n * @param position the position of the pixel to resolve in\r\n * absolute coordinates, as an object with top and left properties\r\n * @param useDocRelative if true, value will be based on document position vs parent position (Optional. Default false).\r\n * Useful when grid is within `position: relative` element\r\n *\r\n * Returns an object with properties `x` and `y` i.e. the column and row in the grid.\r\n */\r\n public getCellFromPixel(position: MousePosition, useDocRelative = false): CellPosition {\r\n let box = this.el.getBoundingClientRect();\r\n // console.log(`getBoundingClientRect left: ${box.left} top: ${box.top} w: ${box.w} h: ${box.h}`)\r\n let containerPos: {top: number, left: number};\r\n if (useDocRelative) {\r\n containerPos = {top: box.top + document.documentElement.scrollTop, left: box.left};\r\n // console.log(`getCellFromPixel scrollTop: ${document.documentElement.scrollTop}`)\r\n } else {\r\n containerPos = {top: this.el.offsetTop, left: this.el.offsetLeft}\r\n // console.log(`getCellFromPixel offsetTop: ${containerPos.left} offsetLeft: ${containerPos.top}`)\r\n }\r\n let relativeLeft = position.left - containerPos.left;\r\n let relativeTop = position.top - containerPos.top;\r\n\r\n let columnWidth = (box.width / this.opts.column);\r\n let rowHeight = (box.height / parseInt(this.el.getAttribute('gs-current-row')));\r\n\r\n return {x: Math.floor(relativeLeft / columnWidth), y: Math.floor(relativeTop / rowHeight)};\r\n }\r\n\r\n /** returns the current number of rows, which will be at least `minRow` if set */\r\n public getRow(): number {\r\n return Math.max(this.engine.getRow(), this.opts.minRow);\r\n }\r\n\r\n /**\r\n * Checks if specified area is empty.\r\n * @param x the position x.\r\n * @param y the position y.\r\n * @param w the width of to check\r\n * @param h the height of to check\r\n */\r\n public isAreaEmpty(x: number, y: number, w: number, h: number): boolean {\r\n return this.engine.isAreaEmpty(x, y, w, h);\r\n }\r\n\r\n /**\r\n * If you add elements to your grid by hand, you have to tell gridstack afterwards to make them widgets.\r\n * If you want gridstack to add the elements for you, use `addWidget()` instead.\r\n * Makes the given element a widget and returns it.\r\n * @param els widget or single selector to convert.\r\n *\r\n * @example\r\n * let grid = GridStack.init();\r\n * grid.el.appendChild('<div id=\"gsi-1\" gs-w=\"3\"></div>');\r\n * grid.makeWidget('#gsi-1');\r\n */\r\n public makeWidget(els: GridStackElement): GridItemHTMLElement {\r\n let el = GridStack.getElement(els);\r\n this._prepareElement(el, true);\r\n this._updateContainerHeight();\r\n this._triggerAddEvent();\r\n this._triggerChangeEvent();\r\n return el;\r\n }\r\n\r\n /**\r\n * Event handler that extracts our CustomEvent data out automatically for receiving custom\r\n * notifications (see doc for supported events)\r\n * @param name of the event (see possible values) or list of names space separated\r\n * @param callback function called with event and optional second/third param\r\n * (see README documentation for each signature).\r\n *\r\n * @example\r\n * grid.on('added', function(e, items) { log('added ', items)} );\r\n * or\r\n * grid.on('added removed change', function(e, items) { log(e.type, items)} );\r\n *\r\n * Note: in some cases it is the same as calling native handler and parsing the event.\r\n * grid.el.addEventListener('added', function(event) { log('added ', event.detail)} );\r\n *\r\n */\r\n public on(name: GridStackEvent, callback: GridStackEventHandlerCallback): GridStack {\r\n // check for array of names being passed instead\r\n if (name.indexOf(' ') !== -1) {\r\n let names = name.split(' ') as GridStackEvent[];\r\n names.forEach(name => this.on(name, callback));\r\n return this;\r\n }\r\n\r\n if (name === 'change' || name === 'added' || name === 'removed' || name === 'enable' || name === 'disable') {\r\n // native CustomEvent handlers - cash the generic handlers so we can easily remove\r\n let noData = (name === 'enable' || name === 'disable');\r\n if (noData) {\r\n this._gsEventHandler[name] = (event: Event) => callback(event);\r\n } else {\r\n this._gsEventHandler[name] = (event: CustomEvent) => callback(event, event.detail);\r\n }\r\n this.el.addEventListener(name, this._gsEventHandler[name]);\r\n } else if (name === 'drag' || name === 'dragstart' || name === 'dragstop' || name === 'resizestart' || name === 'resize' || name === 'resizestop' || name === 'dropped') {\r\n // drag&drop stop events NEED to be call them AFTER we update node attributes so handle them ourself.\r\n // do same for start event to make it easier...\r\n this._gsEventHandler[name] = callback;\r\n } else {\r\n console.log('GridStack.on(' + name + ') event not supported, but you can still use $(\".grid-stack\").on(...) while jquery-ui is still used internally.');\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * unsubscribe from the 'on' event below\r\n * @param name of the event (see possible values)\r\n */\r\n public off(name: GridStackEvent): GridStack {\r\n // check for array of names being passed instead\r\n if (name.indexOf(' ') !== -1) {\r\n let names = name.split(' ') as GridStackEvent[];\r\n names.forEach(name => this.off(name));\r\n return this;\r\n }\r\n\r\n if (name === 'change' || name === 'added' || name === 'removed' || name === 'enable' || name === 'disable') {\r\n // remove native CustomEvent handlers\r\n if (this._gsEventHandler[name]) {\r\n this.el.removeEventListener(name, this._gsEventHandler[name]);\r\n }\r\n }\r\n delete this._gsEventHandler[name];\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Removes widget from the grid.\r\n * @param el widget or selector to modify\r\n * @param removeDOM if `false` DOM element won't be removed from the tree (Default? true).\r\n * @param triggerEvent if `false` (quiet mode) element will not be added to removed list and no 'removed' callbacks will be called (Default? true).\r\n */\r\n public removeWidget(els: GridStackElement, removeDOM = true, triggerEvent = true): GridStack {\r\n GridStack.getElements(els).forEach(el => {\r\n if (el.parentElement !== this.el) return; // not our child!\r\n let node = el.gridstackNode;\r\n // For Meteor support: https://github.com/gridstack/gridstack.js/pull/272\r\n if (!node) {\r\n node = this.engine.nodes.find(n => el === n.el);\r\n }\r\n if (!node) return;\r\n\r\n // remove our DOM data (circular link) and drag&drop permanently\r\n delete el.gridstackNode;\r\n GridStackDDI.get().remove(el);\r\n\r\n this.engine.removeNode(node, removeDOM, triggerEvent);\r\n\r\n if (removeDOM && el.parentElement) {\r\n el.remove(); // in batch mode engine.removeNode doesn't call back to remove DOM\r\n }\r\n });\r\n if (triggerEvent) {\r\n this._triggerRemoveEvent();\r\n this._triggerChangeEvent();\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * Removes all widgets from the grid.\r\n * @param removeDOM if `false` DOM elements won't be removed from the tree (Default? `true`).\r\n */\r\n public removeAll(removeDOM = true): GridStack {\r\n // always remove our DOM data (circular link) before list gets emptied and drag&drop permanently\r\n this.engine.nodes.forEach(n => {\r\n delete n.el.gridstackNode;\r\n GridStackDDI.get().remove(n.el);\r\n });\r\n this.engine.removeAll(removeDOM);\r\n this._triggerRemoveEvent();\r\n return this;\r\n }\r\n\r\n /**\r\n * Toggle the grid animation state. Toggles the `grid-stack-animate` class.\r\n * @param doAnimate if true the grid will animate.\r\n */\r\n public setAnimation(doAnimate: boolean): GridStack {\r\n if (doAnimate) {\r\n this.el.classList.add('grid-stack-animate');\r\n } else {\r\n this.el.classList.remove('grid-stack-animate');\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * Toggle the grid static state, which permanently removes/add Drag&Drop support, unlike disable()/enable() that just turns it off/on.\r\n * Also toggle the grid-stack-static class.\r\n * @param val if true the grid become static.\r\n */\r\n public setStatic(val: boolean, updateClass = true): GridStack {\r\n if (this.opts.staticGrid === val) return this;\r\n this.opts.staticGrid = val;\r\n this._setupRemoveDrop();\r\n this._setupAcceptWidget();\r\n this.engine.nodes.forEach(n => this._prepareDragDropByNode(n)); // either delete or init Drag&drop\r\n if (updateClass) { this._setStaticClass(); }\r\n return this;\r\n }\r\n\r\n /**\r\n * Updates widget position/size and other info. Note: if you need to call this on all nodes, use load() instead which will update what changed.\r\n * @param els widget or selector of objects to modify (note: setting the same x,y for multiple items will be indeterministic and likely unwanted)\r\n * @param opt new widget options (x,y,w,h, etc..). Only those set will be updated.\r\n */\r\n public update(els: GridStackElement, opt: GridStackWidget): GridStack {\r\n\r\n // support legacy call for now ?\r\n if (arguments.length > 2) {\r\n console.warn('gridstack.ts: `update(el, x, y, w, h)` is deprecated. Use `update({x, w, content, ...})`. It will be removed soon');\r\n // eslint-disable-next-line prefer-rest-params\r\n let a = arguments, i = 1;\r\n opt = { x:a[i++], y:a[i++], w:a[i++], h:a[i++] };\r\n return this.update(els, opt);\r\n }\r\n\r\n GridStack.getElements(els).forEach(el => {\r\n if (!el || !el.gridstackNode) return;\r\n let n = el.gridstackNode;\r\n let w = Utils.cloneDeep(opt); // make a copy we can modify in case they re-use it or multiple items\r\n delete w.autoPosition;\r\n\r\n // move/resize widget if anything changed\r\n let keys = ['x', 'y', 'w', 'h'];\r\n let m: GridStackWidget;\r\n if (keys.some(k => w[k] !== undefined && w[k] !== n[k])) {\r\n m = {};\r\n keys.forEach(k => {\r\n m[k] = (w[k] !== undefined) ? w[k] : n[k];\r\n delete w[k];\r\n });\r\n }\r\n // for a move as well IFF there is any min/max fields set\r\n if (!m && (w.minW || w.minH || w.maxW || w.maxH)) {\r\n m = {}; // will use node position but validate values\r\n }\r\n\r\n // check for content changing\r\n if (w.content) {\r\n let sub = el.querySelector('.grid-stack-item-content');\r\n if (sub && sub.innerHTML !== w.content) {\r\n sub.innerHTML = w.content;\r\n }\r\n delete w.content;\r\n }\r\n\r\n // any remaining fields are assigned, but check for dragging changes, resize constrain\r\n let changed = false;\r\n let ddChanged = false;\r\n for (const key in w) {\r\n if (key[0] !== '_' && n[key] !== w[key]) {\r\n n[key] = w[key];\r\n changed = true;\r\n ddChanged = ddChanged || (!this.opts.staticGrid && (key === 'noResize' || key === 'noMove' || key === 'locked'));\r\n }\r\n }\r\n\r\n // finally move the widget\r\n if (m) {\r\n this.engine.cleanNodes()\r\n .beginUpdate(n)\r\n .moveNode(n, m);\r\n this._updateContainerHeight();\r\n this._triggerChangeEvent();\r\n this.engine.endUpdate();\r\n }\r\n if (changed) { // move will only update x,y,w,h so update the rest too\r\n this._writeAttr(el, n);\r\n }\r\n if (ddChanged) {\r\n this._prepareDragDropByNode(n);\r\n }\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Updates the margins which will set all 4 sides at once - see `GridStackOptions.margin` for format options (CSS string format of 1,2,4 values or single number).\r\n * @param value margin value\r\n */\r\n public margin(value: numberOrString): GridStack {\r\n let isMultiValue = (typeof value === 'string' && value.split(' ').length > 1);\r\n // check if we can skip re-creating our CSS file... won't check if multi values (too much hassle)\r\n if (!isMultiValue) {\r\n let data = Utils.parseHeight(value);\r\n if (this.opts.marginUnit === data.unit && this.opts.margin === data.h) return;\r\n }\r\n // re-use existing margin handling\r\n this.opts.margin = value;\r\n this.opts.marginTop = this.opts.marginBottom = this.opts.marginLeft = this.opts.marginRight = undefined;\r\n this.initMargin();\r\n\r\n this._updateStyles(true); // true = force re-create\r\n\r\n return this;\r\n }\r\n\r\n /** returns current margin number value (undefined if 4 sides don't match) */\r\n public getMargin(): number { return this.opts.margin as number; }\r\n\r\n /**\r\n * Returns true if the height of the grid will be less than the vertical\r\n * constraint. Always returns true if grid doesn't have height constraint.\r\n * @param node contains x,y,w,h,auto-position options\r\n *\r\n * @example\r\n * if (grid.willItFit(newWidget)) {\r\n * grid.addWidget(newWidget);\r\n * } else {\r\n * alert('Not enough free space to place the widget');\r\n * }\r\n */\r\n public willItFit(node: GridStackWidget): boolean {\r\n // support legacy call for now\r\n if (arguments.length > 1) {\r\n console.warn('gridstack.ts: `willItFit(x,y,w,h,autoPosition)` is deprecated. Use `willItFit({x, y,...})`. It will be removed soon');\r\n // eslint-disable-next-line prefer-rest-params\r\n let a = arguments, i = 0,\r\n w: GridStackWidget = { x:a[i++], y:a[i++], w:a[i++], h:a[i++], autoPosition:a[i++] };\r\n return this.willItFit(w);\r\n }\r\n return this.engine.willItFit(node);\r\n }\r\n\r\n /** @internal */\r\n private _triggerChangeEvent(): GridStack {\r\n if (this.engine.batchMode) return this;\r\n let elements = this.engine.getDirtyNodes(true); // verify they really changed\r\n if (elements && elements.length) {\r\n if (!this._ignoreLayoutsNodeChange) {\r\n this.engine.layoutsNodesChange(elements);\r\n }\r\n this._triggerEvent('change', elements);\r\n }\r\n this.engine.saveInitial(); // we called, now reset initial values & dirty flags\r\n return this;\r\n }\r\n\r\n /** @internal */\r\n private _triggerAddEvent(): GridStack {\r\n if (this.engine.batchMode) return this;\r\n if (this.engine.addedNodes && this.engine.addedNodes.length > 0) {\r\n if (!this._ignoreLayoutsNodeChange) {\r\n this.engine.layoutsNodesChange(this.engine.addedNodes);\r\n }\r\n // prevent added nodes from also triggering 'change' event (which is called next)\r\n this.engine.addedNodes.forEach(n => { delete n._dirty; });\r\n this._triggerEvent('added', this.engine.addedNodes);\r\n this.engine.addedNodes = [];\r\n }\r\n return this;\r\n }\r\n\r\n /** @internal */\r\n public _triggerRemoveEvent(): GridStack {\r\n if (this.engine.batchMode) return this;\r\n if (this.engine.removedNodes && this.engine.removedNodes.length > 0) {\r\n this._triggerEvent('removed', this.engine.removedNodes);\r\n this.engine.removedNodes = [];\r\n }\r\n return this;\r\n }\r\n\r\n /** @internal */\r\n private _triggerEvent(name: string, data?: GridStackNode[]): GridStack {\r\n let event = data ? new CustomEvent(name, {bubbles: false, detail: data}) : new Event(name);\r\n this.el.dispatchEvent(event);\r\n return this;\r\n }\r\n\r\n /** @internal called to delete the current dynamic style sheet used for our layout */\r\n private _removeStylesheet(): GridStack {\r\n\r\n if (this._styles) {\r\n Utils.removeStylesheet(this._styles._id);\r\n delete this._styles;\r\n }\r\n return this;\r\n }\r\n\r\n /** @internal updated/create the CSS styles for row based layout and initial margin setting */\r\n private _updateStyles(forceUpdate = false, maxH?: number): GridStack {\r\n // call to delete existing one if we change cellHeight / margin\r\n if (forceUpdate) {\r\n this._removeStylesheet();\r\n }\r\n\r\n this._updateContainerHeight();\r\n\r\n // if user is telling us they will handle the CSS themselves by setting heights to 0. Do we need this opts really ??\r\n if (this.opts.cellHeight === 0) {\r\n return this;\r\n }\r\n\r\n let cellHeight = this.opts.cellHeight as number;\r\n let cellHeightUnit = this.opts.cellHeightUnit;\r\n let prefix = `.${this.opts._styleSheetClass} > .${this.opts.itemClass}`;\r\n\r\n // create one as needed\r\n if (!this._styles) {\r\n let id = 'gridstack-style-' + (Math.random() * 100000).toFixed();\r\n // insert style to parent (instead of 'head' by default) to support WebComponent\r\n let styleLocation = this.opts.styleInHead ? undefined : this.el.parentNode as HTMLElement;\r\n this._styles = Utils.createStylesheet(id, styleLocation);\r\n if (!this._styles) return this;\r\n this._styles._id = id;\r\n this._styles._max = 0;\r\n\r\n // these are done once only\r\n Utils.addCSSRule(this._styles, prefix, `min-height: ${cellHeight}${cellHeightUnit}`);\r\n // content margins\r\n let top: string = this.opts.marginTop + this.opts.marginUnit;\r\n let bottom: string = this.opts.marginBottom + this.opts.marginUnit;\r\n let right: string = this.opts.marginRight + this.opts.marginUnit;\r\n let left: string = this.opts.marginLeft + this.opts.marginUnit;\r\n let content = `${prefix} > .grid-stack-item-content`;\r\n let placeholder = `.${this.opts._styleSheetClass} > .grid-stack-placeholder > .placeholder-content`;\r\n Utils.addCSSRule(this._styles, content, `top: ${top}; right: ${right}; bottom: ${bottom}; left: ${left};`);\r\n Utils.addCSSRule(this._styles, placeholder, `top: ${top}; right: ${right}; bottom: ${bottom}; left: ${left};`);\r\n // resize handles offset (to match margin)\r\n Utils.addCSSRule(this._styles, `${prefix} > .ui-resizable-ne`, `right: ${right}`);\r\n Utils.addCSSRule(this._styles, `${prefix} > .ui-resizable-e`, `right: ${right}`);\r\n Utils.addCSSRule(this._styles, `${prefix} > .ui-resizable-se`, `right: ${right}; bottom: ${bottom}`);\r\n Utils.addCSSRule(this._styles, `${prefix} > .ui-resizable-nw`, `left: ${left}`);\r\n Utils.addCSSRule(this._styles, `${prefix} > .ui-resizable-w`, `left: ${left}`);\r\n Utils.addCSSRule(this._styles, `${prefix} > .ui-resizable-sw`, `left: ${left}; bottom: ${bottom}`);\r\n }\r\n\r\n // now update the height specific fields\r\n maxH = maxH || this._styles._max;\r\n if (maxH > this._styles._max) {\r\n let getHeight = (rows: number): string => (cellHeight * rows) + cellHeightUnit;\r\n for (let i = this._styles._max + 1; i <= maxH; i++) { // start at 1\r\n let h: string = getHeight(i);\r\n Utils.addCSSRule(this._styles, `${prefix}[gs-y=\"${i-1}\"]`, `top: ${getHeight(i-1)}`); // start at 0\r\n Utils.addCSSRule(this._styles, `${prefix}[gs-h=\"${i}\"]`, `height: ${h}`);\r\n Utils.addCSSRule(this._styles, `${prefix}[gs-min-h=\"${i}\"]`, `min-height: ${h}`);\r\n Utils.addCSSRule(this._styles, `${prefix}[gs-max-h=\"${i}\"]`, `max-height: ${h}`);\r\n }\r\n this._styles._max = maxH;\r\n }\r\n return this;\r\n }\r\n\r\n /** @internal */\r\n private _updateContainerHeight(): GridStack {\r\n if (!this.engine || this.engine.batchMode) return this;\r\n let row = this.getRow() + this._extraDragRow; // checks for minRow already\r\n // check for css min height\r\n let cssMinHeight = parseInt(getComputedStyle(this.el)['min-height']);\r\n if (cssMinHeight > 0) {\r\n let minRow = Math.round(cssMinHeight / this.getCellHeight(true));\r\n if (row < minRow) {\r\n row = minRow;\r\n }\r\n }\r\n this.el.setAttribute('gs-current-row', String(row));\r\n if (row === 0) {\r\n this.el.style.removeProperty('height');\r\n return this;\r\n }\r\n let cellHeight = this.opts.cellHeight as number;\r\n let unit = this.opts.cellHeightUnit;\r\n if (!cellHeight) return this;\r\n this.el.style.height = row * cellHeight + unit;\r\n return this;\r\n }\r\n\r\n /** @internal */\r\n private _prepareElement(el: GridItemHTMLElement, triggerAddEvent = false, node?: GridStackNode): GridStack {\r\n if (!node) {\r\n el.classList.add(this.opts.itemClass);\r\n node = this._readAttr(el);\r\n }\r\n el.gridstackNode = node;\r\n node.el = el;\r\n node.grid = this;\r\n let copy = {...node};\r\n node = this.engine.addNode(node, triggerAddEvent);\r\n // write node attr back in case there was collision or we have to fix bad values during addNode()\r\n if (!Utils.same(node, copy)) {\r\n this._writeAttr(el, node);\r\n }\r\n this._prepareDragDropByNode(node);\r\n return this;\r\n }\r\n\r\n /** @internal call to write position x,y,w,h attributes back to element */\r\n private _writePosAttr(el: HTMLElement, n: GridStackPosition): GridStack {\r\n if (n.x !== undefined && n.x !== null) { el.setAttribute('gs-x', String(n.x)); }\r\n if (n.y !== undefined && n.y !== null) { el.setAttribute('gs-y', String(n.y)); }\r\n if (n.w) { el.setAttribute('gs-w', String(n.w)); }\r\n if (n.h) { el.setAttribute('gs-h', String(n.h)); }\r\n return this;\r\n }\r\n\r\n /** @internal call to write any default attributes back to element */\r\n private _writeAttr(el: HTMLElement, node: GridStackWidget): GridStack {\r\n if (!node) return this;\r\n this._writePosAttr(el, node);\r\n\r\n let attrs /*: GridStackWidget but strings */ = { // remaining attributes\r\n autoPosition: 'gs-auto-position',\r\n minW: 'gs-min-w',\r\n minH: 'gs-min-h',\r\n maxW: 'gs-max-w',\r\n maxH: 'gs-max-h',\r\n noResize: 'gs-no-resize',\r\n noMove: 'gs-no-move',\r\n locked: 'gs-locked',\r\n id: 'gs-id',\r\n resizeHandles: 'gs-resize-handles'\r\n };\r\n for (const key in attrs) {\r\n if (node[key]) { // 0 is valid for x,y only but done above already and not in list anyway\r\n el.setAttribute(attrs[key], String(node[key]));\r\n } else {\r\n el.removeAttribute(attrs[key]);\r\n }\r\n }\r\n return this;\r\n }\r\n\r\n /** @internal call to read any default attributes from element */\r\n private _readAttr(el: HTMLElement): GridStackWidget {\r\n let node: GridStackNode = {};\r\n node.x = Utils.toNumber(el.getAttribute('gs-x'));\r\n node.y = Utils.toNumber(el.getAttribute('gs-y'));\r\n node.w = Utils.toNumber(el.getAttribute('gs-w'));\r\n node.h = Utils.toNumber(el.getAttribute('gs-h'));\r\n node.maxW = Utils.toNumber(el.getAttribute('gs-max-w'));\r\n node.minW = Utils.toNumber(el.getAttribute('gs-min-w'));\r\n node.maxH = Utils.toNumber(el.getAttribute('gs-max-h'));\r\n node.minH = Utils.toNumber(el.getAttribute('gs-min-h'));\r\n node.autoPosition = Utils.toBool(el.getAttribute('gs-auto-position'));\r\n node.noResize = Utils.toBool(el.getAttribute('gs-no-resize'));\r\n node.noMove = Utils.toBool(el.getAttribute('gs-no-move'));\r\n node.locked = Utils.toBool(el.getAttribute('gs-locked'));\r\n node.resizeHandles = el.getAttribute('gs-resize-handles');\r\n node.id = el.getAttribute('gs-id');\r\n\r\n // remove any key not found (null or false which is default)\r\n for (const key in node) {\r\n if (!node.hasOwnProperty(key)) return;\r\n if (!node[key] && node[key] !== 0) { // 0 can be valid value (x,y only really)\r\n delete node[key];\r\n }\r\n }\r\n\r\n return node;\r\n }\r\n\r\n /** @internal */\r\n private _setStaticClass(): GridStack {\r\n let classes = ['grid-stack-static'];\r\n\r\n if (this.opts.staticGrid) {\r\n this.el.classList.add(...classes);\r\n this.el.setAttribute('gs-static', 'true');\r\n } else {\r\n this.el.classList.remove(...classes);\r\n this.el.removeAttribute('gs-static');\r\n\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * called when we are being resized by the window - check if the one Column Mode needs to be turned on/off\r\n * and remember the prev columns we used, as well as check for auto cell height (square)\r\n */\r\n public onParentResize(): GridStack {\r\n if (!this.el || !this.el.clientWidth) return; // return if we're gone or no size yet (will get called again)\r\n let oneColumn = !this.opts.disableOneColumnMode && this.el.clientWidth <= this.opts.minWidth;\r\n let changedOneColumn = false;\r\n\r\n if ((this.opts.column === 1) !== oneColumn) {\r\n changedOneColumn = true;\r\n if (this.opts.animate) { this.setAnimation(false); } // 1 <-> 12 is too radical, turn off animation\r\n this.column(oneColumn ? 1 : this._prevColumn);\r\n if (this.opts.animate) { this.setAnimation(true); }\r\n }\r\n\r\n // make the cells content square again\r\n if (this._isAutoCellHeight) {\r\n if (!changedOneColumn && this.opts.cellHeightThrottle) {\r\n if (!this._cellHeightThrottle) {\r\n this._cellHeightThrottle = Utils.throttle(() => this.cellHeight(), this.opts.cellHeightThrottle);\r\n }\r\n this._cellHeightThrottle();\r\n } else {\r\n // immediate update if we've changed to/from oneColumn or have no threshold\r\n this.cellHeight();\r\n }\r\n }\r\n\r\n // finally update any nested grids\r\n this.engine.nodes.forEach(n => {\r\n if (n.subGrid) {(n.subGrid as GridStack).onParentResize()}\r\n });\r\n\r\n return this;\r\n }\r\n\r\n /** add or remove the window size event handler */\r\n private _updateWindowResizeEvent(forceRemove = false): GridStack {\r\n // only add event if we're not nested (parent will call us) and we're auto sizing cells or supporting oneColumn (i.e. doing work)\r\n const workTodo = (this._isAutoCellHeight || !this.opts.disableOneColumnMode) && !this.opts._isNested;\r\n\r\n if (!forceRemove && workTodo && !this._windowResizeBind) {\r\n this._windowResizeBind = this.onParentResize.bind(this); // so we can properly remove later\r\n window.addEventListener('resize', this._windowResizeBind);\r\n } else if ((forceRemove || !workTodo) && this._windowResizeBind) {\r\n window.removeEventListener('resize', this._windowResizeBind);\r\n delete this._windowResizeBind; // remove link to us so we can free\r\n }\r\n\r\n return this;\r\n }\r\n\r\n /** @internal convert a potential selector into actual element */\r\n public static getElement(els: GridStackElement = '.grid-stack-item'): GridItemHTMLElement { return Utils.getElement(els) }\r\n /** @internal */\r\n public static getElements(els: GridStackElement = '.grid-stack-item'): GridItemHTMLElement[] { return Utils.getElements(els) }\r\n /** @internal */\r\n public static getGridElement(els: GridStackElement): GridHTMLElement { return GridStack.getElement(els) }\r\n /** @internal */\r\n public static getGridElements(els: string): GridHTMLElement[] { return Utils.getElements(els) }\r\n\r\n /** @internal initialize margin top/bottom/left/right and units */\r\n private initMargin(): GridStack {\r\n\r\n let data: HeightData;\r\n let margin = 0;\r\n\r\n // support passing multiple values like CSS (ex: '5px 10px 0 20px')\r\n let margins: string[] = [];\r\n if (typeof this.opts.margin === 'string') {\r\n margins = this.opts.margin.split(' ')\r\n }\r\n if (margins.length === 2) { // top/bot, left/right like CSS\r\n this.opts.marginTop = this.opts.marginBottom = margins[0];\r\n this.opts.marginLeft = this.opts.marginRight = margins[1];\r\n } else if (margins.length === 4) { // Clockwise like CSS\r\n this.opts.marginTop = margins[0];\r\n this.opts.marginRight = margins[1];\r\n this.opts.marginBottom = margins[2];\r\n this.opts.marginLeft = margins[3];\r\n } else {\r\n data = Utils.parseHeight(this.opts.margin);\r\n this.opts.marginUnit = data.unit;\r\n margin = this.opts.margin = data.h;\r\n }\r\n\r\n // see if top/bottom/left/right need to be set as well\r\n if (this.opts.marginTop === undefined) {\r\n this.opts.marginTop = margin;\r\n } else {\r\n data = Utils.parseHeight(this.opts.marginTop);\r\n this.opts.marginTop = data.h;\r\n delete this.opts.margin;\r\n }\r\n\r\n if (this.opts.marginBottom === undefined) {\r\n this.opts.marginBottom = margin;\r\n } else {\r\n data = Utils.parseHeight(this.opts.marginBottom);\r\n this.opts.marginBottom = data.h;\r\n delete this.opts.margin;\r\n }\r\n\r\n if (this.opts.marginRight === undefined) {\r\n this.opts.marginRight = margin;\r\n } else {\r\n data = Utils.parseHeight(this.opts.marginRight);\r\n this.opts.marginRight = data.h;\r\n delete this.opts.margin;\r\n }\r\n\r\n if (this.opts.marginLeft === undefined) {\r\n this.opts.marginLeft = margin;\r\n } else {\r\n data = Utils.parseHeight(this.opts.marginLeft);\r\n this.opts.marginLeft = data.h;\r\n delete this.opts.margin;\r\n }\r\n this.opts.marginUnit = data.unit; // in case side were spelled out, use those units instead...\r\n if (this.opts.marginTop === this.opts.marginBottom && this.opts.marginLeft === this.opts.marginRight && this.opts.marginTop === this.opts.marginRight) {\r\n this.opts.margin = this.opts.marginTop; // makes it easier to check for no-ops in setMargin()\r\n }\r\n return this;\r\n }\r\n\r\n /*\r\n * drag&drop empty stubs that will be implemented in gridstack-dd.ts for non static grid\r\n * so we don't incur the load unless needed.\r\n * NOTE: had to make those methods public in order to define them else as\r\n * GridStack.prototype._setupAcceptWidget = function()\r\n * maybe there is a better way ????\r\n */\r\n /* eslint-disable @typescript-eslint/no-unused-vars */\r\n\r\n /**\r\n * call to setup dragging in from the outside (say toolbar), by specifying the class selection and options.\r\n * Called during GridStack.init() as options, but can also be called directly (last param are cached) in case the toolbar\r\n * is dynamically create and needs to change later.\r\n * @param dragIn string selector (ex: '.sidebar .grid-stack-item')\r\n * @param dragInOptions options - see DDDragInOpt. (default: {revert: 'invalid', handle: '.grid-stack-item-content', scroll: false, appendTo: 'body'}\r\n **/\r\n public static setupDragIn(dragIn?: string, dragInOptions?: DDDragInOpt): void { /* implemented in gridstack-dd.ts */ }\r\n\r\n /**\r\n * Enables/Disables dragging by the user of specific grid element. If you want all items, and have it affect future items, use enableMove() instead. No-op for static grids.\r\n * IF you are looking to prevent an item from moving (due to being pushed around by another during collision) use locked property instead.\r\n * @param els widget or selector to modify.\r\n * @param val if true widget will be draggable.\r\n */\r\n public movable(els: GridStackElement, val: boolean): GridStack { return this }\r\n /**\r\n * Enables/Disables user resizing of specific grid element. If you want all items, and have it affect future items, use enableResize() instead. No-op for static grids.\r\n * @param els widget or selector to modify\r\n * @param val if true widget will be resizable.\r\n */\r\n public resizable(els: GridStackElement, val: boolean): GridStack { return this }\r\n /**\r\n * Temporarily disables widgets moving/resizing.\r\n * If you want a more permanent way (which freezes up resources) use `setStatic(true)` instead.\r\n * Note: no-op for static grid\r\n * This is a shortcut for:\r\n * @example\r\n * grid.enableMove(false);\r\n * grid.enableResize(false);\r\n */\r\n public disable(): GridStack { return this }\r\n /**\r\n * Re-enables widgets moving/resizing - see disable().\r\n * Note: no-op for static grid.\r\n * This is a shortcut for:\r\n * @example\r\n * grid.enableMove(true);\r\n * grid.enableResize(true);\r\n */\r\n public enable(): GridStack { return this }\r\n /**\r\n * Enables/disables widget moving. No-op for static grids.\r\n */\r\n public enableMove(doEnable: boolean): GridStack { return this }\r\n /**\r\n * Enables/disables widget resizing. No-op for static grids.\r\n */\r\n public enableResize(doEnable: boolean): GridStack { return this }\r\n\r\n /** @internal called to add drag over support to support widgets */\r\n public _setupAcceptWidget(): GridStack { return this }\r\n /** @internal called to setup a trash drop zone if the user specifies it */\r\n public _setupRemoveDrop(): GridStack { return this }\r\n /** @internal prepares the element for drag&drop **/\r\n public _prepareDragDropByNode(node: GridStackNode): GridStack { return this }\r\n /** @internal handles actual drag/resize start **/\r\n public _onStartMoving(el: GridItemHTMLElement, event: Event, ui: DDUIData, node: GridStackNode, cellWidth: number, cellHeight: number): void { return }\r\n /** @internal handles actual drag/resize **/\r\n public _dragOrResize(el: GridItemHTMLElement, event: Event, ui: DDUIData, node: GridStackNode, cellWidth: number, cellHeight: number): void { return }\r\n /** @internal called when a node leaves our area (mouse out or shape outside) **/\r\n public _leave(el: GridItemHTMLElement, helper?: GridItemHTMLElement): void { return }\r\n}\r\n","/**\n * dd-base-impl.ts 4.2.6\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\n */\n\nexport type EventCallback = (event: Event) => boolean|void;\nexport abstract class DDBaseImplement {\n /** returns the enable state, but you have to call enable()/disable() to change (as other things need to happen) */\n public get disabled(): boolean { return this._disabled; }\n\n /** @internal */\n private _disabled = false;\n /** @internal */\n private _eventRegister: {\n [eventName: string]: EventCallback;\n } = {};\n\n public on(event: string, callback: EventCallback): void {\n this._eventRegister[event] = callback;\n }\n\n public off(event: string): void {\n delete this._eventRegister[event];\n }\n\n public enable(): void {\n this._disabled = false;\n }\n\n public disable(): void {\n this._disabled = true;\n }\n\n public destroy(): void {\n delete this._eventRegister;\n }\n\n public triggerEvent(eventName: string, event: Event): boolean|void {\n if (!this.disabled && this._eventRegister && this._eventRegister[eventName])\n return this._eventRegister[eventName](event);\n }\n}\n\nexport interface HTMLElementExtendOpt<T> {\n el: HTMLElement;\n option: T;\n updateOption(T): DDBaseImplement;\n}\n","/**\n * dd-draggable.ts 4.2.6\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\n */\n\nimport { DDManager } from './dd-manager';\nimport { DDUtils } from './dd-utils';\nimport { DDBaseImplement, HTMLElementExtendOpt } from './dd-base-impl';\nimport { GridItemHTMLElement, DDUIData } from '../types';\n\n// TODO: merge with DDDragOpt ?\nexport interface DDDraggableOpt {\n appendTo?: string | HTMLElement;\n containment?: string | HTMLElement; // TODO: not implemented yet\n handle?: string;\n revert?: string | boolean | unknown; // TODO: not implemented yet\n scroll?: boolean; // nature support by HTML5 drag drop, can't be switch to off actually\n helper?: string | HTMLElement | ((event: Event) => HTMLElement);\n basePosition?: 'fixed' | 'absolute';\n start?: (event: Event, ui: DDUIData) => void;\n stop?: (event: Event) => void;\n drag?: (event: Event, ui: DDUIData) => void;\n}\n\ninterface DragOffset {\n left: number;\n top: number;\n width: number;\n height: number;\n offsetLeft: number;\n offsetTop: number;\n}\n\nexport class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt<DDDraggableOpt> {\n public el: HTMLElement;\n public option: DDDraggableOpt;\n public helper: HTMLElement; // used by GridStackDDNative\n\n /** @internal */\n private dragOffset: DragOffset;\n /** @internal */\n private dragElementOriginStyle: Array<string>;\n /** @internal */\n private dragFollowTimer: number;\n /** @internal */\n private dragEl: HTMLElement;\n /** @internal */\n private dragging = false;\n /** @internal */\n private paintTimer: number;\n /** @internal */\n private parentOriginStylePosition: string;\n /** @internal */\n private helperContainment: HTMLElement;\n /** @internal */\n private static basePosition: 'fixed' | 'absolute' = 'absolute';\n /** @internal #1541 can't have {passive: true} on Safari as otherwise it reverts animate back to old location on drop */\n private static dragEventListenerOption = true; // DDUtils.isEventSupportPassiveOption ? { capture: true, passive: true } : true;\n /** @internal */\n private static originStyleProp = ['transition', 'pointerEvents', 'position',\n 'left', 'top', 'opacity', 'zIndex', 'width', 'height', 'willChange'];\n\n constructor(el: HTMLElement, option: DDDraggableOpt = {}) {\n super();\n this.el = el;\n this.option = option;\n // get the element that is actually supposed to be dragged by\n let className = option.handle.substring(1);\n this.dragEl = el.classList.contains(className) ? el : el.querySelector(option.handle) || el;\n // create var event binding so we can easily remove and still look like TS methods (unlike anonymous functions)\n this._dragStart = this._dragStart.bind(this);\n this._drag = this._drag.bind(this);\n this._dragEnd = this._dragEnd.bind(this);\n this.enable();\n }\n\n public on(event: 'drag' | 'dragstart' | 'dragstop', callback: (event: DragEvent) => void): void {\n super.on(event, callback);\n }\n\n public off(event: 'drag' | 'dragstart' | 'dragstop'): void {\n super.off(event);\n }\n\n public enable(): void {\n super.enable();\n this.dragEl.draggable = true;\n this.dragEl.addEventListener('dragstart', this._dragStart);\n this.el.classList.remove('ui-draggable-disabled');\n this.el.classList.add('ui-draggable');\n }\n\n public disable(forDestroy = false): void {\n super.disable();\n this.dragEl.removeAttribute('draggable');\n this.dragEl.removeEventListener('dragstart', this._dragStart);\n this.el.classList.remove('ui-draggable');\n if (!forDestroy) this.el.classList.add('ui-draggable-disabled');\n }\n\n public destroy(): void {\n if (this.dragging) {\n // Destroy while dragging should remove dragend listener and manually trigger\n // dragend, otherwise dragEnd can't perform dragstop because eventRegistry is\n // destroyed.\n this._dragEnd({} as DragEvent);\n }\n this.disable(true);\n delete this.el;\n delete this.helper;\n delete this.option;\n super.destroy();\n }\n\n public updateOption(opts: DDDraggableOpt): DDDraggable {\n Object.keys(opts).forEach(key => this.option[key] = opts[key]);\n return this;\n }\n\n /** @internal */\n private _dragStart(event: DragEvent): void {\n DDManager.dragElement = this;\n this.helper = this._createHelper(event);\n this._setupHelperContainmentStyle();\n this.dragOffset = this._getDragOffset(event, this.el, this.helperContainment);\n const ev = DDUtils.initEvent<DragEvent>(event, { target: this.el, type: 'dragstart' });\n if (this.helper !== this.el) {\n this._setupDragFollowNodeNotifyStart(ev);\n // immediately set external helper initial position to avoid flickering behavior and unnecessary looping in `_packNodes()`\n this._dragFollow(event);\n } else {\n this.dragFollowTimer = window.setTimeout(() => {\n delete this.dragFollowTimer;\n this._setupDragFollowNodeNotifyStart(ev);\n }, 0);\n }\n this._cancelDragGhost(event);\n }\n\n /** @internal */\n private _setupDragFollowNodeNotifyStart(ev: Event): DDDraggable {\n this._setupHelperStyle();\n document.addEventListener('dragover', this._drag, DDDraggable.dragEventListenerOption);\n this.dragEl.addEventListener('dragend', this._dragEnd);\n if (this.option.start) {\n this.option.start(ev, this.ui());\n }\n this.dragging = true;\n this.helper.classList.add('ui-draggable-dragging');\n this.triggerEvent('dragstart', ev);\n return this;\n }\n\n /** @internal */\n private _drag(event: DragEvent): void {\n // Safari: prevent default to allow drop to happen instead of reverting back (with animation) and delaying dragend #1541\n // https://stackoverflow.com/questions/61760755/how-to-fire-dragend-event-immediately\n event.preventDefault();\n this._dragFollow(event);\n const ev = DDUtils.initEvent<DragEvent>(event, { target: this.el, type: 'drag' });\n if (this.option.drag) {\n this.option.drag(ev, this.ui());\n }\n this.triggerEvent('drag', ev);\n }\n\n /** @internal */\n private _dragEnd(event: DragEvent): void {\n if (this.dragFollowTimer) {\n clearTimeout(this.dragFollowTimer);\n delete this.dragFollowTimer;\n return;\n } else {\n if (this.paintTimer) {\n cancelAnimationFrame(this.paintTimer);\n }\n document.removeEventListener('dragover', this._drag, DDDraggable.dragEventListenerOption);\n this.dragEl.removeEventListener('dragend', this._dragEnd);\n }\n this.dragging = false;\n this.helper.classList.remove('ui-draggable-dragging');\n this.helperContainment.style.position = this.parentOriginStylePosition || null;\n if (this.helper === this.el) {\n this._removeHelperStyle();\n } else {\n this.helper.remove();\n }\n const ev = DDUtils.initEvent<DragEvent>(event, { target: this.el, type: 'dragstop' });\n if (this.option.stop) {\n this.option.stop(ev); // Note: ui() not used by gridstack so don't pass\n }\n this.triggerEvent('dragstop', ev);\n delete DDManager.dragElement;\n delete this.helper;\n }\n\n /** @internal create a clone copy (or user defined method) of the original drag item if set */\n private _createHelper(event: DragEvent): HTMLElement {\n let helper = this.el;\n if (typeof this.option.helper === 'function') {\n helper = this.option.helper(event);\n } else if (this.option.helper === 'clone') {\n helper = DDUtils.clone(this.el);\n }\n if (!document.body.contains(helper)) {\n DDUtils.appendTo(helper, this.option.appendTo === 'parent' ? this.el.parentNode : this.option.appendTo);\n }\n if (helper === this.el) {\n this.dragElementOriginStyle = DDDraggable.originStyleProp.map(prop => this.el.style[prop]);\n }\n return helper;\n }\n\n /** @internal */\n private _setupHelperStyle(): DDDraggable {\n this.helper.style.pointerEvents = 'none';\n this.helper.style.width = this.dragOffset.width + 'px';\n this.helper.style.height = this.dragOffset.height + 'px';\n this.helper.style.willChange = 'left, top';\n this.helper.style.transition = 'none'; // show up instantly\n this.helper.style.position = this.option.basePosition || DDDraggable.basePosition;\n this.helper.style.zIndex = '1000';\n setTimeout(() => {\n if (this.helper) {\n this.helper.style.transition = null; // recover animation\n }\n }, 0);\n return this;\n }\n\n /** @internal */\n private _removeHelperStyle(): DDDraggable {\n // don't bother restoring styles if we're gonna remove anyway...\n let node = this.helper ? (this.helper as GridItemHTMLElement).gridstackNode : undefined;\n if (!node || !node._isAboutToRemove) {\n DDDraggable.originStyleProp.forEach(prop => {\n this.helper.style[prop] = this.dragElementOriginStyle[prop] || null;\n });\n }\n delete this.dragElementOriginStyle;\n return this;\n }\n\n /** @internal */\n private _dragFollow(event: DragEvent): void {\n if (this.paintTimer) {\n cancelAnimationFrame(this.paintTimer);\n }\n this.paintTimer = requestAnimationFrame(() => {\n delete this.paintTimer;\n const offset = this.dragOffset;\n let containmentRect = { left: 0, top: 0 };\n if (this.helper.style.position === 'absolute') {\n const { left, top } = this.helperContainment.getBoundingClientRect();\n containmentRect = { left, top };\n }\n this.helper.style.left = event.clientX + offset.offsetLeft - containmentRect.left + 'px';\n this.helper.style.top = event.clientY + offset.offsetTop - containmentRect.top + 'px';\n });\n }\n\n /** @internal */\n private _setupHelperContainmentStyle(): DDDraggable {\n this.helperContainment = this.helper.parentElement;\n if (this.option.basePosition !== 'fixed') {\n this.parentOriginStylePosition = this.helperContainment.style.position;\n if (window.getComputedStyle(this.helperContainment).position.match(/static/)) {\n this.helperContainment.style.position = 'relative';\n }\n }\n return this;\n }\n\n /** @internal prevent the default gost image to be created (which has wrongas we move the helper/element instead\n * (legacy jquery UI code updates the top/left of the item).\n * TODO: maybe use mouse event instead of HTML5 drag as we have to work around it anyway, or change code to not update\n * the actual grid-item but move the gost image around (and special case jq version) ?\n **/\n private _cancelDragGhost(e: DragEvent): DDDraggable {\n /* doesn't seem to do anything...\n let t = e.dataTransfer;\n t.effectAllowed = 'none';\n t.dropEffect = 'none';\n t.setData('text', '');\n */\n\n // NOTE: according to spec (and required by Safari see #1540) the image has to be visible in the browser (in dom and not hidden) so make it a 1px div\n let img = document.createElement('div');\n img.style.width = '1px';\n img.style.height = '1px';\n img.style.position = 'fixed'; // prevent unwanted scrollbar\n document.body.appendChild(img);\n e.dataTransfer.setDragImage(img, 0, 0);\n setTimeout(() => document.body.removeChild(img)); // nuke once drag had a chance to grab this 'image'\n\n e.stopPropagation();\n return this;\n }\n\n /** @internal */\n private _getDragOffset(event: DragEvent, el: HTMLElement, parent: HTMLElement): DragOffset {\n\n // in case ancestor has transform/perspective css properties that change the viewpoint\n let xformOffsetX = 0;\n let xformOffsetY = 0;\n if (parent) {\n const testEl = document.createElement('div');\n DDUtils.addElStyles(testEl, {\n opacity: '0',\n position: 'fixed',\n top: 0 + 'px',\n left: 0 + 'px',\n width: '1px',\n height: '1px',\n zIndex: '-999999',\n });\n parent.appendChild(testEl);\n const testElPosition = testEl.getBoundingClientRect();\n parent.removeChild(testEl);\n xformOffsetX = testElPosition.left;\n xformOffsetY = testElPosition.top;\n // TODO: scale ?\n }\n\n const targetOffset = el.getBoundingClientRect();\n return {\n left: targetOffset.left,\n top: targetOffset.top,\n offsetLeft: - event.clientX + targetOffset.left - xformOffsetX,\n offsetTop: - event.clientY + targetOffset.top - xformOffsetY,\n width: targetOffset.width,\n height: targetOffset.height\n };\n }\n\n /** @internal TODO: set to public as called by DDDroppable! */\n public ui = (): DDUIData => {\n const containmentEl = this.el.parentElement;\n const containmentRect = containmentEl.getBoundingClientRect();\n const offset = this.helper.getBoundingClientRect();\n return {\n position: { //Current CSS position of the helper as { top, left } object\n top: offset.top - containmentRect.top,\n left: offset.left - containmentRect.left\n }\n /* not used by GridStack for now...\n helper: [this.helper], //The object arr representing the helper that's being dragged.\n offset: { top: offset.top, left: offset.left } // Current offset position of the helper as { top, left } object.\n */\n };\n }\n}\n\n\n","/**\n * dd-droppable.ts 4.2.6\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\n */\n\nimport { DDDraggable } from './dd-draggable';\nimport { DDManager } from './dd-manager';\nimport { DDBaseImplement, HTMLElementExtendOpt } from './dd-base-impl';\nimport { DDUtils } from './dd-utils';\n\nexport interface DDDroppableOpt {\n accept?: string | ((el: HTMLElement) => boolean);\n drop?: (event: DragEvent, ui) => void;\n over?: (event: DragEvent, ui) => void;\n out?: (event: DragEvent, ui) => void;\n}\n\nexport class DDDroppable extends DDBaseImplement implements HTMLElementExtendOpt<DDDroppableOpt> {\n\n public accept: (el: HTMLElement) => boolean;\n public el: HTMLElement;\n public option: DDDroppableOpt;\n\n /** @internal */\n private moving: boolean;\n\n constructor(el: HTMLElement, opts: DDDroppableOpt = {}) {\n super();\n this.el = el;\n this.option = opts;\n // create var event binding so we can easily remove and still look like TS methods (unlike anonymous functions)\n this._dragEnter = this._dragEnter.bind(this);\n this._dragOver = this._dragOver.bind(this);\n this._dragLeave = this._dragLeave.bind(this);\n this._drop = this._drop.bind(this);\n\n this.el.classList.add('ui-droppable');\n this.el.addEventListener('dragenter', this._dragEnter);\n this._setupAccept();\n }\n\n public on(event: 'drop' | 'dropover' | 'dropout', callback: (event: DragEvent) => void): void {\n super.on(event, callback);\n }\n\n public off(event: 'drop' | 'dropover' | 'dropout'): void {\n super.off(event);\n }\n\n public enable(): void {\n if (!this.disabled) return;\n super.enable();\n this.el.classList.remove('ui-droppable-disabled');\n this.el.addEventListener('dragenter', this._dragEnter);\n }\n\n public disable(forDestroy=false): void {\n if (this.disabled) return;\n super.disable();\n if (!forDestroy) this.el.classList.add('ui-droppable-disabled');\n this.el.removeEventListener('dragenter', this._dragEnter);\n }\n\n public destroy(): void {\n if (this.moving) {\n this._removeLeaveCallbacks();\n } \n this.disable(true);\n this.el.classList.remove('ui-droppable');\n this.el.classList.remove('ui-droppable-disabled');\n delete this.moving;\n super.destroy();\n }\n\n public updateOption(opts: DDDroppableOpt): DDDroppable {\n Object.keys(opts).forEach(key => this.option[key] = opts[key]);\n this._setupAccept();\n return this;\n }\n\n /** @internal called when the cursor enters our area - prepare for a possible drop and track leaving */\n private _dragEnter(event: DragEvent): void {\n if (!this._canDrop()) return;\n event.preventDefault();\n\n if (this.moving) return; // ignore multiple 'dragenter' as we go over existing items\n this.moving = true;\n\n const ev = DDUtils.initEvent<DragEvent>(event, { target: this.el, type: 'dropover' });\n if (this.option.over) {\n this.option.over(ev, this._ui(DDManager.dragElement))\n }\n this.triggerEvent('dropover', ev);\n this.el.addEventListener('dragover', this._dragOver);\n this.el.addEventListener('drop', this._drop);\n this.el.addEventListener('dragleave', this._dragLeave);\n this.el.classList.add('ui-droppable-over');\n }\n\n /** @internal called when an moving to drop item is being dragged over - do nothing but eat the event */\n private _dragOver(event: DragEvent): void {\n event.preventDefault();\n event.stopPropagation();\n }\n\n /** @internal called when the item is leaving our area, stop tracking if we had moving item */\n private _dragLeave(event: DragEvent): void {\n\n // ignore leave events on our children (get when starting to drag our items)\n // Note: Safari Mac has null relatedTarget which causes #1684 so check if DragEvent is inside the grid instead\n if (!event.relatedTarget) {\n const { bottom, left, right, top } = this.el.getBoundingClientRect();\n if (event.x < right && event.x > left && event.y < bottom && event.y > top) return;\n } else if (this.el.contains(event.relatedTarget as HTMLElement)) return;\n\n this._removeLeaveCallbacks();\n if (this.moving) {\n event.preventDefault();\n const ev = DDUtils.initEvent<DragEvent>(event, { target: this.el, type: 'dropout' });\n if (this.option.out) {\n this.option.out(ev, this._ui(DDManager.dragElement))\n }\n this.triggerEvent('dropout', ev);\n }\n delete this.moving;\n }\n\n /** @internal item is being dropped on us - call the client drop event */\n private _drop(event: DragEvent): void {\n if (!this.moving) return; // should not have received event...\n event.preventDefault();\n const ev = DDUtils.initEvent<DragEvent>(event, { target: this.el, type: 'drop' });\n if (this.option.drop) {\n this.option.drop(ev, this._ui(DDManager.dragElement))\n }\n this.triggerEvent('drop', ev);\n this._removeLeaveCallbacks();\n delete this.moving;\n }\n\n /** @internal called to remove callbacks when leaving or dropping */\n private _removeLeaveCallbacks() {\n this.el.removeEventListener('dragleave', this._dragLeave);\n this.el.classList.remove('ui-droppable-over');\n if (this.moving) {\n this.el.removeEventListener('dragover', this._dragOver);\n this.el.removeEventListener('drop', this._drop);\n }\n // Note: this.moving is reset by callee of this routine to control the flow\n }\n\n /** @internal */\n private _canDrop(): boolean {\n return DDManager.dragElement && (!this.accept || this.accept(DDManager.dragElement.el));\n }\n\n /** @internal */\n private _setupAccept(): DDDroppable {\n if (this.option.accept && typeof this.option.accept === 'string') {\n this.accept = (el: HTMLElement) => {\n return el.matches(this.option.accept as string)\n }\n } else {\n this.accept = this.option.accept as ((el: HTMLElement) => boolean);\n }\n return this;\n }\n\n /** @internal */\n private _ui(drag: DDDraggable) {\n return {\n draggable: drag.el,\n ...drag.ui()\n };\n }\n}\n\n","/**\n * dd-elements.ts 4.2.6\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\n */\n\nimport { DDResizable, DDResizableOpt } from './dd-resizable';\nimport { GridItemHTMLElement } from './../types';\nimport { DDDraggable, DDDraggableOpt } from './dd-draggable';\nimport { DDDroppable, DDDroppableOpt } from './dd-droppable';\n\nexport interface DDElementHost extends GridItemHTMLElement {\n ddElement?: DDElement;\n}\n\nexport class DDElement {\n\n static init(el: DDElementHost): DDElement {\n if (!el.ddElement) { el.ddElement = new DDElement(el); }\n return el.ddElement;\n }\n\n public el: DDElementHost;\n public ddDraggable?: DDDraggable;\n public ddDroppable?: DDDroppable;\n public ddResizable?: DDResizable;\n\n constructor(el: DDElementHost) {\n this.el = el;\n }\n\n public on(eventName: string, callback: (event: MouseEvent) => void): DDElement {\n if (this.ddDraggable && ['drag', 'dragstart', 'dragstop'].indexOf(eventName) > -1) {\n this.ddDraggable.on(eventName as 'drag' | 'dragstart' | 'dragstop', callback);\n } else if (this.ddDroppable && ['drop', 'dropover', 'dropout'].indexOf(eventName) > -1) {\n this.ddDroppable.on(eventName as 'drop' | 'dropover' | 'dropout', callback);\n } else if (this.ddResizable && ['resizestart', 'resize', 'resizestop'].indexOf(eventName) > -1) {\n this.ddResizable.on(eventName as 'resizestart' | 'resize' | 'resizestop', callback);\n }\n return this;\n }\n\n public off(eventName: string): DDElement {\n if (this.ddDraggable && ['drag', 'dragstart', 'dragstop'].indexOf(eventName) > -1) {\n this.ddDraggable.off(eventName as 'drag' | 'dragstart' | 'dragstop');\n } else if (this.ddDroppable && ['drop', 'dropover', 'dropout'].indexOf(eventName) > -1) {\n this.ddDroppable.off(eventName as 'drop' | 'dropover' | 'dropout');\n } else if (this.ddResizable && ['resizestart', 'resize', 'resizestop'].indexOf(eventName) > -1) {\n this.ddResizable.off(eventName as 'resizestart' | 'resize' | 'resizestop');\n }\n return this;\n }\n\n public setupDraggable(opts: DDDraggableOpt): DDElement {\n if (!this.ddDraggable) {\n this.ddDraggable = new DDDraggable(this.el, opts);\n } else {\n this.ddDraggable.updateOption(opts);\n }\n return this;\n }\n\n public cleanDraggable(): DDElement {\n if (this.ddDraggable) {\n this.ddDraggable.destroy();\n delete this.ddDraggable;\n }\n return this;\n }\n\n public setupResizable(opts: DDResizableOpt): DDElement {\n if (!this.ddResizable) {\n this.ddResizable = new DDResizable(this.el, opts);\n } else {\n this.ddResizable.updateOption(opts);\n }\n return this;\n }\n\n public cleanResizable(): DDElement {\n if (this.ddResizable) {\n this.ddResizable.destroy();\n delete this.ddResizable;\n }\n return this;\n }\n\n public setupDroppable(opts: DDDroppableOpt): DDElement {\n if (!this.ddDroppable) {\n this.ddDroppable = new DDDroppable(this.el, opts);\n } else {\n this.ddDroppable.updateOption(opts);\n }\n return this;\n }\n\n public cleanDroppable(): DDElement {\n if (this.ddDroppable) {\n this.ddDroppable.destroy();\n delete this.ddDroppable;\n }\n return this;\n }\n}\n","/**\n * dd-manager.ts 4.2.6\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\n */\n\nimport { DDDraggable } from './dd-draggable';\n\nexport class DDManager {\n static dragElement: DDDraggable;\n}\n","/**\n * dd-resizable-handle.ts 4.2.6\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\n */\n\nexport interface DDResizableHandleOpt {\n start?: (event) => void;\n move?: (event) => void;\n stop?: (event) => void;\n}\n\nexport class DDResizableHandle {\n /** @internal */\n private el: HTMLElement;\n /** @internal */\n private host: HTMLElement;\n /** @internal */\n private option: DDResizableHandleOpt;\n /** @internal */\n private dir: string;\n /** @internal true after we've moved enough pixels to start a resize */\n private moving = false;\n /** @internal */\n private mouseDownEvent: MouseEvent;\n /** @internal */\n private static prefix = 'ui-resizable-';\n\n constructor(host: HTMLElement, direction: string, option: DDResizableHandleOpt) {\n this.host = host;\n this.dir = direction;\n this.option = option;\n // create var event binding so we can easily remove and still look like TS methods (unlike anonymous functions)\n this._mouseDown = this._mouseDown.bind(this);\n this._mouseMove = this._mouseMove.bind(this);\n this._mouseUp = this._mouseUp.bind(this);\n\n this._init();\n }\n\n /** @internal */\n private _init(): DDResizableHandle {\n const el = document.createElement('div');\n el.classList.add('ui-resizable-handle');\n el.classList.add(`${DDResizableHandle.prefix}${this.dir}`);\n el.style.zIndex = '100';\n el.style.userSelect = 'none';\n this.el = el;\n this.host.appendChild(this.el);\n this.el.addEventListener('mousedown', this._mouseDown);\n return this;\n }\n\n /** call this when resize handle needs to be removed and cleaned up */\n public destroy(): DDResizableHandle {\n if (this.moving) this._mouseUp(this.mouseDownEvent);\n this.el.removeEventListener('mousedown', this._mouseDown);\n this.host.removeChild(this.el);\n delete this.el;\n delete this.host;\n return this;\n }\n\n /** @internal called on mouse down on us: capture move on the entire document (mouse might not stay on us) until we release the mouse */\n private _mouseDown(e: MouseEvent): void {\n e.preventDefault();\n this.mouseDownEvent = e;\n document.addEventListener('mousemove', this._mouseMove, true); // capture, not bubble\n document.addEventListener('mouseup', this._mouseUp);\n }\n\n /** @internal */\n private _mouseMove(e: MouseEvent): void {\n let s = this.mouseDownEvent;\n // don't start unless we've moved at least 3 pixels\n if (!this.moving && Math.abs(e.x - s.x) + Math.abs(e.y - s.y) > 2) {\n this.moving = true;\n this._triggerEvent('start', this.mouseDownEvent);\n } else if (this.moving) {\n this._triggerEvent('move', e);\n }\n }\n\n /** @internal */\n private _mouseUp(e: MouseEvent): void {\n if (this.moving) {\n this._triggerEvent('stop', e);\n }\n document.removeEventListener('mousemove', this._mouseMove, true);\n document.removeEventListener('mouseup', this._mouseUp);\n delete this.moving;\n delete this.mouseDownEvent;\n }\n\n /** @internal */\n private _triggerEvent(name: string, event: MouseEvent): DDResizableHandle {\n if (this.option[name]) this.option[name](event);\n return this;\n }\n}\n","/**\n * dd-resizable.ts 4.2.6\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\n */\n\nimport { DDResizableHandle } from './dd-resizable-handle';\nimport { DDBaseImplement, HTMLElementExtendOpt } from './dd-base-impl';\nimport { DDUtils } from './dd-utils';\nimport { Utils } from '../utils';\nimport { DDUIData, Rect, Size } from '../types';\n\n// TODO: merge with DDDragOpt\nexport interface DDResizableOpt {\n autoHide?: boolean;\n handles?: string;\n maxHeight?: number;\n maxWidth?: number;\n minHeight?: number;\n minWidth?: number;\n basePosition?: 'fixed' | 'absolute';\n start?: (event: Event, ui: DDUIData) => void;\n stop?: (event: Event) => void;\n resize?: (event: Event, ui: DDUIData) => void;\n}\n\nexport class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt<DDResizableOpt> {\n\n // have to be public else complains for HTMLElementExtendOpt ?\n public el: HTMLElement;\n public option: DDResizableOpt;\n\n /** @internal */\n private handlers: DDResizableHandle[];\n /** @internal */\n private originalRect: Rect;\n /** @internal */\n private temporalRect: Rect;\n /** @internal */\n private scrollY: number;\n /** @internal */\n private scrolled: number;\n /** @internal */\n private scrollEl: HTMLElement;\n /** @internal */\n private startEvent: MouseEvent;\n /** @internal value saved in the same order as _originStyleProp[] */\n private elOriginStyleVal: string[];\n /** @internal */\n private parentOriginStylePosition: string;\n /** @internal */\n private static _originStyleProp = ['width', 'height', 'position', 'left', 'top', 'opacity', 'zIndex'];\n\n constructor(el: HTMLElement, opts: DDResizableOpt = {}) {\n super();\n this.el = el;\n this.option = opts;\n this.enable();\n this._setupAutoHide();\n this._setupHandlers();\n }\n\n public on(event: 'resizestart' | 'resize' | 'resizestop', callback: (event: DragEvent) => void): void {\n super.on(event, callback);\n }\n\n public off(event: 'resizestart' | 'resize' | 'resizestop'): void {\n super.off(event);\n }\n\n public enable(): void {\n super.enable();\n this.el.classList.add('ui-resizable');\n this.el.classList.remove('ui-resizable-disabled');\n }\n\n public disable(): void {\n super.disable();\n this.el.classList.add('ui-resizable-disabled');\n this.el.classList.remove('ui-resizable');\n }\n\n public destroy(): void {\n this._removeHandlers();\n if (this.option.autoHide) {\n this.el.removeEventListener('mouseover', this._showHandlers);\n this.el.removeEventListener('mouseout', this._hideHandlers);\n }\n this.el.classList.remove('ui-resizable');\n delete this.el;\n super.destroy();\n }\n\n public updateOption(opts: DDResizableOpt): DDResizable {\n let updateHandles = (opts.handles && opts.handles !== this.option.handles);\n let updateAutoHide = (opts.autoHide && opts.autoHide !== this.option.autoHide);\n Object.keys(opts).forEach(key => this.option[key] = opts[key]);\n if (updateHandles) {\n this._removeHandlers();\n this._setupHandlers();\n }\n if (updateAutoHide) {\n this._setupAutoHide();\n }\n return this;\n }\n\n /** @internal */\n private _setupAutoHide(): DDResizable {\n if (this.option.autoHide) {\n this.el.classList.add('ui-resizable-autohide');\n // use mouseover/mouseout instead of mouseenter/mouseleave to get better performance;\n this.el.addEventListener('mouseover', this._showHandlers);\n this.el.addEventListener('mouseout', this._hideHandlers);\n } else {\n this.el.classList.remove('ui-resizable-autohide');\n this.el.removeEventListener('mouseover', this._showHandlers);\n this.el.removeEventListener('mouseout', this._hideHandlers);\n }\n return this;\n }\n\n /** @internal */\n private _showHandlers = () => {\n this.el.classList.remove('ui-resizable-autohide');\n }\n\n /** @internal */\n private _hideHandlers = () => {\n this.el.classList.add('ui-resizable-autohide');\n }\n\n /** @internal */\n private _setupHandlers(): DDResizable {\n let handlerDirection = this.option.handles || 'e,s,se';\n if (handlerDirection === 'all') {\n handlerDirection = 'n,e,s,w,se,sw,ne,nw';\n }\n this.handlers = handlerDirection.split(',')\n .map(dir => dir.trim())\n .map(dir => new DDResizableHandle(this.el, dir, {\n start: (event: MouseEvent) => {\n this._resizeStart(event);\n },\n stop: (event: MouseEvent) => {\n this._resizeStop(event);\n },\n move: (event: MouseEvent) => {\n this._resizing(event, dir);\n }\n }));\n return this;\n }\n\n /** @internal */\n private _resizeStart(event: MouseEvent): DDResizable {\n this.originalRect = this.el.getBoundingClientRect();\n this.scrollEl = Utils.getScrollElement(this.el);\n this.scrollY = this.scrollEl.scrollTop;\n this.startEvent = event;\n this._setupHelper();\n this._applyChange();\n const ev = DDUtils.initEvent<MouseEvent>(event, { type: 'resizestart', target: this.el });\n if (this.option.start) {\n this.option.start(ev, this._ui());\n }\n this.el.classList.add('ui-resizable-resizing');\n this.triggerEvent('resizestart', ev);\n return this;\n }\n\n /** @internal */\n private _resizing(event: MouseEvent, dir: string): DDResizable {\n this.scrolled = this.scrollEl.scrollTop - this.scrollY;\n this.temporalRect = this._getChange(event, dir);\n this._applyChange();\n const ev = DDUtils.initEvent<MouseEvent>(event, { type: 'resize', target: this.el });\n if (this.option.resize) {\n this.option.resize(ev, this._ui());\n }\n this.triggerEvent('resize', ev);\n return this;\n }\n\n /** @internal */\n private _resizeStop(event: MouseEvent): DDResizable {\n const ev = DDUtils.initEvent<MouseEvent>(event, { type: 'resizestop', target: this.el });\n if (this.option.stop) {\n this.option.stop(ev); // Note: ui() not used by gridstack so don't pass\n }\n this.el.classList.remove('ui-resizable-resizing');\n this.triggerEvent('resizestop', ev);\n this._cleanHelper();\n delete this.startEvent;\n delete this.originalRect;\n delete this.temporalRect;\n delete this.scrollY;\n delete this.scrolled;\n return this;\n }\n\n /** @internal */\n private _setupHelper(): DDResizable {\n this.elOriginStyleVal = DDResizable._originStyleProp.map(prop => this.el.style[prop]);\n this.parentOriginStylePosition = this.el.parentElement.style.position;\n if (window.getComputedStyle(this.el.parentElement).position.match(/static/)) {\n this.el.parentElement.style.position = 'relative';\n }\n this.el.style.position = this.option.basePosition || 'absolute'; // or 'fixed'\n this.el.style.opacity = '0.8';\n this.el.style.zIndex = '1000';\n return this;\n }\n\n /** @internal */\n private _cleanHelper(): DDResizable {\n DDResizable._originStyleProp.forEach((prop, i) => {\n this.el.style[prop] = this.elOriginStyleVal[i] || null;\n });\n this.el.parentElement.style.position = this.parentOriginStylePosition || null;\n return this;\n }\n\n /** @internal */\n private _getChange(event: MouseEvent, dir: string): Rect {\n const oEvent = this.startEvent;\n const newRect = { // Note: originalRect is a complex object, not a simple Rect, so copy out.\n width: this.originalRect.width,\n height: this.originalRect.height + this.scrolled,\n left: this.originalRect.left,\n top: this.originalRect.top - this.scrolled\n };\n \n const offsetX = event.clientX - oEvent.clientX;\n const offsetY = event.clientY - oEvent.clientY;\n\n if (dir.indexOf('e') > -1) {\n newRect.width += offsetX;\n } else if (dir.indexOf('w') > -1) {\n newRect.width -= offsetX;\n newRect.left += offsetX;\n }\n if (dir.indexOf('s') > -1) {\n newRect.height += offsetY;\n } else if (dir.indexOf('n') > -1) {\n newRect.height -= offsetY;\n newRect.top += offsetY\n }\n const constrain = this._constrainSize(newRect.width, newRect.height);\n if (Math.round(newRect.width) !== Math.round(constrain.width)) { // round to ignore slight round-off errors\n if (dir.indexOf('w') > -1) {\n newRect.left += newRect.width - constrain.width;\n }\n newRect.width = constrain.width;\n }\n if (Math.round(newRect.height) !== Math.round(constrain.height)) {\n if (dir.indexOf('n') > -1) {\n newRect.top += newRect.height - constrain.height;\n }\n newRect.height = constrain.height;\n }\n return newRect;\n }\n\n /** @internal constrain the size to the set min/max values */\n private _constrainSize(oWidth: number, oHeight: number): Size {\n const maxWidth = this.option.maxWidth || Number.MAX_SAFE_INTEGER;\n const minWidth = this.option.minWidth || oWidth;\n const maxHeight = this.option.maxHeight || Number.MAX_SAFE_INTEGER;\n const minHeight = this.option.minHeight || oHeight;\n const width = Math.min(maxWidth, Math.max(minWidth, oWidth));\n const height = Math.min(maxHeight, Math.max(minHeight, oHeight));\n return { width, height };\n }\n\n /** @internal */\n private _applyChange(): DDResizable {\n let containmentRect = { left: 0, top: 0, width: 0, height: 0 };\n if (this.el.style.position === 'absolute') {\n const containmentEl = this.el.parentElement;\n const { left, top } = containmentEl.getBoundingClientRect();\n containmentRect = { left, top, width: 0, height: 0 };\n }\n if (!this.temporalRect) return this;\n Object.keys(this.temporalRect).forEach(key => {\n const value = this.temporalRect[key];\n this.el.style[key] = value - containmentRect[key] + 'px';\n });\n return this;\n }\n\n /** @internal */\n private _removeHandlers(): DDResizable {\n this.handlers.forEach(handle => handle.destroy());\n delete this.handlers;\n return this;\n }\n\n /** @internal */\n private _ui = (): DDUIData => {\n const containmentEl = this.el.parentElement;\n const containmentRect = containmentEl.getBoundingClientRect();\n const newRect = { // Note: originalRect is a complex object, not a simple Rect, so copy out.\n width: this.originalRect.width,\n height: this.originalRect.height + this.scrolled,\n left: this.originalRect.left,\n top: this.originalRect.top - this.scrolled\n };\n const rect = this.temporalRect || newRect;\n return {\n position: {\n left: rect.left - containmentRect.left,\n top: rect.top - containmentRect.top\n },\n size: {\n width: rect.width,\n height: rect.height\n }\n /* Gridstack ONLY needs position set above... keep around in case.\n element: [this.el], // The object representing the element to be resized\n helper: [], // TODO: not support yet - The object representing the helper that's being resized\n originalElement: [this.el],// we don't wrap here, so simplify as this.el //The object representing the original element before it is wrapped\n originalPosition: { // The position represented as { left, top } before the resizable is resized\n left: this.originalRect.left - containmentRect.left,\n top: this.originalRect.top - containmentRect.top\n },\n originalSize: { // The size represented as { width, height } before the resizable is resized\n width: this.originalRect.width,\n height: this.originalRect.height\n }\n */\n };\n }\n}\n","/**\n * dd-utils.ts 4.2.6\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\n */\nexport class DDUtils {\n\n public static isEventSupportPassiveOption = ((() => {\n let supportsPassive = false;\n let passiveTest = () => {\n // do nothing\n };\n document.addEventListener('test', passiveTest, {\n get passive() {\n supportsPassive = true;\n return true;\n }\n });\n document.removeEventListener('test', passiveTest);\n return supportsPassive;\n })());\n\n public static clone(el: HTMLElement): HTMLElement {\n const node = el.cloneNode(true) as HTMLElement;\n node.removeAttribute('id');\n return node;\n }\n\n public static appendTo(el: HTMLElement, parent: string | HTMLElement | Node): void {\n let parentNode: HTMLElement;\n if (typeof parent === 'string') {\n parentNode = document.querySelector(parent as string);\n } else {\n parentNode = parent as HTMLElement;\n }\n if (parentNode) {\n parentNode.appendChild(el);\n }\n }\n\n public static setPositionRelative(el: HTMLElement): void {\n if (!(/^(?:r|a|f)/).test(window.getComputedStyle(el).position)) {\n el.style.position = \"relative\";\n }\n }\n\n public static addElStyles(el: HTMLElement, styles: { [prop: string]: string | string[] }): void {\n if (styles instanceof Object) {\n for (const s in styles) {\n if (styles.hasOwnProperty(s)) {\n if (Array.isArray(styles[s])) {\n // support fallback value\n (styles[s] as string[]).forEach(val => {\n el.style[s] = val;\n });\n } else {\n el.style[s] = styles[s];\n }\n }\n }\n }\n }\n\n public static initEvent<T>(e: DragEvent | MouseEvent, info: { type: string; target?: EventTarget }): T {\n const evt = { type: info.type };\n const obj = {\n button: 0,\n which: 0,\n buttons: 1,\n bubbles: true,\n cancelable: true,\n target: info.target ? info.target : e.target\n };\n // don't check for `instanceof DragEvent` as Safari use MouseEvent #1540\n if ((e as DragEvent).dataTransfer) {\n evt['dataTransfer'] = (e as DragEvent).dataTransfer; // workaround 'readonly' field.\n }\n ['altKey','ctrlKey','metaKey','shiftKey'].forEach(p => evt[p] = e[p]); // keys\n ['pageX','pageY','clientX','clientY','screenX','screenY'].forEach(p => evt[p] = e[p]); // point info\n return {...evt, ...obj} as unknown as T;\n }\n}","/**\n * gridstack-dd-native.ts 4.2.6\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\n */\n\nimport { DDManager } from './dd-manager';\nimport { DDElement, DDElementHost } from './dd-element';\n\nimport { GridStackElement } from '../gridstack';\nimport { GridStackDD, DDOpts, DDKey, DDDropOpt, DDCallback, DDValue } from '../gridstack-dd';\nimport { GridItemHTMLElement, DDDragInOpt } from '../types';\nimport { Utils } from '../utils';\n\n// export our base class (what user should use) and all associated types\nexport * from '../gridstack-dd';\n\n/**\n * HTML 5 Native DragDrop based drag'n'drop plugin.\n */\nexport class GridStackDDNative extends GridStackDD {\n\n public resizable(el: GridItemHTMLElement, opts: DDOpts, key?: DDKey, value?: DDValue): GridStackDDNative {\n this._getDDElements(el).forEach(dEl => {\n if (opts === 'disable' || opts === 'enable') {\n dEl.ddResizable && dEl.ddResizable[opts](); // can't create DD as it requires options for setupResizable()\n } else if (opts === 'destroy') {\n dEl.ddResizable && dEl.cleanResizable();\n } else if (opts === 'option') {\n dEl.setupResizable({ [key]: value });\n } else {\n const grid = dEl.el.gridstackNode.grid;\n let handles = dEl.el.getAttribute('gs-resize-handles') ? dEl.el.getAttribute('gs-resize-handles') : grid.opts.resizable.handles;\n dEl.setupResizable({\n ...grid.opts.resizable,\n ...{ handles: handles },\n ...{\n start: opts.start,\n stop: opts.stop,\n resize: opts.resize\n }\n });\n }\n });\n return this;\n }\n\n public draggable(el: GridItemHTMLElement, opts: DDOpts, key?: DDKey, value?: DDValue): GridStackDDNative {\n this._getDDElements(el).forEach(dEl => {\n if (opts === 'disable' || opts === 'enable') {\n dEl.ddDraggable && dEl.ddDraggable[opts](); // can't create DD as it requires options for setupDraggable()\n } else if (opts === 'destroy') {\n dEl.ddDraggable && dEl.cleanDraggable();\n } else if (opts === 'option') {\n dEl.setupDraggable({ [key]: value });\n } else {\n const grid = dEl.el.gridstackNode.grid;\n dEl.setupDraggable({\n ...grid.opts.draggable,\n ...{\n containment: (grid.opts._isNested && !grid.opts.dragOut)\n ? grid.el.parentElement\n : (grid.opts.draggable.containment || null),\n start: opts.start,\n stop: opts.stop,\n drag: opts.drag\n }\n });\n }\n });\n return this;\n }\n\n public dragIn(el: GridStackElement, opts: DDDragInOpt): GridStackDDNative {\n this._getDDElements(el).forEach(dEl => dEl.setupDraggable(opts));\n return this;\n }\n\n public droppable(el: GridItemHTMLElement, opts: DDOpts | DDDropOpt, key?: DDKey, value?: DDValue): GridStackDDNative {\n if (typeof opts.accept === 'function' && !opts._accept) {\n opts._accept = opts.accept;\n opts.accept = (el) => opts._accept(el);\n }\n this._getDDElements(el).forEach(dEl => {\n if (opts === 'disable' || opts === 'enable') {\n dEl.ddDroppable && dEl.ddDroppable[opts]();\n } else if (opts === 'destroy') {\n if (dEl.ddDroppable) { // error to call destroy if not there\n dEl.cleanDroppable();\n }\n } else if (opts === 'option') {\n dEl.setupDroppable({ [key]: value });\n } else {\n dEl.setupDroppable(opts);\n }\n });\n return this;\n }\n\n /** true if element is droppable */\n public isDroppable(el: DDElementHost): boolean {\n return !!(el && el.ddElement && el.ddElement.ddDroppable && !el.ddElement.ddDroppable.disabled);\n }\n\n /** true if element is draggable */\n public isDraggable(el: DDElementHost): boolean {\n return !!(el && el.ddElement && el.ddElement.ddDraggable && !el.ddElement.ddDraggable.disabled);\n }\n\n /** true if element is draggable */\n public isResizable(el: DDElementHost): boolean {\n return !!(el && el.ddElement && el.ddElement.ddResizable && !el.ddElement.ddResizable.disabled);\n }\n\n public on(el: GridItemHTMLElement, name: string, callback: DDCallback): GridStackDDNative {\n this._getDDElements(el).forEach(dEl =>\n dEl.on(name, (event: Event) => {\n callback(\n event,\n DDManager.dragElement ? DDManager.dragElement.el : event.target as GridItemHTMLElement,\n DDManager.dragElement ? DDManager.dragElement.helper : null)\n })\n );\n return this;\n }\n\n public off(el: GridItemHTMLElement, name: string): GridStackDD {\n this._getDDElements(el).forEach(dEl => dEl.off(name));\n return this;\n }\n\n /** @internal returns a list of DD elements, creating them on the fly by default */\n private _getDDElements(els: GridStackElement, create = true): DDElement[] {\n let hosts = Utils.getElements(els) as DDElementHost[];\n if (!hosts.length) return [];\n let list = hosts.map(e => e.ddElement || (create ? DDElement.init(e) : null));\n if (!create) { list.filter(d => d); } // remove nulls\n return list;\n }\n}\n\n// finally register ourself\nGridStackDD.registerPlugin(GridStackDDNative);\n","/**\r\n * utils.ts 4.2.6\r\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\r\n */\r\n\r\nimport { GridStackElement, GridStackNode, GridStackOptions, numberOrString, GridStackPosition, GridStackWidget } from './types';\r\n\r\nexport interface HeightData {\r\n h: number;\r\n unit: string;\r\n}\r\n\r\n/** checks for obsolete method names */\r\n// eslint-disable-next-line\r\nexport function obsolete(self, f, oldName: string, newName: string, rev: string): (...args: any[]) => any {\r\n let wrapper = (...args) => {\r\n console.warn('gridstack.js: Function `' + oldName + '` is deprecated in ' + rev + ' and has been replaced ' +\r\n 'with `' + newName + '`. It will be **completely** removed in v1.0');\r\n return f.apply(self, args);\r\n }\r\n wrapper.prototype = f.prototype;\r\n return wrapper;\r\n}\r\n\r\n/** checks for obsolete grid options (can be used for any fields, but msg is about options) */\r\nexport function obsoleteOpts(opts: GridStackOptions, oldName: string, newName: string, rev: string): void {\r\n if (opts[oldName] !== undefined) {\r\n opts[newName] = opts[oldName];\r\n console.warn('gridstack.js: Option `' + oldName + '` is deprecated in ' + rev + ' and has been replaced with `' +\r\n newName + '`. It will be **completely** removed in v1.0');\r\n }\r\n}\r\n\r\n/** checks for obsolete grid options which are gone */\r\nexport function obsoleteOptsDel(opts: GridStackOptions, oldName: string, rev: string, info: string): void {\r\n if (opts[oldName] !== undefined) {\r\n console.warn('gridstack.js: Option `' + oldName + '` is deprecated in ' + rev + info);\r\n }\r\n}\r\n\r\n/** checks for obsolete Jquery element attributes */\r\nexport function obsoleteAttr(el: HTMLElement, oldName: string, newName: string, rev: string): void {\r\n let oldAttr = el.getAttribute(oldName);\r\n if (oldAttr !== null) {\r\n el.setAttribute(newName, oldAttr);\r\n console.warn('gridstack.js: attribute `' + oldName + '`=' + oldAttr + ' is deprecated on this object in ' + rev + ' and has been replaced with `' +\r\n newName + '`. It will be **completely** removed in v1.0');\r\n }\r\n}\r\n\r\n/**\r\n * Utility methods\r\n */\r\nexport class Utils {\r\n\r\n /** convert a potential selector into actual list of html elements */\r\n static getElements(els: GridStackElement): HTMLElement[] {\r\n if (typeof els === 'string') {\r\n let list = document.querySelectorAll(els);\r\n if (!list.length && els[0] !== '.' && els[0] !== '#') {\r\n list = document.querySelectorAll('.' + els);\r\n if (!list.length) { list = document.querySelectorAll('#' + els) }\r\n }\r\n return Array.from(list) as HTMLElement[];\r\n }\r\n return [els];\r\n }\r\n\r\n /** convert a potential selector into actual single element */\r\n static getElement(els: GridStackElement): HTMLElement {\r\n if (typeof els === 'string') {\r\n if (!els.length) return null;\r\n if (els[0] === '#') {\r\n return document.getElementById(els.substring(1));\r\n }\r\n if (els[0] === '.' || els[0] === '[') {\r\n return document.querySelector(els);\r\n }\r\n\r\n // if we start with a digit, assume it's an id (error calling querySelector('#1')) as class are not valid CSS\r\n if(!isNaN(+els[0])) { // start with digit\r\n return document.getElementById(els);\r\n }\r\n\r\n // finally try string, then id then class\r\n let el = document.querySelector(els);\r\n if (!el) { el = document.getElementById(els) }\r\n if (!el) { el = document.querySelector('.' + els) }\r\n return el as HTMLElement;\r\n }\r\n return els;\r\n }\r\n\r\n /** returns true if a and b overlap */\r\n static isIntercepted(a: GridStackPosition, b: GridStackPosition): boolean {\r\n return !(a.y >= b.y + b.h || a.y + a.h <= b.y || a.x + a.w <= b.x || a.x >= b.x + b.w);\r\n }\r\n\r\n /** returns true if a and b touch edges or corners */\r\n static isTouching(a: GridStackPosition, b: GridStackPosition): boolean {\r\n return Utils.isIntercepted(a, {x: b.x-0.5, y: b.y-0.5, w: b.w+1, h: b.h+1})\r\n }\r\n /**\r\n * Sorts array of nodes\r\n * @param nodes array to sort\r\n * @param dir 1 for asc, -1 for desc (optional)\r\n * @param width width of the grid. If undefined the width will be calculated automatically (optional).\r\n **/\r\n static sort(nodes: GridStackNode[], dir?: -1 | 1, column?: number): GridStackNode[] {\r\n column = column || nodes.reduce((col, n) => Math.max(n.x + n.w, col), 0) || 12;\r\n if (dir === -1)\r\n return nodes.sort((a, b) => (b.x + b.y * column)-(a.x + a.y * column));\r\n else\r\n return nodes.sort((b, a) => (b.x + b.y * column)-(a.x + a.y * column));\r\n }\r\n\r\n /**\r\n * creates a style sheet with style id under given parent\r\n * @param id will set the 'gs-style-id' attribute to that id\r\n * @param parent to insert the stylesheet as first child,\r\n * if none supplied it will be appended to the document head instead.\r\n */\r\n static createStylesheet(id: string, parent?: HTMLElement): CSSStyleSheet {\r\n let style: HTMLStyleElement = document.createElement('style');\r\n style.setAttribute('type', 'text/css');\r\n style.setAttribute('gs-style-id', id);\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n if ((style as any).styleSheet) { // TODO: only CSSImportRule have that and different beast ??\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n (style as any).styleSheet.cssText = '';\r\n } else {\r\n style.appendChild(document.createTextNode('')); // WebKit hack\r\n }\r\n if (!parent) {\r\n // default to head\r\n parent = document.getElementsByTagName('head')[0];\r\n parent.appendChild(style);\r\n } else {\r\n parent.insertBefore(style, parent.firstChild);\r\n }\r\n return style.sheet as CSSStyleSheet;\r\n }\r\n\r\n /** removed the given stylesheet id */\r\n static removeStylesheet(id: string): void {\r\n let el = document.querySelector('STYLE[gs-style-id=' + id + ']');\r\n if (el && el.parentNode) el.remove();\r\n }\r\n\r\n /** inserts a CSS rule */\r\n static addCSSRule(sheet: CSSStyleSheet, selector: string, rules: string): void {\r\n if (typeof sheet.addRule === 'function') {\r\n sheet.addRule(selector, rules);\r\n } else if (typeof sheet.insertRule === 'function') {\r\n sheet.insertRule(`${selector}{${rules}}`);\r\n }\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n static toBool(v: unknown): boolean {\r\n if (typeof v === 'boolean') {\r\n return v;\r\n }\r\n if (typeof v === 'string') {\r\n v = v.toLowerCase();\r\n return !(v === '' || v === 'no' || v === 'false' || v === '0');\r\n }\r\n return Boolean(v);\r\n }\r\n\r\n static toNumber(value: null | string): number {\r\n return (value === null || value.length === 0) ? undefined : Number(value);\r\n }\r\n\r\n static parseHeight(val: numberOrString): HeightData {\r\n let h: number;\r\n let unit = 'px';\r\n if (typeof val === 'string') {\r\n let match = val.match(/^(-[0-9]+\\.[0-9]+|[0-9]*\\.[0-9]+|-[0-9]+|[0-9]+)(px|em|rem|vh|vw|%)?$/);\r\n if (!match) {\r\n throw new Error('Invalid height');\r\n }\r\n unit = match[2] || 'px';\r\n h = parseFloat(match[1]);\r\n } else {\r\n h = val;\r\n }\r\n return { h, unit };\r\n }\r\n\r\n /** copies unset fields in target to use the given default sources values */\r\n // eslint-disable-next-line\r\n static defaults(target, ...sources): {} {\r\n\r\n sources.forEach(source => {\r\n for (const key in source) {\r\n if (!source.hasOwnProperty(key)) return;\r\n if (target[key] === null || target[key] === undefined) {\r\n target[key] = source[key];\r\n } else if (typeof source[key] === 'object' && typeof target[key] === 'object') {\r\n // property is an object, recursively add it's field over... #1373\r\n this.defaults(target[key], source[key]);\r\n }\r\n }\r\n });\r\n\r\n return target;\r\n }\r\n\r\n /** given 2 objects return true if they have the same values. Checks for Object {} having same fields and values (just 1 level down) */\r\n static same(a: unknown, b: unknown): boolean {\r\n if (typeof a !== 'object') return a == b;\r\n if (typeof a !== typeof b) return false;\r\n // else we have object, check just 1 level deep for being same things...\r\n if (Object.keys(a).length !== Object.keys(b).length) return false;\r\n for (const key in a) {\r\n if (a[key] !== b[key]) return false;\r\n }\r\n return true;\r\n }\r\n\r\n /* copies over b size & position (GridStackPosition), and possibly min/max as well */\r\n static copyPos(a: GridStackWidget, b: GridStackWidget, minMax = false): GridStackWidget {\r\n a.x = b.x;\r\n a.y = b.y;\r\n a.w = b.w;\r\n a.h = b.h;\r\n if (!minMax) return a;\r\n if (b.minW) a.minW = b.minW;\r\n if (b.minH) a.minH = b.minH;\r\n if (b.maxW) a.maxW = b.maxW;\r\n if (b.maxH) a.maxH = b.maxH;\r\n return a;\r\n }\r\n\r\n /* true if a and b has same size & position */\r\n static samePos(a: GridStackPosition, b: GridStackPosition): boolean {\r\n return a && b && a.x === b.x && a.y === b.y && a.w === b.w && a.h === b.h;\r\n }\r\n\r\n /** removes field from the first object if same as the second objects (like diffing) and internal '_' for saving */\r\n static removeInternalAndSame(a: unknown, b: unknown):void {\r\n if (typeof a !== 'object' || typeof b !== 'object') return;\r\n for (let key in a) {\r\n let val = a[key];\r\n if (key[0] === '_' || val === b[key]) {\r\n delete a[key]\r\n } else if (val && typeof val === 'object' && b[key] !== undefined) {\r\n for (let i in val) {\r\n if (val[i] === b[key][i] || i[0] === '_') { delete val[i] }\r\n }\r\n if (!Object.keys(val).length) { delete a[key] }\r\n }\r\n }\r\n }\r\n\r\n /** return the closest parent matching the given class */\r\n static closestByClass(el: HTMLElement, name: string): HTMLElement {\r\n\r\n while(el = el.parentElement) {\r\n if (el.classList.contains(name)) return el;\r\n }\r\n return null;\r\n }\r\n\r\n /** delay calling the given function for given delay, preventing new calls from happening while waiting */\r\n static throttle(func: () => void, delay: number): () => void {\r\n let isWaiting = false;\r\n return (...args) => {\r\n if (!isWaiting) {\r\n isWaiting = true;\r\n setTimeout(() => { func(...args); isWaiting = false; }, delay);\r\n }\r\n }\r\n }\r\n\r\n static removePositioningStyles(el: HTMLElement): void {\r\n let style = el.style;\r\n if (style.position) {\r\n style.removeProperty('position');\r\n }\r\n if (style.left) {\r\n style.removeProperty('left');\r\n }\r\n if (style.top) {\r\n style.removeProperty('top');\r\n }\r\n if (style.width) {\r\n style.removeProperty('width');\r\n }\r\n if (style.height) {\r\n style.removeProperty('height');\r\n }\r\n }\r\n\r\n /** @internal returns the passed element if scrollable, else the closest parent that will, up to the entire document scrolling element */\r\n static getScrollElement(el?: HTMLElement): HTMLElement {\r\n if (!el) return document.scrollingElement as HTMLElement;\r\n const style = getComputedStyle(el);\r\n const overflowRegex = /(auto|scroll)/;\r\n\r\n if (overflowRegex.test(style.overflow + style.overflowY)) {\r\n return el;\r\n } else {\r\n return this.getScrollElement(el.parentElement);\r\n }\r\n }\r\n\r\n /** @internal */\r\n static updateScrollPosition(el: HTMLElement, position: {top: number}, distance: number): void {\r\n // is widget in view?\r\n let rect = el.getBoundingClientRect();\r\n let innerHeightOrClientHeight = (window.innerHeight || document.documentElement.clientHeight);\r\n if (rect.top < 0 ||\r\n rect.bottom > innerHeightOrClientHeight\r\n ) {\r\n // set scrollTop of first parent that scrolls\r\n // if parent is larger than el, set as low as possible\r\n // to get entire widget on screen\r\n let offsetDiffDown = rect.bottom - innerHeightOrClientHeight;\r\n let offsetDiffUp = rect.top;\r\n let scrollEl = this.getScrollElement(el);\r\n if (scrollEl !== null) {\r\n let prevScroll = scrollEl.scrollTop;\r\n if (rect.top < 0 && distance < 0) {\r\n // moving up\r\n if (el.offsetHeight > innerHeightOrClientHeight) {\r\n scrollEl.scrollTop += distance;\r\n } else {\r\n scrollEl.scrollTop += Math.abs(offsetDiffUp) > Math.abs(distance) ? distance : offsetDiffUp;\r\n }\r\n } else if (distance > 0) {\r\n // moving down\r\n if (el.offsetHeight > innerHeightOrClientHeight) {\r\n scrollEl.scrollTop += distance;\r\n } else {\r\n scrollEl.scrollTop += offsetDiffDown > distance ? distance : offsetDiffDown;\r\n }\r\n }\r\n // move widget y by amount scrolled\r\n position.top += scrollEl.scrollTop - prevScroll;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * @internal Function used to scroll the page.\r\n *\r\n * @param event `MouseEvent` that triggers the resize\r\n * @param el `HTMLElement` that's being resized\r\n * @param distance Distance from the V edges to start scrolling\r\n */\r\n static updateScrollResize(event: MouseEvent, el: HTMLElement, distance: number): void {\r\n const scrollEl = this.getScrollElement(el);\r\n const height = scrollEl.clientHeight;\r\n // #1727 event.clientY is relative to viewport, so must compare this against position of scrollEl getBoundingClientRect().top\r\n // #1745 Special situation if scrollEl is document 'html': here browser spec states that\r\n // clientHeight is height of viewport, but getBoundingClientRect() is rectangle of html element;\r\n // this discrepancy arises because in reality scrollbar is attached to viewport, not html element itself.\r\n const offsetTop = (scrollEl === this.getScrollElement()) ? 0 : scrollEl.getBoundingClientRect().top;\r\n const pointerPosY = event.clientY - offsetTop;\r\n const top = pointerPosY < distance;\r\n const bottom = pointerPosY > height - distance;\r\n\r\n if (top) {\r\n // This also can be done with a timeout to keep scrolling while the mouse is\r\n // in the scrolling zone. (will have smoother behavior)\r\n scrollEl.scrollBy({ behavior: 'smooth', top: pointerPosY - distance});\r\n } else if (bottom) {\r\n scrollEl.scrollBy({ behavior: 'smooth', top: distance - (height - pointerPosY)});\r\n }\r\n }\r\n\r\n /** single level clone, returning a new object with same top fields. This will share sub objects and arrays */\r\n static clone<T>(obj: T): T {\r\n if (obj === null || obj === undefined || typeof(obj) !== 'object') {\r\n return obj;\r\n }\r\n // return Object.assign({}, obj);\r\n if (obj instanceof Array) {\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n return [...obj] as any;\r\n }\r\n return {...obj};\r\n }\r\n\r\n /**\r\n * Recursive clone version that returns a full copy, checking for nested objects and arrays ONLY.\r\n * Note: this will use as-is any key starting with double __ (and not copy inside) some lib have circular dependencies.\r\n */\r\n static cloneDeep<T>(obj: T): T {\r\n // return JSON.parse(JSON.stringify(obj)); // doesn't work with date format ?\r\n const ret = Utils.clone(obj);\r\n for (const key in ret) {\r\n // NOTE: we don't support function/circular dependencies so skip those properties for now...\r\n if (ret.hasOwnProperty(key) && typeof(ret[key]) === 'object' && key.substring(0, 2) !== '__') {\r\n ret[key] = Utils.cloneDeep(obj[key]);\r\n }\r\n }\r\n return ret;\r\n }\r\n}\r\n\r\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(930);\n"],"sourceRoot":""}