gridstack 12.3.3 → 12.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) 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 +4 -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 +6 -4
  7. package/dist/angular/fesm2015/gridstack-angular.mjs.map +1 -1
  8. package/dist/angular/fesm2020/gridstack-angular.mjs +7 -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 +4 -4
  12. package/dist/angular/lib/types.d.ts +1 -1
  13. package/dist/angular/package.json +1 -1
  14. package/dist/angular/projects/lib/src/index.d.ts +5 -0
  15. package/dist/angular/projects/lib/src/index.js +9 -0
  16. package/dist/angular/projects/lib/src/index.js.map +1 -0
  17. package/dist/angular/projects/lib/src/lib/base-widget.d.ts +56 -0
  18. package/dist/angular/projects/lib/src/lib/base-widget.js +94 -0
  19. package/dist/angular/projects/lib/src/lib/base-widget.js.map +1 -0
  20. package/dist/angular/projects/lib/src/lib/gridstack-item.component.d.ts +76 -0
  21. package/dist/angular/projects/lib/src/lib/gridstack-item.component.js +112 -0
  22. package/dist/angular/projects/lib/src/lib/gridstack-item.component.js.map +1 -0
  23. package/dist/angular/projects/lib/src/lib/gridstack.component.d.ts +233 -0
  24. package/dist/angular/projects/lib/src/lib/gridstack.component.js +457 -0
  25. package/dist/angular/projects/lib/src/lib/gridstack.component.js.map +1 -0
  26. package/dist/angular/projects/lib/src/lib/gridstack.module.d.ts +29 -0
  27. package/dist/angular/projects/lib/src/lib/gridstack.module.js +52 -0
  28. package/dist/angular/projects/lib/src/lib/gridstack.module.js.map +1 -0
  29. package/dist/angular/projects/lib/src/lib/types.d.ts +51 -0
  30. package/dist/angular/projects/lib/src/lib/types.js +6 -0
  31. package/dist/angular/projects/lib/src/lib/types.js.map +1 -0
  32. package/dist/angular/src/base-widget.ts +13 -13
  33. package/dist/angular/src/gridstack-item.component.ts +5 -5
  34. package/dist/angular/src/gridstack.component.ts +34 -32
  35. package/dist/angular/src/gridstack.module.ts +4 -4
  36. package/dist/angular/src/types.ts +3 -2
  37. package/dist/gridstack-all.js +1 -1
  38. package/dist/gridstack-all.js.LICENSE.txt +1 -1
  39. package/dist/gridstack-all.js.map +1 -1
  40. package/dist/gridstack.css +1 -1
  41. package/dist/src/dd-base-impl.d.ts +1 -1
  42. package/dist/src/dd-base-impl.js +1 -1
  43. package/dist/src/dd-base-impl.js.map +1 -1
  44. package/dist/src/dd-draggable.d.ts +1 -1
  45. package/dist/src/dd-draggable.js +1 -1
  46. package/dist/src/dd-draggable.js.map +1 -1
  47. package/dist/src/dd-droppable.d.ts +1 -1
  48. package/dist/src/dd-droppable.js +7 -1
  49. package/dist/src/dd-droppable.js.map +1 -1
  50. package/dist/src/dd-element.d.ts +1 -1
  51. package/dist/src/dd-element.js +1 -1
  52. package/dist/src/dd-element.js.map +1 -1
  53. package/dist/src/dd-gridstack.d.ts +1 -1
  54. package/dist/src/dd-gridstack.js +1 -1
  55. package/dist/src/dd-gridstack.js.map +1 -1
  56. package/dist/src/dd-manager.d.ts +1 -1
  57. package/dist/src/dd-manager.js +1 -1
  58. package/dist/src/dd-manager.js.map +1 -1
  59. package/dist/src/dd-resizable-handle.d.ts +5 -4
  60. package/dist/src/dd-resizable-handle.js +23 -8
  61. package/dist/src/dd-resizable-handle.js.map +1 -1
  62. package/dist/src/dd-resizable.d.ts +3 -5
  63. package/dist/src/dd-resizable.js +5 -10
  64. package/dist/src/dd-resizable.js.map +1 -1
  65. package/dist/src/dd-touch.d.ts +1 -1
  66. package/dist/src/dd-touch.js +1 -1
  67. package/dist/src/dd-touch.js.map +1 -1
  68. package/dist/src/gridstack-engine.d.ts +1 -1
  69. package/dist/src/gridstack-engine.js +7 -1
  70. package/dist/src/gridstack-engine.js.map +1 -1
  71. package/dist/src/gridstack.d.ts +1 -2
  72. package/dist/src/gridstack.js +9 -18
  73. package/dist/src/gridstack.js.map +1 -1
  74. package/dist/src/gridstack.scss +1 -1
  75. package/dist/src/types.d.ts +11 -6
  76. package/dist/src/types.js +1 -1
  77. package/dist/src/types.js.map +1 -1
  78. package/dist/src/utils.d.ts +1 -270
  79. package/dist/src/utils.js +37 -31
  80. package/dist/src/utils.js.map +1 -1
  81. package/doc/API.md +166 -165
  82. package/package.json +5 -5
  83. package/dist/dd-base-impl.d.ts +0 -69
  84. package/dist/dd-base-impl.js +0 -70
  85. package/dist/dd-base-impl.js.map +0 -1
  86. package/dist/dd-draggable.d.ts +0 -20
  87. package/dist/dd-draggable.js +0 -364
  88. package/dist/dd-draggable.js.map +0 -1
  89. package/dist/dd-droppable.d.ts +0 -26
  90. package/dist/dd-droppable.js +0 -149
  91. package/dist/dd-droppable.js.map +0 -1
  92. package/dist/dd-element.d.ts +0 -27
  93. package/dist/dd-element.js +0 -91
  94. package/dist/dd-element.js.map +0 -1
  95. package/dist/dd-gridstack.d.ts +0 -82
  96. package/dist/dd-gridstack.js +0 -165
  97. package/dist/dd-gridstack.js.map +0 -1
  98. package/dist/dd-manager.d.ts +0 -43
  99. package/dist/dd-manager.js +0 -14
  100. package/dist/dd-manager.js.map +0 -1
  101. package/dist/dd-resizable-handle.d.ts +0 -18
  102. package/dist/dd-resizable-handle.js +0 -113
  103. package/dist/dd-resizable-handle.js.map +0 -1
  104. package/dist/dd-resizable.d.ts +0 -30
  105. package/dist/dd-resizable.js +0 -304
  106. package/dist/dd-resizable.js.map +0 -1
  107. package/dist/dd-touch.d.ts +0 -33
  108. package/dist/dd-touch.js +0 -145
  109. package/dist/dd-touch.js.map +0 -1
  110. package/dist/gridstack-engine.d.ts +0 -321
  111. package/dist/gridstack-engine.js +0 -1272
  112. package/dist/gridstack-engine.js.map +0 -1
  113. package/dist/gridstack.d.ts +0 -802
  114. package/dist/gridstack.js +0 -2872
  115. package/dist/gridstack.js.map +0 -1
  116. package/dist/spec/gridstack-engine-spec.d.ts +0 -1
  117. package/dist/spec/gridstack-engine-spec.js +0 -358
  118. package/dist/spec/gridstack-engine-spec.js.map +0 -1
  119. package/dist/spec/gridstack-spec.d.ts +0 -1
  120. package/dist/spec/gridstack-spec.js +0 -1780
  121. package/dist/spec/gridstack-spec.js.map +0 -1
  122. package/dist/spec/integration/gridstack-integration.spec.d.ts +0 -1
  123. package/dist/spec/integration/gridstack-integration.spec.js +0 -171
  124. package/dist/spec/integration/gridstack-integration.spec.js.map +0 -1
  125. package/dist/spec/regression-spec.d.ts +0 -1
  126. package/dist/spec/regression-spec.js +0 -100
  127. package/dist/spec/regression-spec.js.map +0 -1
  128. package/dist/spec/utils-spec.d.ts +0 -1
  129. package/dist/spec/utils-spec.js +0 -243
  130. package/dist/spec/utils-spec.js.map +0 -1
  131. package/dist/types.d.ts +0 -427
  132. package/dist/types.js +0 -38
  133. package/dist/types.js.map +0 -1
  134. package/dist/utils.d.ts +0 -283
  135. package/dist/utils.js +0 -787
  136. package/dist/utils.js.map +0 -1
  137. package/dist/vitest.config.d.ts +0 -2
  138. package/dist/vitest.config.js +0 -74
  139. package/dist/vitest.config.js.map +0 -1
  140. package/dist/vitest.setup.d.ts +0 -1
  141. package/dist/vitest.setup.js +0 -90
  142. package/dist/vitest.setup.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gridstack",
