dockview-core 6.3.0 → 6.5.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/README.md +1 -0
- package/dist/cjs/dnd/backend.d.ts +70 -0
- package/dist/cjs/dnd/backend.js +171 -0
- package/dist/cjs/dnd/dropOverlay.d.ts +20 -0
- package/dist/cjs/dnd/dropOverlay.js +197 -0
- package/dist/cjs/dnd/droptarget.d.ts +20 -6
- package/dist/cjs/dnd/droptarget.js +14 -208
- package/dist/cjs/dnd/pointer/index.d.ts +11 -0
- package/dist/cjs/dnd/pointer/index.js +13 -0
- package/dist/cjs/dnd/pointer/longPress.d.ts +32 -0
- package/dist/cjs/dnd/pointer/longPress.js +151 -0
- package/dist/cjs/dnd/pointer/pointerDragController.d.ts +60 -0
- package/dist/cjs/dnd/pointer/pointerDragController.js +241 -0
- package/dist/cjs/dnd/pointer/pointerDragSource.d.ts +61 -0
- package/dist/cjs/dnd/pointer/pointerDragSource.js +195 -0
- package/dist/cjs/dnd/pointer/pointerDropTarget.d.ts +39 -0
- package/dist/cjs/dnd/pointer/pointerDropTarget.js +198 -0
- package/dist/cjs/dnd/pointer/pointerGhost.d.ts +30 -0
- package/dist/cjs/dnd/pointer/pointerGhost.js +44 -0
- package/dist/cjs/dnd/pointer/types.d.ts +16 -0
- package/dist/cjs/dnd/pointer/types.js +2 -0
- package/dist/cjs/dockview/components/panel/content.d.ts +3 -1
- package/dist/cjs/dockview/components/panel/content.js +33 -16
- package/dist/cjs/dockview/components/popupService.js +34 -0
- package/dist/cjs/dockview/components/tab/tab.d.ts +11 -3
- package/dist/cjs/dockview/components/tab/tab.js +151 -117
- package/dist/cjs/dockview/components/titlebar/tabGroupChip.d.ts +9 -2
- package/dist/cjs/dockview/components/titlebar/tabGroupChip.js +15 -6
- package/dist/cjs/dockview/components/titlebar/tabGroups.d.ts +33 -5
- package/dist/cjs/dockview/components/titlebar/tabGroups.js +231 -40
- package/dist/cjs/dockview/components/titlebar/tabs.d.ts +38 -1
- package/dist/cjs/dockview/components/titlebar/tabs.js +372 -251
- package/dist/cjs/dockview/components/titlebar/tabsContainer.d.ts +5 -3
- package/dist/cjs/dockview/components/titlebar/voidContainer.d.ts +6 -2
- package/dist/cjs/dockview/components/titlebar/voidContainer.js +189 -27
- package/dist/cjs/dockview/contextMenu.js +19 -4
- package/dist/cjs/dockview/dndCapabilities.d.ts +19 -0
- package/dist/cjs/dockview/dndCapabilities.js +39 -0
- package/dist/cjs/dockview/dockviewComponent.d.ts +1 -0
- package/dist/cjs/dockview/dockviewComponent.js +54 -33
- package/dist/cjs/dockview/dockviewGroupPanelModel.d.ts +9 -5
- package/dist/cjs/dockview/dockviewGroupPanelModel.js +25 -11
- package/dist/cjs/dockview/events.d.ts +2 -1
- package/dist/cjs/dockview/events.js +1 -0
- package/dist/cjs/dockview/options.d.ts +18 -3
- package/dist/cjs/dockview/options.js +1 -0
- package/dist/cjs/dom.js +7 -3
- package/dist/cjs/overlay/overlay.d.ts +12 -0
- package/dist/cjs/overlay/overlay.js +84 -16
- package/dist/cjs/paneview/draggablePaneviewPanel.d.ts +3 -1
- package/dist/cjs/paneview/draggablePaneviewPanel.js +27 -26
- package/dist/cjs/paneview/options.d.ts +4 -3
- package/dist/dockview-core.js +2199 -834
- package/dist/dockview-core.min.js +2 -2
- package/dist/dockview-core.min.js.map +1 -1
- package/dist/dockview-core.min.noStyle.js +2 -2
- package/dist/dockview-core.min.noStyle.js.map +1 -1
- package/dist/dockview-core.noStyle.js +2202 -837
- package/dist/esm/dnd/backend.d.ts +70 -0
- package/dist/esm/dnd/backend.js +148 -0
- package/dist/esm/dnd/dropOverlay.d.ts +20 -0
- package/dist/esm/dnd/dropOverlay.js +192 -0
- package/dist/esm/dnd/droptarget.d.ts +20 -6
- package/dist/esm/dnd/droptarget.js +16 -210
- package/dist/esm/dnd/pointer/index.d.ts +11 -0
- package/dist/esm/dnd/pointer/index.js +5 -0
- package/dist/esm/dnd/pointer/longPress.d.ts +32 -0
- package/dist/esm/dnd/pointer/longPress.js +127 -0
- package/dist/esm/dnd/pointer/pointerDragController.d.ts +60 -0
- package/dist/esm/dnd/pointer/pointerDragController.js +191 -0
- package/dist/esm/dnd/pointer/pointerDragSource.d.ts +61 -0
- package/dist/esm/dnd/pointer/pointerDragSource.js +171 -0
- package/dist/esm/dnd/pointer/pointerDropTarget.d.ts +39 -0
- package/dist/esm/dnd/pointer/pointerDropTarget.js +168 -0
- package/dist/esm/dnd/pointer/pointerGhost.d.ts +30 -0
- package/dist/esm/dnd/pointer/pointerGhost.js +39 -0
- package/dist/esm/dnd/pointer/types.d.ts +16 -0
- package/dist/esm/dnd/pointer/types.js +1 -0
- package/dist/esm/dockview/components/panel/content.d.ts +3 -1
- package/dist/esm/dockview/components/panel/content.js +33 -16
- package/dist/esm/dockview/components/popupService.js +34 -0
- package/dist/esm/dockview/components/tab/tab.d.ts +11 -3
- package/dist/esm/dockview/components/tab/tab.js +139 -114
- package/dist/esm/dockview/components/titlebar/tabGroupChip.d.ts +9 -2
- package/dist/esm/dockview/components/titlebar/tabGroupChip.js +15 -6
- package/dist/esm/dockview/components/titlebar/tabGroups.d.ts +33 -5
- package/dist/esm/dockview/components/titlebar/tabGroups.js +177 -12
- package/dist/esm/dockview/components/titlebar/tabs.d.ts +38 -1
- package/dist/esm/dockview/components/titlebar/tabs.js +348 -227
- package/dist/esm/dockview/components/titlebar/tabsContainer.d.ts +5 -3
- package/dist/esm/dockview/components/titlebar/voidContainer.d.ts +6 -2
- package/dist/esm/dockview/components/titlebar/voidContainer.js +179 -31
- package/dist/esm/dockview/contextMenu.js +19 -4
- package/dist/esm/dockview/dndCapabilities.d.ts +19 -0
- package/dist/esm/dockview/dndCapabilities.js +36 -0
- package/dist/esm/dockview/dockviewComponent.d.ts +1 -0
- package/dist/esm/dockview/dockviewComponent.js +55 -34
- package/dist/esm/dockview/dockviewGroupPanelModel.d.ts +9 -5
- package/dist/esm/dockview/dockviewGroupPanelModel.js +24 -11
- package/dist/esm/dockview/events.d.ts +2 -1
- package/dist/esm/dockview/events.js +1 -0
- package/dist/esm/dockview/options.d.ts +18 -3
- package/dist/esm/dockview/options.js +1 -0
- package/dist/esm/dom.js +7 -3
- package/dist/esm/overlay/overlay.d.ts +12 -0
- package/dist/esm/overlay/overlay.js +85 -17
- package/dist/esm/paneview/draggablePaneviewPanel.d.ts +3 -1
- package/dist/esm/paneview/draggablePaneviewPanel.js +26 -20
- package/dist/esm/paneview/options.d.ts +4 -3
- package/dist/package/main.cjs.js +2202 -837
- package/dist/package/main.cjs.min.js +2 -2
- package/dist/package/main.esm.min.mjs +2 -2
- package/dist/package/main.esm.mjs +2202 -837
- package/dist/styles/dockview.css +117 -1
- package/package.json +3 -1
- package/dist/cjs/dnd/abstractDragHandler.d.ts +0 -14
- package/dist/cjs/dnd/abstractDragHandler.js +0 -86
- package/dist/cjs/dnd/groupDragHandler.d.ts +0 -12
- package/dist/cjs/dnd/groupDragHandler.js +0 -104
- package/dist/esm/dnd/abstractDragHandler.d.ts +0 -14
- package/dist/esm/dnd/abstractDragHandler.js +0 -63
- package/dist/esm/dnd/groupDragHandler.d.ts +0 -12
- package/dist/esm/dnd/groupDragHandler.js +0 -81
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __values = (this && this.__values) || function(o) {
|
|
18
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
19
|
+
if (m) return m.call(o);
|
|
20
|
+
if (o && typeof o.length === "number") return {
|
|
21
|
+
next: function () {
|
|
22
|
+
if (o && i >= o.length) o = void 0;
|
|
23
|
+
return { value: o && o[i++], done: !o };
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.PointerDragController = void 0;
|
|
30
|
+
var dom_1 = require("../../dom");
|
|
31
|
+
var events_1 = require("../../events");
|
|
32
|
+
var lifecycle_1 = require("../../lifecycle");
|
|
33
|
+
/**
|
|
34
|
+
* Singleton — only one pointer-driven drag active at a time.
|
|
35
|
+
*
|
|
36
|
+
* State is shared across every Dockview instance on the page. Targets
|
|
37
|
+
* from instance B receive hit-tests from drags originating in instance A;
|
|
38
|
+
* that's intentional for cross-instance drops since `LocalSelectionTransfer`
|
|
39
|
+
* is also process-wide. The corollary is that every Tabs subscriber to
|
|
40
|
+
* `onDragMove` fires for every pointer drag globally — each subscriber
|
|
41
|
+
* hit-tests against its own DOM, so this is O(N) per pointermove where N
|
|
42
|
+
* is the number of registered listeners across all instances.
|
|
43
|
+
*/
|
|
44
|
+
var PointerDragController = /** @class */ (function (_super) {
|
|
45
|
+
__extends(PointerDragController, _super);
|
|
46
|
+
function PointerDragController() {
|
|
47
|
+
var _this = _super.call(this) || this;
|
|
48
|
+
_this._targets = new Set();
|
|
49
|
+
/** Kept in sync with `_targets` so hit-testing is allocation-free. */
|
|
50
|
+
_this._targetByElement = new Map();
|
|
51
|
+
_this._onDragStart = new events_1.Emitter();
|
|
52
|
+
_this.onDragStart = _this._onDragStart.event;
|
|
53
|
+
_this._onDragMove = new events_1.Emitter();
|
|
54
|
+
_this.onDragMove = _this._onDragMove.event;
|
|
55
|
+
_this._onDragEnd = new events_1.Emitter();
|
|
56
|
+
_this.onDragEnd = _this._onDragEnd.event;
|
|
57
|
+
_this.addDisposables(_this._onDragStart, _this._onDragMove, _this._onDragEnd);
|
|
58
|
+
return _this;
|
|
59
|
+
}
|
|
60
|
+
PointerDragController.getInstance = function () {
|
|
61
|
+
if (!PointerDragController._instance) {
|
|
62
|
+
PointerDragController._instance = new PointerDragController();
|
|
63
|
+
}
|
|
64
|
+
return PointerDragController._instance;
|
|
65
|
+
};
|
|
66
|
+
Object.defineProperty(PointerDragController.prototype, "active", {
|
|
67
|
+
get: function () {
|
|
68
|
+
return this._active;
|
|
69
|
+
},
|
|
70
|
+
enumerable: false,
|
|
71
|
+
configurable: true
|
|
72
|
+
});
|
|
73
|
+
PointerDragController.prototype.registerTarget = function (target) {
|
|
74
|
+
var _this = this;
|
|
75
|
+
this._targets.add(target);
|
|
76
|
+
this._targetByElement.set(target.element, target);
|
|
77
|
+
return {
|
|
78
|
+
dispose: function () {
|
|
79
|
+
_this._targets.delete(target);
|
|
80
|
+
if (_this._targetByElement.get(target.element) === target) {
|
|
81
|
+
_this._targetByElement.delete(target.element);
|
|
82
|
+
}
|
|
83
|
+
if (_this._currentTarget === target) {
|
|
84
|
+
_this._currentTarget = undefined;
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
PointerDragController.prototype.beginDrag = function (args) {
|
|
90
|
+
var _this = this;
|
|
91
|
+
var _a, _b, _c;
|
|
92
|
+
if (this._active) {
|
|
93
|
+
this.cancel();
|
|
94
|
+
}
|
|
95
|
+
var pointerEvent = args.pointerEvent, source = args.source;
|
|
96
|
+
// Call `getData()` before mutating controller state — a throw
|
|
97
|
+
// here would otherwise leave `_active` populated with no window
|
|
98
|
+
// listeners installed, blocking every subsequent drag.
|
|
99
|
+
var dataDisposable = args.getData();
|
|
100
|
+
this._active = {
|
|
101
|
+
pointerId: pointerEvent.pointerId,
|
|
102
|
+
startX: pointerEvent.clientX,
|
|
103
|
+
startY: pointerEvent.clientY,
|
|
104
|
+
source: source,
|
|
105
|
+
};
|
|
106
|
+
this._onDragMoveCallback = args.onDragMove;
|
|
107
|
+
this._onDragEndCallback = args.onDragEnd;
|
|
108
|
+
this._dataDisposable = dataDisposable;
|
|
109
|
+
this._ghost = args.ghost;
|
|
110
|
+
// Iframes capture pointermove once the cursor crosses into them,
|
|
111
|
+
// which would freeze the drag from the parent window's POV.
|
|
112
|
+
this._iframeShield = (0, dom_1.disableIframePointEvents)((_a = source.ownerDocument) !== null && _a !== void 0 ? _a : document);
|
|
113
|
+
var startEvent = {
|
|
114
|
+
clientX: pointerEvent.clientX,
|
|
115
|
+
clientY: pointerEvent.clientY,
|
|
116
|
+
pointerEvent: pointerEvent,
|
|
117
|
+
};
|
|
118
|
+
this._onDragStart.fire(startEvent);
|
|
119
|
+
// Source's owning window — popout drags fire on their own window,
|
|
120
|
+
// not the main one.
|
|
121
|
+
var targetWindow = (_c = (_b = source.ownerDocument) === null || _b === void 0 ? void 0 : _b.defaultView) !== null && _c !== void 0 ? _c : window;
|
|
122
|
+
this._moveListener = (0, events_1.addDisposableListener)(targetWindow, 'pointermove', function (e) {
|
|
123
|
+
if (!_this._active || e.pointerId !== _this._active.pointerId) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
_this._handleMove(e);
|
|
127
|
+
});
|
|
128
|
+
this._upListener = (0, events_1.addDisposableListener)(targetWindow, 'pointerup', function (e) {
|
|
129
|
+
if (!_this._active || e.pointerId !== _this._active.pointerId) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
_this._handleEnd(e, true);
|
|
133
|
+
});
|
|
134
|
+
this._cancelListener = (0, events_1.addDisposableListener)(targetWindow, 'pointercancel', function (e) {
|
|
135
|
+
if (!_this._active || e.pointerId !== _this._active.pointerId) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
_this._handleEnd(e, false);
|
|
139
|
+
});
|
|
140
|
+
};
|
|
141
|
+
PointerDragController.prototype.cancel = function () {
|
|
142
|
+
var _a, _b;
|
|
143
|
+
if (!this._active) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
(_a = this._currentTarget) === null || _a === void 0 ? void 0 : _a.handleDragLeave();
|
|
147
|
+
this._teardown();
|
|
148
|
+
(_b = this._dataDisposable) === null || _b === void 0 ? void 0 : _b.dispose();
|
|
149
|
+
this._dataDisposable = undefined;
|
|
150
|
+
};
|
|
151
|
+
PointerDragController.prototype._findTargetUnder = function (x, y) {
|
|
152
|
+
var e_1, _a;
|
|
153
|
+
var _b, _c;
|
|
154
|
+
// `elementsFromPoint` is topmost-first; walk up to find the closest
|
|
155
|
+
// registered ancestor (so a tab beats the layout-root that contains it).
|
|
156
|
+
// Use the source's owning document so popout drags hit their own targets.
|
|
157
|
+
var sourceDoc = (_c = (_b = this._active) === null || _b === void 0 ? void 0 : _b.source.ownerDocument) !== null && _c !== void 0 ? _c : document;
|
|
158
|
+
var elements = sourceDoc.elementsFromPoint(x, y);
|
|
159
|
+
try {
|
|
160
|
+
for (var elements_1 = __values(elements), elements_1_1 = elements_1.next(); !elements_1_1.done; elements_1_1 = elements_1.next()) {
|
|
161
|
+
var el = elements_1_1.value;
|
|
162
|
+
var current = el;
|
|
163
|
+
while (current) {
|
|
164
|
+
var target = this._targetByElement.get(current);
|
|
165
|
+
if (target) {
|
|
166
|
+
return target;
|
|
167
|
+
}
|
|
168
|
+
current = current.parentElement;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
173
|
+
finally {
|
|
174
|
+
try {
|
|
175
|
+
if (elements_1_1 && !elements_1_1.done && (_a = elements_1.return)) _a.call(elements_1);
|
|
176
|
+
}
|
|
177
|
+
finally { if (e_1) throw e_1.error; }
|
|
178
|
+
}
|
|
179
|
+
return undefined;
|
|
180
|
+
};
|
|
181
|
+
PointerDragController.prototype._handleMove = function (e) {
|
|
182
|
+
var _a, _b, _c;
|
|
183
|
+
(_a = this._ghost) === null || _a === void 0 ? void 0 : _a.update(e.clientX, e.clientY);
|
|
184
|
+
var dragEvent = {
|
|
185
|
+
clientX: e.clientX,
|
|
186
|
+
clientY: e.clientY,
|
|
187
|
+
pointerEvent: e,
|
|
188
|
+
};
|
|
189
|
+
var newTarget = this._findTargetUnder(e.clientX, e.clientY);
|
|
190
|
+
if (newTarget !== this._currentTarget) {
|
|
191
|
+
(_b = this._currentTarget) === null || _b === void 0 ? void 0 : _b.handleDragLeave();
|
|
192
|
+
this._currentTarget = newTarget;
|
|
193
|
+
}
|
|
194
|
+
if (newTarget) {
|
|
195
|
+
newTarget.handleDragOver(dragEvent);
|
|
196
|
+
}
|
|
197
|
+
(_c = this._onDragMoveCallback) === null || _c === void 0 ? void 0 : _c.call(this, dragEvent);
|
|
198
|
+
this._onDragMove.fire(dragEvent);
|
|
199
|
+
};
|
|
200
|
+
PointerDragController.prototype._handleEnd = function (e, dropped) {
|
|
201
|
+
var _a;
|
|
202
|
+
var dragEvent = {
|
|
203
|
+
clientX: e.clientX,
|
|
204
|
+
clientY: e.clientY,
|
|
205
|
+
pointerEvent: e,
|
|
206
|
+
};
|
|
207
|
+
if (dropped && this._currentTarget) {
|
|
208
|
+
this._currentTarget.handleDrop(dragEvent);
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
(_a = this._currentTarget) === null || _a === void 0 ? void 0 : _a.handleDragLeave();
|
|
212
|
+
}
|
|
213
|
+
var onEnd = this._onDragEndCallback;
|
|
214
|
+
var dataDisposable = this._dataDisposable;
|
|
215
|
+
this._teardown();
|
|
216
|
+
this._dataDisposable = undefined;
|
|
217
|
+
// Defer disposal so drop handlers can still read the transfer data.
|
|
218
|
+
setTimeout(function () { return dataDisposable === null || dataDisposable === void 0 ? void 0 : dataDisposable.dispose(); }, 0);
|
|
219
|
+
onEnd === null || onEnd === void 0 ? void 0 : onEnd(dragEvent, dropped);
|
|
220
|
+
this._onDragEnd.fire(dragEvent);
|
|
221
|
+
};
|
|
222
|
+
PointerDragController.prototype._teardown = function () {
|
|
223
|
+
var _a, _b, _c, _d, _e;
|
|
224
|
+
this._currentTarget = undefined;
|
|
225
|
+
this._active = undefined;
|
|
226
|
+
this._onDragMoveCallback = undefined;
|
|
227
|
+
this._onDragEndCallback = undefined;
|
|
228
|
+
(_a = this._ghost) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
229
|
+
this._ghost = undefined;
|
|
230
|
+
(_b = this._iframeShield) === null || _b === void 0 ? void 0 : _b.release();
|
|
231
|
+
this._iframeShield = undefined;
|
|
232
|
+
(_c = this._moveListener) === null || _c === void 0 ? void 0 : _c.dispose();
|
|
233
|
+
(_d = this._upListener) === null || _d === void 0 ? void 0 : _d.dispose();
|
|
234
|
+
(_e = this._cancelListener) === null || _e === void 0 ? void 0 : _e.dispose();
|
|
235
|
+
this._moveListener = undefined;
|
|
236
|
+
this._upListener = undefined;
|
|
237
|
+
this._cancelListener = undefined;
|
|
238
|
+
};
|
|
239
|
+
return PointerDragController;
|
|
240
|
+
}(lifecycle_1.CompositeDisposable));
|
|
241
|
+
exports.PointerDragController = PointerDragController;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { CompositeDisposable, IDisposable } from '../../lifecycle';
|
|
2
|
+
import { PointerGhost } from './pointerGhost';
|
|
3
|
+
import { PointerDragEvent } from './types';
|
|
4
|
+
export interface PointerDragSourceOptions {
|
|
5
|
+
/** Populate transfer data; returned disposer clears it on drag end. */
|
|
6
|
+
getData: (event: PointerEvent) => IDisposable;
|
|
7
|
+
onDragStart?: (event: PointerEvent) => void;
|
|
8
|
+
onDragMove?: (event: PointerDragEvent) => void;
|
|
9
|
+
onDragEnd?: (event: PointerDragEvent, dropped: boolean) => void;
|
|
10
|
+
/** Cancels the drag at pointerdown time. */
|
|
11
|
+
isCancelled?: (event: PointerEvent) => boolean;
|
|
12
|
+
/** Default 5px. Touch pointers also need `touchInitiationDelay` to elapse. */
|
|
13
|
+
threshold?: number;
|
|
14
|
+
/**
|
|
15
|
+
* Touch-only long-press; movement past `pressTolerance` during the delay
|
|
16
|
+
* still arms the drag (any flick is drag intent). Default 250ms. May be
|
|
17
|
+
* a function so callers can vary it per gesture (e.g. require a longer
|
|
18
|
+
* hold for floating-group redock vs docked-group rearrange).
|
|
19
|
+
*/
|
|
20
|
+
touchInitiationDelay?: number | (() => number);
|
|
21
|
+
/** Default 8px. May be a function — see `touchInitiationDelay`. */
|
|
22
|
+
pressTolerance?: number | (() => number);
|
|
23
|
+
/** Default true: mouse defers to HTML5; pointer path handles touch / pen only. */
|
|
24
|
+
touchOnly?: boolean;
|
|
25
|
+
/** Follow-finger ghost factory; if omitted the user only sees drop overlays. */
|
|
26
|
+
createGhost?: (event: PointerEvent) => PointerGhost | undefined;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Pointer-event drag source. Waits for movement past `threshold` (and
|
|
30
|
+
* touch-only `touchInitiationDelay`) before promoting to a drag so taps
|
|
31
|
+
* pass through unaffected.
|
|
32
|
+
*/
|
|
33
|
+
export declare class PointerDragSource extends CompositeDisposable {
|
|
34
|
+
private readonly element;
|
|
35
|
+
private readonly options;
|
|
36
|
+
private _disabled;
|
|
37
|
+
private _touchOnly;
|
|
38
|
+
private _pendingPointerId;
|
|
39
|
+
private _pendingMoveListener;
|
|
40
|
+
private _pendingUpListener;
|
|
41
|
+
private _pendingCancelListener;
|
|
42
|
+
private _armTimer;
|
|
43
|
+
private _armed;
|
|
44
|
+
private _startX;
|
|
45
|
+
private _startY;
|
|
46
|
+
private _startEvent;
|
|
47
|
+
constructor(element: HTMLElement, options: PointerDragSourceOptions);
|
|
48
|
+
setDisabled(value: boolean): void;
|
|
49
|
+
/**
|
|
50
|
+
* `false` lets the pointer source also handle mouse pointers; used when
|
|
51
|
+
* `dndStrategy: 'pointer'` to drive every input type through this path.
|
|
52
|
+
*/
|
|
53
|
+
setTouchOnly(value: boolean): void;
|
|
54
|
+
private _shouldHandle;
|
|
55
|
+
private _onPointerDown;
|
|
56
|
+
/** For sibling gesture detectors (e.g. LongPressDetector) to dismiss a pending drag. */
|
|
57
|
+
cancelPending(): void;
|
|
58
|
+
private _cancelPending;
|
|
59
|
+
private _beginDrag;
|
|
60
|
+
dispose(): void;
|
|
61
|
+
}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.PointerDragSource = void 0;
|
|
19
|
+
var events_1 = require("../../events");
|
|
20
|
+
var lifecycle_1 = require("../../lifecycle");
|
|
21
|
+
var pointerDragController_1 = require("./pointerDragController");
|
|
22
|
+
var DEFAULT_THRESHOLD = 5;
|
|
23
|
+
var DEFAULT_TOUCH_INITIATION_DELAY = 250;
|
|
24
|
+
var DEFAULT_PRESS_TOLERANCE = 8;
|
|
25
|
+
/**
|
|
26
|
+
* Pointer-event drag source. Waits for movement past `threshold` (and
|
|
27
|
+
* touch-only `touchInitiationDelay`) before promoting to a drag so taps
|
|
28
|
+
* pass through unaffected.
|
|
29
|
+
*/
|
|
30
|
+
var PointerDragSource = /** @class */ (function (_super) {
|
|
31
|
+
__extends(PointerDragSource, _super);
|
|
32
|
+
function PointerDragSource(element, options) {
|
|
33
|
+
var _a;
|
|
34
|
+
var _this = _super.call(this) || this;
|
|
35
|
+
_this.element = element;
|
|
36
|
+
_this.options = options;
|
|
37
|
+
_this._disabled = false;
|
|
38
|
+
_this._armed = false;
|
|
39
|
+
_this._startX = 0;
|
|
40
|
+
_this._startY = 0;
|
|
41
|
+
_this._touchOnly = (_a = options.touchOnly) !== null && _a !== void 0 ? _a : true;
|
|
42
|
+
_this.addDisposables((0, events_1.addDisposableListener)(_this.element, 'pointerdown', function (e) {
|
|
43
|
+
_this._onPointerDown(e);
|
|
44
|
+
}));
|
|
45
|
+
return _this;
|
|
46
|
+
}
|
|
47
|
+
PointerDragSource.prototype.setDisabled = function (value) {
|
|
48
|
+
this._disabled = value;
|
|
49
|
+
if (value) {
|
|
50
|
+
this._cancelPending();
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* `false` lets the pointer source also handle mouse pointers; used when
|
|
55
|
+
* `dndStrategy: 'pointer'` to drive every input type through this path.
|
|
56
|
+
*/
|
|
57
|
+
PointerDragSource.prototype.setTouchOnly = function (value) {
|
|
58
|
+
if (this._touchOnly === value) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
this._touchOnly = value;
|
|
62
|
+
// A pending mouse-tracked drag should be abandoned if we re-enable
|
|
63
|
+
// the touch-only filter mid-flight.
|
|
64
|
+
if (value) {
|
|
65
|
+
this._cancelPending();
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
PointerDragSource.prototype._shouldHandle = function (event) {
|
|
69
|
+
var _a, _b;
|
|
70
|
+
if (this._disabled) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
// Pointer-type filter runs before isCancelled — consumer state read
|
|
74
|
+
// by isCancelled may not be populated for events we'll never handle.
|
|
75
|
+
if (this._touchOnly &&
|
|
76
|
+
event.pointerType !== 'touch' &&
|
|
77
|
+
event.pointerType !== 'pen') {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
if ((_b = (_a = this.options).isCancelled) === null || _b === void 0 ? void 0 : _b.call(_a, event)) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
return true;
|
|
84
|
+
};
|
|
85
|
+
PointerDragSource.prototype._onPointerDown = function (event) {
|
|
86
|
+
var _this = this;
|
|
87
|
+
var _a, _b, _c, _d, _e;
|
|
88
|
+
if (!this._shouldHandle(event)) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
// Defensive: a fresh pointerdown supersedes any in-flight tracking.
|
|
92
|
+
this._cancelPending();
|
|
93
|
+
this._pendingPointerId = event.pointerId;
|
|
94
|
+
this._startX = event.clientX;
|
|
95
|
+
this._startY = event.clientY;
|
|
96
|
+
this._startEvent = event;
|
|
97
|
+
var isTouch = event.pointerType === 'touch' || event.pointerType === 'pen';
|
|
98
|
+
// Touch waits a short window so a still finger can press-and-hold
|
|
99
|
+
// before drifting; once the timer fires, any motion past `threshold`
|
|
100
|
+
// begins the drag.
|
|
101
|
+
var initiationDelayOpt = this.options.touchInitiationDelay;
|
|
102
|
+
var initiationDelay = (_a = (typeof initiationDelayOpt === 'function'
|
|
103
|
+
? initiationDelayOpt()
|
|
104
|
+
: initiationDelayOpt)) !== null && _a !== void 0 ? _a : DEFAULT_TOUCH_INITIATION_DELAY;
|
|
105
|
+
this._armed = !isTouch || initiationDelay <= 0;
|
|
106
|
+
if (isTouch && initiationDelay > 0 && isFinite(initiationDelay)) {
|
|
107
|
+
this._armTimer = setTimeout(function () {
|
|
108
|
+
_this._armTimer = undefined;
|
|
109
|
+
_this._armed = true;
|
|
110
|
+
}, initiationDelay);
|
|
111
|
+
}
|
|
112
|
+
var threshold = (_b = this.options.threshold) !== null && _b !== void 0 ? _b : DEFAULT_THRESHOLD;
|
|
113
|
+
var pressToleranceOpt = this.options.pressTolerance;
|
|
114
|
+
var pressTolerance = (_c = (typeof pressToleranceOpt === 'function'
|
|
115
|
+
? pressToleranceOpt()
|
|
116
|
+
: pressToleranceOpt)) !== null && _c !== void 0 ? _c : DEFAULT_PRESS_TOLERANCE;
|
|
117
|
+
// Source's owning window — popout drags fire on their own window.
|
|
118
|
+
var targetWindow = (_e = (_d = this.element.ownerDocument) === null || _d === void 0 ? void 0 : _d.defaultView) !== null && _e !== void 0 ? _e : window;
|
|
119
|
+
this._pendingMoveListener = (0, events_1.addDisposableListener)(targetWindow, 'pointermove', function (moveEvent) {
|
|
120
|
+
if (moveEvent.pointerId !== _this._pendingPointerId) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
var dx = moveEvent.clientX - _this._startX;
|
|
124
|
+
var dy = moveEvent.clientY - _this._startY;
|
|
125
|
+
var distance = Math.hypot(dx, dy);
|
|
126
|
+
if (_this._armed) {
|
|
127
|
+
if (distance >= threshold) {
|
|
128
|
+
_this._beginDrag(moveEvent);
|
|
129
|
+
}
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
// Pre-arm phase: a flick past `pressTolerance` in any
|
|
133
|
+
// direction is treated as drag intent. The element opts out
|
|
134
|
+
// of native scroll via `touch-action: none`; container-level
|
|
135
|
+
// scrolling lives on the surrounding strip's empty space.
|
|
136
|
+
if (distance > pressTolerance) {
|
|
137
|
+
_this._beginDrag(moveEvent);
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
this._pendingUpListener = (0, events_1.addDisposableListener)(targetWindow, 'pointerup', function (upEvent) {
|
|
141
|
+
if (upEvent.pointerId !== _this._pendingPointerId) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
_this._cancelPending();
|
|
145
|
+
});
|
|
146
|
+
this._pendingCancelListener = (0, events_1.addDisposableListener)(targetWindow, 'pointercancel', function (cancelEvent) {
|
|
147
|
+
if (cancelEvent.pointerId !== _this._pendingPointerId) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
_this._cancelPending();
|
|
151
|
+
});
|
|
152
|
+
};
|
|
153
|
+
/** For sibling gesture detectors (e.g. LongPressDetector) to dismiss a pending drag. */
|
|
154
|
+
PointerDragSource.prototype.cancelPending = function () {
|
|
155
|
+
this._cancelPending();
|
|
156
|
+
};
|
|
157
|
+
PointerDragSource.prototype._cancelPending = function () {
|
|
158
|
+
var _a, _b, _c;
|
|
159
|
+
this._pendingPointerId = undefined;
|
|
160
|
+
if (this._armTimer !== undefined) {
|
|
161
|
+
clearTimeout(this._armTimer);
|
|
162
|
+
this._armTimer = undefined;
|
|
163
|
+
}
|
|
164
|
+
this._armed = false;
|
|
165
|
+
(_a = this._pendingMoveListener) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
166
|
+
(_b = this._pendingUpListener) === null || _b === void 0 ? void 0 : _b.dispose();
|
|
167
|
+
(_c = this._pendingCancelListener) === null || _c === void 0 ? void 0 : _c.dispose();
|
|
168
|
+
this._pendingMoveListener = undefined;
|
|
169
|
+
this._pendingUpListener = undefined;
|
|
170
|
+
this._pendingCancelListener = undefined;
|
|
171
|
+
this._startEvent = undefined;
|
|
172
|
+
};
|
|
173
|
+
PointerDragSource.prototype._beginDrag = function (triggerEvent) {
|
|
174
|
+
var _this = this;
|
|
175
|
+
var _a, _b, _c, _d, _e;
|
|
176
|
+
var startEvent = (_a = this._startEvent) !== null && _a !== void 0 ? _a : triggerEvent;
|
|
177
|
+
this._cancelPending();
|
|
178
|
+
(_c = (_b = this.options).onDragStart) === null || _c === void 0 ? void 0 : _c.call(_b, startEvent);
|
|
179
|
+
var ghost = (_e = (_d = this.options).createGhost) === null || _e === void 0 ? void 0 : _e.call(_d, startEvent);
|
|
180
|
+
pointerDragController_1.PointerDragController.getInstance().beginDrag({
|
|
181
|
+
pointerEvent: triggerEvent,
|
|
182
|
+
source: this.element,
|
|
183
|
+
getData: function () { return _this.options.getData(startEvent); },
|
|
184
|
+
ghost: ghost,
|
|
185
|
+
onDragMove: this.options.onDragMove,
|
|
186
|
+
onDragEnd: this.options.onDragEnd,
|
|
187
|
+
});
|
|
188
|
+
};
|
|
189
|
+
PointerDragSource.prototype.dispose = function () {
|
|
190
|
+
this._cancelPending();
|
|
191
|
+
_super.prototype.dispose.call(this);
|
|
192
|
+
};
|
|
193
|
+
return PointerDragSource;
|
|
194
|
+
}(lifecycle_1.CompositeDisposable));
|
|
195
|
+
exports.PointerDragSource = PointerDragSource;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Event } from '../../events';
|
|
2
|
+
import { CompositeDisposable } from '../../lifecycle';
|
|
3
|
+
import { CanDisplayOverlay, DropTargetTargetModel, DroptargetEvent, DroptargetOverlayModel, IDropTarget, Position, WillShowOverlayEvent } from '../droptarget';
|
|
4
|
+
export interface PointerDropTargetOptions {
|
|
5
|
+
canDisplayOverlay: CanDisplayOverlay;
|
|
6
|
+
acceptedTargetZones: Position[];
|
|
7
|
+
overlayModel?: DroptargetOverlayModel;
|
|
8
|
+
/** Render into an external anchor container (floating groups, layout root). */
|
|
9
|
+
getOverrideTarget?: () => DropTargetTargetModel | undefined;
|
|
10
|
+
/** Outline element for positioning; falls back to the drop element. */
|
|
11
|
+
getOverlayOutline?: () => HTMLElement | null;
|
|
12
|
+
className?: string;
|
|
13
|
+
}
|
|
14
|
+
/** Pointer-driven counterpart to `Droptarget` with identical visual output. */
|
|
15
|
+
export declare class PointerDropTarget extends CompositeDisposable implements IDropTarget {
|
|
16
|
+
private readonly element;
|
|
17
|
+
private readonly options;
|
|
18
|
+
private _targetElement;
|
|
19
|
+
private _overlayElement;
|
|
20
|
+
private _state;
|
|
21
|
+
private _acceptedTargetZonesSet;
|
|
22
|
+
private readonly _onDrop;
|
|
23
|
+
readonly onDrop: Event<DroptargetEvent>;
|
|
24
|
+
private readonly _onWillShowOverlay;
|
|
25
|
+
readonly onWillShowOverlay: Event<WillShowOverlayEvent>;
|
|
26
|
+
private _disabled;
|
|
27
|
+
get disabled(): boolean;
|
|
28
|
+
set disabled(value: boolean);
|
|
29
|
+
get state(): Position | undefined;
|
|
30
|
+
constructor(element: HTMLElement, options: PointerDropTargetOptions);
|
|
31
|
+
setTargetZones(zones: Position[]): void;
|
|
32
|
+
setOverlayModel(model: DroptargetOverlayModel): void;
|
|
33
|
+
dispose(): void;
|
|
34
|
+
private _onDragOver;
|
|
35
|
+
private _onDragLeave;
|
|
36
|
+
private _onDropEvent;
|
|
37
|
+
private _calculateQuadrant;
|
|
38
|
+
private _removeOverlay;
|
|
39
|
+
}
|