gridstack 12.3.2 → 12.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/dist/angular/esm2020/lib/base-widget.mjs +2 -2
  2. package/dist/angular/esm2020/lib/gridstack-item.component.mjs +2 -2
  3. package/dist/angular/esm2020/lib/gridstack.component.mjs +2 -2
  4. package/dist/angular/esm2020/lib/gridstack.module.mjs +2 -2
  5. package/dist/angular/esm2020/lib/types.mjs +2 -2
  6. package/dist/angular/fesm2015/gridstack-angular.mjs +4 -4
  7. package/dist/angular/fesm2015/gridstack-angular.mjs.map +1 -1
  8. package/dist/angular/fesm2020/gridstack-angular.mjs +5 -5
  9. package/dist/angular/fesm2020/gridstack-angular.mjs.map +1 -1
  10. package/dist/angular/lib/gridstack-item.component.d.ts +1 -1
  11. package/dist/angular/lib/gridstack.component.d.ts +1 -1
  12. package/dist/angular/lib/types.d.ts +1 -1
  13. package/dist/angular/package.json +1 -1
  14. package/dist/angular/src/base-widget.ts +1 -1
  15. package/dist/angular/src/gridstack-item.component.ts +1 -1
  16. package/dist/angular/src/gridstack.component.ts +1 -1
  17. package/dist/angular/src/gridstack.module.ts +1 -1
  18. package/dist/angular/src/types.ts +1 -1
  19. package/dist/gridstack-all.js +1 -1
  20. package/dist/gridstack-all.js.LICENSE.txt +1 -1
  21. package/dist/gridstack-all.js.map +1 -1
  22. package/dist/gridstack.css +1 -1
  23. package/dist/spec/gridstack-engine-spec.d.ts +1 -0
  24. package/dist/spec/gridstack-engine-spec.js +358 -0
  25. package/dist/spec/gridstack-engine-spec.js.map +1 -0
  26. package/dist/spec/gridstack-spec.d.ts +1 -0
  27. package/dist/spec/gridstack-spec.js +1780 -0
  28. package/dist/spec/gridstack-spec.js.map +1 -0
  29. package/dist/spec/integration/gridstack-integration.spec.d.ts +1 -0
  30. package/dist/spec/integration/gridstack-integration.spec.js +171 -0
  31. package/dist/spec/integration/gridstack-integration.spec.js.map +1 -0
  32. package/dist/spec/regression-spec.d.ts +1 -0
  33. package/dist/spec/regression-spec.js +100 -0
  34. package/dist/spec/regression-spec.js.map +1 -0
  35. package/dist/spec/utils-spec.d.ts +1 -0
  36. package/dist/spec/utils-spec.js +243 -0
  37. package/dist/spec/utils-spec.js.map +1 -0
  38. package/dist/src/dd-base-impl.d.ts +69 -0
  39. package/dist/src/dd-base-impl.js +70 -0
  40. package/dist/src/dd-base-impl.js.map +1 -0
  41. package/dist/src/dd-draggable.d.ts +20 -0
  42. package/dist/src/dd-draggable.js +364 -0
  43. package/dist/src/dd-draggable.js.map +1 -0
  44. package/dist/src/dd-droppable.d.ts +26 -0
  45. package/dist/src/dd-droppable.js +149 -0
  46. package/dist/src/dd-droppable.js.map +1 -0
  47. package/dist/src/dd-element.d.ts +27 -0
  48. package/dist/src/dd-element.js +91 -0
  49. package/dist/src/dd-element.js.map +1 -0
  50. package/dist/src/dd-gridstack.d.ts +82 -0
  51. package/dist/src/dd-gridstack.js +165 -0
  52. package/dist/src/dd-gridstack.js.map +1 -0
  53. package/dist/src/dd-manager.d.ts +43 -0
  54. package/dist/src/dd-manager.js +14 -0
  55. package/dist/src/dd-manager.js.map +1 -0
  56. package/dist/src/dd-resizable-handle.d.ts +18 -0
  57. package/dist/src/dd-resizable-handle.js +113 -0
  58. package/dist/src/dd-resizable-handle.js.map +1 -0
  59. package/dist/src/dd-resizable.d.ts +30 -0
  60. package/dist/src/dd-resizable.js +304 -0
  61. package/dist/src/dd-resizable.js.map +1 -0
  62. package/dist/src/dd-touch.d.ts +33 -0
  63. package/dist/src/dd-touch.js +145 -0
  64. package/dist/src/dd-touch.js.map +1 -0
  65. package/dist/src/gridstack-engine.d.ts +321 -0
  66. package/dist/src/gridstack-engine.js +1272 -0
  67. package/dist/src/gridstack-engine.js.map +1 -0
  68. package/dist/src/gridstack.d.ts +802 -0
  69. package/dist/src/gridstack.js +2872 -0
  70. package/dist/src/gridstack.js.map +1 -0
  71. package/dist/src/gridstack.scss +1 -1
  72. package/dist/src/types.d.ts +427 -0
  73. package/dist/src/types.js +38 -0
  74. package/dist/src/types.js.map +1 -0
  75. package/dist/src/utils.d.ts +283 -0
  76. package/dist/src/utils.js +790 -0
  77. package/dist/src/utils.js.map +1 -0
  78. package/dist/vitest.config.d.ts +2 -0
  79. package/dist/vitest.config.js +74 -0
  80. package/dist/vitest.config.js.map +1 -0
  81. package/dist/vitest.setup.d.ts +1 -0
  82. package/dist/vitest.setup.js +90 -0
  83. package/dist/vitest.setup.js.map +1 -0
  84. package/doc/API.md +22 -22
  85. package/package.json +21 -9
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dd-droppable.js","sourceRoot":"","sources":["../../src/dd-droppable.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,eAAe,EAAwB,MAAM,gBAAgB,CAAC;AACvE,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAUjE,yBAAyB;AAEzB,MAAM,OAAO,WAAY,SAAQ,eAAe;IAI9C,YAAmB,EAAe,EAAS,SAAyB,EAAE;QACpE,KAAK,EAAE,CAAC;QADS,OAAE,GAAF,EAAE,CAAa;QAAS,WAAM,GAAN,MAAM,CAAqB;QAEpE,+GAA+G;QAC/G,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/C,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/C,IAAI,CAAC,MAAM,EAAE,CAAC;QACd,IAAI,CAAC,YAAY,EAAE,CAAC;IACtB,CAAC;IAEM,EAAE,CAAC,KAAsC,EAAE,QAAoC;QACpF,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,CAA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C,CAAC;SACpI;aAAM;YACL,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;SAClC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,gBAAgB;IACN,GAAG,CAAC,IAAiB;QAC7B,OAAO;YACL,SAAS,EAAE,IAAI,CAAC,EAAE;YAClB,GAAG,IAAI,CAAC,EAAE,EAAE;SACb,CAAC;IACJ,CAAC;CACF","sourcesContent":["/**\n * dd-droppable.ts 12.3.3\n * Copyright (c) 2021-2025 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 { Utils } from './utils';\nimport { DDElementHost } from './dd-element';\nimport { isTouch, pointerenter, pointerleave } from './dd-touch';\nimport { DDUIData } from './types';\n\nexport interface DDDroppableOpt {\n accept?: string | ((el: HTMLElement) => boolean);\n drop?: (event: DragEvent, ui: DDUIData) => void;\n over?: (event: DragEvent, ui: DDUIData) => void;\n out?: (event: DragEvent, ui: DDUIData) => void;\n}\n\n// let count = 0; // TEST\n\nexport class DDDroppable extends DDBaseImplement implements HTMLElementExtendOpt<DDDroppableOpt> {\n\n public accept: (el: HTMLElement) => boolean;\n\n constructor(public el: HTMLElement, public option: DDDroppableOpt = {}) {\n super();\n // create var event binding so we can easily remove and still look like TS methods (unlike anonymous functions)\n this._mouseEnter = this._mouseEnter.bind(this);\n this._mouseLeave = this._mouseLeave.bind(this);\n this.enable();\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 === false) return;\n super.enable();\n this.el.classList.add('ui-droppable');\n this.el.classList.remove('ui-droppable-disabled');\n this.el.addEventListener('mouseenter', this._mouseEnter);\n this.el.addEventListener('mouseleave', this._mouseLeave);\n if (isTouch) {\n this.el.addEventListener('pointerenter', pointerenter);\n this.el.addEventListener('pointerleave', pointerleave);\n }\n }\n\n public disable(forDestroy = false): void {\n if (this.disabled === true) return;\n super.disable();\n this.el.classList.remove('ui-droppable');\n if (!forDestroy) this.el.classList.add('ui-droppable-disabled');\n this.el.removeEventListener('mouseenter', this._mouseEnter);\n this.el.removeEventListener('mouseleave', this._mouseLeave);\n if (isTouch) {\n this.el.removeEventListener('pointerenter', pointerenter);\n this.el.removeEventListener('pointerleave', pointerleave);\n }\n }\n\n public destroy(): void {\n this.disable(true);\n this.el.classList.remove('ui-droppable');\n this.el.classList.remove('ui-droppable-disabled');\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 protected _mouseEnter(e: MouseEvent): void {\n // console.log(`${count++} Enter ${this.el.id || (this.el as GridHTMLElement).gridstack.opts.id}`); // TEST\n if (!DDManager.dragElement) return;\n if (!this._canDrop(DDManager.dragElement.el)) return;\n e.preventDefault();\n e.stopPropagation();\n\n // make sure when we enter this, that the last one gets a leave FIRST to correctly cleanup as we don't always do\n if (DDManager.dropElement && DDManager.dropElement !== this) {\n DDManager.dropElement._mouseLeave(e as DragEvent, true); // calledByEnter = true\n }\n DDManager.dropElement = this;\n\n const ev = Utils.initEvent<DragEvent>(e, { 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.classList.add('ui-droppable-over');\n // console.log('tracking'); // TEST\n }\n\n /** @internal called when the item is leaving our area, stop tracking if we had moving item */\n protected _mouseLeave(e: MouseEvent, calledByEnter = false): void {\n // console.log(`${count++} Leave ${this.el.id || (this.el as GridHTMLElement).gridstack.opts.id}`); // TEST\n if (!DDManager.dragElement || DDManager.dropElement !== this) return;\n e.preventDefault();\n e.stopPropagation();\n\n const ev = Utils.initEvent<DragEvent>(e, { 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 if (DDManager.dropElement === this) {\n delete DDManager.dropElement;\n // console.log('not tracking'); // TEST\n\n // if we're still over a parent droppable, send it an enter as we don't get one from leaving nested children\n if (!calledByEnter) {\n let parentDrop: DDDroppable;\n let parent: DDElementHost = this.el.parentElement;\n while (!parentDrop && parent) {\n parentDrop = parent.ddElement?.ddDroppable;\n parent = parent.parentElement;\n }\n if (parentDrop) {\n parentDrop._mouseEnter(e);\n }\n }\n }\n }\n\n /** item is being dropped on us - called by the drag mouseup handler - this calls the client drop event */\n public drop(e: MouseEvent): void {\n e.preventDefault();\n const ev = Utils.initEvent<DragEvent>(e, { 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 }\n\n /** @internal true if element matches the string/method accept option */\n protected _canDrop(el: HTMLElement): boolean {\n return el && (!this.accept || this.accept(el));\n }\n\n /** @internal */\n protected _setupAccept(): DDDroppable {\n if (!this.option.accept) return this;\n if (typeof this.option.accept === 'string') {\n this.accept = (el: HTMLElement) => el.classList.contains(this.option.accept as string) || el.matches(this.option.accept as string);\n } else {\n this.accept = this.option.accept;\n }\n return this;\n }\n\n /** @internal */\n protected _ui(drag: DDDraggable): DDUIData {\n return {\n draggable: drag.el,\n ...drag.ui()\n };\n }\n}\n\n"]}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * dd-elements.ts 12.3.3
3
+ * Copyright (c) 2021-2025 Alain Dumesny - see GridStack root license
4
+ */
5
+ import { DDResizable, DDResizableOpt } from './dd-resizable';
6
+ import { DDDragOpt, GridItemHTMLElement } from './types';
7
+ import { DDDraggable } from './dd-draggable';
8
+ import { DDDroppable, DDDroppableOpt } from './dd-droppable';
9
+ export interface DDElementHost extends GridItemHTMLElement {
10
+ ddElement?: DDElement;
11
+ }
12
+ export declare class DDElement {
13
+ el: DDElementHost;
14
+ static init(el: DDElementHost): DDElement;
15
+ ddDraggable?: DDDraggable;
16
+ ddDroppable?: DDDroppable;
17
+ ddResizable?: DDResizable;
18
+ constructor(el: DDElementHost);
19
+ on(eventName: string, callback: (event: MouseEvent) => void): DDElement;
20
+ off(eventName: string): DDElement;
21
+ setupDraggable(opts: DDDragOpt): DDElement;
22
+ cleanDraggable(): DDElement;
23
+ setupResizable(opts: DDResizableOpt): DDElement;
24
+ cleanResizable(): DDElement;
25
+ setupDroppable(opts: DDDroppableOpt): DDElement;
26
+ cleanDroppable(): DDElement;
27
+ }
@@ -0,0 +1,91 @@
1
+ /**
2
+ * dd-elements.ts 12.3.3
3
+ * Copyright (c) 2021-2025 Alain Dumesny - see GridStack root license
4
+ */
5
+ import { DDResizable } from './dd-resizable';
6
+ import { DDDraggable } from './dd-draggable';
7
+ import { DDDroppable } from './dd-droppable';
8
+ export class DDElement {
9
+ static init(el) {
10
+ if (!el.ddElement) {
11
+ el.ddElement = new DDElement(el);
12
+ }
13
+ return el.ddElement;
14
+ }
15
+ constructor(el) {
16
+ this.el = el;
17
+ }
18
+ on(eventName, callback) {
19
+ if (this.ddDraggable && ['drag', 'dragstart', 'dragstop'].indexOf(eventName) > -1) {
20
+ this.ddDraggable.on(eventName, callback);
21
+ }
22
+ else if (this.ddDroppable && ['drop', 'dropover', 'dropout'].indexOf(eventName) > -1) {
23
+ this.ddDroppable.on(eventName, callback);
24
+ }
25
+ else if (this.ddResizable && ['resizestart', 'resize', 'resizestop'].indexOf(eventName) > -1) {
26
+ this.ddResizable.on(eventName, callback);
27
+ }
28
+ return this;
29
+ }
30
+ off(eventName) {
31
+ if (this.ddDraggable && ['drag', 'dragstart', 'dragstop'].indexOf(eventName) > -1) {
32
+ this.ddDraggable.off(eventName);
33
+ }
34
+ else if (this.ddDroppable && ['drop', 'dropover', 'dropout'].indexOf(eventName) > -1) {
35
+ this.ddDroppable.off(eventName);
36
+ }
37
+ else if (this.ddResizable && ['resizestart', 'resize', 'resizestop'].indexOf(eventName) > -1) {
38
+ this.ddResizable.off(eventName);
39
+ }
40
+ return this;
41
+ }
42
+ setupDraggable(opts) {
43
+ if (!this.ddDraggable) {
44
+ this.ddDraggable = new DDDraggable(this.el, opts);
45
+ }
46
+ else {
47
+ this.ddDraggable.updateOption(opts);
48
+ }
49
+ return this;
50
+ }
51
+ cleanDraggable() {
52
+ if (this.ddDraggable) {
53
+ this.ddDraggable.destroy();
54
+ delete this.ddDraggable;
55
+ }
56
+ return this;
57
+ }
58
+ setupResizable(opts) {
59
+ if (!this.ddResizable) {
60
+ this.ddResizable = new DDResizable(this.el, opts);
61
+ }
62
+ else {
63
+ this.ddResizable.updateOption(opts);
64
+ }
65
+ return this;
66
+ }
67
+ cleanResizable() {
68
+ if (this.ddResizable) {
69
+ this.ddResizable.destroy();
70
+ delete this.ddResizable;
71
+ }
72
+ return this;
73
+ }
74
+ setupDroppable(opts) {
75
+ if (!this.ddDroppable) {
76
+ this.ddDroppable = new DDDroppable(this.el, opts);
77
+ }
78
+ else {
79
+ this.ddDroppable.updateOption(opts);
80
+ }
81
+ return this;
82
+ }
83
+ cleanDroppable() {
84
+ if (this.ddDroppable) {
85
+ this.ddDroppable.destroy();
86
+ delete this.ddDroppable;
87
+ }
88
+ return this;
89
+ }
90
+ }
91
+ //# sourceMappingURL=dd-element.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dd-element.js","sourceRoot":"","sources":["../../src/dd-element.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAkB,MAAM,gBAAgB,CAAC;AAE7D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAkB,MAAM,gBAAgB,CAAC;AAM7D,MAAM,OAAO,SAAS;IAEpB,MAAM,CAAC,IAAI,CAAC,EAAiB;QAC3B,IAAI,CAAC,EAA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C;IAEM,cAAc,CAAC,IAAoB;QACxC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACrB,IAAI,CAAC,WAAW,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;SACnD;aAAM;YACL,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;SACrC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,cAAc;QACnB,IAAI,IAAI,CAAC,WAAW,EAAE;YACpB,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;YAC3B,OAAO,IAAI,CAAC,WAAW,CAAC;SACzB;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["/**\n * dd-elements.ts 12.3.3\n * Copyright (c) 2021-2025 Alain Dumesny - see GridStack root license\n */\n\nimport { DDResizable, DDResizableOpt } from './dd-resizable';\nimport { DDDragOpt, GridItemHTMLElement } from './types';\nimport { DDDraggable } 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 ddDraggable?: DDDraggable;\n public ddDroppable?: DDDroppable;\n public ddResizable?: DDResizable;\n\n constructor(public el: DDElementHost) {}\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: DDDragOpt): 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"]}
@@ -0,0 +1,82 @@
1
+ /**
2
+ * dd-gridstack.ts 12.3.3
3
+ * Copyright (c) 2021-2025 Alain Dumesny - see GridStack root license
4
+ */
5
+ import { GridItemHTMLElement, GridStackElement, DDDragOpt } from './types';
6
+ import { DDElementHost } from './dd-element';
7
+ /**
8
+ * Drag & Drop options for drop targets.
9
+ * Configures which elements can be dropped onto a grid.
10
+ */
11
+ export type DDDropOpt = {
12
+ /** Function to determine if an element can be dropped (see GridStackOptions.acceptWidgets) */
13
+ accept?: (el: GridItemHTMLElement) => boolean;
14
+ };
15
+ /**
16
+ * Drag & Drop operation types used throughout the DD system.
17
+ * Can be control commands or configuration objects.
18
+ */
19
+ export type DDOpts = 'enable' | 'disable' | 'destroy' | 'option' | string | any;
20
+ /**
21
+ * Keys for DD configuration options that can be set via the 'option' command.
22
+ */
23
+ export type DDKey = 'minWidth' | 'minHeight' | 'maxWidth' | 'maxHeight' | 'maxHeightMoveUp' | 'maxWidthMoveLeft';
24
+ /**
25
+ * Values for DD configuration options (numbers or strings with units).
26
+ */
27
+ export type DDValue = number | string;
28
+ /**
29
+ * Callback function type for drag & drop events.
30
+ *
31
+ * @param event - The DOM event that triggered the callback
32
+ * @param arg2 - The grid item element being dragged/dropped
33
+ * @param helper - Optional helper element used during drag operations
34
+ */
35
+ export type DDCallback = (event: Event, arg2: GridItemHTMLElement, helper?: GridItemHTMLElement) => void;
36
+ /**
37
+ * HTML Native Mouse and Touch Events Drag and Drop functionality.
38
+ *
39
+ * This class provides the main drag & drop implementation for GridStack,
40
+ * handling resizing, dragging, and dropping of grid items using native HTML5 events.
41
+ * It manages the interaction between different DD components and the grid system.
42
+ */
43
+ export declare class DDGridStack {
44
+ /**
45
+ * Enable/disable/configure resizing for grid elements.
46
+ *
47
+ * @param el - Grid item element(s) to configure
48
+ * @param opts - Resize options or command ('enable', 'disable', 'destroy', 'option', or config object)
49
+ * @param key - Option key when using 'option' command
50
+ * @param value - Option value when using 'option' command
51
+ * @returns this instance for chaining
52
+ *
53
+ * @example
54
+ * dd.resizable(element, 'enable'); // Enable resizing
55
+ * dd.resizable(element, 'option', 'minWidth', 100); // Set minimum width
56
+ */
57
+ resizable(el: GridItemHTMLElement, opts: DDOpts, key?: DDKey, value?: DDValue): DDGridStack;
58
+ /**
59
+ * Enable/disable/configure dragging for grid elements.
60
+ *
61
+ * @param el - Grid item element(s) to configure
62
+ * @param opts - Drag options or command ('enable', 'disable', 'destroy', 'option', or config object)
63
+ * @param key - Option key when using 'option' command
64
+ * @param value - Option value when using 'option' command
65
+ * @returns this instance for chaining
66
+ *
67
+ * @example
68
+ * dd.draggable(element, 'enable'); // Enable dragging
69
+ * dd.draggable(element, {handle: '.drag-handle'}); // Configure drag handle
70
+ */
71
+ draggable(el: GridItemHTMLElement, opts: DDOpts, key?: DDKey, value?: DDValue): DDGridStack;
72
+ dragIn(el: GridStackElement, opts: DDDragOpt): DDGridStack;
73
+ droppable(el: GridItemHTMLElement, opts: DDOpts | DDDropOpt, key?: DDKey, value?: DDValue): DDGridStack;
74
+ /** true if element is droppable */
75
+ isDroppable(el: DDElementHost): boolean;
76
+ /** true if element is draggable */
77
+ isDraggable(el: DDElementHost): boolean;
78
+ /** true if element is draggable */
79
+ isResizable(el: DDElementHost): boolean;
80
+ on(el: GridItemHTMLElement, name: string, callback: DDCallback): DDGridStack;
81
+ off(el: GridItemHTMLElement, name: string): DDGridStack;
82
+ }
@@ -0,0 +1,165 @@
1
+ /**
2
+ * dd-gridstack.ts 12.3.3
3
+ * Copyright (c) 2021-2025 Alain Dumesny - see GridStack root license
4
+ */
5
+ import { Utils } from './utils';
6
+ import { DDManager } from './dd-manager';
7
+ import { DDElement } from './dd-element';
8
+ // let count = 0; // TEST
9
+ /**
10
+ * HTML Native Mouse and Touch Events Drag and Drop functionality.
11
+ *
12
+ * This class provides the main drag & drop implementation for GridStack,
13
+ * handling resizing, dragging, and dropping of grid items using native HTML5 events.
14
+ * It manages the interaction between different DD components and the grid system.
15
+ */
16
+ export class DDGridStack {
17
+ /**
18
+ * Enable/disable/configure resizing for grid elements.
19
+ *
20
+ * @param el - Grid item element(s) to configure
21
+ * @param opts - Resize options or command ('enable', 'disable', 'destroy', 'option', or config object)
22
+ * @param key - Option key when using 'option' command
23
+ * @param value - Option value when using 'option' command
24
+ * @returns this instance for chaining
25
+ *
26
+ * @example
27
+ * dd.resizable(element, 'enable'); // Enable resizing
28
+ * dd.resizable(element, 'option', 'minWidth', 100); // Set minimum width
29
+ */
30
+ resizable(el, opts, key, value) {
31
+ this._getDDElements(el, opts).forEach(dEl => {
32
+ if (opts === 'disable' || opts === 'enable') {
33
+ dEl.ddResizable && dEl.ddResizable[opts](); // can't create DD as it requires options for setupResizable()
34
+ }
35
+ else if (opts === 'destroy') {
36
+ dEl.ddResizable && dEl.cleanResizable();
37
+ }
38
+ else if (opts === 'option') {
39
+ dEl.setupResizable({ [key]: value });
40
+ }
41
+ else {
42
+ const n = dEl.el.gridstackNode;
43
+ const grid = n.grid;
44
+ let handles = dEl.el.getAttribute('gs-resize-handles') || grid.opts.resizable.handles || 'e,s,se';
45
+ if (handles === 'all')
46
+ handles = 'n,e,s,w,se,sw,ne,nw';
47
+ // NOTE: keep the resize handles as e,w don't have enough space (10px) to show resize corners anyway. limit during drag instead
48
+ // restrict vertical resize if height is done to match content anyway... odd to have it spring back
49
+ // if (Utils.shouldSizeToContent(n, true)) {
50
+ // const doE = handles.indexOf('e') !== -1;
51
+ // const doW = handles.indexOf('w') !== -1;
52
+ // handles = doE ? (doW ? 'e,w' : 'e') : (doW ? 'w' : '');
53
+ // }
54
+ const autoHide = !grid.opts.alwaysShowResizeHandle;
55
+ dEl.setupResizable({
56
+ ...grid.opts.resizable,
57
+ ...{ handles, autoHide },
58
+ ...{
59
+ start: opts.start,
60
+ stop: opts.stop,
61
+ resize: opts.resize
62
+ }
63
+ });
64
+ }
65
+ });
66
+ return this;
67
+ }
68
+ /**
69
+ * Enable/disable/configure dragging for grid elements.
70
+ *
71
+ * @param el - Grid item element(s) to configure
72
+ * @param opts - Drag options or command ('enable', 'disable', 'destroy', 'option', or config object)
73
+ * @param key - Option key when using 'option' command
74
+ * @param value - Option value when using 'option' command
75
+ * @returns this instance for chaining
76
+ *
77
+ * @example
78
+ * dd.draggable(element, 'enable'); // Enable dragging
79
+ * dd.draggable(element, {handle: '.drag-handle'}); // Configure drag handle
80
+ */
81
+ draggable(el, opts, key, value) {
82
+ this._getDDElements(el, opts).forEach(dEl => {
83
+ if (opts === 'disable' || opts === 'enable') {
84
+ dEl.ddDraggable && dEl.ddDraggable[opts](); // can't create DD as it requires options for setupDraggable()
85
+ }
86
+ else if (opts === 'destroy') {
87
+ dEl.ddDraggable && dEl.cleanDraggable();
88
+ }
89
+ else if (opts === 'option') {
90
+ dEl.setupDraggable({ [key]: value });
91
+ }
92
+ else {
93
+ const grid = dEl.el.gridstackNode.grid;
94
+ dEl.setupDraggable({
95
+ ...grid.opts.draggable,
96
+ ...{
97
+ // containment: (grid.parentGridNode && grid.opts.dragOut === false) ? grid.el.parentElement : (grid.opts.draggable.containment || null),
98
+ start: opts.start,
99
+ stop: opts.stop,
100
+ drag: opts.drag
101
+ }
102
+ });
103
+ }
104
+ });
105
+ return this;
106
+ }
107
+ dragIn(el, opts) {
108
+ this._getDDElements(el).forEach(dEl => dEl.setupDraggable(opts));
109
+ return this;
110
+ }
111
+ droppable(el, opts, key, value) {
112
+ if (typeof opts.accept === 'function' && !opts._accept) {
113
+ opts._accept = opts.accept;
114
+ opts.accept = (el) => opts._accept(el);
115
+ }
116
+ this._getDDElements(el, opts).forEach(dEl => {
117
+ if (opts === 'disable' || opts === 'enable') {
118
+ dEl.ddDroppable && dEl.ddDroppable[opts]();
119
+ }
120
+ else if (opts === 'destroy') {
121
+ dEl.ddDroppable && dEl.cleanDroppable();
122
+ }
123
+ else if (opts === 'option') {
124
+ dEl.setupDroppable({ [key]: value });
125
+ }
126
+ else {
127
+ dEl.setupDroppable(opts);
128
+ }
129
+ });
130
+ return this;
131
+ }
132
+ /** true if element is droppable */
133
+ isDroppable(el) {
134
+ return !!(el?.ddElement?.ddDroppable && !el.ddElement.ddDroppable.disabled);
135
+ }
136
+ /** true if element is draggable */
137
+ isDraggable(el) {
138
+ return !!(el?.ddElement?.ddDraggable && !el.ddElement.ddDraggable.disabled);
139
+ }
140
+ /** true if element is draggable */
141
+ isResizable(el) {
142
+ return !!(el?.ddElement?.ddResizable && !el.ddElement.ddResizable.disabled);
143
+ }
144
+ on(el, name, callback) {
145
+ this._getDDElements(el).forEach(dEl => dEl.on(name, (event) => {
146
+ callback(event, DDManager.dragElement ? DDManager.dragElement.el : event.target, DDManager.dragElement ? DDManager.dragElement.helper : null);
147
+ }));
148
+ return this;
149
+ }
150
+ off(el, name) {
151
+ this._getDDElements(el).forEach(dEl => dEl.off(name));
152
+ return this;
153
+ }
154
+ /** @internal returns a list of DD elements, creating them on the fly by default unless option is to destroy or disable */
155
+ _getDDElements(els, opts) {
156
+ // don't force create if we're going to destroy it, unless it's a grid which is used as drop target for it's children
157
+ const create = els.gridstack || opts !== 'destroy' && opts !== 'disable';
158
+ const hosts = Utils.getElements(els);
159
+ if (!hosts.length)
160
+ return [];
161
+ const list = hosts.map(e => e.ddElement || (create ? DDElement.init(e) : null)).filter(d => d); // remove nulls
162
+ return list;
163
+ }
164
+ }
165
+ //# sourceMappingURL=dd-gridstack.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dd-gridstack.js","sourceRoot":"","sources":["../../src/dd-gridstack.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,SAAS,EAAiB,MAAM,cAAc,CAAC;AAsCxD,yBAAyB;AAEzB;;;;;;GAMG;AACH,MAAM,OAAO,WAAW;IAEtB;;;;;;;;;;;;OAYG;IACI,SAAS,CAAC,EAAuB,EAAE,IAAY,EAAE,GAAW,EAAE,KAAe;QAClF,IAAI,CAAC,cAAc,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YAC1C,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,QAAQ,EAAE;gBAC3C,GAAG,CAAC,WAAW,IAAI,GAAG,CAAC,WAAW,CAAC,IAAI,CAA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AM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,eAAe;QAC/G,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["/**\r\n * dd-gridstack.ts 12.3.3\r\n * Copyright (c) 2021-2025 Alain Dumesny - see GridStack root license\r\n */\r\n\r\n/* eslint-disable @typescript-eslint/no-unused-vars */\r\nimport { GridItemHTMLElement, GridStackElement, DDDragOpt } from './types';\r\nimport { Utils } from './utils';\r\nimport { DDManager } from './dd-manager';\r\nimport { DDElement, DDElementHost } from './dd-element';\r\nimport { GridHTMLElement } from './gridstack';\r\n\r\n/**\r\n * Drag & Drop options for drop targets.\r\n * Configures which elements can be dropped onto a grid.\r\n */\r\nexport type DDDropOpt = {\r\n /** Function to determine if an element can be dropped (see GridStackOptions.acceptWidgets) */\r\n accept?: (el: GridItemHTMLElement) => boolean;\r\n}\r\n\r\n/**\r\n * Drag & Drop operation types used throughout the DD system.\r\n * Can be control commands or configuration objects.\r\n */\r\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\r\nexport type DDOpts = 'enable' | 'disable' | 'destroy' | 'option' | string | any;\r\n\r\n/**\r\n * Keys for DD configuration options that can be set via the 'option' command.\r\n */\r\nexport type DDKey = 'minWidth' | 'minHeight' | 'maxWidth' | 'maxHeight' | 'maxHeightMoveUp' | 'maxWidthMoveLeft';\r\n\r\n/**\r\n * Values for DD configuration options (numbers or strings with units).\r\n */\r\nexport type DDValue = number | string;\r\n\r\n/**\r\n * Callback function type for drag & drop events.\r\n *\r\n * @param event - The DOM event that triggered the callback\r\n * @param arg2 - The grid item element being dragged/dropped\r\n * @param helper - Optional helper element used during drag operations\r\n */\r\nexport type DDCallback = (event: Event, arg2: GridItemHTMLElement, helper?: GridItemHTMLElement) => void;\r\n\r\n// let count = 0; // TEST\r\n\r\n/**\r\n * HTML Native Mouse and Touch Events Drag and Drop functionality.\r\n *\r\n * This class provides the main drag & drop implementation for GridStack,\r\n * handling resizing, dragging, and dropping of grid items using native HTML5 events.\r\n * It manages the interaction between different DD components and the grid system.\r\n */\r\nexport class DDGridStack {\r\n\r\n /**\r\n * Enable/disable/configure resizing for grid elements.\r\n *\r\n * @param el - Grid item element(s) to configure\r\n * @param opts - Resize options or command ('enable', 'disable', 'destroy', 'option', or config object)\r\n * @param key - Option key when using 'option' command\r\n * @param value - Option value when using 'option' command\r\n * @returns this instance for chaining\r\n *\r\n * @example\r\n * dd.resizable(element, 'enable'); // Enable resizing\r\n * dd.resizable(element, 'option', 'minWidth', 100); // Set minimum width\r\n */\r\n public resizable(el: GridItemHTMLElement, opts: DDOpts, key?: DDKey, value?: DDValue): DDGridStack {\r\n this._getDDElements(el, opts).forEach(dEl => {\r\n if (opts === 'disable' || opts === 'enable') {\r\n dEl.ddResizable && dEl.ddResizable[opts](); // can't create DD as it requires options for setupResizable()\r\n } else if (opts === 'destroy') {\r\n dEl.ddResizable && dEl.cleanResizable();\r\n } else if (opts === 'option') {\r\n dEl.setupResizable({ [key]: value });\r\n } else {\r\n const n = dEl.el.gridstackNode;\r\n const grid = n.grid;\r\n let handles = dEl.el.getAttribute('gs-resize-handles') || grid.opts.resizable.handles || 'e,s,se';\r\n if (handles === 'all') handles = 'n,e,s,w,se,sw,ne,nw';\r\n // NOTE: keep the resize handles as e,w don't have enough space (10px) to show resize corners anyway. limit during drag instead\r\n // restrict vertical resize if height is done to match content anyway... odd to have it spring back\r\n // if (Utils.shouldSizeToContent(n, true)) {\r\n // const doE = handles.indexOf('e') !== -1;\r\n // const doW = handles.indexOf('w') !== -1;\r\n // handles = doE ? (doW ? 'e,w' : 'e') : (doW ? 'w' : '');\r\n // }\r\n const autoHide = !grid.opts.alwaysShowResizeHandle;\r\n dEl.setupResizable({\r\n ...grid.opts.resizable,\r\n ...{ handles, autoHide },\r\n ...{\r\n start: opts.start,\r\n stop: opts.stop,\r\n resize: opts.resize\r\n }\r\n });\r\n }\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Enable/disable/configure dragging for grid elements.\r\n *\r\n * @param el - Grid item element(s) to configure\r\n * @param opts - Drag options or command ('enable', 'disable', 'destroy', 'option', or config object)\r\n * @param key - Option key when using 'option' command\r\n * @param value - Option value when using 'option' command\r\n * @returns this instance for chaining\r\n *\r\n * @example\r\n * dd.draggable(element, 'enable'); // Enable dragging\r\n * dd.draggable(element, {handle: '.drag-handle'}); // Configure drag handle\r\n */\r\n public draggable(el: GridItemHTMLElement, opts: DDOpts, key?: DDKey, value?: DDValue): DDGridStack {\r\n this._getDDElements(el, opts).forEach(dEl => {\r\n if (opts === 'disable' || opts === 'enable') {\r\n dEl.ddDraggable && dEl.ddDraggable[opts](); // can't create DD as it requires options for setupDraggable()\r\n } else if (opts === 'destroy') {\r\n dEl.ddDraggable && dEl.cleanDraggable();\r\n } else if (opts === 'option') {\r\n dEl.setupDraggable({ [key]: value });\r\n } else {\r\n const grid = dEl.el.gridstackNode.grid;\r\n dEl.setupDraggable({\r\n ...grid.opts.draggable,\r\n ...{\r\n // containment: (grid.parentGridNode && grid.opts.dragOut === false) ? grid.el.parentElement : (grid.opts.draggable.containment || null),\r\n start: opts.start,\r\n stop: opts.stop,\r\n drag: opts.drag\r\n }\r\n });\r\n }\r\n });\r\n return this;\r\n }\r\n\r\n public dragIn(el: GridStackElement, opts: DDDragOpt): DDGridStack {\r\n this._getDDElements(el).forEach(dEl => dEl.setupDraggable(opts));\r\n return this;\r\n }\r\n\r\n public droppable(el: GridItemHTMLElement, opts: DDOpts | DDDropOpt, key?: DDKey, value?: DDValue): DDGridStack {\r\n if (typeof opts.accept === 'function' && !opts._accept) {\r\n opts._accept = opts.accept;\r\n opts.accept = (el) => opts._accept(el);\r\n }\r\n this._getDDElements(el, opts).forEach(dEl => {\r\n if (opts === 'disable' || opts === 'enable') {\r\n dEl.ddDroppable && dEl.ddDroppable[opts]();\r\n } else if (opts === 'destroy') {\r\n dEl.ddDroppable && dEl.cleanDroppable();\r\n } else if (opts === 'option') {\r\n dEl.setupDroppable({ [key]: value });\r\n } else {\r\n dEl.setupDroppable(opts);\r\n }\r\n });\r\n return this;\r\n }\r\n\r\n /** true if element is droppable */\r\n public isDroppable(el: DDElementHost): boolean {\r\n return !!(el?.ddElement?.ddDroppable && !el.ddElement.ddDroppable.disabled);\r\n }\r\n\r\n /** true if element is draggable */\r\n public isDraggable(el: DDElementHost): boolean {\r\n return !!(el?.ddElement?.ddDraggable && !el.ddElement.ddDraggable.disabled);\r\n }\r\n\r\n /** true if element is draggable */\r\n public isResizable(el: DDElementHost): boolean {\r\n return !!(el?.ddElement?.ddResizable && !el.ddElement.ddResizable.disabled);\r\n }\r\n\r\n public on(el: GridItemHTMLElement, name: string, callback: DDCallback): DDGridStack {\r\n this._getDDElements(el).forEach(dEl =>\r\n dEl.on(name, (event: Event) => {\r\n callback(\r\n event,\r\n DDManager.dragElement ? DDManager.dragElement.el : event.target as GridItemHTMLElement,\r\n DDManager.dragElement ? DDManager.dragElement.helper : null)\r\n })\r\n );\r\n return this;\r\n }\r\n\r\n public off(el: GridItemHTMLElement, name: string): DDGridStack {\r\n this._getDDElements(el).forEach(dEl => dEl.off(name));\r\n return this;\r\n }\r\n\r\n /** @internal returns a list of DD elements, creating them on the fly by default unless option is to destroy or disable */\r\n protected _getDDElements(els: GridStackElement, opts?: DDOpts): DDElement[] {\r\n // don't force create if we're going to destroy it, unless it's a grid which is used as drop target for it's children\r\n const create = (els as GridHTMLElement).gridstack || opts !== 'destroy' && opts !== 'disable';\r\n const hosts = Utils.getElements(els) as DDElementHost[];\r\n if (!hosts.length) return [];\r\n const list = hosts.map(e => e.ddElement || (create ? DDElement.init(e) : null)).filter(d => d); // remove nulls\r\n return list;\r\n }\r\n}\r\n"]}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * dd-manager.ts 12.3.3
3
+ * Copyright (c) 2021-2025 Alain Dumesny - see GridStack root license
4
+ */
5
+ import { DDDraggable } from './dd-draggable';
6
+ import { DDDroppable } from './dd-droppable';
7
+ import { DDResizable } from './dd-resizable';
8
+ /**
9
+ * Global state manager for all Drag & Drop instances.
10
+ *
11
+ * This class maintains shared state across all drag & drop operations,
12
+ * ensuring proper coordination between multiple grids and drag/drop elements.
13
+ * All properties are static to provide global access throughout the DD system.
14
+ */
15
+ export declare class DDManager {
16
+ /**
17
+ * Controls drag operation pausing behavior.
18
+ * If set to true or a number (milliseconds), dragging placement and collision
19
+ * detection will only happen after the user pauses movement.
20
+ * This improves performance during rapid mouse movements.
21
+ */
22
+ static pauseDrag: boolean | number;
23
+ /**
24
+ * Flag indicating if a mouse down event was already handled.
25
+ * Prevents multiple handlers from processing the same mouse event.
26
+ */
27
+ static mouseHandled: boolean;
28
+ /**
29
+ * Reference to the element currently being dragged.
30
+ * Used to track the active drag operation across the system.
31
+ */
32
+ static dragElement: DDDraggable;
33
+ /**
34
+ * Reference to the drop target element currently under the cursor.
35
+ * Used to handle drop operations and hover effects.
36
+ */
37
+ static dropElement: DDDroppable;
38
+ /**
39
+ * Reference to the element currently being resized.
40
+ * Helps ignore nested grid resize handles during resize operations.
41
+ */
42
+ static overResizeElement: DDResizable;
43
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * dd-manager.ts 12.3.3
3
+ * Copyright (c) 2021-2025 Alain Dumesny - see GridStack root license
4
+ */
5
+ /**
6
+ * Global state manager for all Drag & Drop instances.
7
+ *
8
+ * This class maintains shared state across all drag & drop operations,
9
+ * ensuring proper coordination between multiple grids and drag/drop elements.
10
+ * All properties are static to provide global access throughout the DD system.
11
+ */
12
+ export class DDManager {
13
+ }
14
+ //# sourceMappingURL=dd-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dd-manager.js","sourceRoot":"","sources":["../../src/dd-manager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH;;;;;;GAMG;AACH,MAAM,OAAO,SAAS;CAiCrB","sourcesContent":["/**\n * dd-manager.ts 12.3.3\n * Copyright (c) 2021-2025 Alain Dumesny - see GridStack root license\n */\n\nimport { DDDraggable } from './dd-draggable';\nimport { DDDroppable } from './dd-droppable';\nimport { DDResizable } from './dd-resizable';\n\n/**\n * Global state manager for all Drag & Drop instances.\n *\n * This class maintains shared state across all drag & drop operations,\n * ensuring proper coordination between multiple grids and drag/drop elements.\n * All properties are static to provide global access throughout the DD system.\n */\nexport class DDManager {\n /**\n * Controls drag operation pausing behavior.\n * If set to true or a number (milliseconds), dragging placement and collision\n * detection will only happen after the user pauses movement.\n * This improves performance during rapid mouse movements.\n */\n public static pauseDrag: boolean | number;\n\n /**\n * Flag indicating if a mouse down event was already handled.\n * Prevents multiple handlers from processing the same mouse event.\n */\n public static mouseHandled: boolean;\n\n /**\n * Reference to the element currently being dragged.\n * Used to track the active drag operation across the system.\n */\n public static dragElement: DDDraggable;\n\n /**\n * Reference to the drop target element currently under the cursor.\n * Used to handle drop operations and hover effects.\n */\n public static dropElement: DDDroppable;\n\n /**\n * Reference to the element currently being resized.\n * Helps ignore nested grid resize handles during resize operations.\n */\n public static overResizeElement: DDResizable;\n\n}\n"]}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * dd-resizable-handle.ts 12.3.3
3
+ * Copyright (c) 2021-2025 Alain Dumesny - see GridStack root license
4
+ */
5
+ import { GridItemHTMLElement } from './gridstack';
6
+ export interface DDResizableHandleOpt {
7
+ start?: (event: any) => void;
8
+ move?: (event: any) => void;
9
+ stop?: (event: any) => void;
10
+ }
11
+ export declare class DDResizableHandle {
12
+ protected host: GridItemHTMLElement;
13
+ protected dir: string;
14
+ protected option: DDResizableHandleOpt;
15
+ constructor(host: GridItemHTMLElement, dir: string, option: DDResizableHandleOpt);
16
+ /** call this when resize handle needs to be removed and cleaned up */
17
+ destroy(): DDResizableHandle;
18
+ }
@@ -0,0 +1,113 @@
1
+ /**
2
+ * dd-resizable-handle.ts 12.3.3
3
+ * Copyright (c) 2021-2025 Alain Dumesny - see GridStack root license
4
+ */
5
+ import { isTouch, pointerdown, touchend, touchmove, touchstart } from './dd-touch';
6
+ class DDResizableHandle {
7
+ constructor(host, dir, option) {
8
+ this.host = host;
9
+ this.dir = dir;
10
+ this.option = option;
11
+ /** @internal true after we've moved enough pixels to start a resize */
12
+ this.moving = false;
13
+ // create var event binding so we can easily remove and still look like TS methods (unlike anonymous functions)
14
+ this._mouseDown = this._mouseDown.bind(this);
15
+ this._mouseMove = this._mouseMove.bind(this);
16
+ this._mouseUp = this._mouseUp.bind(this);
17
+ this._keyEvent = this._keyEvent.bind(this);
18
+ this._init();
19
+ }
20
+ /** @internal */
21
+ _init() {
22
+ const el = this.el = document.createElement('div');
23
+ el.classList.add('ui-resizable-handle');
24
+ el.classList.add(`${DDResizableHandle.prefix}${this.dir}`);
25
+ el.style.zIndex = '100';
26
+ el.style.userSelect = 'none';
27
+ this.host.appendChild(this.el);
28
+ this.el.addEventListener('mousedown', this._mouseDown);
29
+ if (isTouch) {
30
+ this.el.addEventListener('touchstart', touchstart);
31
+ this.el.addEventListener('pointerdown', pointerdown);
32
+ // this.el.style.touchAction = 'none'; // not needed unlike pointerdown doc comment
33
+ }
34
+ return this;
35
+ }
36
+ /** call this when resize handle needs to be removed and cleaned up */
37
+ destroy() {
38
+ if (this.moving)
39
+ this._mouseUp(this.mouseDownEvent);
40
+ this.el.removeEventListener('mousedown', this._mouseDown);
41
+ if (isTouch) {
42
+ this.el.removeEventListener('touchstart', touchstart);
43
+ this.el.removeEventListener('pointerdown', pointerdown);
44
+ }
45
+ this.host.removeChild(this.el);
46
+ delete this.el;
47
+ delete this.host;
48
+ return this;
49
+ }
50
+ /** @internal called on mouse down on us: capture move on the entire document (mouse might not stay on us) until we release the mouse */
51
+ _mouseDown(e) {
52
+ this.mouseDownEvent = e;
53
+ document.addEventListener('mousemove', this._mouseMove, { capture: true, passive: true }); // capture, not bubble
54
+ document.addEventListener('mouseup', this._mouseUp, true);
55
+ if (isTouch) {
56
+ this.el.addEventListener('touchmove', touchmove);
57
+ this.el.addEventListener('touchend', touchend);
58
+ }
59
+ e.stopPropagation();
60
+ e.preventDefault();
61
+ }
62
+ /** @internal */
63
+ _mouseMove(e) {
64
+ const s = this.mouseDownEvent;
65
+ if (this.moving) {
66
+ this._triggerEvent('move', e);
67
+ }
68
+ else if (Math.abs(e.x - s.x) + Math.abs(e.y - s.y) > 2) {
69
+ // don't start unless we've moved at least 3 pixels
70
+ this.moving = true;
71
+ this._triggerEvent('start', this.mouseDownEvent);
72
+ this._triggerEvent('move', e);
73
+ // now track keyboard events to cancel
74
+ document.addEventListener('keydown', this._keyEvent);
75
+ }
76
+ e.stopPropagation();
77
+ // e.preventDefault(); passive = true
78
+ }
79
+ /** @internal */
80
+ _mouseUp(e) {
81
+ if (this.moving) {
82
+ this._triggerEvent('stop', e);
83
+ document.removeEventListener('keydown', this._keyEvent);
84
+ }
85
+ document.removeEventListener('mousemove', this._mouseMove, true);
86
+ document.removeEventListener('mouseup', this._mouseUp, true);
87
+ if (isTouch) {
88
+ this.el.removeEventListener('touchmove', touchmove);
89
+ this.el.removeEventListener('touchend', touchend);
90
+ }
91
+ delete this.moving;
92
+ delete this.mouseDownEvent;
93
+ e.stopPropagation();
94
+ e.preventDefault();
95
+ }
96
+ /** @internal call when keys are being pressed - use Esc to cancel */
97
+ _keyEvent(e) {
98
+ if (e.key === 'Escape') {
99
+ this.host.gridstackNode?.grid?.engine.restoreInitial();
100
+ this._mouseUp(this.mouseDownEvent);
101
+ }
102
+ }
103
+ /** @internal */
104
+ _triggerEvent(name, event) {
105
+ if (this.option[name])
106
+ this.option[name](event);
107
+ return this;
108
+ }
109
+ }
110
+ /** @internal */
111
+ DDResizableHandle.prefix = 'ui-resizable-';
112
+ export { DDResizableHandle };
113
+ //# sourceMappingURL=dd-resizable-handle.js.map