3
- "version": "12.3.3",
3
+ "version": "12.4.0",
4
4
  "license": "MIT",
5
5
  "author": "Alain Dumesny <alaind831+github@gmail.com> (https://github.com/adumesny)",
6
6
  "contributors": [
@@ -25,10 +25,10 @@
25
25
  }
26
26
  ],
27
27
  "scripts": {
28
- "build": "yarn --no-progress && yarn build:ng && grunt && webpack && tsc --stripInternal && yarn doc",
28
+ "build": "yarn build:ng && grunt && webpack && tsc --project tsconfig.build.json --stripInternal && yarn doc",
29
29
  "build:ng": "cd angular && yarn --no-progress && yarn build lib",
30
30
  "w": "webpack",
31
- "t": "rm -rf dist/* && grunt && tsc --stripInternal",
31
+ "t": "rm -rf dist/* && grunt && tsc --project tsconfig.build.json --stripInternal",
32
32
  "doc": "doctoc ./README.md && doctoc ./doc/CHANGES.md && node scripts/generate-docs.js",
33
33
  "doc:main": "node scripts/generate-docs.js --main-only",
34
34
  "doc:angular": "node scripts/generate-docs.js --angular-only",
@@ -44,7 +44,7 @@
44
44
  "test:e2e": "playwright test",
45
45
  "test:e2e:ui": "playwright test --ui",
46
46
  "test:e2e:headed": "playwright test --headed",
47
- "lint": "tsc --noEmit && eslint src/*.ts",
47
+ "lint": "tsc --project tsconfig.build.json --noEmit && eslint src/*.ts angular/projects/lib/src/**/*.ts",
48
48
  "reset": "rm -rf dist node_modules",
49
49
  "prepublishOnly": "yarn build"
50
50
  },
@@ -93,7 +93,7 @@
93
93
  "grunt-protractor-runner": "^5.0.0",
94
94
  "grunt-protractor-webdriver": "^0.2.5",
95
95
  "grunt-sass": "3.1.0",
96
- "happy-dom": "^15.7.4",
96
+ "happy-dom": "^20.0.0",
97
97
  "jsdom": "^25.0.0",
98
98
  "protractor": "^7.0.0",
99
99
  "sass": "^1.62.0",
