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-resizable-handle.js","sourceRoot":"","sources":["../../src/dd-resizable-handle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AASnF,MAAa,iBAAiB;IAU5B,YAAsB,IAAyB,EAAY,GAAW,EAAY,MAA4B;QAAxF,SAAI,GAAJ,IAAI,CAAqB;QAAY,QAAG,GAAH,GAAG,CAAQ;QAAY,WAAM,GAAN,MAAM,CAAsB;QAP9G,uEAAuE;QAC7D,WAAM,GAAG,KAAK,CAAC;QAOvB,+GAA+G;QAC/G,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE3C,IAAI,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;IAED,gBAAgB;IACN,KAAK;QACb,MAAM,EAAE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CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC;QAChD,OAAO,IAAI,CAAC;IACd,CAAC;;AA1GD,gBAAgB;AACC,wBAAM,GAAG,eAAe,AAAlB,CAAmB;SAR/B,iBAAiB","sourcesContent":["/**\n * dd-resizable-handle.ts 12.3.3\n * Copyright (c) 2021-2025 Alain Dumesny - see GridStack root license\n */\n\nimport { isTouch, pointerdown, touchend, touchmove, touchstart } from './dd-touch';\nimport { GridItemHTMLElement } from './gridstack';\n\nexport interface DDResizableHandleOpt {\n start?: (event) => void;\n move?: (event) => void;\n stop?: (event) => void;\n}\n\nexport class DDResizableHandle {\n /** @internal */\n protected el: HTMLElement;\n /** @internal true after we've moved enough pixels to start a resize */\n protected moving = false;\n /** @internal */\n protected mouseDownEvent: MouseEvent;\n /** @internal */\n protected static prefix = 'ui-resizable-';\n\n constructor(protected host: GridItemHTMLElement, protected dir: string, protected option: DDResizableHandleOpt) {\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\n this._init();\n }\n\n /** @internal */\n protected _init(): DDResizableHandle {\n const el = this.el = document.createElement('div');\n el.classList.add('ui-resizable-handle');\n el.classList.add(`${DDResizableHandle.prefix}${this.dir}`);\n el.style.zIndex = '100';\n el.style.userSelect = 'none';\n this.host.appendChild(this.el);\n this.el.addEventListener('mousedown', this._mouseDown);\n if (isTouch) {\n this.el.addEventListener('touchstart', touchstart);\n this.el.addEventListener('pointerdown', pointerdown);\n // this.el.style.touchAction = 'none'; // not needed unlike pointerdown doc comment\n }\n return this;\n }\n\n /** call this when resize handle needs to be removed and cleaned up */\n public destroy(): DDResizableHandle {\n if (this.moving) this._mouseUp(this.mouseDownEvent);\n this.el.removeEventListener('mousedown', this._mouseDown);\n if (isTouch) {\n this.el.removeEventListener('touchstart', touchstart);\n this.el.removeEventListener('pointerdown', pointerdown);\n }\n this.host.removeChild(this.el);\n delete this.el;\n delete this.host;\n return this;\n }\n\n /** @internal called on mouse down on us: capture move on the entire document (mouse might not stay on us) until we release the mouse */\n protected _mouseDown(e: MouseEvent): void {\n this.mouseDownEvent = e;\n document.addEventListener('mousemove', this._mouseMove, { capture: true, passive: true}); // capture, not bubble\n document.addEventListener('mouseup', this._mouseUp, true);\n if (isTouch) {\n this.el.addEventListener('touchmove', touchmove);\n this.el.addEventListener('touchend', touchend);\n }\n e.stopPropagation();\n e.preventDefault();\n }\n\n /** @internal */\n protected _mouseMove(e: MouseEvent): void {\n const s = this.mouseDownEvent;\n if (this.moving) {\n this._triggerEvent('move', e);\n } else if (Math.abs(e.x - s.x) + Math.abs(e.y - s.y) > 2) {\n // don't start unless we've moved at least 3 pixels\n this.moving = true;\n this._triggerEvent('start', this.mouseDownEvent);\n this._triggerEvent('move', e);\n // now track keyboard events to cancel\n document.addEventListener('keydown', this._keyEvent);\n }\n e.stopPropagation();\n // e.preventDefault(); passive = true\n }\n\n /** @internal */\n protected _mouseUp(e: MouseEvent): void {\n if (this.moving) {\n this._triggerEvent('stop', e);\n document.removeEventListener('keydown', this._keyEvent);\n }\n document.removeEventListener('mousemove', this._mouseMove, true);\n document.removeEventListener('mouseup', this._mouseUp, true);\n if (isTouch) {\n this.el.removeEventListener('touchmove', touchmove);\n this.el.removeEventListener('touchend', touchend);\n }\n delete this.moving;\n delete this.mouseDownEvent;\n e.stopPropagation();\n e.preventDefault();\n }\n\n /** @internal call when keys are being pressed - use Esc to cancel */\n protected _keyEvent(e: KeyboardEvent): void {\n if (e.key === 'Escape') {\n this.host.gridstackNode?.grid?.engine.restoreInitial();\n this._mouseUp(this.mouseDownEvent);\n }\n }\n\n\n\n /** @internal */\n protected _triggerEvent(name: string, event: MouseEvent): DDResizableHandle {\n if (this.option[name]) this.option[name](event);\n return this;\n }\n}\n"]}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * dd-resizable.ts 12.3.3
3
+ * Copyright (c) 2021-2025 Alain Dumesny - see GridStack root license
4
+ */
5
+ import { DDBaseImplement, HTMLElementExtendOpt } from './dd-base-impl';
6
+ import { DDUIData, GridItemHTMLElement } from './types';
7
+ export interface DDResizableOpt {
8
+ autoHide?: boolean;
9
+ handles?: string;
10
+ maxHeight?: number;
11
+ maxHeightMoveUp?: number;
12
+ maxWidth?: number;
13
+ maxWidthMoveLeft?: number;
14
+ minHeight?: number;
15
+ minWidth?: number;
16
+ start?: (event: Event, ui: DDUIData) => void;
17
+ stop?: (event: Event) => void;
18
+ resize?: (event: Event, ui: DDUIData) => void;
19
+ }
20
+ export declare class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt<DDResizableOpt> {
21
+ el: GridItemHTMLElement;
22
+ option: DDResizableOpt;
23
+ constructor(el: GridItemHTMLElement, option?: DDResizableOpt);
24
+ on(event: 'resizestart' | 'resize' | 'resizestop', callback: (event: DragEvent) => void): void;
25
+ off(event: 'resizestart' | 'resize' | 'resizestop'): void;
26
+ enable(): void;
27
+ disable(): void;
28
+ destroy(): void;
29
+ updateOption(opts: DDResizableOpt): DDResizable;
30
+ }
@@ -0,0 +1,304 @@
1
+ /**
2
+ * dd-resizable.ts 12.3.3
3
+ * Copyright (c) 2021-2025 Alain Dumesny - see GridStack root license
4
+ */
5
+ import { DDResizableHandle } from './dd-resizable-handle';
6
+ import { DDBaseImplement } from './dd-base-impl';
7
+ import { Utils } from './utils';
8
+ import { DDManager } from './dd-manager';
9
+ class DDResizable extends DDBaseImplement {
10
+ // have to be public else complains for HTMLElementExtendOpt ?
11
+ constructor(el, option = {}) {
12
+ super();
13
+ this.el = el;
14
+ this.option = option;
15
+ /** @internal */
16
+ this.rectScale = { x: 1, y: 1 };
17
+ /** @internal */
18
+ this._ui = () => {
19
+ const containmentEl = this.el.parentElement;
20
+ const containmentRect = containmentEl.getBoundingClientRect();
21
+ const newRect = {
22
+ width: this.originalRect.width,
23
+ height: this.originalRect.height + this.scrolled,
24
+ left: this.originalRect.left,
25
+ top: this.originalRect.top - this.scrolled
26
+ };
27
+ const rect = this.temporalRect || newRect;
28
+ return {
29
+ position: {
30
+ left: (rect.left - containmentRect.left) * this.rectScale.x,
31
+ top: (rect.top - containmentRect.top) * this.rectScale.y
32
+ },
33
+ size: {
34
+ width: rect.width * this.rectScale.x,
35
+ height: rect.height * this.rectScale.y
36
+ }
37
+ /* Gridstack ONLY needs position set above... keep around in case.
38
+ element: [this.el], // The object representing the element to be resized
39
+ helper: [], // TODO: not support yet - The object representing the helper that's being resized
40
+ originalElement: [this.el],// we don't wrap here, so simplify as this.el //The object representing the original element before it is wrapped
41
+ originalPosition: { // The position represented as { left, top } before the resizable is resized
42
+ left: this.originalRect.left - containmentRect.left,
43
+ top: this.originalRect.top - containmentRect.top
44
+ },
45
+ originalSize: { // The size represented as { width, height } before the resizable is resized
46
+ width: this.originalRect.width,
47
+ height: this.originalRect.height
48
+ }
49
+ */
50
+ };
51
+ };
52
+ // create var event binding so we can easily remove and still look like TS methods (unlike anonymous functions)
53
+ this._mouseOver = this._mouseOver.bind(this);
54
+ this._mouseOut = this._mouseOut.bind(this);
55
+ this.enable();
56
+ this._setupAutoHide(this.option.autoHide);
57
+ this._setupHandlers();
58
+ }
59
+ on(event, callback) {
60
+ super.on(event, callback);
61
+ }
62
+ off(event) {
63
+ super.off(event);
64
+ }
65
+ enable() {
66
+ super.enable();
67
+ this.el.classList.remove('ui-resizable-disabled');
68
+ this._setupAutoHide(this.option.autoHide);
69
+ }
70
+ disable() {
71
+ super.disable();
72
+ this.el.classList.add('ui-resizable-disabled');
73
+ this._setupAutoHide(false);
74
+ }
75
+ destroy() {
76
+ this._removeHandlers();
77
+ this._setupAutoHide(false);
78
+ delete this.el;
79
+ super.destroy();
80
+ }
81
+ updateOption(opts) {
82
+ const updateHandles = (opts.handles && opts.handles !== this.option.handles);
83
+ const updateAutoHide = (opts.autoHide && opts.autoHide !== this.option.autoHide);
84
+ Object.keys(opts).forEach(key => this.option[key] = opts[key]);
85
+ if (updateHandles) {
86
+ this._removeHandlers();
87
+ this._setupHandlers();
88
+ }
89
+ if (updateAutoHide) {
90
+ this._setupAutoHide(this.option.autoHide);
91
+ }
92
+ return this;
93
+ }
94
+ /** @internal turns auto hide on/off */
95
+ _setupAutoHide(auto) {
96
+ if (auto) {
97
+ this.el.classList.add('ui-resizable-autohide');
98
+ // use mouseover and not mouseenter to get better performance and track for nested cases
99
+ this.el.addEventListener('mouseover', this._mouseOver);
100
+ this.el.addEventListener('mouseout', this._mouseOut);
101
+ }
102
+ else {
103
+ this.el.classList.remove('ui-resizable-autohide');
104
+ this.el.removeEventListener('mouseover', this._mouseOver);
105
+ this.el.removeEventListener('mouseout', this._mouseOut);
106
+ if (DDManager.overResizeElement === this) {
107
+ delete DDManager.overResizeElement;
108
+ }
109
+ }
110
+ return this;
111
+ }
112
+ /** @internal */
113
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
114
+ _mouseOver(e) {
115
+ // console.log(`${count++} pre-enter ${(this.el as GridItemHTMLElement).gridstackNode._id}`)
116
+ // already over a child, ignore. Ideally we just call e.stopPropagation() but see https://github.com/gridstack/gridstack.js/issues/2018
117
+ if (DDManager.overResizeElement || DDManager.dragElement)
118
+ return;
119
+ DDManager.overResizeElement = this;
120
+ // console.log(`${count++} enter ${(this.el as GridItemHTMLElement).gridstackNode._id}`)
121
+ this.el.classList.remove('ui-resizable-autohide');
122
+ }
123
+ /** @internal */
124
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
125
+ _mouseOut(e) {
126
+ // console.log(`${count++} pre-leave ${(this.el as GridItemHTMLElement).gridstackNode._id}`)
127
+ if (DDManager.overResizeElement !== this)
128
+ return;
129
+ delete DDManager.overResizeElement;
130
+ // console.log(`${count++} leave ${(this.el as GridItemHTMLElement).gridstackNode._id}`)
131
+ this.el.classList.add('ui-resizable-autohide');
132
+ }
133
+ /** @internal */
134
+ _setupHandlers() {
135
+ this.handlers = this.option.handles.split(',')
136
+ .map(dir => dir.trim())
137
+ .map(dir => new DDResizableHandle(this.el, dir, {
138
+ start: (event) => {
139
+ this._resizeStart(event);
140
+ },
141
+ stop: (event) => {
142
+ this._resizeStop(event);
143
+ },
144
+ move: (event) => {
145
+ this._resizing(event, dir);
146
+ }
147
+ }));
148
+ return this;
149
+ }
150
+ /** @internal */
151
+ _resizeStart(event) {
152
+ this.sizeToContent = Utils.shouldSizeToContent(this.el.gridstackNode, true); // strick true only and not number
153
+ this.originalRect = this.el.getBoundingClientRect();
154
+ this.scrollEl = Utils.getScrollElement(this.el);
155
+ this.scrollY = this.scrollEl.scrollTop;
156
+ this.scrolled = 0;
157
+ this.startEvent = event;
158
+ this._setupHelper();
159
+ this._applyChange();
160
+ const ev = Utils.initEvent(event, { type: 'resizestart', target: this.el });
161
+ if (this.option.start) {
162
+ this.option.start(ev, this._ui());
163
+ }
164
+ this.el.classList.add('ui-resizable-resizing');
165
+ this.triggerEvent('resizestart', ev);
166
+ return this;
167
+ }
168
+ /** @internal */
169
+ _resizing(event, dir) {
170
+ this.scrolled = this.scrollEl.scrollTop - this.scrollY;
171
+ this.temporalRect = this._getChange(event, dir);
172
+ this._applyChange();
173
+ const ev = Utils.initEvent(event, { type: 'resize', target: this.el });
174
+ if (this.option.resize) {
175
+ this.option.resize(ev, this._ui());
176
+ }
177
+ this.triggerEvent('resize', ev);
178
+ return this;
179
+ }
180
+ /** @internal */
181
+ _resizeStop(event) {
182
+ const ev = Utils.initEvent(event, { type: 'resizestop', target: this.el });
183
+ // Remove style attr now, so the stop handler can rebuild style attrs
184
+ this._cleanHelper();
185
+ if (this.option.stop) {
186
+ this.option.stop(ev); // Note: ui() not used by gridstack so don't pass
187
+ }
188
+ this.el.classList.remove('ui-resizable-resizing');
189
+ this.triggerEvent('resizestop', ev);
190
+ delete this.startEvent;
191
+ delete this.originalRect;
192
+ delete this.temporalRect;
193
+ delete this.scrollY;
194
+ delete this.scrolled;
195
+ return this;
196
+ }
197
+ /** @internal */
198
+ _setupHelper() {
199
+ this.elOriginStyleVal = DDResizable._originStyleProp.map(prop => this.el.style[prop]);
200
+ this.parentOriginStylePosition = this.el.parentElement.style.position;
201
+ const parent = this.el.parentElement;
202
+ const dragTransform = Utils.getValuesFromTransformedElement(parent);
203
+ this.rectScale = {
204
+ x: dragTransform.xScale,
205
+ y: dragTransform.yScale
206
+ };
207
+ if (getComputedStyle(this.el.parentElement).position.match(/static/)) {
208
+ this.el.parentElement.style.position = 'relative';
209
+ }
210
+ this.el.style.position = 'absolute';
211
+ this.el.style.opacity = '0.8';
212
+ return this;
213
+ }
214
+ /** @internal */
215
+ _cleanHelper() {
216
+ DDResizable._originStyleProp.forEach((prop, i) => {
217
+ this.el.style[prop] = this.elOriginStyleVal[i] || null;
218
+ });
219
+ this.el.parentElement.style.position = this.parentOriginStylePosition || null;
220
+ return this;
221
+ }
222
+ /** @internal */
223
+ _getChange(event, dir) {
224
+ const oEvent = this.startEvent;
225
+ const newRect = {
226
+ width: this.originalRect.width,
227
+ height: this.originalRect.height + this.scrolled,
228
+ left: this.originalRect.left,
229
+ top: this.originalRect.top - this.scrolled
230
+ };
231
+ const offsetX = event.clientX - oEvent.clientX;
232
+ const offsetY = this.sizeToContent ? 0 : event.clientY - oEvent.clientY; // prevent vert resize
233
+ let moveLeft;
234
+ let moveUp;
235
+ if (dir.indexOf('e') > -1) {
236
+ newRect.width += offsetX;
237
+ }
238
+ else if (dir.indexOf('w') > -1) {
239
+ newRect.width -= offsetX;
240
+ newRect.left += offsetX;
241
+ moveLeft = true;
242
+ }
243
+ if (dir.indexOf('s') > -1) {
244
+ newRect.height += offsetY;
245
+ }
246
+ else if (dir.indexOf('n') > -1) {
247
+ newRect.height -= offsetY;
248
+ newRect.top += offsetY;
249
+ moveUp = true;
250
+ }
251
+ const constrain = this._constrainSize(newRect.width, newRect.height, moveLeft, moveUp);
252
+ if (Math.round(newRect.width) !== Math.round(constrain.width)) { // round to ignore slight round-off errors
253
+ if (dir.indexOf('w') > -1) {
254
+ newRect.left += newRect.width - constrain.width;
255
+ }
256
+ newRect.width = constrain.width;
257
+ }
258
+ if (Math.round(newRect.height) !== Math.round(constrain.height)) {
259
+ if (dir.indexOf('n') > -1) {
260
+ newRect.top += newRect.height - constrain.height;
261
+ }
262
+ newRect.height = constrain.height;
263
+ }
264
+ return newRect;
265
+ }
266
+ /** @internal constrain the size to the set min/max values */
267
+ _constrainSize(oWidth, oHeight, moveLeft, moveUp) {
268
+ const o = this.option;
269
+ const maxWidth = (moveLeft ? o.maxWidthMoveLeft : o.maxWidth) || Number.MAX_SAFE_INTEGER;
270
+ const minWidth = o.minWidth / this.rectScale.x || oWidth;
271
+ const maxHeight = (moveUp ? o.maxHeightMoveUp : o.maxHeight) || Number.MAX_SAFE_INTEGER;
272
+ const minHeight = o.minHeight / this.rectScale.y || oHeight;
273
+ const width = Math.min(maxWidth, Math.max(minWidth, oWidth));
274
+ const height = Math.min(maxHeight, Math.max(minHeight, oHeight));
275
+ return { width, height };
276
+ }
277
+ /** @internal */
278
+ _applyChange() {
279
+ let containmentRect = { left: 0, top: 0, width: 0, height: 0 };
280
+ if (this.el.style.position === 'absolute') {
281
+ const containmentEl = this.el.parentElement;
282
+ const { left, top } = containmentEl.getBoundingClientRect();
283
+ containmentRect = { left, top, width: 0, height: 0 };
284
+ }
285
+ if (!this.temporalRect)
286
+ return this;
287
+ Object.keys(this.temporalRect).forEach(key => {
288
+ const value = this.temporalRect[key];
289
+ const scaleReciprocal = key === 'width' || key === 'left' ? this.rectScale.x : key === 'height' || key === 'top' ? this.rectScale.y : 1;
290
+ this.el.style[key] = (value - containmentRect[key]) * scaleReciprocal + 'px';
291
+ });
292
+ return this;
293
+ }
294
+ /** @internal */
295
+ _removeHandlers() {
296
+ this.handlers.forEach(handle => handle.destroy());
297
+ delete this.handlers;
298
+ return this;
299
+ }
300
+ }
301
+ /** @internal */
302
+ DDResizable._originStyleProp = ['width', 'height', 'position', 'left', 'top', 'opacity', 'zIndex'];
303
+ export {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","sourcesContent":["/**\n * dd-resizable.ts 12.3.3\n * Copyright (c) 2021-2025 Alain Dumesny - see GridStack root license\n */\n\nimport { DDResizableHandle } from './dd-resizable-handle';\nimport { DDBaseImplement, HTMLElementExtendOpt } from './dd-base-impl';\nimport { Utils } from './utils';\nimport { DDUIData, GridItemHTMLElement, Rect, Size } from './types';\nimport { DDManager } from './dd-manager';\n\n// import { GridItemHTMLElement } from './types'; let count = 0; // TEST\n\n// TODO: merge with DDDragOpt\nexport interface DDResizableOpt {\n autoHide?: boolean;\n handles?: string;\n maxHeight?: number;\n maxHeightMoveUp?: number;\n maxWidth?: number;\n maxWidthMoveLeft?: number;\n minHeight?: number;\n minWidth?: number;\n start?: (event: Event, ui: DDUIData) => void;\n stop?: (event: Event) => void;\n resize?: (event: Event, ui: DDUIData) => void;\n}\n\ninterface RectScaleReciprocal {\n x: number;\n y: number;\n}\n\nexport class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt<DDResizableOpt> {\n /** @internal */\n protected handlers: DDResizableHandle[];\n /** @internal */\n protected originalRect: Rect;\n /** @internal */\n protected rectScale: RectScaleReciprocal = { x: 1, y: 1 };\n /** @internal */\n protected temporalRect: Rect;\n /** @internal */\n protected scrollY: number;\n /** @internal */\n protected scrolled: number;\n /** @internal */\n protected scrollEl: HTMLElement;\n /** @internal */\n protected startEvent: MouseEvent;\n /** @internal value saved in the same order as _originStyleProp[] */\n protected elOriginStyleVal: string[];\n /** @internal */\n protected parentOriginStylePosition: string;\n /** @internal */\n protected static _originStyleProp = ['width', 'height', 'position', 'left', 'top', 'opacity', 'zIndex'];\n /** @internal */\n protected sizeToContent: boolean;\n\n // have to be public else complains for HTMLElementExtendOpt ?\n constructor(public el: GridItemHTMLElement, public option: DDResizableOpt = {}) {\n super();\n // create var event binding so we can easily remove and still look like TS methods (unlike anonymous functions)\n this._mouseOver = this._mouseOver.bind(this);\n this._mouseOut = this._mouseOut.bind(this);\n this.enable();\n this._setupAutoHide(this.option.autoHide);\n this._setupHandlers();\n }\n\n public on(event: 'resizestart' | 'resize' | 'resizestop', callback: (event: DragEvent) => void): void {\n super.on(event, callback);\n }\n\n public off(event: 'resizestart' | 'resize' | 'resizestop'): void {\n super.off(event);\n }\n\n public enable(): void {\n super.enable();\n this.el.classList.remove('ui-resizable-disabled');\n this._setupAutoHide(this.option.autoHide);\n }\n\n public disable(): void {\n super.disable();\n this.el.classList.add('ui-resizable-disabled');\n this._setupAutoHide(false);\n }\n\n public destroy(): void {\n this._removeHandlers();\n this._setupAutoHide(false);\n delete this.el;\n super.destroy();\n }\n\n public updateOption(opts: DDResizableOpt): DDResizable {\n const updateHandles = (opts.handles && opts.handles !== this.option.handles);\n const updateAutoHide = (opts.autoHide && opts.autoHide !== this.option.autoHide);\n Object.keys(opts).forEach(key => this.option[key] = opts[key]);\n if (updateHandles) {\n this._removeHandlers();\n this._setupHandlers();\n }\n if (updateAutoHide) {\n this._setupAutoHide(this.option.autoHide);\n }\n return this;\n }\n\n /** @internal turns auto hide on/off */\n protected _setupAutoHide(auto: boolean): DDResizable {\n if (auto) {\n this.el.classList.add('ui-resizable-autohide');\n // use mouseover and not mouseenter to get better performance and track for nested cases\n this.el.addEventListener('mouseover', this._mouseOver);\n this.el.addEventListener('mouseout', this._mouseOut);\n } else {\n this.el.classList.remove('ui-resizable-autohide');\n this.el.removeEventListener('mouseover', this._mouseOver);\n this.el.removeEventListener('mouseout', this._mouseOut);\n if (DDManager.overResizeElement === this) {\n delete DDManager.overResizeElement;\n }\n }\n return this;\n }\n\n /** @internal */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n protected _mouseOver(e: Event): void {\n // console.log(`${count++} pre-enter ${(this.el as GridItemHTMLElement).gridstackNode._id}`)\n // already over a child, ignore. Ideally we just call e.stopPropagation() but see https://github.com/gridstack/gridstack.js/issues/2018\n if (DDManager.overResizeElement || DDManager.dragElement) return;\n DDManager.overResizeElement = this;\n // console.log(`${count++} enter ${(this.el as GridItemHTMLElement).gridstackNode._id}`)\n this.el.classList.remove('ui-resizable-autohide');\n }\n\n /** @internal */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n protected _mouseOut(e: Event): void {\n // console.log(`${count++} pre-leave ${(this.el as GridItemHTMLElement).gridstackNode._id}`)\n if (DDManager.overResizeElement !== this) return;\n delete DDManager.overResizeElement;\n // console.log(`${count++} leave ${(this.el as GridItemHTMLElement).gridstackNode._id}`)\n this.el.classList.add('ui-resizable-autohide');\n }\n\n /** @internal */\n protected _setupHandlers(): DDResizable {\n this.handlers = this.option.handles.split(',')\n .map(dir => dir.trim())\n .map(dir => new DDResizableHandle(this.el, dir, {\n start: (event: MouseEvent) => {\n this._resizeStart(event);\n },\n stop: (event: MouseEvent) => {\n this._resizeStop(event);\n },\n move: (event: MouseEvent) => {\n this._resizing(event, dir);\n }\n }));\n return this;\n }\n\n /** @internal */\n protected _resizeStart(event: MouseEvent): DDResizable {\n this.sizeToContent = Utils.shouldSizeToContent(this.el.gridstackNode, true); // strick true only and not number\n this.originalRect = this.el.getBoundingClientRect();\n this.scrollEl = Utils.getScrollElement(this.el);\n this.scrollY = this.scrollEl.scrollTop;\n this.scrolled = 0;\n this.startEvent = event;\n this._setupHelper();\n this._applyChange();\n const ev = Utils.initEvent<MouseEvent>(event, { type: 'resizestart', target: this.el });\n if (this.option.start) {\n this.option.start(ev, this._ui());\n }\n this.el.classList.add('ui-resizable-resizing');\n this.triggerEvent('resizestart', ev);\n return this;\n }\n\n /** @internal */\n protected _resizing(event: MouseEvent, dir: string): DDResizable {\n this.scrolled = this.scrollEl.scrollTop - this.scrollY;\n this.temporalRect = this._getChange(event, dir);\n this._applyChange();\n const ev = Utils.initEvent<MouseEvent>(event, { type: 'resize', target: this.el });\n if (this.option.resize) {\n this.option.resize(ev, this._ui());\n }\n this.triggerEvent('resize', ev);\n return this;\n }\n\n /** @internal */\n protected _resizeStop(event: MouseEvent): DDResizable {\n const ev = Utils.initEvent<MouseEvent>(event, { type: 'resizestop', target: this.el });\n // Remove style attr now, so the stop handler can rebuild style attrs\n this._cleanHelper();\n if (this.option.stop) {\n this.option.stop(ev); // Note: ui() not used by gridstack so don't pass\n }\n this.el.classList.remove('ui-resizable-resizing');\n this.triggerEvent('resizestop', ev);\n delete this.startEvent;\n delete this.originalRect;\n delete this.temporalRect;\n delete this.scrollY;\n delete this.scrolled;\n return this;\n }\n\n /** @internal */\n protected _setupHelper(): DDResizable {\n this.elOriginStyleVal = DDResizable._originStyleProp.map(prop => this.el.style[prop]);\n this.parentOriginStylePosition = this.el.parentElement.style.position;\n\n const parent = this.el.parentElement;\n const dragTransform = Utils.getValuesFromTransformedElement(parent);\n this.rectScale = {\n x: dragTransform.xScale,\n y: dragTransform.yScale\n };\n\n if (getComputedStyle(this.el.parentElement).position.match(/static/)) {\n this.el.parentElement.style.position = 'relative';\n }\n this.el.style.position = 'absolute';\n this.el.style.opacity = '0.8';\n return this;\n }\n\n /** @internal */\n protected _cleanHelper(): DDResizable {\n DDResizable._originStyleProp.forEach((prop, i) => {\n this.el.style[prop] = this.elOriginStyleVal[i] || null;\n });\n this.el.parentElement.style.position = this.parentOriginStylePosition || null;\n return this;\n }\n\n /** @internal */\n protected _getChange(event: MouseEvent, dir: string): Rect {\n const oEvent = this.startEvent;\n const newRect = { // Note: originalRect is a complex object, not a simple Rect, so copy out.\n width: this.originalRect.width,\n height: this.originalRect.height + this.scrolled,\n left: this.originalRect.left,\n top: this.originalRect.top - this.scrolled\n };\n\n const offsetX = event.clientX - oEvent.clientX;\n const offsetY = this.sizeToContent ? 0 : event.clientY - oEvent.clientY; // prevent vert resize\n let moveLeft: boolean;\n let moveUp: boolean;\n\n if (dir.indexOf('e') > -1) {\n newRect.width += offsetX;\n } else if (dir.indexOf('w') > -1) {\n newRect.width -= offsetX;\n newRect.left += offsetX;\n moveLeft = true;\n }\n if (dir.indexOf('s') > -1) {\n newRect.height += offsetY;\n } else if (dir.indexOf('n') > -1) {\n newRect.height -= offsetY;\n newRect.top += offsetY\n moveUp = true;\n }\n const constrain = this._constrainSize(newRect.width, newRect.height, moveLeft, moveUp);\n if (Math.round(newRect.width) !== Math.round(constrain.width)) { // round to ignore slight round-off errors\n if (dir.indexOf('w') > -1) {\n newRect.left += newRect.width - constrain.width;\n }\n newRect.width = constrain.width;\n }\n if (Math.round(newRect.height) !== Math.round(constrain.height)) {\n if (dir.indexOf('n') > -1) {\n newRect.top += newRect.height - constrain.height;\n }\n newRect.height = constrain.height;\n }\n return newRect;\n }\n\n /** @internal constrain the size to the set min/max values */\n protected _constrainSize(oWidth: number, oHeight: number, moveLeft: boolean, moveUp: boolean): Size {\n const o = this.option;\n const maxWidth = (moveLeft ? o.maxWidthMoveLeft : o.maxWidth) || Number.MAX_SAFE_INTEGER;\n const minWidth = o.minWidth / this.rectScale.x || oWidth;\n const maxHeight = (moveUp ? o.maxHeightMoveUp : o.maxHeight) || Number.MAX_SAFE_INTEGER;\n const minHeight = o.minHeight / this.rectScale.y || oHeight;\n const width = Math.min(maxWidth, Math.max(minWidth, oWidth));\n const height = Math.min(maxHeight, Math.max(minHeight, oHeight));\n return { width, height };\n }\n\n /** @internal */\n protected _applyChange(): DDResizable {\n let containmentRect = { left: 0, top: 0, width: 0, height: 0 };\n if (this.el.style.position === 'absolute') {\n const containmentEl = this.el.parentElement;\n const { left, top } = containmentEl.getBoundingClientRect();\n containmentRect = { left, top, width: 0, height: 0 };\n }\n if (!this.temporalRect) return this;\n Object.keys(this.temporalRect).forEach(key => {\n const value = this.temporalRect[key];\n const scaleReciprocal = key === 'width' || key === 'left' ? this.rectScale.x : key === 'height' || key === 'top' ? this.rectScale.y : 1;\n this.el.style[key] = (value - containmentRect[key]) * scaleReciprocal + 'px';\n });\n return this;\n }\n\n /** @internal */\n protected _removeHandlers(): DDResizable {\n this.handlers.forEach(handle => handle.destroy());\n delete this.handlers;\n return this;\n }\n\n /** @internal */\n protected _ui = (): DDUIData => {\n const containmentEl = this.el.parentElement;\n const containmentRect = containmentEl.getBoundingClientRect();\n const newRect = { // Note: originalRect is a complex object, not a simple Rect, so copy out.\n width: this.originalRect.width,\n height: this.originalRect.height + this.scrolled,\n left: this.originalRect.left,\n top: this.originalRect.top - this.scrolled\n };\n const rect = this.temporalRect || newRect;\n return {\n position: {\n left: (rect.left - containmentRect.left) * this.rectScale.x,\n top: (rect.top - containmentRect.top) * this.rectScale.y\n },\n size: {\n width: rect.width * this.rectScale.x,\n height: rect.height * this.rectScale.y\n }\n /* Gridstack ONLY needs position set above... keep around in case.\n element: [this.el], // The object representing the element to be resized\n helper: [], // TODO: not support yet - The object representing the helper that's being resized\n originalElement: [this.el],// we don't wrap here, so simplify as this.el //The object representing the original element before it is wrapped\n originalPosition: { // The position represented as { left, top } before the resizable is resized\n left: this.originalRect.left - containmentRect.left,\n top: this.originalRect.top - containmentRect.top\n },\n originalSize: { // The size represented as { width, height } before the resizable is resized\n width: this.originalRect.width,\n height: this.originalRect.height\n }\n */\n };\n }\n}\n"]}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * touch.ts 12.3.3
3
+ * Copyright (c) 2021-2025 Alain Dumesny - see GridStack root license
4
+ */
5
+ /**
6
+ * Detect touch support - Windows Surface devices and other touch devices
7
+ * should we use this instead ? (what we had for always showing resize handles)
8
+ * /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)
9
+ */
10
+ export declare const isTouch: boolean;
11
+ /**
12
+ * Handle the touchstart events
13
+ * @param {Object} e The widget element's touchstart event
14
+ */
15
+ export declare function touchstart(e: TouchEvent): void;
16
+ /**
17
+ * Handle the touchmove events
18
+ * @param {Object} e The document's touchmove event
19
+ */
20
+ export declare function touchmove(e: TouchEvent): void;
21
+ /**
22
+ * Handle the touchend events
23
+ * @param {Object} e The document's touchend event
24
+ */
25
+ export declare function touchend(e: TouchEvent): void;
26
+ /**
27
+ * Note we don't get touchenter/touchleave (which are deprecated)
28
+ * see https://stackoverflow.com/questions/27908339/js-touch-equivalent-for-mouseenter
29
+ * so instead of PointerEvent to still get enter/leave and send the matching mouse event.
30
+ */
31
+ export declare function pointerdown(e: PointerEvent): void;
32
+ export declare function pointerenter(e: PointerEvent): void;
33
+ export declare function pointerleave(e: PointerEvent): void;
@@ -0,0 +1,145 @@
1
+ /**
2
+ * touch.ts 12.3.3
3
+ * Copyright (c) 2021-2025 Alain Dumesny - see GridStack root license
4
+ */
5
+ import { DDManager } from './dd-manager';
6
+ import { Utils } from './utils';
7
+ /**
8
+ * Detect touch support - Windows Surface devices and other touch devices
9
+ * should we use this instead ? (what we had for always showing resize handles)
10
+ * /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)
11
+ */
12
+ export const isTouch = typeof window !== 'undefined' && typeof document !== 'undefined' &&
13
+ ('ontouchstart' in document
14
+ || 'ontouchstart' in window
15
+ // || !!window.TouchEvent // true on Windows 10 Chrome desktop so don't use this
16
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
+ || (window.DocumentTouch && document instanceof window.DocumentTouch)
18
+ || navigator.maxTouchPoints > 0
19
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
+ || navigator.msMaxTouchPoints > 0);
21
+ // interface TouchCoord {x: number, y: number};
22
+ class DDTouch {
23
+ }
24
+ /**
25
+ * Get the x,y position of a touch event
26
+ */
27
+ // function getTouchCoords(e: TouchEvent): TouchCoord {
28
+ // return {
29
+ // x: e.changedTouches[0].pageX,
30
+ // y: e.changedTouches[0].pageY
31
+ // };
32
+ // }
33
+ /**
34
+ * Simulate a mouse event based on a corresponding touch event
35
+ * @param {Object} e A touch event
36
+ * @param {String} simulatedType The corresponding mouse event
37
+ */
38
+ function simulateMouseEvent(e, simulatedType) {
39
+ // Ignore multi-touch events
40
+ if (e.touches.length > 1)
41
+ return;
42
+ // Prevent "Ignored attempt to cancel a touchmove event with cancelable=false" errors
43
+ if (e.cancelable)
44
+ e.preventDefault();
45
+ // Dispatch the simulated event to the target element
46
+ Utils.simulateMouseEvent(e.changedTouches[0], simulatedType);
47
+ }
48
+ /**
49
+ * Simulate a mouse event based on a corresponding Pointer event
50
+ * @param {Object} e A pointer event
51
+ * @param {String} simulatedType The corresponding mouse event
52
+ */
53
+ function simulatePointerMouseEvent(e, simulatedType) {
54
+ // Prevent "Ignored attempt to cancel a touchmove event with cancelable=false" errors
55
+ if (e.cancelable)
56
+ e.preventDefault();
57
+ // Dispatch the simulated event to the target element
58
+ Utils.simulateMouseEvent(e, simulatedType);
59
+ }
60
+ /**
61
+ * Handle the touchstart events
62
+ * @param {Object} e The widget element's touchstart event
63
+ */
64
+ export function touchstart(e) {
65
+ // Ignore the event if another widget is already being handled
66
+ if (DDTouch.touchHandled)
67
+ return;
68
+ DDTouch.touchHandled = true;
69
+ // Simulate the mouse events
70
+ // simulateMouseEvent(e, 'mouseover');
71
+ // simulateMouseEvent(e, 'mousemove');
72
+ simulateMouseEvent(e, 'mousedown');
73
+ }
74
+ /**
75
+ * Handle the touchmove events
76
+ * @param {Object} e The document's touchmove event
77
+ */
78
+ export function touchmove(e) {
79
+ // Ignore event if not handled by us
80
+ if (!DDTouch.touchHandled)
81
+ return;
82
+ simulateMouseEvent(e, 'mousemove');
83
+ }
84
+ /**
85
+ * Handle the touchend events
86
+ * @param {Object} e The document's touchend event
87
+ */
88
+ export function touchend(e) {
89
+ // Ignore event if not handled
90
+ if (!DDTouch.touchHandled)
91
+ return;
92
+ // cancel delayed leave event when we release on ourself which happens BEFORE we get this!
93
+ if (DDTouch.pointerLeaveTimeout) {
94
+ window.clearTimeout(DDTouch.pointerLeaveTimeout);
95
+ delete DDTouch.pointerLeaveTimeout;
96
+ }
97
+ const wasDragging = !!DDManager.dragElement;
98
+ // Simulate the mouseup event
99
+ simulateMouseEvent(e, 'mouseup');
100
+ // simulateMouseEvent(event, 'mouseout');
101
+ // If the touch interaction did not move, it should trigger a click
102
+ if (!wasDragging) {
103
+ simulateMouseEvent(e, 'click');
104
+ }
105
+ // Unset the flag to allow other widgets to inherit the touch event
106
+ DDTouch.touchHandled = false;
107
+ }
108
+ /**
109
+ * Note we don't get touchenter/touchleave (which are deprecated)
110
+ * see https://stackoverflow.com/questions/27908339/js-touch-equivalent-for-mouseenter
111
+ * so instead of PointerEvent to still get enter/leave and send the matching mouse event.
112
+ */
113
+ export function pointerdown(e) {
114
+ // console.log("pointer down")
115
+ if (e.pointerType === 'mouse')
116
+ return;
117
+ e.target.releasePointerCapture(e.pointerId); // <- Important!
118
+ }
119
+ export function pointerenter(e) {
120
+ // ignore the initial one we get on pointerdown on ourself
121
+ if (!DDManager.dragElement) {
122
+ // console.log('pointerenter ignored');
123
+ return;
124
+ }
125
+ // console.log('pointerenter');
126
+ if (e.pointerType === 'mouse')
127
+ return;
128
+ simulatePointerMouseEvent(e, 'mouseenter');
129
+ }
130
+ export function pointerleave(e) {
131
+ // ignore the leave on ourself we get before releasing the mouse over ourself
132
+ // by delaying sending the event and having the up event cancel us
133
+ if (!DDManager.dragElement) {
134
+ // console.log('pointerleave ignored');
135
+ return;
136
+ }
137
+ if (e.pointerType === 'mouse')
138
+ return;
139
+ DDTouch.pointerLeaveTimeout = window.setTimeout(() => {
140
+ delete DDTouch.pointerLeaveTimeout;
141
+ // console.log('pointerleave delayed');
142
+ simulatePointerMouseEvent(e, 'mouseleave');
143
+ }, 10);
144
+ }
145
+ //# sourceMappingURL=dd-touch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dd-touch.js","sourceRoot":"","sources":["../../src/dd-touch.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC;;;;GAIG;AACH,MAAM,CAAC,MAAM,OAAO,GAAY,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,QAAQ,KAAK,WAAW;IAC9F,CAAE,cAAc,IAAI,QAAQ;WACvB,cAAc,IAAI,MAAM;QAC3B,gFAAgF;QAChF,8DAA8D;WAC3D,C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SAAS,CAAC,WAAW,EAAE;QAC1B,uCAAuC;QACvC,OAAO;KACR;IACD,IAAI,CAAC,CAAC,WAAW,KAAK,OAAO;QAAE,OAAO;IACtC,OAAO,CAAC,mBAAmB,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE;QACnD,OAAO,OAAO,CAAC,mBAAmB,CAAC;QACnC,uCAAuC;QACvC,yBAAyB,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;IAC7C,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC","sourcesContent":["/**\n * touch.ts 12.3.3\n * Copyright (c) 2021-2025 Alain Dumesny - see GridStack root license\n */\n\nimport { DDManager } from './dd-manager';\nimport { Utils } from './utils';\n\n/**\n * Detect touch support - Windows Surface devices and other touch devices\n * should we use this instead ? (what we had for always showing resize handles)\n * /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)\n */\nexport const isTouch: boolean = typeof window !== 'undefined' && typeof document !== 'undefined' &&\n ( 'ontouchstart' in document\n || 'ontouchstart' in window\n // || !!window.TouchEvent // true on Windows 10 Chrome desktop so don't use this\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n || ((window as any).DocumentTouch && document instanceof (window as any).DocumentTouch)\n || navigator.maxTouchPoints > 0\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n || (navigator as any).msMaxTouchPoints > 0\n );\n\n// interface TouchCoord {x: number, y: number};\n\nclass DDTouch {\n public static touchHandled: boolean;\n public static pointerLeaveTimeout: number;\n}\n\n/**\n* Get the x,y position of a touch event\n*/\n// function getTouchCoords(e: TouchEvent): TouchCoord {\n// return {\n// x: e.changedTouches[0].pageX,\n// y: e.changedTouches[0].pageY\n// };\n// }\n\n/**\n * Simulate a mouse event based on a corresponding touch event\n * @param {Object} e A touch event\n * @param {String} simulatedType The corresponding mouse event\n */\nfunction simulateMouseEvent(e: TouchEvent, simulatedType: string) {\n\n // Ignore multi-touch events\n if (e.touches.length > 1) return;\n\n // Prevent \"Ignored attempt to cancel a touchmove event with cancelable=false\" errors\n if (e.cancelable) e.preventDefault();\n\n // Dispatch the simulated event to the target element\n Utils.simulateMouseEvent(e.changedTouches[0], simulatedType);\n}\n\n/**\n * Simulate a mouse event based on a corresponding Pointer event\n * @param {Object} e A pointer event\n * @param {String} simulatedType The corresponding mouse event\n */\nfunction simulatePointerMouseEvent(e: PointerEvent, simulatedType: string) {\n\n // Prevent \"Ignored attempt to cancel a touchmove event with cancelable=false\" errors\n if (e.cancelable) e.preventDefault();\n\n // Dispatch the simulated event to the target element\n Utils.simulateMouseEvent(e, simulatedType);\n}\n\n\n/**\n * Handle the touchstart events\n * @param {Object} e The widget element's touchstart event\n */\nexport function touchstart(e: TouchEvent): void {\n // Ignore the event if another widget is already being handled\n if (DDTouch.touchHandled) return;\n DDTouch.touchHandled = true;\n\n // Simulate the mouse events\n // simulateMouseEvent(e, 'mouseover');\n // simulateMouseEvent(e, 'mousemove');\n simulateMouseEvent(e, 'mousedown');\n}\n\n/**\n * Handle the touchmove events\n * @param {Object} e The document's touchmove event\n */\nexport function touchmove(e: TouchEvent): void {\n // Ignore event if not handled by us\n if (!DDTouch.touchHandled) return;\n\n simulateMouseEvent(e, 'mousemove');\n}\n\n/**\n * Handle the touchend events\n * @param {Object} e The document's touchend event\n */\nexport function touchend(e: TouchEvent): void {\n\n // Ignore event if not handled\n if (!DDTouch.touchHandled) return;\n\n // cancel delayed leave event when we release on ourself which happens BEFORE we get this!\n if (DDTouch.pointerLeaveTimeout) {\n window.clearTimeout(DDTouch.pointerLeaveTimeout);\n delete DDTouch.pointerLeaveTimeout;\n }\n\n const wasDragging = !!DDManager.dragElement;\n\n // Simulate the mouseup event\n simulateMouseEvent(e, 'mouseup');\n // simulateMouseEvent(event, 'mouseout');\n\n // If the touch interaction did not move, it should trigger a click\n if (!wasDragging) {\n simulateMouseEvent(e, 'click');\n }\n\n // Unset the flag to allow other widgets to inherit the touch event\n DDTouch.touchHandled = false;\n}\n\n/**\n * Note we don't get touchenter/touchleave (which are deprecated)\n * see https://stackoverflow.com/questions/27908339/js-touch-equivalent-for-mouseenter\n * so instead of PointerEvent to still get enter/leave and send the matching mouse event.\n */\nexport function pointerdown(e: PointerEvent): void {\n // console.log(\"pointer down\")\n if (e.pointerType === 'mouse') return;\n (e.target as HTMLElement).releasePointerCapture(e.pointerId) // <- Important!\n}\n\nexport function pointerenter(e: PointerEvent): void {\n // ignore the initial one we get on pointerdown on ourself\n if (!DDManager.dragElement) {\n // console.log('pointerenter ignored');\n return;\n }\n // console.log('pointerenter');\n if (e.pointerType === 'mouse') return;\n simulatePointerMouseEvent(e, 'mouseenter');\n}\n\nexport function pointerleave(e: PointerEvent): void {\n // ignore the leave on ourself we get before releasing the mouse over ourself\n // by delaying sending the event and having the up event cancel us\n if (!DDManager.dragElement) {\n // console.log('pointerleave ignored');\n return;\n }\n if (e.pointerType === 'mouse') return;\n DDTouch.pointerLeaveTimeout = window.setTimeout(() => {\n delete DDTouch.pointerLeaveTimeout;\n // console.log('pointerleave delayed');\n simulatePointerMouseEvent(e, 'mouseleave');\n }, 10);\n}\n\n"]}