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.
- package/dist/angular/esm2020/lib/base-widget.mjs +2 -2
- package/dist/angular/esm2020/lib/gridstack-item.component.mjs +2 -2
- package/dist/angular/esm2020/lib/gridstack.component.mjs +4 -2
- package/dist/angular/esm2020/lib/gridstack.module.mjs +2 -2
- package/dist/angular/esm2020/lib/types.mjs +2 -2
- package/dist/angular/fesm2015/gridstack-angular.mjs +6 -4
- package/dist/angular/fesm2015/gridstack-angular.mjs.map +1 -1
- package/dist/angular/fesm2020/gridstack-angular.mjs +7 -5
- package/dist/angular/fesm2020/gridstack-angular.mjs.map +1 -1
- package/dist/angular/lib/gridstack-item.component.d.ts +1 -1
- package/dist/angular/lib/gridstack.component.d.ts +4 -4
- package/dist/angular/lib/types.d.ts +1 -1
- package/dist/angular/package.json +1 -1
- package/dist/angular/projects/lib/src/index.d.ts +5 -0
- package/dist/angular/projects/lib/src/index.js +9 -0
- package/dist/angular/projects/lib/src/index.js.map +1 -0
- package/dist/angular/projects/lib/src/lib/base-widget.d.ts +56 -0
- package/dist/angular/projects/lib/src/lib/base-widget.js +94 -0
- package/dist/angular/projects/lib/src/lib/base-widget.js.map +1 -0
- package/dist/angular/projects/lib/src/lib/gridstack-item.component.d.ts +76 -0
- package/dist/angular/projects/lib/src/lib/gridstack-item.component.js +112 -0
- package/dist/angular/projects/lib/src/lib/gridstack-item.component.js.map +1 -0
- package/dist/angular/projects/lib/src/lib/gridstack.component.d.ts +233 -0
- package/dist/angular/projects/lib/src/lib/gridstack.component.js +457 -0
- package/dist/angular/projects/lib/src/lib/gridstack.component.js.map +1 -0
- package/dist/angular/projects/lib/src/lib/gridstack.module.d.ts +29 -0
- package/dist/angular/projects/lib/src/lib/gridstack.module.js +52 -0
- package/dist/angular/projects/lib/src/lib/gridstack.module.js.map +1 -0
- package/dist/angular/projects/lib/src/lib/types.d.ts +51 -0
- package/dist/angular/projects/lib/src/lib/types.js +6 -0
- package/dist/angular/projects/lib/src/lib/types.js.map +1 -0
- package/dist/angular/src/base-widget.ts +13 -13
- package/dist/angular/src/gridstack-item.component.ts +5 -5
- package/dist/angular/src/gridstack.component.ts +34 -32
- package/dist/angular/src/gridstack.module.ts +4 -4
- package/dist/angular/src/types.ts +3 -2
- package/dist/gridstack-all.js +1 -1
- package/dist/gridstack-all.js.LICENSE.txt +1 -1
- package/dist/gridstack-all.js.map +1 -1
- package/dist/gridstack.css +1 -1
- package/dist/src/dd-base-impl.d.ts +1 -1
- package/dist/src/dd-base-impl.js +1 -1
- package/dist/src/dd-base-impl.js.map +1 -1
- package/dist/src/dd-draggable.d.ts +1 -1
- package/dist/src/dd-draggable.js +1 -1
- package/dist/src/dd-draggable.js.map +1 -1
- package/dist/src/dd-droppable.d.ts +1 -1
- package/dist/src/dd-droppable.js +7 -1
- package/dist/src/dd-droppable.js.map +1 -1
- package/dist/src/dd-element.d.ts +1 -1
- package/dist/src/dd-element.js +1 -1
- package/dist/src/dd-element.js.map +1 -1
- package/dist/src/dd-gridstack.d.ts +1 -1
- package/dist/src/dd-gridstack.js +1 -1
- package/dist/src/dd-gridstack.js.map +1 -1
- package/dist/src/dd-manager.d.ts +1 -1
- package/dist/src/dd-manager.js +1 -1
- package/dist/src/dd-manager.js.map +1 -1
- package/dist/src/dd-resizable-handle.d.ts +5 -4
- package/dist/src/dd-resizable-handle.js +23 -8
- package/dist/src/dd-resizable-handle.js.map +1 -1
- package/dist/src/dd-resizable.d.ts +3 -5
- package/dist/src/dd-resizable.js +5 -10
- package/dist/src/dd-resizable.js.map +1 -1
- package/dist/src/dd-touch.d.ts +1 -1
- package/dist/src/dd-touch.js +1 -1
- package/dist/src/dd-touch.js.map +1 -1
- package/dist/src/gridstack-engine.d.ts +1 -1
- package/dist/src/gridstack-engine.js +7 -1
- package/dist/src/gridstack-engine.js.map +1 -1
- package/dist/src/gridstack.d.ts +1 -2
- package/dist/src/gridstack.js +9 -18
- package/dist/src/gridstack.js.map +1 -1
- package/dist/src/gridstack.scss +1 -1
- package/dist/src/types.d.ts +11 -6
- package/dist/src/types.js +1 -1
- package/dist/src/types.js.map +1 -1
- package/dist/src/utils.d.ts +1 -270
- package/dist/src/utils.js +37 -31
- package/dist/src/utils.js.map +1 -1
- package/doc/API.md +166 -165
- package/package.json +5 -5
- package/dist/dd-base-impl.d.ts +0 -69
- package/dist/dd-base-impl.js +0 -70
- package/dist/dd-base-impl.js.map +0 -1
- package/dist/dd-draggable.d.ts +0 -20
- package/dist/dd-draggable.js +0 -364
- package/dist/dd-draggable.js.map +0 -1
- package/dist/dd-droppable.d.ts +0 -26
- package/dist/dd-droppable.js +0 -149
- package/dist/dd-droppable.js.map +0 -1
- package/dist/dd-element.d.ts +0 -27
- package/dist/dd-element.js +0 -91
- package/dist/dd-element.js.map +0 -1
- package/dist/dd-gridstack.d.ts +0 -82
- package/dist/dd-gridstack.js +0 -165
- package/dist/dd-gridstack.js.map +0 -1
- package/dist/dd-manager.d.ts +0 -43
- package/dist/dd-manager.js +0 -14
- package/dist/dd-manager.js.map +0 -1
- package/dist/dd-resizable-handle.d.ts +0 -18
- package/dist/dd-resizable-handle.js +0 -113
- package/dist/dd-resizable-handle.js.map +0 -1
- package/dist/dd-resizable.d.ts +0 -30
- package/dist/dd-resizable.js +0 -304
- package/dist/dd-resizable.js.map +0 -1
- package/dist/dd-touch.d.ts +0 -33
- package/dist/dd-touch.js +0 -145
- package/dist/dd-touch.js.map +0 -1
- package/dist/gridstack-engine.d.ts +0 -321
- package/dist/gridstack-engine.js +0 -1272
- package/dist/gridstack-engine.js.map +0 -1
- package/dist/gridstack.d.ts +0 -802
- package/dist/gridstack.js +0 -2872
- package/dist/gridstack.js.map +0 -1
- package/dist/spec/gridstack-engine-spec.d.ts +0 -1
- package/dist/spec/gridstack-engine-spec.js +0 -358
- package/dist/spec/gridstack-engine-spec.js.map +0 -1
- package/dist/spec/gridstack-spec.d.ts +0 -1
- package/dist/spec/gridstack-spec.js +0 -1780
- package/dist/spec/gridstack-spec.js.map +0 -1
- package/dist/spec/integration/gridstack-integration.spec.d.ts +0 -1
- package/dist/spec/integration/gridstack-integration.spec.js +0 -171
- package/dist/spec/integration/gridstack-integration.spec.js.map +0 -1
- package/dist/spec/regression-spec.d.ts +0 -1
- package/dist/spec/regression-spec.js +0 -100
- package/dist/spec/regression-spec.js.map +0 -1
- package/dist/spec/utils-spec.d.ts +0 -1
- package/dist/spec/utils-spec.js +0 -243
- package/dist/spec/utils-spec.js.map +0 -1
- package/dist/types.d.ts +0 -427
- package/dist/types.js +0 -38
- package/dist/types.js.map +0 -1
- package/dist/utils.d.ts +0 -283
- package/dist/utils.js +0 -787
- package/dist/utils.js.map +0 -1
- package/dist/vitest.config.d.ts +0 -2
- package/dist/vitest.config.js +0 -74
- package/dist/vitest.config.js.map +0 -1
- package/dist/vitest.setup.d.ts +0 -1
- package/dist/vitest.setup.js +0 -90
- package/dist/vitest.setup.js.map +0 -1
package/dist/dd-droppable.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* dd-droppable.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 { DDUIData } from './types';
|
|
7
|
-
export interface DDDroppableOpt {
|
|
8
|
-
accept?: string | ((el: HTMLElement) => boolean);
|
|
9
|
-
drop?: (event: DragEvent, ui: DDUIData) => void;
|
|
10
|
-
over?: (event: DragEvent, ui: DDUIData) => void;
|
|
11
|
-
out?: (event: DragEvent, ui: DDUIData) => void;
|
|
12
|
-
}
|
|
13
|
-
export declare class DDDroppable extends DDBaseImplement implements HTMLElementExtendOpt<DDDroppableOpt> {
|
|
14
|
-
el: HTMLElement;
|
|
15
|
-
option: DDDroppableOpt;
|
|
16
|
-
accept: (el: HTMLElement) => boolean;
|
|
17
|
-
constructor(el: HTMLElement, option?: DDDroppableOpt);
|
|
18
|
-
on(event: 'drop' | 'dropover' | 'dropout', callback: (event: DragEvent) => void): void;
|
|
19
|
-
off(event: 'drop' | 'dropover' | 'dropout'): void;
|
|
20
|
-
enable(): void;
|
|
21
|
-
disable(forDestroy?: boolean): void;
|
|
22
|
-
destroy(): void;
|
|
23
|
-
updateOption(opts: DDDroppableOpt): DDDroppable;
|
|
24
|
-
/** item is being dropped on us - called by the drag mouseup handler - this calls the client drop event */
|
|
25
|
-
drop(e: MouseEvent): void;
|
|
26
|
-
}
|
package/dist/dd-droppable.js
DELETED
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* dd-droppable.ts 12.3.2
|
|
3
|
-
* Copyright (c) 2021-2025 Alain Dumesny - see GridStack root license
|
|
4
|
-
*/
|
|
5
|
-
import { DDManager } from './dd-manager';
|
|
6
|
-
import { DDBaseImplement } from './dd-base-impl';
|
|
7
|
-
import { Utils } from './utils';
|
|
8
|
-
import { isTouch, pointerenter, pointerleave } from './dd-touch';
|
|
9
|
-
// let count = 0; // TEST
|
|
10
|
-
export class DDDroppable extends DDBaseImplement {
|
|
11
|
-
constructor(el, option = {}) {
|
|
12
|
-
super();
|
|
13
|
-
this.el = el;
|
|
14
|
-
this.option = option;
|
|
15
|
-
// create var event binding so we can easily remove and still look like TS methods (unlike anonymous functions)
|
|
16
|
-
this._mouseEnter = this._mouseEnter.bind(this);
|
|
17
|
-
this._mouseLeave = this._mouseLeave.bind(this);
|
|
18
|
-
this.enable();
|
|
19
|
-
this._setupAccept();
|
|
20
|
-
}
|
|
21
|
-
on(event, callback) {
|
|
22
|
-
super.on(event, callback);
|
|
23
|
-
}
|
|
24
|
-
off(event) {
|
|
25
|
-
super.off(event);
|
|
26
|
-
}
|
|
27
|
-
enable() {
|
|
28
|
-
if (this.disabled === false)
|
|
29
|
-
return;
|
|
30
|
-
super.enable();
|
|
31
|
-
this.el.classList.add('ui-droppable');
|
|
32
|
-
this.el.classList.remove('ui-droppable-disabled');
|
|
33
|
-
this.el.addEventListener('mouseenter', this._mouseEnter);
|
|
34
|
-
this.el.addEventListener('mouseleave', this._mouseLeave);
|
|
35
|
-
if (isTouch) {
|
|
36
|
-
this.el.addEventListener('pointerenter', pointerenter);
|
|
37
|
-
this.el.addEventListener('pointerleave', pointerleave);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
disable(forDestroy = false) {
|
|
41
|
-
if (this.disabled === true)
|
|
42
|
-
return;
|
|
43
|
-
super.disable();
|
|
44
|
-
this.el.classList.remove('ui-droppable');
|
|
45
|
-
if (!forDestroy)
|
|
46
|
-
this.el.classList.add('ui-droppable-disabled');
|
|
47
|
-
this.el.removeEventListener('mouseenter', this._mouseEnter);
|
|
48
|
-
this.el.removeEventListener('mouseleave', this._mouseLeave);
|
|
49
|
-
if (isTouch) {
|
|
50
|
-
this.el.removeEventListener('pointerenter', pointerenter);
|
|
51
|
-
this.el.removeEventListener('pointerleave', pointerleave);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
destroy() {
|
|
55
|
-
this.disable(true);
|
|
56
|
-
this.el.classList.remove('ui-droppable');
|
|
57
|
-
this.el.classList.remove('ui-droppable-disabled');
|
|
58
|
-
super.destroy();
|
|
59
|
-
}
|
|
60
|
-
updateOption(opts) {
|
|
61
|
-
Object.keys(opts).forEach(key => this.option[key] = opts[key]);
|
|
62
|
-
this._setupAccept();
|
|
63
|
-
return this;
|
|
64
|
-
}
|
|
65
|
-
/** @internal called when the cursor enters our area - prepare for a possible drop and track leaving */
|
|
66
|
-
_mouseEnter(e) {
|
|
67
|
-
// console.log(`${count++} Enter ${this.el.id || (this.el as GridHTMLElement).gridstack.opts.id}`); // TEST
|
|
68
|
-
if (!DDManager.dragElement)
|
|
69
|
-
return;
|
|
70
|
-
if (!this._canDrop(DDManager.dragElement.el))
|
|
71
|
-
return;
|
|
72
|
-
e.preventDefault();
|
|
73
|
-
e.stopPropagation();
|
|
74
|
-
// make sure when we enter this, that the last one gets a leave FIRST to correctly cleanup as we don't always do
|
|
75
|
-
if (DDManager.dropElement && DDManager.dropElement !== this) {
|
|
76
|
-
DDManager.dropElement._mouseLeave(e, true); // calledByEnter = true
|
|
77
|
-
}
|
|
78
|
-
DDManager.dropElement = this;
|
|
79
|
-
const ev = Utils.initEvent(e, { target: this.el, type: 'dropover' });
|
|
80
|
-
if (this.option.over) {
|
|
81
|
-
this.option.over(ev, this._ui(DDManager.dragElement));
|
|
82
|
-
}
|
|
83
|
-
this.triggerEvent('dropover', ev);
|
|
84
|
-
this.el.classList.add('ui-droppable-over');
|
|
85
|
-
// console.log('tracking'); // TEST
|
|
86
|
-
}
|
|
87
|
-
/** @internal called when the item is leaving our area, stop tracking if we had moving item */
|
|
88
|
-
_mouseLeave(e, calledByEnter = false) {
|
|
89
|
-
// console.log(`${count++} Leave ${this.el.id || (this.el as GridHTMLElement).gridstack.opts.id}`); // TEST
|
|
90
|
-
if (!DDManager.dragElement || DDManager.dropElement !== this)
|
|
91
|
-
return;
|
|
92
|
-
e.preventDefault();
|
|
93
|
-
e.stopPropagation();
|
|
94
|
-
const ev = Utils.initEvent(e, { target: this.el, type: 'dropout' });
|
|
95
|
-
if (this.option.out) {
|
|
96
|
-
this.option.out(ev, this._ui(DDManager.dragElement));
|
|
97
|
-
}
|
|
98
|
-
this.triggerEvent('dropout', ev);
|
|
99
|
-
if (DDManager.dropElement === this) {
|
|
100
|
-
delete DDManager.dropElement;
|
|
101
|
-
// console.log('not tracking'); // TEST
|
|
102
|
-
// if we're still over a parent droppable, send it an enter as we don't get one from leaving nested children
|
|
103
|
-
if (!calledByEnter) {
|
|
104
|
-
let parentDrop;
|
|
105
|
-
let parent = this.el.parentElement;
|
|
106
|
-
while (!parentDrop && parent) {
|
|
107
|
-
parentDrop = parent.ddElement?.ddDroppable;
|
|
108
|
-
parent = parent.parentElement;
|
|
109
|
-
}
|
|
110
|
-
if (parentDrop) {
|
|
111
|
-
parentDrop._mouseEnter(e);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
/** item is being dropped on us - called by the drag mouseup handler - this calls the client drop event */
|
|
117
|
-
drop(e) {
|
|
118
|
-
e.preventDefault();
|
|
119
|
-
const ev = Utils.initEvent(e, { target: this.el, type: 'drop' });
|
|
120
|
-
if (this.option.drop) {
|
|
121
|
-
this.option.drop(ev, this._ui(DDManager.dragElement));
|
|
122
|
-
}
|
|
123
|
-
this.triggerEvent('drop', ev);
|
|
124
|
-
}
|
|
125
|
-
/** @internal true if element matches the string/method accept option */
|
|
126
|
-
_canDrop(el) {
|
|
127
|
-
return el && (!this.accept || this.accept(el));
|
|
128
|
-
}
|
|
129
|
-
/** @internal */
|
|
130
|
-
_setupAccept() {
|
|
131
|
-
if (!this.option.accept)
|
|
132
|
-
return this;
|
|
133
|
-
if (typeof this.option.accept === 'string') {
|
|
134
|
-
this.accept = (el) => el.classList.contains(this.option.accept) || el.matches(this.option.accept);
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
this.accept = this.option.accept;
|
|
138
|
-
}
|
|
139
|
-
return this;
|
|
140
|
-
}
|
|
141
|
-
/** @internal */
|
|
142
|
-
_ui(drag) {
|
|
143
|
-
return {
|
|
144
|
-
draggable: drag.el,
|
|
145
|
-
...drag.ui()
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
//# sourceMappingURL=dd-droppable.js.map
|
package/dist/dd-droppable.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dd-droppable.js","sourceRoot":"","sources":["../src/dd-droppable.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,eAAe,EAAwB,MAAM,gBAAgB,CAAC;AACvE,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,OAA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;SACtD;QACD,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAChC,CAAC;IAED,wEAAwE;IAC9D,QAAQ,CAAC,EAAe;QAChC,OAAO,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;IACjD,CAAC;IAED,gBAAgB;IACN,YAAY;QACpB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM;YAAE,OAAO,IAAI,CAAC;QACrC,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,QAAQ,EAAE;YAC1C,IAAI,CAAC,MAAM,GAAG,CAAC,EAAe,EAAE,EAAE,CAAC,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,MAAgB,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,MAAgB,CAAC,CAAC;SACpI;aAAM;YACL,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;SAClC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,gBAAgB;IACN,GAAG,CAAC,IAAiB;QAC7B,OAAO;YACL,SAAS,EAAE,IAAI,CAAC,EAAE;YAClB,GAAG,IAAI,CAAC,EAAE,EAAE;SACb,CAAC;IACJ,CAAC;CACF","sourcesContent":["/**\n * dd-droppable.ts 12.3.2\n * Copyright (c) 2021-2025 Alain Dumesny - see GridStack root license\n */\n\nimport { DDDraggable } from './dd-draggable';\nimport { DDManager } from './dd-manager';\nimport { DDBaseImplement, HTMLElementExtendOpt } from './dd-base-impl';\nimport { Utils } from './utils';\nimport { DDElementHost } from './dd-element';\nimport { isTouch, pointerenter, pointerleave } from './dd-touch';\nimport { DDUIData } from './types';\n\nexport interface DDDroppableOpt {\n accept?: string | ((el: HTMLElement) => boolean);\n drop?: (event: DragEvent, ui: DDUIData) => void;\n over?: (event: DragEvent, ui: DDUIData) => void;\n out?: (event: DragEvent, ui: DDUIData) => void;\n}\n\n// let count = 0; // TEST\n\nexport class DDDroppable extends DDBaseImplement implements HTMLElementExtendOpt<DDDroppableOpt> {\n\n public accept: (el: HTMLElement) => boolean;\n\n constructor(public el: HTMLElement, public option: DDDroppableOpt = {}) {\n super();\n // create var event binding so we can easily remove and still look like TS methods (unlike anonymous functions)\n this._mouseEnter = this._mouseEnter.bind(this);\n this._mouseLeave = this._mouseLeave.bind(this);\n this.enable();\n this._setupAccept();\n }\n\n public on(event: 'drop' | 'dropover' | 'dropout', callback: (event: DragEvent) => void): void {\n super.on(event, callback);\n }\n\n public off(event: 'drop' | 'dropover' | 'dropout'): void {\n super.off(event);\n }\n\n public enable(): void {\n if (this.disabled === false) return;\n super.enable();\n this.el.classList.add('ui-droppable');\n this.el.classList.remove('ui-droppable-disabled');\n this.el.addEventListener('mouseenter', this._mouseEnter);\n this.el.addEventListener('mouseleave', this._mouseLeave);\n if (isTouch) {\n this.el.addEventListener('pointerenter', pointerenter);\n this.el.addEventListener('pointerleave', pointerleave);\n }\n }\n\n public disable(forDestroy = false): void {\n if (this.disabled === true) return;\n super.disable();\n this.el.classList.remove('ui-droppable');\n if (!forDestroy) this.el.classList.add('ui-droppable-disabled');\n this.el.removeEventListener('mouseenter', this._mouseEnter);\n this.el.removeEventListener('mouseleave', this._mouseLeave);\n if (isTouch) {\n this.el.removeEventListener('pointerenter', pointerenter);\n this.el.removeEventListener('pointerleave', pointerleave);\n }\n }\n\n public destroy(): void {\n this.disable(true);\n this.el.classList.remove('ui-droppable');\n this.el.classList.remove('ui-droppable-disabled');\n super.destroy();\n }\n\n public updateOption(opts: DDDroppableOpt): DDDroppable {\n Object.keys(opts).forEach(key => this.option[key] = opts[key]);\n this._setupAccept();\n return this;\n }\n\n /** @internal called when the cursor enters our area - prepare for a possible drop and track leaving */\n protected _mouseEnter(e: MouseEvent): void {\n // console.log(`${count++} Enter ${this.el.id || (this.el as GridHTMLElement).gridstack.opts.id}`); // TEST\n if (!DDManager.dragElement) return;\n if (!this._canDrop(DDManager.dragElement.el)) return;\n e.preventDefault();\n e.stopPropagation();\n\n // make sure when we enter this, that the last one gets a leave FIRST to correctly cleanup as we don't always do\n if (DDManager.dropElement && DDManager.dropElement !== this) {\n DDManager.dropElement._mouseLeave(e as DragEvent, true); // calledByEnter = true\n }\n DDManager.dropElement = this;\n\n const ev = Utils.initEvent<DragEvent>(e, { target: this.el, type: 'dropover' });\n if (this.option.over) {\n this.option.over(ev, this._ui(DDManager.dragElement))\n }\n this.triggerEvent('dropover', ev);\n this.el.classList.add('ui-droppable-over');\n // console.log('tracking'); // TEST\n }\n\n /** @internal called when the item is leaving our area, stop tracking if we had moving item */\n protected _mouseLeave(e: MouseEvent, calledByEnter = false): void {\n // console.log(`${count++} Leave ${this.el.id || (this.el as GridHTMLElement).gridstack.opts.id}`); // TEST\n if (!DDManager.dragElement || DDManager.dropElement !== this) return;\n e.preventDefault();\n e.stopPropagation();\n\n const ev = Utils.initEvent<DragEvent>(e, { target: this.el, type: 'dropout' });\n if (this.option.out) {\n this.option.out(ev, this._ui(DDManager.dragElement))\n }\n this.triggerEvent('dropout', ev);\n\n if (DDManager.dropElement === this) {\n delete DDManager.dropElement;\n // console.log('not tracking'); // TEST\n\n // if we're still over a parent droppable, send it an enter as we don't get one from leaving nested children\n if (!calledByEnter) {\n let parentDrop: DDDroppable;\n let parent: DDElementHost = this.el.parentElement;\n while (!parentDrop && parent) {\n parentDrop = parent.ddElement?.ddDroppable;\n parent = parent.parentElement;\n }\n if (parentDrop) {\n parentDrop._mouseEnter(e);\n }\n }\n }\n }\n\n /** item is being dropped on us - called by the drag mouseup handler - this calls the client drop event */\n public drop(e: MouseEvent): void {\n e.preventDefault();\n const ev = Utils.initEvent<DragEvent>(e, { target: this.el, type: 'drop' });\n if (this.option.drop) {\n this.option.drop(ev, this._ui(DDManager.dragElement))\n }\n this.triggerEvent('drop', ev);\n }\n\n /** @internal true if element matches the string/method accept option */\n protected _canDrop(el: HTMLElement): boolean {\n return el && (!this.accept || this.accept(el));\n }\n\n /** @internal */\n protected _setupAccept(): DDDroppable {\n if (!this.option.accept) return this;\n if (typeof this.option.accept === 'string') {\n this.accept = (el: HTMLElement) => el.classList.contains(this.option.accept as string) || el.matches(this.option.accept as string);\n } else {\n this.accept = this.option.accept;\n }\n return this;\n }\n\n /** @internal */\n protected _ui(drag: DDDraggable): DDUIData {\n return {\n draggable: drag.el,\n ...drag.ui()\n };\n }\n}\n\n"]}
|
package/dist/dd-element.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* dd-elements.ts 12.3.2
|
|
3
|
-
* Copyright (c) 2021-2025 Alain Dumesny - see GridStack root license
|
|
4
|
-
*/
|
|
5
|
-
import { DDResizable, DDResizableOpt } from './dd-resizable';
|
|
6
|
-
import { DDDragOpt, GridItemHTMLElement } from './types';
|
|
7
|
-
import { DDDraggable } from './dd-draggable';
|
|
8
|
-
import { DDDroppable, DDDroppableOpt } from './dd-droppable';
|
|
9
|
-
export interface DDElementHost extends GridItemHTMLElement {
|
|
10
|
-
ddElement?: DDElement;
|
|
11
|
-
}
|
|
12
|
-
export declare class DDElement {
|
|
13
|
-
el: DDElementHost;
|
|
14
|
-
static init(el: DDElementHost): DDElement;
|
|
15
|
-
ddDraggable?: DDDraggable;
|
|
16
|
-
ddDroppable?: DDDroppable;
|
|
17
|
-
ddResizable?: DDResizable;
|
|
18
|
-
constructor(el: DDElementHost);
|
|
19
|
-
on(eventName: string, callback: (event: MouseEvent) => void): DDElement;
|
|
20
|
-
off(eventName: string): DDElement;
|
|
21
|
-
setupDraggable(opts: DDDragOpt): DDElement;
|
|
22
|
-
cleanDraggable(): DDElement;
|
|
23
|
-
setupResizable(opts: DDResizableOpt): DDElement;
|
|
24
|
-
cleanResizable(): DDElement;
|
|
25
|
-
setupDroppable(opts: DDDroppableOpt): DDElement;
|
|
26
|
-
cleanDroppable(): DDElement;
|
|
27
|
-
}
|
package/dist/dd-element.js
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* dd-elements.ts 12.3.2
|
|
3
|
-
* Copyright (c) 2021-2025 Alain Dumesny - see GridStack root license
|
|
4
|
-
*/
|
|
5
|
-
import { DDResizable } from './dd-resizable';
|
|
6
|
-
import { DDDraggable } from './dd-draggable';
|
|
7
|
-
import { DDDroppable } from './dd-droppable';
|
|
8
|
-
export class DDElement {
|
|
9
|
-
static init(el) {
|
|
10
|
-
if (!el.ddElement) {
|
|
11
|
-
el.ddElement = new DDElement(el);
|
|
12
|
-
}
|
|
13
|
-
return el.ddElement;
|
|
14
|
-
}
|
|
15
|
-
constructor(el) {
|
|
16
|
-
this.el = el;
|
|
17
|
-
}
|
|
18
|
-
on(eventName, callback) {
|
|
19
|
-
if (this.ddDraggable && ['drag', 'dragstart', 'dragstop'].indexOf(eventName) > -1) {
|
|
20
|
-
this.ddDraggable.on(eventName, callback);
|
|
21
|
-
}
|
|
22
|
-
else if (this.ddDroppable && ['drop', 'dropover', 'dropout'].indexOf(eventName) > -1) {
|
|
23
|
-
this.ddDroppable.on(eventName, callback);
|
|
24
|
-
}
|
|
25
|
-
else if (this.ddResizable && ['resizestart', 'resize', 'resizestop'].indexOf(eventName) > -1) {
|
|
26
|
-
this.ddResizable.on(eventName, callback);
|
|
27
|
-
}
|
|
28
|
-
return this;
|
|
29
|
-
}
|
|
30
|
-
off(eventName) {
|
|
31
|
-
if (this.ddDraggable && ['drag', 'dragstart', 'dragstop'].indexOf(eventName) > -1) {
|
|
32
|
-
this.ddDraggable.off(eventName);
|
|
33
|
-
}
|
|
34
|
-
else if (this.ddDroppable && ['drop', 'dropover', 'dropout'].indexOf(eventName) > -1) {
|
|
35
|
-
this.ddDroppable.off(eventName);
|
|
36
|
-
}
|
|
37
|
-
else if (this.ddResizable && ['resizestart', 'resize', 'resizestop'].indexOf(eventName) > -1) {
|
|
38
|
-
this.ddResizable.off(eventName);
|
|
39
|
-
}
|
|
40
|
-
return this;
|
|
41
|
-
}
|
|
42
|
-
setupDraggable(opts) {
|
|
43
|
-
if (!this.ddDraggable) {
|
|
44
|
-
this.ddDraggable = new DDDraggable(this.el, opts);
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
this.ddDraggable.updateOption(opts);
|
|
48
|
-
}
|
|
49
|
-
return this;
|
|
50
|
-
}
|
|
51
|
-
cleanDraggable() {
|
|
52
|
-
if (this.ddDraggable) {
|
|
53
|
-
this.ddDraggable.destroy();
|
|
54
|
-
delete this.ddDraggable;
|
|
55
|
-
}
|
|
56
|
-
return this;
|
|
57
|
-
}
|
|
58
|
-
setupResizable(opts) {
|
|
59
|
-
if (!this.ddResizable) {
|
|
60
|
-
this.ddResizable = new DDResizable(this.el, opts);
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
this.ddResizable.updateOption(opts);
|
|
64
|
-
}
|
|
65
|
-
return this;
|
|
66
|
-
}
|
|
67
|
-
cleanResizable() {
|
|
68
|
-
if (this.ddResizable) {
|
|
69
|
-
this.ddResizable.destroy();
|
|
70
|
-
delete this.ddResizable;
|
|
71
|
-
}
|
|
72
|
-
return this;
|
|
73
|
-
}
|
|
74
|
-
setupDroppable(opts) {
|
|
75
|
-
if (!this.ddDroppable) {
|
|
76
|
-
this.ddDroppable = new DDDroppable(this.el, opts);
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
this.ddDroppable.updateOption(opts);
|
|
80
|
-
}
|
|
81
|
-
return this;
|
|
82
|
-
}
|
|
83
|
-
cleanDroppable() {
|
|
84
|
-
if (this.ddDroppable) {
|
|
85
|
-
this.ddDroppable.destroy();
|
|
86
|
-
delete this.ddDroppable;
|
|
87
|
-
}
|
|
88
|
-
return this;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
//# sourceMappingURL=dd-element.js.map
|
package/dist/dd-element.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{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I,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;SACnD;aAAM;YACL,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;SACrC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,cAAc;QACnB,IAAI,IAAI,CAAC,WAAW,EAAE;YACpB,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;YAC3B,OAAO,IAAI,CAAC,WAAW,CAAC;SACzB;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,cAAc,CAAC,IAAoB;QACxC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACrB,IAAI,CAAC,WAAW,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;SACnD;aAAM;YACL,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;SACrC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,cAAc;QACnB,IAAI,IAAI,CAAC,WAAW,EAAE;YACpB,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;YAC3B,OAAO,IAAI,CAAC,WAAW,CAAC;SACzB;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["/**\n * dd-elements.ts 12.3.2\n * Copyright (c) 2021-2025 Alain Dumesny - see GridStack root license\n */\n\nimport { DDResizable, DDResizableOpt } from './dd-resizable';\nimport { DDDragOpt, GridItemHTMLElement } from './types';\nimport { DDDraggable } from './dd-draggable';\nimport { DDDroppable, DDDroppableOpt } from './dd-droppable';\n\nexport interface DDElementHost extends GridItemHTMLElement {\n ddElement?: DDElement;\n}\n\nexport class DDElement {\n\n static init(el: DDElementHost): DDElement {\n if (!el.ddElement) { el.ddElement = new DDElement(el); }\n return el.ddElement;\n }\n\n public ddDraggable?: DDDraggable;\n public ddDroppable?: DDDroppable;\n public ddResizable?: DDResizable;\n\n constructor(public el: DDElementHost) {}\n\n public on(eventName: string, callback: (event: MouseEvent) => void): DDElement {\n if (this.ddDraggable && ['drag', 'dragstart', 'dragstop'].indexOf(eventName) > -1) {\n this.ddDraggable.on(eventName as 'drag' | 'dragstart' | 'dragstop', callback);\n } else if (this.ddDroppable && ['drop', 'dropover', 'dropout'].indexOf(eventName) > -1) {\n this.ddDroppable.on(eventName as 'drop' | 'dropover' | 'dropout', callback);\n } else if (this.ddResizable && ['resizestart', 'resize', 'resizestop'].indexOf(eventName) > -1) {\n this.ddResizable.on(eventName as 'resizestart' | 'resize' | 'resizestop', callback);\n }\n return this;\n }\n\n public off(eventName: string): DDElement {\n if (this.ddDraggable && ['drag', 'dragstart', 'dragstop'].indexOf(eventName) > -1) {\n this.ddDraggable.off(eventName as 'drag' | 'dragstart' | 'dragstop');\n } else if (this.ddDroppable && ['drop', 'dropover', 'dropout'].indexOf(eventName) > -1) {\n this.ddDroppable.off(eventName as 'drop' | 'dropover' | 'dropout');\n } else if (this.ddResizable && ['resizestart', 'resize', 'resizestop'].indexOf(eventName) > -1) {\n this.ddResizable.off(eventName as 'resizestart' | 'resize' | 'resizestop');\n }\n return this;\n }\n\n public setupDraggable(opts: DDDragOpt): DDElement {\n if (!this.ddDraggable) {\n this.ddDraggable = new DDDraggable(this.el, opts);\n } else {\n this.ddDraggable.updateOption(opts);\n }\n return this;\n }\n\n public cleanDraggable(): DDElement {\n if (this.ddDraggable) {\n this.ddDraggable.destroy();\n delete this.ddDraggable;\n }\n return this;\n }\n\n public setupResizable(opts: DDResizableOpt): DDElement {\n if (!this.ddResizable) {\n this.ddResizable = new DDResizable(this.el, opts);\n } else {\n this.ddResizable.updateOption(opts);\n }\n return this;\n }\n\n public cleanResizable(): DDElement {\n if (this.ddResizable) {\n this.ddResizable.destroy();\n delete this.ddResizable;\n }\n return this;\n }\n\n public setupDroppable(opts: DDDroppableOpt): DDElement {\n if (!this.ddDroppable) {\n this.ddDroppable = new DDDroppable(this.el, opts);\n } else {\n this.ddDroppable.updateOption(opts);\n }\n return this;\n }\n\n public cleanDroppable(): DDElement {\n if (this.ddDroppable) {\n this.ddDroppable.destroy();\n delete this.ddDroppable;\n }\n return this;\n }\n}\n"]}
|
package/dist/dd-gridstack.d.ts
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* dd-gridstack.ts 12.3.2
|
|
3
|
-
* Copyright (c) 2021-2025 Alain Dumesny - see GridStack root license
|
|
4
|
-
*/
|
|
5
|
-
import { GridItemHTMLElement, GridStackElement, DDDragOpt } from './types';
|
|
6
|
-
import { DDElementHost } from './dd-element';
|
|
7
|
-
/**
|
|
8
|
-
* Drag & Drop options for drop targets.
|
|
9
|
-
* Configures which elements can be dropped onto a grid.
|
|
10
|
-
*/
|
|
11
|
-
export type DDDropOpt = {
|
|
12
|
-
/** Function to determine if an element can be dropped (see GridStackOptions.acceptWidgets) */
|
|
13
|
-
accept?: (el: GridItemHTMLElement) => boolean;
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Drag & Drop operation types used throughout the DD system.
|
|
17
|
-
* Can be control commands or configuration objects.
|
|
18
|
-
*/
|
|
19
|
-
export type DDOpts = 'enable' | 'disable' | 'destroy' | 'option' | string | any;
|
|
20
|
-
/**
|
|
21
|
-
* Keys for DD configuration options that can be set via the 'option' command.
|
|
22
|
-
*/
|
|
23
|
-
export type DDKey = 'minWidth' | 'minHeight' | 'maxWidth' | 'maxHeight' | 'maxHeightMoveUp' | 'maxWidthMoveLeft';
|
|
24
|
-
/**
|
|
25
|
-
* Values for DD configuration options (numbers or strings with units).
|
|
26
|
-
*/
|
|
27
|
-
export type DDValue = number | string;
|
|
28
|
-
/**
|
|
29
|
-
* Callback function type for drag & drop events.
|
|
30
|
-
*
|
|
31
|
-
* @param event - The DOM event that triggered the callback
|
|
32
|
-
* @param arg2 - The grid item element being dragged/dropped
|
|
33
|
-
* @param helper - Optional helper element used during drag operations
|
|
34
|
-
*/
|
|
35
|
-
export type DDCallback = (event: Event, arg2: GridItemHTMLElement, helper?: GridItemHTMLElement) => void;
|
|
36
|
-
/**
|
|
37
|
-
* HTML Native Mouse and Touch Events Drag and Drop functionality.
|
|
38
|
-
*
|
|
39
|
-
* This class provides the main drag & drop implementation for GridStack,
|
|
40
|
-
* handling resizing, dragging, and dropping of grid items using native HTML5 events.
|
|
41
|
-
* It manages the interaction between different DD components and the grid system.
|
|
42
|
-
*/
|
|
43
|
-
export declare class DDGridStack {
|
|
44
|
-
/**
|
|
45
|
-
* Enable/disable/configure resizing for grid elements.
|
|
46
|
-
*
|
|
47
|
-
* @param el - Grid item element(s) to configure
|
|
48
|
-
* @param opts - Resize options or command ('enable', 'disable', 'destroy', 'option', or config object)
|
|
49
|
-
* @param key - Option key when using 'option' command
|
|
50
|
-
* @param value - Option value when using 'option' command
|
|
51
|
-
* @returns this instance for chaining
|
|
52
|
-
*
|
|
53
|
-
* @example
|
|
54
|
-
* dd.resizable(element, 'enable'); // Enable resizing
|
|
55
|
-
* dd.resizable(element, 'option', 'minWidth', 100); // Set minimum width
|
|
56
|
-
*/
|
|
57
|
-
resizable(el: GridItemHTMLElement, opts: DDOpts, key?: DDKey, value?: DDValue): DDGridStack;
|
|
58
|
-
/**
|
|
59
|
-
* Enable/disable/configure dragging for grid elements.
|
|
60
|
-
*
|
|
61
|
-
* @param el - Grid item element(s) to configure
|
|
62
|
-
* @param opts - Drag options or command ('enable', 'disable', 'destroy', 'option', or config object)
|
|
63
|
-
* @param key - Option key when using 'option' command
|
|
64
|
-
* @param value - Option value when using 'option' command
|
|
65
|
-
* @returns this instance for chaining
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* dd.draggable(element, 'enable'); // Enable dragging
|
|
69
|
-
* dd.draggable(element, {handle: '.drag-handle'}); // Configure drag handle
|
|
70
|
-
*/
|
|
71
|
-
draggable(el: GridItemHTMLElement, opts: DDOpts, key?: DDKey, value?: DDValue): DDGridStack;
|
|
72
|
-
dragIn(el: GridStackElement, opts: DDDragOpt): DDGridStack;
|
|
73
|
-
droppable(el: GridItemHTMLElement, opts: DDOpts | DDDropOpt, key?: DDKey, value?: DDValue): DDGridStack;
|
|
74
|
-
/** true if element is droppable */
|
|
75
|
-
isDroppable(el: DDElementHost): boolean;
|
|
76
|
-
/** true if element is draggable */
|
|
77
|
-
isDraggable(el: DDElementHost): boolean;
|
|
78
|
-
/** true if element is draggable */
|
|
79
|
-
isResizable(el: DDElementHost): boolean;
|
|
80
|
-
on(el: GridItemHTMLElement, name: string, callback: DDCallback): DDGridStack;
|
|
81
|
-
off(el: GridItemHTMLElement, name: string): DDGridStack;
|
|
82
|
-
}
|
package/dist/dd-gridstack.js
DELETED
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* dd-gridstack.ts 12.3.2
|
|
3
|
-
* Copyright (c) 2021-2025 Alain Dumesny - see GridStack root license
|
|
4
|
-
*/
|
|
5
|
-
import { Utils } from './utils';
|
|
6
|
-
import { DDManager } from './dd-manager';
|
|
7
|
-
import { DDElement } from './dd-element';
|
|
8
|
-
// let count = 0; // TEST
|
|
9
|
-
/**
|
|
10
|
-
* HTML Native Mouse and Touch Events Drag and Drop functionality.
|
|
11
|
-
*
|
|
12
|
-
* This class provides the main drag & drop implementation for GridStack,
|
|
13
|
-
* handling resizing, dragging, and dropping of grid items using native HTML5 events.
|
|
14
|
-
* It manages the interaction between different DD components and the grid system.
|
|
15
|
-
*/
|
|
16
|
-
export class DDGridStack {
|
|
17
|
-
/**
|
|
18
|
-
* Enable/disable/configure resizing for grid elements.
|
|
19
|
-
*
|
|
20
|
-
* @param el - Grid item element(s) to configure
|
|
21
|
-
* @param opts - Resize options or command ('enable', 'disable', 'destroy', 'option', or config object)
|
|
22
|
-
* @param key - Option key when using 'option' command
|
|
23
|
-
* @param value - Option value when using 'option' command
|
|
24
|
-
* @returns this instance for chaining
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* dd.resizable(element, 'enable'); // Enable resizing
|
|
28
|
-
* dd.resizable(element, 'option', 'minWidth', 100); // Set minimum width
|
|
29
|
-
*/
|
|
30
|
-
resizable(el, opts, key, value) {
|
|
31
|
-
this._getDDElements(el, opts).forEach(dEl => {
|
|
32
|
-
if (opts === 'disable' || opts === 'enable') {
|
|
33
|
-
dEl.ddResizable && dEl.ddResizable[opts](); // can't create DD as it requires options for setupResizable()
|
|
34
|
-
}
|
|
35
|
-
else if (opts === 'destroy') {
|
|
36
|
-
dEl.ddResizable && dEl.cleanResizable();
|
|
37
|
-
}
|
|
38
|
-
else if (opts === 'option') {
|
|
39
|
-
dEl.setupResizable({ [key]: value });
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
const n = dEl.el.gridstackNode;
|
|
43
|
-
const grid = n.grid;
|
|
44
|
-
let handles = dEl.el.getAttribute('gs-resize-handles') || grid.opts.resizable.handles || 'e,s,se';
|
|
45
|
-
if (handles === 'all')
|
|
46
|
-
handles = 'n,e,s,w,se,sw,ne,nw';
|
|
47
|
-
// NOTE: keep the resize handles as e,w don't have enough space (10px) to show resize corners anyway. limit during drag instead
|
|
48
|
-
// restrict vertical resize if height is done to match content anyway... odd to have it spring back
|
|
49
|
-
// if (Utils.shouldSizeToContent(n, true)) {
|
|
50
|
-
// const doE = handles.indexOf('e') !== -1;
|
|
51
|
-
// const doW = handles.indexOf('w') !== -1;
|
|
52
|
-
// handles = doE ? (doW ? 'e,w' : 'e') : (doW ? 'w' : '');
|
|
53
|
-
// }
|
|
54
|
-
const autoHide = !grid.opts.alwaysShowResizeHandle;
|
|
55
|
-
dEl.setupResizable({
|
|
56
|
-
...grid.opts.resizable,
|
|
57
|
-
...{ handles, autoHide },
|
|
58
|
-
...{
|
|
59
|
-
start: opts.start,
|
|
60
|
-
stop: opts.stop,
|
|
61
|
-
resize: opts.resize
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
return this;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Enable/disable/configure dragging for grid elements.
|
|
70
|
-
*
|
|
71
|
-
* @param el - Grid item element(s) to configure
|
|
72
|
-
* @param opts - Drag options or command ('enable', 'disable', 'destroy', 'option', or config object)
|
|
73
|
-
* @param key - Option key when using 'option' command
|
|
74
|
-
* @param value - Option value when using 'option' command
|
|
75
|
-
* @returns this instance for chaining
|
|
76
|
-
*
|
|
77
|
-
* @example
|
|
78
|
-
* dd.draggable(element, 'enable'); // Enable dragging
|
|
79
|
-
* dd.draggable(element, {handle: '.drag-handle'}); // Configure drag handle
|
|
80
|
-
*/
|
|
81
|
-
draggable(el, opts, key, value) {
|
|
82
|
-
this._getDDElements(el, opts).forEach(dEl => {
|
|
83
|
-
if (opts === 'disable' || opts === 'enable') {
|
|
84
|
-
dEl.ddDraggable && dEl.ddDraggable[opts](); // can't create DD as it requires options for setupDraggable()
|
|
85
|
-
}
|
|
86
|
-
else if (opts === 'destroy') {
|
|
87
|
-
dEl.ddDraggable && dEl.cleanDraggable();
|
|
88
|
-
}
|
|
89
|
-
else if (opts === 'option') {
|
|
90
|
-
dEl.setupDraggable({ [key]: value });
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
const grid = dEl.el.gridstackNode.grid;
|
|
94
|
-
dEl.setupDraggable({
|
|
95
|
-
...grid.opts.draggable,
|
|
96
|
-
...{
|
|
97
|
-
// containment: (grid.parentGridNode && grid.opts.dragOut === false) ? grid.el.parentElement : (grid.opts.draggable.containment || null),
|
|
98
|
-
start: opts.start,
|
|
99
|
-
stop: opts.stop,
|
|
100
|
-
drag: opts.drag
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
return this;
|
|
106
|
-
}
|
|
107
|
-
dragIn(el, opts) {
|
|
108
|
-
this._getDDElements(el).forEach(dEl => dEl.setupDraggable(opts));
|
|
109
|
-
return this;
|
|
110
|
-
}
|
|
111
|
-
droppable(el, opts, key, value) {
|
|
112
|
-
if (typeof opts.accept === 'function' && !opts._accept) {
|
|
113
|
-
opts._accept = opts.accept;
|
|
114
|
-
opts.accept = (el) => opts._accept(el);
|
|
115
|
-
}
|
|
116
|
-
this._getDDElements(el, opts).forEach(dEl => {
|
|
117
|
-
if (opts === 'disable' || opts === 'enable') {
|
|
118
|
-
dEl.ddDroppable && dEl.ddDroppable[opts]();
|
|
119
|
-
}
|
|
120
|
-
else if (opts === 'destroy') {
|
|
121
|
-
dEl.ddDroppable && dEl.cleanDroppable();
|
|
122
|
-
}
|
|
123
|
-
else if (opts === 'option') {
|
|
124
|
-
dEl.setupDroppable({ [key]: value });
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
dEl.setupDroppable(opts);
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
return this;
|
|
131
|
-
}
|
|
132
|
-
/** true if element is droppable */
|
|
133
|
-
isDroppable(el) {
|
|
134
|
-
return !!(el?.ddElement?.ddDroppable && !el.ddElement.ddDroppable.disabled);
|
|
135
|
-
}
|
|
136
|
-
/** true if element is draggable */
|
|
137
|
-
isDraggable(el) {
|
|
138
|
-
return !!(el?.ddElement?.ddDraggable && !el.ddElement.ddDraggable.disabled);
|
|
139
|
-
}
|
|
140
|
-
/** true if element is draggable */
|
|
141
|
-
isResizable(el) {
|
|
142
|
-
return !!(el?.ddElement?.ddResizable && !el.ddElement.ddResizable.disabled);
|
|
143
|
-
}
|
|
144
|
-
on(el, name, callback) {
|
|
145
|
-
this._getDDElements(el).forEach(dEl => dEl.on(name, (event) => {
|
|
146
|
-
callback(event, DDManager.dragElement ? DDManager.dragElement.el : event.target, DDManager.dragElement ? DDManager.dragElement.helper : null);
|
|
147
|
-
}));
|
|
148
|
-
return this;
|
|
149
|
-
}
|
|
150
|
-
off(el, name) {
|
|
151
|
-
this._getDDElements(el).forEach(dEl => dEl.off(name));
|
|
152
|
-
return this;
|
|
153
|
-
}
|
|
154
|
-
/** @internal returns a list of DD elements, creating them on the fly by default unless option is to destroy or disable */
|
|
155
|
-
_getDDElements(els, opts) {
|
|
156
|
-
// don't force create if we're going to destroy it, unless it's a grid which is used as drop target for it's children
|
|
157
|
-
const create = els.gridstack || opts !== 'destroy' && opts !== 'disable';
|
|
158
|
-
const hosts = Utils.getElements(els);
|
|
159
|
-
if (!hosts.length)
|
|
160
|
-
return [];
|
|
161
|
-
const list = hosts.map(e => e.ddElement || (create ? DDElement.init(e) : null)).filter(d => d); // remove nulls
|
|
162
|
-
return list;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
//# sourceMappingURL=dd-gridstack.js.map
|
package/dist/dd-gridstack.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dd-gridstack.js","sourceRoot":"","sources":["../src/dd-gridstack.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,SAAS,EAAiB,MAAM,cAAc,CAAC;AAsCxD,yBAAyB;AAEzB;;;;;;GAMG;AACH,MAAM,OAAO,WAAW;IAEtB;;;;;;;;;;;;OAYG;IACI,SAAS,CAAC,EAAuB,EAAE,IAAY,EAAE,GAAW,EAAE,KAAe;QAClF,IAAI,CAAC,cAAc,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YAC1C,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,QAAQ,EAAE;gBAC3C,GAAG,CAAC,WAAW,IAAI,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,8DAA8D;aAC3G;iBAAM,IAAI,IAAI,KAAK,SAAS,EAAE;gBAC7B,GAAG,CAAC,WAAW,IAAI,GAAG,CAAC,cAAc,EAAE,CAAC;aACzC;iBAAM,IAAI,IAAI,KAAK,QAAQ,EAAE;gBAC5B,GAAG,CAAC,cAAc,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KA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,EACL,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,MAA6B,EACtF,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;QAChE,CAAC,CAAC,CACH,CAAC;QACF,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,GAAG,CAAC,EAAuB,EAAE,IAAY;QAC9C,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;QACtD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,0HAA0H;IAChH,cAAc,CAAC,GAAqB,EAAE,IAAa;QAC3D,qHAAqH;QACrH,MAAM,MAAM,GAAI,GAAuB,CAAC,SAAS,IAAK,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,SAAS,CAAC;QAC/F,MAAM,KAAK,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,CAAoB,CAAC;QACxD,IAAI,CAAC,KAAK,CAAC,MAAM;YAAE,OAAO,EAAE,CAAC;QAC7B,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,eAAe;QAC/G,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["/**\r\n * dd-gridstack.ts 12.3.2\r\n * Copyright (c) 2021-2025 Alain Dumesny - see GridStack root license\r\n */\r\n\r\n/* eslint-disable @typescript-eslint/no-unused-vars */\r\nimport { GridItemHTMLElement, GridStackElement, DDDragOpt } from './types';\r\nimport { Utils } from './utils';\r\nimport { DDManager } from './dd-manager';\r\nimport { DDElement, DDElementHost } from './dd-element';\r\nimport { GridHTMLElement } from './gridstack';\r\n\r\n/**\r\n * Drag & Drop options for drop targets.\r\n * Configures which elements can be dropped onto a grid.\r\n */\r\nexport type DDDropOpt = {\r\n /** Function to determine if an element can be dropped (see GridStackOptions.acceptWidgets) */\r\n accept?: (el: GridItemHTMLElement) => boolean;\r\n}\r\n\r\n/**\r\n * Drag & Drop operation types used throughout the DD system.\r\n * Can be control commands or configuration objects.\r\n */\r\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\r\nexport type DDOpts = 'enable' | 'disable' | 'destroy' | 'option' | string | any;\r\n\r\n/**\r\n * Keys for DD configuration options that can be set via the 'option' command.\r\n */\r\nexport type DDKey = 'minWidth' | 'minHeight' | 'maxWidth' | 'maxHeight' | 'maxHeightMoveUp' | 'maxWidthMoveLeft';\r\n\r\n/**\r\n * Values for DD configuration options (numbers or strings with units).\r\n */\r\nexport type DDValue = number | string;\r\n\r\n/**\r\n * Callback function type for drag & drop events.\r\n * \r\n * @param event - The DOM event that triggered the callback\r\n * @param arg2 - The grid item element being dragged/dropped\r\n * @param helper - Optional helper element used during drag operations\r\n */\r\nexport type DDCallback = (event: Event, arg2: GridItemHTMLElement, helper?: GridItemHTMLElement) => void;\r\n\r\n// let count = 0; // TEST\r\n\r\n/**\r\n * HTML Native Mouse and Touch Events Drag and Drop functionality.\r\n * \r\n * This class provides the main drag & drop implementation for GridStack,\r\n * handling resizing, dragging, and dropping of grid items using native HTML5 events.\r\n * It manages the interaction between different DD components and the grid system.\r\n */\r\nexport class DDGridStack {\r\n\r\n /**\r\n * Enable/disable/configure resizing for grid elements.\r\n * \r\n * @param el - Grid item element(s) to configure\r\n * @param opts - Resize options or command ('enable', 'disable', 'destroy', 'option', or config object)\r\n * @param key - Option key when using 'option' command\r\n * @param value - Option value when using 'option' command\r\n * @returns this instance for chaining\r\n * \r\n * @example\r\n * dd.resizable(element, 'enable'); // Enable resizing\r\n * dd.resizable(element, 'option', 'minWidth', 100); // Set minimum width\r\n */\r\n public resizable(el: GridItemHTMLElement, opts: DDOpts, key?: DDKey, value?: DDValue): DDGridStack {\r\n this._getDDElements(el, opts).forEach(dEl => {\r\n if (opts === 'disable' || opts === 'enable') {\r\n dEl.ddResizable && dEl.ddResizable[opts](); // can't create DD as it requires options for setupResizable()\r\n } else if (opts === 'destroy') {\r\n dEl.ddResizable && dEl.cleanResizable();\r\n } else if (opts === 'option') {\r\n dEl.setupResizable({ [key]: value });\r\n } else {\r\n const n = dEl.el.gridstackNode;\r\n const grid = n.grid;\r\n let handles = dEl.el.getAttribute('gs-resize-handles') || grid.opts.resizable.handles || 'e,s,se';\r\n if (handles === 'all') handles = 'n,e,s,w,se,sw,ne,nw';\r\n // NOTE: keep the resize handles as e,w don't have enough space (10px) to show resize corners anyway. limit during drag instead\r\n // restrict vertical resize if height is done to match content anyway... odd to have it spring back\r\n // if (Utils.shouldSizeToContent(n, true)) {\r\n // const doE = handles.indexOf('e') !== -1;\r\n // const doW = handles.indexOf('w') !== -1;\r\n // handles = doE ? (doW ? 'e,w' : 'e') : (doW ? 'w' : '');\r\n // }\r\n const autoHide = !grid.opts.alwaysShowResizeHandle;\r\n dEl.setupResizable({\r\n ...grid.opts.resizable,\r\n ...{ handles, autoHide },\r\n ...{\r\n start: opts.start,\r\n stop: opts.stop,\r\n resize: opts.resize\r\n }\r\n });\r\n }\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Enable/disable/configure dragging for grid elements.\r\n * \r\n * @param el - Grid item element(s) to configure\r\n * @param opts - Drag options or command ('enable', 'disable', 'destroy', 'option', or config object)\r\n * @param key - Option key when using 'option' command\r\n * @param value - Option value when using 'option' command\r\n * @returns this instance for chaining\r\n * \r\n * @example\r\n * dd.draggable(element, 'enable'); // Enable dragging\r\n * dd.draggable(element, {handle: '.drag-handle'}); // Configure drag handle\r\n */\r\n public draggable(el: GridItemHTMLElement, opts: DDOpts, key?: DDKey, value?: DDValue): DDGridStack {\r\n this._getDDElements(el, opts).forEach(dEl => {\r\n if (opts === 'disable' || opts === 'enable') {\r\n dEl.ddDraggable && dEl.ddDraggable[opts](); // can't create DD as it requires options for setupDraggable()\r\n } else if (opts === 'destroy') {\r\n dEl.ddDraggable && dEl.cleanDraggable();\r\n } else if (opts === 'option') {\r\n dEl.setupDraggable({ [key]: value });\r\n } else {\r\n const grid = dEl.el.gridstackNode.grid;\r\n dEl.setupDraggable({\r\n ...grid.opts.draggable,\r\n ...{\r\n // containment: (grid.parentGridNode && grid.opts.dragOut === false) ? grid.el.parentElement : (grid.opts.draggable.containment || null),\r\n start: opts.start,\r\n stop: opts.stop,\r\n drag: opts.drag\r\n }\r\n });\r\n }\r\n });\r\n return this;\r\n }\r\n\r\n public dragIn(el: GridStackElement, opts: DDDragOpt): DDGridStack {\r\n this._getDDElements(el).forEach(dEl => dEl.setupDraggable(opts));\r\n return this;\r\n }\r\n\r\n public droppable(el: GridItemHTMLElement, opts: DDOpts | DDDropOpt, key?: DDKey, value?: DDValue): DDGridStack {\r\n if (typeof opts.accept === 'function' && !opts._accept) {\r\n opts._accept = opts.accept;\r\n opts.accept = (el) => opts._accept(el);\r\n }\r\n this._getDDElements(el, opts).forEach(dEl => {\r\n if (opts === 'disable' || opts === 'enable') {\r\n dEl.ddDroppable && dEl.ddDroppable[opts]();\r\n } else if (opts === 'destroy') {\r\n dEl.ddDroppable && dEl.cleanDroppable();\r\n } else if (opts === 'option') {\r\n dEl.setupDroppable({ [key]: value });\r\n } else {\r\n dEl.setupDroppable(opts);\r\n }\r\n });\r\n return this;\r\n }\r\n\r\n /** true if element is droppable */\r\n public isDroppable(el: DDElementHost): boolean {\r\n return !!(el?.ddElement?.ddDroppable && !el.ddElement.ddDroppable.disabled);\r\n }\r\n\r\n /** true if element is draggable */\r\n public isDraggable(el: DDElementHost): boolean {\r\n return !!(el?.ddElement?.ddDraggable && !el.ddElement.ddDraggable.disabled);\r\n }\r\n\r\n /** true if element is draggable */\r\n public isResizable(el: DDElementHost): boolean {\r\n return !!(el?.ddElement?.ddResizable && !el.ddElement.ddResizable.disabled);\r\n }\r\n\r\n public on(el: GridItemHTMLElement, name: string, callback: DDCallback): DDGridStack {\r\n this._getDDElements(el).forEach(dEl =>\r\n dEl.on(name, (event: Event) => {\r\n callback(\r\n event,\r\n DDManager.dragElement ? DDManager.dragElement.el : event.target as GridItemHTMLElement,\r\n DDManager.dragElement ? DDManager.dragElement.helper : null)\r\n })\r\n );\r\n return this;\r\n }\r\n\r\n public off(el: GridItemHTMLElement, name: string): DDGridStack {\r\n this._getDDElements(el).forEach(dEl => dEl.off(name));\r\n return this;\r\n }\r\n\r\n /** @internal returns a list of DD elements, creating them on the fly by default unless option is to destroy or disable */\r\n protected _getDDElements(els: GridStackElement, opts?: DDOpts): DDElement[] {\r\n // don't force create if we're going to destroy it, unless it's a grid which is used as drop target for it's children\r\n const create = (els as GridHTMLElement).gridstack || opts !== 'destroy' && opts !== 'disable';\r\n const hosts = Utils.getElements(els) as DDElementHost[];\r\n if (!hosts.length) return [];\r\n const list = hosts.map(e => e.ddElement || (create ? DDElement.init(e) : null)).filter(d => d); // remove nulls\r\n return list;\r\n }\r\n}\r\n"]}
|