@@ -1,69 +0,0 @@
1
- /**
2
- * dd-base-impl.ts 12.3.2
3
- * Copyright (c) 2021-2025 Alain Dumesny - see GridStack root license
4
- */
5
- /**
6
- * Type for event callback functions used in drag & drop operations.
7
- * Can return boolean to indicate if the event should continue propagation.
8
- */
9
- export type EventCallback = (event: Event) => boolean | void;
10
- /**
11
- * Abstract base class for all drag & drop implementations.
12
- * Provides common functionality for event handling, enable/disable state,
13
- * and lifecycle management used by draggable, droppable, and resizable implementations.
14
- */
15
- export declare abstract class DDBaseImplement {
16
- /**
17
- * Returns the current disabled state.
18
- * Note: Use enable()/disable() methods to change state as other operations need to happen.
19
- */
20
- get disabled(): boolean;
21
- /**
22
- * Register an event callback for the specified event.
23
- *
24
- * @param event - Event name to listen for
25
- * @param callback - Function to call when event occurs
26
- */
27
- on(event: string, callback: EventCallback): void;
28
- /**
29
- * Unregister an event callback for the specified event.
30
- *
31
- * @param event - Event name to stop listening for
32
- */
33
- off(event: string): void;
34
- /**
35
- * Enable this drag & drop implementation.
36
- * Subclasses should override to perform additional setup.
37
- */
38
- enable(): void;
39
- /**
40
- * Disable this drag & drop implementation.
41
- * Subclasses should override to perform additional cleanup.
42
- */
43
- disable(): void;
44
- /**
45
- * Destroy this drag & drop implementation and clean up resources.
46
- * Removes all event handlers and clears internal state.
47
- */
48
- destroy(): void;
49
- /**
50
- * Trigger a registered event callback if one exists and the implementation is enabled.
51
- *
52
- * @param eventName - Name of the event to trigger
53
- * @param event - DOM event object to pass to the callback
54
- * @returns Result from the callback function, if any
55
- */
56
- triggerEvent(eventName: string, event: Event): boolean | void;
57
- }
58
- /**
59
- * Interface for HTML elements extended with drag & drop options.
60
- * Used to associate DD configuration with DOM elements.
61
- */
62
- export interface HTMLElementExtendOpt<T> {
63
- /** The HTML element being extended */
64
- el: HTMLElement;
65
- /** The drag & drop options/configuration */
66
- option: T;
67
- /** Method to update the options and return the DD implementation */
68
- updateOption(T: any): DDBaseImplement;
69
- }
@@ -1,70 +0,0 @@
1
- /**
2
- * dd-base-impl.ts 12.3.2
3
- * Copyright (c) 2021-2025 Alain Dumesny - see GridStack root license
4
- */
5
- /**
6
- * Abstract base class for all drag & drop implementations.
7
- * Provides common functionality for event handling, enable/disable state,
8
- * and lifecycle management used by draggable, droppable, and resizable implementations.
9
- */
10
- export class DDBaseImplement {
11
- constructor() {
12
- /** @internal */
13
- this._eventRegister = {};
14
- }
15
- /**
16
- * Returns the current disabled state.
17
- * Note: Use enable()/disable() methods to change state as other operations need to happen.
18
- */
19
- get disabled() { return this._disabled; }
20
- /**
21
- * Register an event callback for the specified event.
22
- *
23
- * @param event - Event name to listen for
24
- * @param callback - Function to call when event occurs
25
- */
26
- on(event, callback) {
27
- this._eventRegister[event] = callback;
28
- }
29
- /**
30
- * Unregister an event callback for the specified event.
31
- *
32
- * @param event - Event name to stop listening for
33
- */
34
- off(event) {
35
- delete this._eventRegister[event];
36
- }
37
- /**
38
- * Enable this drag & drop implementation.
39
- * Subclasses should override to perform additional setup.
40
- */
41
- enable() {
42
- this._disabled = false;
43
- }
44
- /**
45
- * Disable this drag & drop implementation.
46
- * Subclasses should override to perform additional cleanup.
47
- */
48
- disable() {
49
- this._disabled = true;
50
- }
51
- /**
52
- * Destroy this drag & drop implementation and clean up resources.
53
- * Removes all event handlers and clears internal state.
54
- */
55
- destroy() {
56
- delete this._eventRegister;
57
- }
58
- /**
59
- * Trigger a registered event callback if one exists and the implementation is enabled.
60
- *
61
- * @param eventName - Name of the event to trigger
62
- * @param event - DOM event object to pass to the callback
63
- * @returns Result from the callback function, if any
64
- */
65
- triggerEvent(eventName, event) {
66
- if (!this.disabled && this._eventRegister && this._eventRegister[eventName])
67
- return this._eventRegister[eventName](event);
68
- }
69
- }
70
- //# sourceMappingURL=dd-base-impl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dd-base-impl.js","sourceRoot":"","sources":["../src/dd-base-impl.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH;;;;GAIG;AACH,MAAM,OAAgB,eAAe;IAArC;QASE,gBAAgB;QACN,mBAAc,GAEpB,EAAE,CAAC;IAwDT,CAAC;IAnEC;;;OAGG;IACH,IAAW,QAAQ,KAAgB,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IAS3D;;;;;OAKG;IACI,EAAE,CAAC,KAAa,EAAE,QAAuB;QAC9C,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAC;IACxC,CAAC;IAED;;;;OAIG;IACI,GAAG,CAAC,KAAa;QACtB,OAAO,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;IAED;;;OAGG;IACI,MAAM;QACX,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;IACzB,CAAC;IAED;;;OAGG;IACI,OAAO;QACZ,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;IAED;;;OAGG;IACI,OAAO;QACZ,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAED;;;;;;OAMG;IACI,YAAY,CAAC,SAAiB,EAAE,KAAY;QACjD,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC;YACzE,OAAO,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC;IACjD,CAAC;CACF","sourcesContent":["/**\n * dd-base-impl.ts 12.3.2\n * Copyright (c) 2021-2025 Alain Dumesny - see GridStack root license\n */\n\n/**\n * Type for event callback functions used in drag & drop operations.\n * Can return boolean to indicate if the event should continue propagation.\n */\nexport type EventCallback = (event: Event) => boolean|void;\n\n/**\n * Abstract base class for all drag & drop implementations.\n * Provides common functionality for event handling, enable/disable state,\n * and lifecycle management used by draggable, droppable, and resizable implementations.\n */\nexport abstract class DDBaseImplement {\n /**\n * Returns the current disabled state.\n * Note: Use enable()/disable() methods to change state as other operations need to happen.\n */\n public get disabled(): boolean { return this._disabled; }\n\n /** @internal */\n protected _disabled: boolean; // initial state to differentiate from false\n /** @internal */\n protected _eventRegister: {\n [eventName: string]: EventCallback;\n } = {};\n\n /**\n * Register an event callback for the specified event.\n * \n * @param event - Event name to listen for\n * @param callback - Function to call when event occurs\n */\n public on(event: string, callback: EventCallback): void {\n this._eventRegister[event] = callback;\n }\n\n /**\n * Unregister an event callback for the specified event.\n * \n * @param event - Event name to stop listening for\n */\n public off(event: string): void {\n delete this._eventRegister[event];\n }\n\n /**\n * Enable this drag & drop implementation.\n * Subclasses should override to perform additional setup.\n */\n public enable(): void {\n this._disabled = false;\n }\n\n /**\n * Disable this drag & drop implementation.\n * Subclasses should override to perform additional cleanup.\n */\n public disable(): void {\n this._disabled = true;\n }\n\n /**\n * Destroy this drag & drop implementation and clean up resources.\n * Removes all event handlers and clears internal state.\n */\n public destroy(): void {\n delete this._eventRegister;\n }\n\n /**\n * Trigger a registered event callback if one exists and the implementation is enabled.\n * \n * @param eventName - Name of the event to trigger\n * @param event - DOM event object to pass to the callback\n * @returns Result from the callback function, if any\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\n/**\n * Interface for HTML elements extended with drag & drop options.\n * Used to associate DD configuration with DOM elements.\n */\nexport interface HTMLElementExtendOpt<T> {\n /** The HTML element being extended */\n el: HTMLElement;\n /** The drag & drop options/configuration */\n option: T;\n /** Method to update the options and return the DD implementation */\n updateOption(T): DDBaseImplement;\n}\n"]}
@@ -1,20 +0,0 @@
1
- /**
2
- * dd-draggable.ts 12.3.2
3
- * Copyright (c) 2021-2025 Alain Dumesny - see GridStack root license
4
- */
5
- import { DDBaseImplement, HTMLElementExtendOpt } from './dd-base-impl';
6
- import { GridItemHTMLElement, DDDragOpt } from './types';
7
- type DDDragEvent = 'drag' | 'dragstart' | 'dragstop';
8
- export declare class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt<DDDragOpt> {
9
- el: GridItemHTMLElement;
10
- option: DDDragOpt;
11
- helper: HTMLElement;
12
- constructor(el: GridItemHTMLElement, option?: DDDragOpt);
13
- on(event: DDDragEvent, callback: (event: DragEvent) => void): void;
14
- off(event: DDDragEvent): void;
15
- enable(): void;
16
- disable(forDestroy?: boolean): void;
17
- destroy(): void;
18
- updateOption(opts: DDDragOpt): DDDraggable;
19
- }
20
- export {};
@@ -1,364 +0,0 @@
1
- /**
2
- * dd-draggable.ts 12.3.2
3
- * Copyright (c) 2021-2025 Alain Dumesny - see GridStack root license
4
- */
5
- import { DDManager } from './dd-manager';
6
- import { Utils } from './utils';
7
- import { DDBaseImplement } from './dd-base-impl';
8
- import { isTouch, touchend, touchmove, touchstart, pointerdown } from './dd-touch';
9
- // make sure we are not clicking on known object that handles mouseDown
10
- const skipMouseDown = 'input,textarea,button,select,option,[contenteditable="true"],.ui-resizable-handle';
11
- // let count = 0; // TEST
12
- class DDDraggable extends DDBaseImplement {
13
- constructor(el, option = {}) {
14
- super();
15
- this.el = el;
16
- this.option = option;
17
- /** @internal */
18
- this.dragTransform = {
19
- xScale: 1,
20
- yScale: 1,
21
- xOffset: 0,
22
- yOffset: 0
23
- };
24
- // get the element that is actually supposed to be dragged by
25
- const handleName = option?.handle?.substring(1);
26
- const n = el.gridstackNode;
27
- this.dragEls = !handleName || el.classList.contains(handleName) ? [el] : (n?.subGrid ? [el.querySelector(option.handle) || el] : Array.from(el.querySelectorAll(option.handle)));
28
- if (this.dragEls.length === 0) {
29
- this.dragEls = [el];
30
- }
31
- // create var event binding so we can easily remove and still look like TS methods (unlike anonymous functions)
32
- this._mouseDown = this._mouseDown.bind(this);
33
- this._mouseMove = this._mouseMove.bind(this);
34
- this._mouseUp = this._mouseUp.bind(this);
35
- this._keyEvent = this._keyEvent.bind(this);
36
- this.enable();
37
- }
38
- on(event, callback) {
39
- super.on(event, callback);
40
- }
41
- off(event) {
42
- super.off(event);
43
- }
44
- enable() {
45
- if (this.disabled === false)
46
- return;
47
- super.enable();
48
- this.dragEls.forEach(dragEl => {
49
- dragEl.addEventListener('mousedown', this._mouseDown);
50
- if (isTouch) {
51
- dragEl.addEventListener('touchstart', touchstart);
52
- dragEl.addEventListener('pointerdown', pointerdown);
53
- // dragEl.style.touchAction = 'none'; // not needed unlike pointerdown doc comment
54
- }
55
- });
56
- this.el.classList.remove('ui-draggable-disabled');
57
- }
58
- disable(forDestroy = false) {
59
- if (this.disabled === true)
60
- return;
61
- super.disable();
62
- this.dragEls.forEach(dragEl => {
63
- dragEl.removeEventListener('mousedown', this._mouseDown);
64
- if (isTouch) {
65
- dragEl.removeEventListener('touchstart', touchstart);
66
- dragEl.removeEventListener('pointerdown', pointerdown);
67
- }
68
- });
69
- if (!forDestroy)
70
- this.el.classList.add('ui-draggable-disabled');
71
- }
72
- destroy() {
73
- if (this.dragTimeout)
74
- window.clearTimeout(this.dragTimeout);
75
- delete this.dragTimeout;
76
- if (this.mouseDownEvent)
77
- this._mouseUp(this.mouseDownEvent);
78
- this.disable(true);
79
- delete this.el;
80
- delete this.helper;
81
- delete this.option;
82
- super.destroy();
83
- }
84
- updateOption(opts) {
85
- Object.keys(opts).forEach(key => this.option[key] = opts[key]);
86
- return this;
87
- }
88
- /** @internal call when mouse goes down before a dragstart happens */
89
- _mouseDown(e) {
90
- // don't let more than one widget handle mouseStart
91
- if (DDManager.mouseHandled)
92
- return;
93
- if (e.button !== 0)
94
- return true; // only left click
95
- // make sure we are not clicking on known object that handles mouseDown, or ones supplied by the user
96
- if (!this.dragEls.find(el => el === e.target) && e.target.closest(skipMouseDown))
97
- return true;
98
- if (this.option.cancel) {
99
- if (e.target.closest(this.option.cancel))
100
- return true;
101
- }
102
- this.mouseDownEvent = e;
103
- delete this.dragging;
104
- delete DDManager.dragElement;
105
- delete DDManager.dropElement;
106
- // document handler so we can continue receiving moves as the item is 'fixed' position, and capture=true so WE get a first crack
107
- document.addEventListener('mousemove', this._mouseMove, { capture: true, passive: true }); // true=capture, not bubble
108
- document.addEventListener('mouseup', this._mouseUp, true);
109
- if (isTouch) {
110
- e.currentTarget.addEventListener('touchmove', touchmove);
111
- e.currentTarget.addEventListener('touchend', touchend);
112
- }
113
- e.preventDefault();
114
- // preventDefault() prevents blur event which occurs just after mousedown event.
115
- // if an editable content has focus, then blur must be call
116
- if (document.activeElement)
117
- document.activeElement.blur();
118
- DDManager.mouseHandled = true;
119
- return true;
120
- }
121
- /** @internal method to call actual drag event */
122
- _callDrag(e) {
123
- if (!this.dragging)
124
- return;
125
- const ev = Utils.initEvent(e, { target: this.el, type: 'drag' });
126
- if (this.option.drag) {
127
- this.option.drag(ev, this.ui());
128
- }
129
- this.triggerEvent('drag', ev);
130
- }
131
- /** @internal called when the main page (after successful mousedown) receives a move event to drag the item around the screen */
132
- _mouseMove(e) {
133
- // console.log(`${count++} move ${e.x},${e.y}`)
134
- const s = this.mouseDownEvent;
135
- this.lastDrag = e;
136
- if (this.dragging) {
137
- this._dragFollow(e);
138
- // delay actual grid handling drag until we pause for a while if set
139
- if (DDManager.pauseDrag) {
140
- const pause = Number.isInteger(DDManager.pauseDrag) ? DDManager.pauseDrag : 100;
141
- if (this.dragTimeout)
142
- window.clearTimeout(this.dragTimeout);
143
- this.dragTimeout = window.setTimeout(() => this._callDrag(e), pause);
144
- }
145
- else {
146
- this._callDrag(e);
147
- }
148
- }
149
- else if (Math.abs(e.x - s.x) + Math.abs(e.y - s.y) > 3) {
150
- /**
151
- * don't start unless we've moved at least 3 pixels
152
- */
153
- this.dragging = true;
154
- DDManager.dragElement = this;
155
- // if we're dragging an actual grid item, set the current drop as the grid (to detect enter/leave)
156
- const grid = this.el.gridstackNode?.grid;
157
- if (grid) {
158
- DDManager.dropElement = grid.el.ddElement.ddDroppable;
159
- }
160
- else {
161
- delete DDManager.dropElement;
162
- }
163
- this.helper = this._createHelper();
164
- this._setupHelperContainmentStyle();
165
- this.dragTransform = Utils.getValuesFromTransformedElement(this.helperContainment);
166
- this.dragOffset = this._getDragOffset(e, this.el, this.helperContainment);
167
- this._setupHelperStyle(e);
168
- const ev = Utils.initEvent(e, { target: this.el, type: 'dragstart' });
169
- if (this.option.start) {
170
- this.option.start(ev, this.ui());
171
- }
172
- this.triggerEvent('dragstart', ev);
173
- // now track keyboard events to cancel or rotate
174
- document.addEventListener('keydown', this._keyEvent);
175
- }
176
- // e.preventDefault(); // passive = true. OLD: was needed otherwise we get text sweep text selection as we drag around
177
- return true;
178
- }
179
- /** @internal call when the mouse gets released to drop the item at current location */
180
- _mouseUp(e) {
181
- document.removeEventListener('mousemove', this._mouseMove, true);
182
- document.removeEventListener('mouseup', this._mouseUp, true);
183
- if (isTouch && e.currentTarget) { // destroy() during nested grid call us again wit fake _mouseUp
184
- e.currentTarget.removeEventListener('touchmove', touchmove, true);
185
- e.currentTarget.removeEventListener('touchend', touchend, true);
186
- }
187
- if (this.dragging) {
188
- delete this.dragging;
189
- delete this.el.gridstackNode?._origRotate;
190
- document.removeEventListener('keydown', this._keyEvent);
191
- // reset the drop target if dragging over ourself (already parented, just moving during stop callback below)
192
- if (DDManager.dropElement?.el === this.el.parentElement) {
193
- delete DDManager.dropElement;
194
- }
195
- this.helperContainment.style.position = this.parentOriginStylePosition || null;
196
- if (this.helper !== this.el)
197
- this.helper.remove(); // hide now
198
- this._removeHelperStyle();
199
- const ev = Utils.initEvent(e, { target: this.el, type: 'dragstop' });
200
- if (this.option.stop) {
201
- this.option.stop(ev); // NOTE: destroy() will be called when removing item, so expect NULL ptr after!
202
- }
203
- this.triggerEvent('dragstop', ev);
204
- // call the droppable method to receive the item
205
- if (DDManager.dropElement) {
206
- DDManager.dropElement.drop(e);
207
- }
208
- }
209
- delete this.helper;
210
- delete this.mouseDownEvent;
211
- delete DDManager.dragElement;
212
- delete DDManager.dropElement;
213
- delete DDManager.mouseHandled;
214
- e.preventDefault();
215
- }
216
- /** @internal call when keys are being pressed - use Esc to cancel, R to rotate */
217
- _keyEvent(e) {
218
- const n = this.el.gridstackNode;
219
- const grid = n?.grid || DDManager.dropElement?.el?.gridstack;
220
- if (e.key === 'Escape') {
221
- if (n && n._origRotate) {
222
- n._orig = n._origRotate;
223
- delete n._origRotate;
224
- }
225
- grid?.cancelDrag();
226
- this._mouseUp(this.mouseDownEvent);
227
- }
228
- else if (n && grid && (e.key === 'r' || e.key === 'R')) {
229
- if (!Utils.canBeRotated(n))
230
- return;
231
- n._origRotate = n._origRotate || { ...n._orig }; // store the real orig size in case we Esc after doing rotation
232
- delete n._moving; // force rotate to happen (move waits for >50% coverage otherwise)
233
- grid.setAnimation(false) // immediate rotate so _getDragOffset() gets the right dom size below
234
- .rotate(n.el, { top: -this.dragOffset.offsetTop, left: -this.dragOffset.offsetLeft })
235
- .setAnimation();
236
- n._moving = true;
237
- this.dragOffset = this._getDragOffset(this.lastDrag, n.el, this.helperContainment);
238
- this.helper.style.width = this.dragOffset.width + 'px';
239
- this.helper.style.height = this.dragOffset.height + 'px';
240
- Utils.swap(n._orig, 'w', 'h');
241
- delete n._rect;
242
- this._mouseMove(this.lastDrag);
243
- }
244
- }
245
- /** @internal create a clone copy (or user defined method) of the original drag item if set */
246
- _createHelper() {
247
- let helper = this.el;
248
- if (typeof this.option.helper === 'function') {
249
- helper = this.option.helper(this.el);
250
- }
251
- else if (this.option.helper === 'clone') {
252
- helper = Utils.cloneNode(this.el);
253
- }
254
- if (!helper.parentElement) {
255
- Utils.appendTo(helper, this.option.appendTo === 'parent' ? this.el.parentElement : this.option.appendTo);
256
- }
257
- this.dragElementOriginStyle = DDDraggable.originStyleProp.map(prop => this.el.style[prop]);
258
- return helper;
259
- }
260
- /** @internal set the fix position of the dragged item */
261
- _setupHelperStyle(e) {
262
- this.helper.classList.add('ui-draggable-dragging');
263
- this.el.gridstackNode?.grid?.el.classList.add('grid-stack-dragging');
264
- // TODO: set all at once with style.cssText += ... ? https://stackoverflow.com/questions/3968593
265
- const style = this.helper.style;
266
- style.pointerEvents = 'none'; // needed for over items to get enter/leave
267
- // style.cursor = 'move'; // TODO: can't set with pointerEvents=none ! (no longer in CSS either as no-op)
268
- style.width = this.dragOffset.width + 'px';
269
- style.height = this.dragOffset.height + 'px';
270
- style.willChange = 'left, top';
271
- style.position = 'fixed'; // let us drag between grids by not clipping as parent .grid-stack is position: 'relative'
272
- this._dragFollow(e); // now position it
273
- style.transition = 'none'; // show up instantly
274
- setTimeout(() => {
275
- if (this.helper) {
276
- style.transition = null; // recover animation
277
- }
278
- }, 0);
279
- return this;
280
- }
281
- /** @internal restore back the original style before dragging */
282
- _removeHelperStyle() {
283
- this.helper.classList.remove('ui-draggable-dragging');
284
- this.el.gridstackNode?.grid?.el.classList.remove('grid-stack-dragging');
285
- const node = this.helper?.gridstackNode;
286
- // don't bother restoring styles if we're gonna remove anyway...
287
- if (!node?._isAboutToRemove && this.dragElementOriginStyle) {
288
- const helper = this.helper;
289
- // don't animate, otherwise we animate offseted when switching back to 'absolute' from 'fixed'.
290
- // TODO: this also removes resizing animation which doesn't have this issue, but others.
291
- // Ideally both would animate ('move' would immediately restore 'absolute' and adjust coordinate to match,
292
- // then trigger a delay (repaint) to restore to final dest with animate) but then we need to make sure 'resizestop'
293
- // is called AFTER 'transitionend' event is received (see https://github.com/gridstack/gridstack.js/issues/2033)
294
- const transition = this.dragElementOriginStyle['transition'] || null;
295
- helper.style.transition = this.dragElementOriginStyle['transition'] = 'none'; // can't be NULL #1973
296
- DDDraggable.originStyleProp.forEach(prop => helper.style[prop] = this.dragElementOriginStyle[prop] || null);
297
- setTimeout(() => helper.style.transition = transition, 50); // recover animation from saved vars after a pause (0 isn't enough #1973)
298
- }
299
- delete this.dragElementOriginStyle;
300
- return this;
301
- }
302
- /** @internal updates the top/left position to follow the mouse */
303
- _dragFollow(e) {
304
- const containmentRect = { left: 0, top: 0 };
305
- // if (this.helper.style.position === 'absolute') { // we use 'fixed'
306
- // const { left, top } = this.helperContainment.getBoundingClientRect();
307
- // containmentRect = { left, top };
308
- // }
309
- const style = this.helper.style;
310
- const offset = this.dragOffset;
311
- style.left = (e.clientX + offset.offsetLeft - containmentRect.left) * this.dragTransform.xScale + 'px';
312
- style.top = (e.clientY + offset.offsetTop - containmentRect.top) * this.dragTransform.yScale + 'px';
313
- }
314
- /** @internal */
315
- _setupHelperContainmentStyle() {
316
- this.helperContainment = this.helper.parentElement;
317
- if (this.helper.style.position !== 'fixed') {
318
- this.parentOriginStylePosition = this.helperContainment.style.position;
319
- if (getComputedStyle(this.helperContainment).position.match(/static/)) {
320
- this.helperContainment.style.position = 'relative';
321
- }
322
- }
323
- return this;
324
- }
325
- /** @internal */
326
- _getDragOffset(event, el, parent) {
327
- // in case ancestor has transform/perspective css properties that change the viewpoint
328
- let xformOffsetX = 0;
329
- let xformOffsetY = 0;
330
- if (parent) {
331
- xformOffsetX = this.dragTransform.xOffset;
332
- xformOffsetY = this.dragTransform.yOffset;
333
- }
334
- const targetOffset = el.getBoundingClientRect();
335
- return {
336
- left: targetOffset.left,
337
- top: targetOffset.top,
338
- offsetLeft: -event.clientX + targetOffset.left - xformOffsetX,
339
- offsetTop: -event.clientY + targetOffset.top - xformOffsetY,
340
- width: targetOffset.width * this.dragTransform.xScale,
341
- height: targetOffset.height * this.dragTransform.yScale
342
- };
343
- }
344
- /** @internal TODO: set to public as called by DDDroppable! */
345
- ui() {
346
- const containmentEl = this.el.parentElement;
347
- const containmentRect = containmentEl.getBoundingClientRect();
348
- const offset = this.helper.getBoundingClientRect();
349
- return {
350
- position: {
351
- top: (offset.top - containmentRect.top) * this.dragTransform.yScale,
352
- left: (offset.left - containmentRect.left) * this.dragTransform.xScale
353
- }
354
- /* not used by GridStack for now...
355
- helper: [this.helper], //The object arr representing the helper that's being dragged.
356
- offset: { top: offset.top, left: offset.left } // Current offset position of the helper as { top, left } object.
357
- */
358
- };
359
- }
360
- }
361
- /** @internal properties we change during dragging, and restore back */
362
- DDDraggable.originStyleProp = ['width', 'height', 'transform', 'transform-origin', 'transition', 'pointerEvents', 'position', 'left', 'top', 'minWidth', 'willChange'];
363
- export { DDDraggable };
364
- //# sourceMappingURL=dd-draggable.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dd-draggable.js","sourceRoot":"","sources":["../src/dd-draggable.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAiB,KAAK,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAwB,MAAM,gBAAgB,CAAC;AAGvE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM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YAAY,CAAC,AAA3I,CAA4I;SApBjK,WAAW","sourcesContent":["/**\n * dd-draggable.ts 12.3.2\n * Copyright (c) 2021-2025 Alain Dumesny - see GridStack root license\n */\n\nimport { DDManager } from './dd-manager';\nimport { DragTransform, Utils } from './utils';\nimport { DDBaseImplement, HTMLElementExtendOpt } from './dd-base-impl';\nimport { GridItemHTMLElement, DDUIData, GridStackNode, GridStackPosition, DDDragOpt } from './types';\nimport { DDElementHost } from './dd-element';\nimport { isTouch, touchend, touchmove, touchstart, pointerdown } from './dd-touch';\nimport { GridHTMLElement } from './gridstack';\n\ninterface DragOffset {\n left: number;\n top: number;\n width: number;\n height: number;\n offsetLeft: number;\n offsetTop: number;\n}\n\ninterface GridStackNodeRotate extends GridStackNode {\n _origRotate?: GridStackPosition;\n}\n\ntype DDDragEvent = 'drag' | 'dragstart' | 'dragstop';\n\n// make sure we are not clicking on known object that handles mouseDown\nconst skipMouseDown = 'input,textarea,button,select,option,[contenteditable=\"true\"],.ui-resizable-handle';\n\n// let count = 0; // TEST\n\nexport class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt<DDDragOpt> {\n public helper: HTMLElement; // used by GridStackDDNative\n\n /** @internal */\n protected mouseDownEvent: MouseEvent;\n /** @internal */\n protected dragOffset: DragOffset;\n /** @internal */\n protected dragElementOriginStyle: Array<string>;\n /** @internal */\n protected dragEls: HTMLElement[];\n /** @internal true while we are dragging an item around */\n protected dragging: boolean;\n /** @internal last drag event */\n protected lastDrag: DragEvent;\n /** @internal */\n protected parentOriginStylePosition: string;\n /** @internal */\n protected helperContainment: HTMLElement;\n /** @internal properties we change during dragging, and restore back */\n protected static originStyleProp = ['width', 'height', 'transform', 'transform-origin', 'transition', 'pointerEvents', 'position', 'left', 'top', 'minWidth', 'willChange'];\n /** @internal pause before we call the actual drag hit collision code */\n protected dragTimeout: number;\n /** @internal */\n protected dragTransform: DragTransform = {\n xScale: 1,\n yScale: 1,\n xOffset: 0,\n yOffset: 0\n };\n\n constructor(public el: GridItemHTMLElement, public option: DDDragOpt = {}) {\n super();\n\n // get the element that is actually supposed to be dragged by\n const handleName = option?.handle?.substring(1);\n const n = el.gridstackNode;\n this.dragEls = !handleName || el.classList.contains(handleName) ? [el] : (n?.subGrid ? [el.querySelector(option.handle) || el] : Array.from(el.querySelectorAll(option.handle)));\n if (this.dragEls.length === 0) {\n this.dragEls = [el];\n }\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 this._keyEvent = this._keyEvent.bind(this);\n this.enable();\n }\n\n public on(event: DDDragEvent, callback: (event: DragEvent) => void): void {\n super.on(event, callback);\n }\n\n public off(event: DDDragEvent): void {\n super.off(event);\n }\n\n public enable(): void {\n if (this.disabled === false) return;\n super.enable();\n this.dragEls.forEach(dragEl => {\n dragEl.addEventListener('mousedown', this._mouseDown);\n if (isTouch) {\n dragEl.addEventListener('touchstart', touchstart);\n dragEl.addEventListener('pointerdown', pointerdown);\n // dragEl.style.touchAction = 'none'; // not needed unlike pointerdown doc comment\n }\n });\n this.el.classList.remove('ui-draggable-disabled');\n }\n\n public disable(forDestroy = false): void {\n if (this.disabled === true) return;\n super.disable();\n this.dragEls.forEach(dragEl => {\n dragEl.removeEventListener('mousedown', this._mouseDown);\n if (isTouch) {\n dragEl.removeEventListener('touchstart', touchstart);\n dragEl.removeEventListener('pointerdown', pointerdown);\n }\n });\n if (!forDestroy) this.el.classList.add('ui-draggable-disabled');\n }\n\n public destroy(): void {\n if (this.dragTimeout) window.clearTimeout(this.dragTimeout);\n delete this.dragTimeout;\n if (this.mouseDownEvent) this._mouseUp(this.mouseDownEvent);\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: DDDragOpt): DDDraggable {\n Object.keys(opts).forEach(key => this.option[key] = opts[key]);\n return this;\n }\n\n /** @internal call when mouse goes down before a dragstart happens */\n protected _mouseDown(e: MouseEvent): boolean {\n // don't let more than one widget handle mouseStart\n if (DDManager.mouseHandled) return;\n if (e.button !== 0) return true; // only left click\n\n // make sure we are not clicking on known object that handles mouseDown, or ones supplied by the user\n if (!this.dragEls.find(el => el === e.target) && (e.target as HTMLElement).closest(skipMouseDown)) return true;\n if (this.option.cancel) {\n if ((e.target as HTMLElement).closest(this.option.cancel)) return true;\n }\n\n this.mouseDownEvent = e;\n delete this.dragging;\n delete DDManager.dragElement;\n delete DDManager.dropElement;\n // document handler so we can continue receiving moves as the item is 'fixed' position, and capture=true so WE get a first crack\n document.addEventListener('mousemove', this._mouseMove, { capture: true, passive: true }); // true=capture, not bubble\n document.addEventListener('mouseup', this._mouseUp, true);\n if (isTouch) {\n e.currentTarget.addEventListener('touchmove', touchmove);\n e.currentTarget.addEventListener('touchend', touchend);\n }\n\n e.preventDefault();\n // preventDefault() prevents blur event which occurs just after mousedown event.\n // if an editable content has focus, then blur must be call\n if (document.activeElement) (document.activeElement as HTMLElement).blur();\n\n DDManager.mouseHandled = true;\n return true;\n }\n\n /** @internal method to call actual drag event */\n protected _callDrag(e: DragEvent): void {\n if (!this.dragging) return;\n const ev = Utils.initEvent<DragEvent>(e, { 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 called when the main page (after successful mousedown) receives a move event to drag the item around the screen */\n protected _mouseMove(e: DragEvent): boolean {\n // console.log(`${count++} move ${e.x},${e.y}`)\n const s = this.mouseDownEvent;\n this.lastDrag = e;\n\n if (this.dragging) {\n this._dragFollow(e);\n // delay actual grid handling drag until we pause for a while if set\n if (DDManager.pauseDrag) {\n const pause = Number.isInteger(DDManager.pauseDrag) ? DDManager.pauseDrag as number : 100;\n if (this.dragTimeout) window.clearTimeout(this.dragTimeout);\n this.dragTimeout = window.setTimeout(() => this._callDrag(e), pause);\n } else {\n this._callDrag(e);\n }\n } else if (Math.abs(e.x - s.x) + Math.abs(e.y - s.y) > 3) {\n /**\n * don't start unless we've moved at least 3 pixels\n */\n this.dragging = true;\n DDManager.dragElement = this;\n // if we're dragging an actual grid item, set the current drop as the grid (to detect enter/leave)\n const grid = this.el.gridstackNode?.grid;\n if (grid) {\n DDManager.dropElement = (grid.el as DDElementHost).ddElement.ddDroppable;\n } else {\n delete DDManager.dropElement;\n }\n this.helper = this._createHelper();\n this._setupHelperContainmentStyle();\n this.dragTransform = Utils.getValuesFromTransformedElement(this.helperContainment);\n this.dragOffset = this._getDragOffset(e, this.el, this.helperContainment);\n this._setupHelperStyle(e);\n\n const ev = Utils.initEvent<DragEvent>(e, { target: this.el, type: 'dragstart' });\n if (this.option.start) {\n this.option.start(ev, this.ui());\n }\n this.triggerEvent('dragstart', ev);\n // now track keyboard events to cancel or rotate\n document.addEventListener('keydown', this._keyEvent);\n }\n // e.preventDefault(); // passive = true. OLD: was needed otherwise we get text sweep text selection as we drag around\n return true;\n }\n\n /** @internal call when the mouse gets released to drop the item at current location */\n protected _mouseUp(e: MouseEvent): void {\n document.removeEventListener('mousemove', this._mouseMove, true);\n document.removeEventListener('mouseup', this._mouseUp, true);\n if (isTouch && e.currentTarget) { // destroy() during nested grid call us again wit fake _mouseUp\n e.currentTarget.removeEventListener('touchmove', touchmove, true);\n e.currentTarget.removeEventListener('touchend', touchend, true);\n }\n if (this.dragging) {\n delete this.dragging;\n delete (this.el.gridstackNode as GridStackNodeRotate)?._origRotate;\n document.removeEventListener('keydown', this._keyEvent);\n\n // reset the drop target if dragging over ourself (already parented, just moving during stop callback below)\n if (DDManager.dropElement?.el === this.el.parentElement) {\n delete DDManager.dropElement;\n }\n\n this.helperContainment.style.position = this.parentOriginStylePosition || null;\n if (this.helper !== this.el) this.helper.remove(); // hide now\n this._removeHelperStyle();\n\n const ev = Utils.initEvent<DragEvent>(e, { target: this.el, type: 'dragstop' });\n if (this.option.stop) {\n this.option.stop(ev); // NOTE: destroy() will be called when removing item, so expect NULL ptr after!\n }\n this.triggerEvent('dragstop', ev);\n\n // call the droppable method to receive the item\n if (DDManager.dropElement) {\n DDManager.dropElement.drop(e);\n }\n }\n delete this.helper;\n delete this.mouseDownEvent;\n delete DDManager.dragElement;\n delete DDManager.dropElement;\n delete DDManager.mouseHandled;\n e.preventDefault();\n }\n\n /** @internal call when keys are being pressed - use Esc to cancel, R to rotate */\n protected _keyEvent(e: KeyboardEvent): void {\n const n = this.el.gridstackNode as GridStackNodeRotate;\n const grid = n?.grid || (DDManager.dropElement?.el as GridHTMLElement)?.gridstack;\n\n if (e.key === 'Escape') {\n if (n && n._origRotate) {\n n._orig = n._origRotate;\n delete n._origRotate;\n }\n grid?.cancelDrag();\n this._mouseUp(this.mouseDownEvent);\n } else if (n && grid && (e.key === 'r' || e.key === 'R')) {\n if (!Utils.canBeRotated(n)) return;\n n._origRotate = n._origRotate || { ...n._orig }; // store the real orig size in case we Esc after doing rotation\n delete n._moving; // force rotate to happen (move waits for >50% coverage otherwise)\n grid.setAnimation(false) // immediate rotate so _getDragOffset() gets the right dom size below\n .rotate(n.el, { top: -this.dragOffset.offsetTop, left: -this.dragOffset.offsetLeft })\n .setAnimation();\n n._moving = true;\n this.dragOffset = this._getDragOffset(this.lastDrag, n.el, this.helperContainment);\n this.helper.style.width = this.dragOffset.width + 'px';\n this.helper.style.height = this.dragOffset.height + 'px';\n Utils.swap(n._orig, 'w', 'h');\n delete n._rect;\n this._mouseMove(this.lastDrag);\n }\n }\n\n /** @internal create a clone copy (or user defined method) of the original drag item if set */\n protected _createHelper(): HTMLElement {\n let helper = this.el;\n if (typeof this.option.helper === 'function') {\n helper = this.option.helper(this.el);\n } else if (this.option.helper === 'clone') {\n helper = Utils.cloneNode(this.el);\n }\n if (!helper.parentElement) {\n Utils.appendTo(helper, this.option.appendTo === 'parent' ? this.el.parentElement : this.option.appendTo);\n }\n this.dragElementOriginStyle = DDDraggable.originStyleProp.map(prop => this.el.style[prop]);\n return helper;\n }\n\n /** @internal set the fix position of the dragged item */\n protected _setupHelperStyle(e: DragEvent): DDDraggable {\n this.helper.classList.add('ui-draggable-dragging');\n this.el.gridstackNode?.grid?.el.classList.add('grid-stack-dragging');\n // TODO: set all at once with style.cssText += ... ? https://stackoverflow.com/questions/3968593\n const style = this.helper.style;\n style.pointerEvents = 'none'; // needed for over items to get enter/leave\n // style.cursor = 'move'; // TODO: can't set with pointerEvents=none ! (no longer in CSS either as no-op)\n style.width = this.dragOffset.width + 'px';\n style.height = this.dragOffset.height + 'px';\n style.willChange = 'left, top';\n style.position = 'fixed'; // let us drag between grids by not clipping as parent .grid-stack is position: 'relative'\n this._dragFollow(e); // now position it\n style.transition = 'none'; // show up instantly\n setTimeout(() => {\n if (this.helper) {\n style.transition = null; // recover animation\n }\n }, 0);\n return this;\n }\n\n /** @internal restore back the original style before dragging */\n protected _removeHelperStyle(): DDDraggable {\n this.helper.classList.remove('ui-draggable-dragging');\n this.el.gridstackNode?.grid?.el.classList.remove('grid-stack-dragging');\n const node = (this.helper as GridItemHTMLElement)?.gridstackNode;\n // don't bother restoring styles if we're gonna remove anyway...\n if (!node?._isAboutToRemove && this.dragElementOriginStyle) {\n const helper = this.helper;\n // don't animate, otherwise we animate offseted when switching back to 'absolute' from 'fixed'.\n // TODO: this also removes resizing animation which doesn't have this issue, but others.\n // Ideally both would animate ('move' would immediately restore 'absolute' and adjust coordinate to match,\n // then trigger a delay (repaint) to restore to final dest with animate) but then we need to make sure 'resizestop'\n // is called AFTER 'transitionend' event is received (see https://github.com/gridstack/gridstack.js/issues/2033)\n const transition = this.dragElementOriginStyle['transition'] || null;\n helper.style.transition = this.dragElementOriginStyle['transition'] = 'none'; // can't be NULL #1973\n DDDraggable.originStyleProp.forEach(prop => helper.style[prop] = this.dragElementOriginStyle[prop] || null);\n setTimeout(() => helper.style.transition = transition, 50); // recover animation from saved vars after a pause (0 isn't enough #1973)\n }\n delete this.dragElementOriginStyle;\n return this;\n }\n\n /** @internal updates the top/left position to follow the mouse */\n protected _dragFollow(e: DragEvent): void {\n const containmentRect = { left: 0, top: 0 };\n // if (this.helper.style.position === 'absolute') { // we use 'fixed'\n // const { left, top } = this.helperContainment.getBoundingClientRect();\n // containmentRect = { left, top };\n // }\n const style = this.helper.style;\n const offset = this.dragOffset;\n style.left = (e.clientX + offset.offsetLeft - containmentRect.left) * this.dragTransform.xScale + 'px';\n style.top = (e.clientY + offset.offsetTop - containmentRect.top) * this.dragTransform.yScale + 'px';\n }\n\n /** @internal */\n protected _setupHelperContainmentStyle(): DDDraggable {\n this.helperContainment = this.helper.parentElement;\n if (this.helper.style.position !== 'fixed') {\n this.parentOriginStylePosition = this.helperContainment.style.position;\n if (getComputedStyle(this.helperContainment).position.match(/static/)) {\n this.helperContainment.style.position = 'relative';\n }\n }\n return this;\n }\n\n /** @internal */\n protected _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 xformOffsetX = this.dragTransform.xOffset;\n xformOffsetY = this.dragTransform.yOffset;\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 * this.dragTransform.xScale,\n height: targetOffset.height * this.dragTransform.yScale\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) * this.dragTransform.yScale,\n left: (offset.left - containmentRect.left) * this.dragTransform.xScale\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"]}