@deephaven/golden-layout 0.43.0 → 0.44.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/css/goldenlayout-base.css +1 -1
- package/css/goldenlayout-base.css.map +1 -1
- package/css/goldenlayout-dark-theme.css +1 -1
- package/css/goldenlayout-dark-theme.css.map +1 -1
- package/dist/GoldenLayout.module.css +1 -0
- package/dist/GoldenLayout.module.css.map +1 -0
- package/dist/GoldenLayoutThemeExport.js +6 -0
- package/dist/GoldenLayoutThemeExport.js.map +1 -0
- package/dist/LayoutManager.js +1001 -0
- package/dist/LayoutManager.js.map +1 -0
- package/dist/base.js +16 -0
- package/dist/base.js.map +1 -0
- package/dist/config/Config.js +42 -0
- package/dist/config/Config.js.map +1 -0
- package/dist/config/ItemConfig.js +14 -0
- package/dist/config/ItemConfig.js.map +1 -0
- package/dist/config/index.js +3 -0
- package/dist/config/index.js.map +1 -0
- package/dist/container/ItemContainer.js +199 -0
- package/dist/container/ItemContainer.js.map +1 -0
- package/dist/container/index.js +3 -0
- package/dist/container/index.js.map +1 -0
- package/dist/controls/BrowserPopout.js +250 -0
- package/dist/controls/BrowserPopout.js.map +1 -0
- package/dist/controls/DragProxy.js +204 -0
- package/dist/controls/DragProxy.js.map +1 -0
- package/dist/controls/DragSource.js +52 -0
- package/dist/controls/DragSource.js.map +1 -0
- package/dist/controls/DragSourceFromEvent.js +71 -0
- package/dist/controls/DragSourceFromEvent.js.map +1 -0
- package/dist/controls/DropTargetIndicator.js +27 -0
- package/dist/controls/DropTargetIndicator.js.map +1 -0
- package/dist/controls/Header.js +736 -0
- package/dist/controls/Header.js.map +1 -0
- package/dist/controls/HeaderButton.js +22 -0
- package/dist/controls/HeaderButton.js.map +1 -0
- package/dist/controls/Splitter.js +49 -0
- package/dist/controls/Splitter.js.map +1 -0
- package/dist/controls/Tab.js +225 -0
- package/dist/controls/Tab.js.map +1 -0
- package/dist/controls/index.js +10 -0
- package/dist/controls/index.js.map +1 -0
- package/dist/declaration.d.js +2 -0
- package/dist/declaration.d.js.map +1 -0
- package/dist/errors/ConfigurationError.js +14 -0
- package/dist/errors/ConfigurationError.js.map +1 -0
- package/dist/errors/index.js +2 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/items/AbstractContentItem.js +565 -0
- package/dist/items/AbstractContentItem.js.map +1 -0
- package/dist/items/Component.js +80 -0
- package/dist/items/Component.js.map +1 -0
- package/dist/items/Root.js +100 -0
- package/dist/items/Root.js.map +1 -0
- package/dist/items/RowOrColumn.js +488 -0
- package/dist/items/RowOrColumn.js.map +1 -0
- package/dist/items/Stack.js +479 -0
- package/dist/items/Stack.js.map +1 -0
- package/dist/items/index.js +8 -0
- package/dist/items/index.js.map +1 -0
- package/dist/utils/BubblingEvent.js +17 -0
- package/dist/utils/BubblingEvent.js.map +1 -0
- package/dist/utils/ConfigMinifier.js +147 -0
- package/dist/utils/ConfigMinifier.js.map +1 -0
- package/dist/utils/DragListener.js +125 -0
- package/dist/utils/DragListener.js.map +1 -0
- package/dist/utils/EventEmitter.js +117 -0
- package/dist/utils/EventEmitter.js.map +1 -0
- package/dist/utils/EventHub.js +108 -0
- package/dist/utils/EventHub.js.map +1 -0
- package/dist/utils/ReactComponentHandler.js +136 -0
- package/dist/utils/ReactComponentHandler.js.map +1 -0
- package/dist/utils/index.js +8 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/utils.js +65 -0
- package/dist/utils/utils.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
3
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
4
|
+
import $ from 'jquery';
|
|
5
|
+
import { getUniqueId, minifyConfig, EventEmitter } from "../utils/index.js";
|
|
6
|
+
/**
|
|
7
|
+
* Pops a content item out into a new browser window.
|
|
8
|
+
* This is achieved by
|
|
9
|
+
*
|
|
10
|
+
* - Creating a new configuration with the content item as root element
|
|
11
|
+
* - Serializing and minifying the configuration
|
|
12
|
+
* - Opening the current window's URL with the configuration as a GET parameter
|
|
13
|
+
* - GoldenLayout when opened in the new window will look for the GET parameter
|
|
14
|
+
* and use it instead of the provided configuration
|
|
15
|
+
*
|
|
16
|
+
* @param config GoldenLayout item config
|
|
17
|
+
* @param dimensions A map with width, height, top and left
|
|
18
|
+
* @param parentId The id of the element the item will be appended to on popIn
|
|
19
|
+
* @param indexInParent The position of this element within its parent
|
|
20
|
+
* @param layoutManager
|
|
21
|
+
*/
|
|
22
|
+
export default class BrowserPopout extends EventEmitter {
|
|
23
|
+
constructor(config, dimensions, parentId, indexInParent, layoutManager) {
|
|
24
|
+
super();
|
|
25
|
+
_defineProperty(this, "isInitialised", false);
|
|
26
|
+
_defineProperty(this, "_config", void 0);
|
|
27
|
+
_defineProperty(this, "_dimensions", void 0);
|
|
28
|
+
_defineProperty(this, "_parentId", void 0);
|
|
29
|
+
_defineProperty(this, "_indexInParent", void 0);
|
|
30
|
+
_defineProperty(this, "_layoutManager", void 0);
|
|
31
|
+
_defineProperty(this, "_popoutWindow", null);
|
|
32
|
+
_defineProperty(this, "_id", null);
|
|
33
|
+
this._config = config;
|
|
34
|
+
this._dimensions = dimensions;
|
|
35
|
+
this._parentId = parentId;
|
|
36
|
+
this._indexInParent = indexInParent;
|
|
37
|
+
this._layoutManager = layoutManager;
|
|
38
|
+
this._createWindow();
|
|
39
|
+
}
|
|
40
|
+
toConfig() {
|
|
41
|
+
var _this$getGlInstance, _this$getGlInstance2, _ref, _this$_popoutWindow$s, _this$_popoutWindow, _this$_popoutWindow2, _ref2, _this$_popoutWindow$s2, _this$_popoutWindow3, _this$_popoutWindow4, _this$getGlInstance3;
|
|
42
|
+
if (this.isInitialised === false) {
|
|
43
|
+
throw new Error("Can't create config, layout not yet initialised");
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
dimensions: {
|
|
47
|
+
width: (_this$getGlInstance = this.getGlInstance()) === null || _this$getGlInstance === void 0 ? void 0 : _this$getGlInstance.width,
|
|
48
|
+
height: (_this$getGlInstance2 = this.getGlInstance()) === null || _this$getGlInstance2 === void 0 ? void 0 : _this$getGlInstance2.height,
|
|
49
|
+
left: (_ref = (_this$_popoutWindow$s = (_this$_popoutWindow = this._popoutWindow) === null || _this$_popoutWindow === void 0 ? void 0 : _this$_popoutWindow.screenX) !== null && _this$_popoutWindow$s !== void 0 ? _this$_popoutWindow$s : (_this$_popoutWindow2 = this._popoutWindow) === null || _this$_popoutWindow2 === void 0 ? void 0 : _this$_popoutWindow2.screenLeft) !== null && _ref !== void 0 ? _ref : 0,
|
|
50
|
+
top: (_ref2 = (_this$_popoutWindow$s2 = (_this$_popoutWindow3 = this._popoutWindow) === null || _this$_popoutWindow3 === void 0 ? void 0 : _this$_popoutWindow3.screenY) !== null && _this$_popoutWindow$s2 !== void 0 ? _this$_popoutWindow$s2 : (_this$_popoutWindow4 = this._popoutWindow) === null || _this$_popoutWindow4 === void 0 ? void 0 : _this$_popoutWindow4.screenTop) !== null && _ref2 !== void 0 ? _ref2 : 0
|
|
51
|
+
},
|
|
52
|
+
content: (_this$getGlInstance3 = this.getGlInstance()) === null || _this$getGlInstance3 === void 0 ? void 0 : _this$getGlInstance3.toConfig().content,
|
|
53
|
+
parentId: this._parentId,
|
|
54
|
+
indexInParent: this._indexInParent
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
getGlInstance() {
|
|
58
|
+
var _this$_popoutWindow5;
|
|
59
|
+
return (_this$_popoutWindow5 = this._popoutWindow) === null || _this$_popoutWindow5 === void 0 ? void 0 : _this$_popoutWindow5.__glInstance;
|
|
60
|
+
}
|
|
61
|
+
getWindow() {
|
|
62
|
+
return this._popoutWindow;
|
|
63
|
+
}
|
|
64
|
+
close() {
|
|
65
|
+
if (this.getGlInstance()) {
|
|
66
|
+
var _this$getGlInstance4;
|
|
67
|
+
(_this$getGlInstance4 = this.getGlInstance()) === null || _this$getGlInstance4 === void 0 ? void 0 : _this$getGlInstance4._$closeWindow();
|
|
68
|
+
} else {
|
|
69
|
+
try {
|
|
70
|
+
var _this$getWindow;
|
|
71
|
+
(_this$getWindow = this.getWindow()) === null || _this$getWindow === void 0 ? void 0 : _this$getWindow.close();
|
|
72
|
+
} catch (e) {}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Returns the popped out item to its original position. If the original
|
|
78
|
+
* parent isn't available anymore it falls back to the layout's topmost element
|
|
79
|
+
*/
|
|
80
|
+
popIn() {
|
|
81
|
+
var _parentItem;
|
|
82
|
+
var index = this._indexInParent;
|
|
83
|
+
var childConfig = null;
|
|
84
|
+
var parentItem = null;
|
|
85
|
+
if (this._parentId) {
|
|
86
|
+
var _this$getGlInstance5;
|
|
87
|
+
/*
|
|
88
|
+
* The $.extend call seems a bit pointless, but it's crucial to
|
|
89
|
+
* copy the config returned by this.getGlInstance().toConfig()
|
|
90
|
+
* onto a new object. Internet Explorer keeps the references
|
|
91
|
+
* to objects on the child window, resulting in the following error
|
|
92
|
+
* once the child window is closed:
|
|
93
|
+
*
|
|
94
|
+
* The callee (server [not server application]) is not available and disappeared
|
|
95
|
+
*/
|
|
96
|
+
childConfig = $.extend(true, {}, (_this$getGlInstance5 = this.getGlInstance()) === null || _this$getGlInstance5 === void 0 ? void 0 : _this$getGlInstance5.toConfig()).content[0];
|
|
97
|
+
parentItem = this._layoutManager.root.getItemsById(this._parentId)[0];
|
|
98
|
+
|
|
99
|
+
/*
|
|
100
|
+
* Fallback if parentItem is not available. Either add it to the topmost
|
|
101
|
+
* item or make it the topmost item if the layout is empty
|
|
102
|
+
*/
|
|
103
|
+
if (!parentItem) {
|
|
104
|
+
var _this$_layoutManager$;
|
|
105
|
+
if (((_this$_layoutManager$ = this._layoutManager.root.contentItems.length) !== null && _this$_layoutManager$ !== void 0 ? _this$_layoutManager$ : 0) > 0) {
|
|
106
|
+
parentItem = this._layoutManager.root.contentItems[0];
|
|
107
|
+
} else {
|
|
108
|
+
parentItem = this._layoutManager.root;
|
|
109
|
+
}
|
|
110
|
+
index = 0;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (!childConfig) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
(_parentItem = parentItem) === null || _parentItem === void 0 ? void 0 : _parentItem.addChild(childConfig, this._indexInParent);
|
|
117
|
+
this.close();
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Creates the URL and window parameter
|
|
122
|
+
* and opens a new window
|
|
123
|
+
*/
|
|
124
|
+
_createWindow() {
|
|
125
|
+
var url = this._createUrl();
|
|
126
|
+
/**
|
|
127
|
+
* Bogus title to prevent re-usage of existing window with the
|
|
128
|
+
* same title. The actual title will be set by the new window's
|
|
129
|
+
* GoldenLayout instance if it detects that it is in subWindowMode
|
|
130
|
+
*/
|
|
131
|
+
var title = Math.floor(Math.random() * 1000000).toString(36);
|
|
132
|
+
/**
|
|
133
|
+
* The options as used in the window.open string
|
|
134
|
+
*/
|
|
135
|
+
var options = this._serializeWindowOptions({
|
|
136
|
+
width: this._dimensions.width,
|
|
137
|
+
height: this._dimensions.height,
|
|
138
|
+
innerWidth: this._dimensions.width,
|
|
139
|
+
innerHeight: this._dimensions.height,
|
|
140
|
+
menubar: 'no',
|
|
141
|
+
toolbar: 'no',
|
|
142
|
+
location: 'no',
|
|
143
|
+
personalbar: 'no',
|
|
144
|
+
resizable: 'yes',
|
|
145
|
+
scrollbars: 'no',
|
|
146
|
+
status: 'no'
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
// I'm not entirely sure how __glInstance is mounted to the popout window
|
|
150
|
+
this._popoutWindow = window.open(url, title, options);
|
|
151
|
+
if (!this._popoutWindow) {
|
|
152
|
+
if (this._layoutManager.config.settings.blockedPopoutsThrowError === true) {
|
|
153
|
+
var error = new Error('Popout blocked');
|
|
154
|
+
error.type = 'popoutBlocked';
|
|
155
|
+
throw error;
|
|
156
|
+
} else {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
$(this._popoutWindow).on('load', this._positionWindow.bind(this)).on('unload beforeunload', this._onClose.bind(this));
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Polling the childwindow to find out if GoldenLayout has been initialised
|
|
164
|
+
* doesn't seem optimal, but the alternatives - adding a callback to the parent
|
|
165
|
+
* window or raising an event on the window object - both would introduce knowledge
|
|
166
|
+
* about the parent to the child window which we'd rather avoid
|
|
167
|
+
*/
|
|
168
|
+
var checkReadyInterval = window.setInterval(() => {
|
|
169
|
+
var _this$_popoutWindow6;
|
|
170
|
+
if ((_this$_popoutWindow6 = this._popoutWindow) !== null && _this$_popoutWindow6 !== void 0 && _this$_popoutWindow6.__glInstance && this._popoutWindow.__glInstance.isInitialised) {
|
|
171
|
+
this._onInitialised();
|
|
172
|
+
window.clearInterval(checkReadyInterval);
|
|
173
|
+
}
|
|
174
|
+
}, 10);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Serialises a map of key:values to a window options string
|
|
179
|
+
*
|
|
180
|
+
* @param windowOptions
|
|
181
|
+
*
|
|
182
|
+
* @returns serialised window options
|
|
183
|
+
*/
|
|
184
|
+
_serializeWindowOptions(windowOptions) {
|
|
185
|
+
var windowOptionsString = [],
|
|
186
|
+
key;
|
|
187
|
+
for (key in windowOptions) {
|
|
188
|
+
windowOptionsString.push(key + '=' + windowOptions[key]);
|
|
189
|
+
}
|
|
190
|
+
return windowOptionsString.join(',');
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Creates the URL for the new window, including the
|
|
195
|
+
* config GET parameter
|
|
196
|
+
*
|
|
197
|
+
* @returns URL
|
|
198
|
+
*/
|
|
199
|
+
_createUrl() {
|
|
200
|
+
var config = {
|
|
201
|
+
content: this._config
|
|
202
|
+
};
|
|
203
|
+
var storageKey = 'gl-window-config-' + getUniqueId();
|
|
204
|
+
config = minifyConfig(config);
|
|
205
|
+
try {
|
|
206
|
+
localStorage.setItem(storageKey, JSON.stringify(config));
|
|
207
|
+
} catch (e) {
|
|
208
|
+
throw new Error('Error while writing to localStorage ' + e.toString());
|
|
209
|
+
}
|
|
210
|
+
var urlParts = document.location.href.split('?');
|
|
211
|
+
|
|
212
|
+
// URL doesn't contain GET-parameters
|
|
213
|
+
if (urlParts.length === 1) {
|
|
214
|
+
return urlParts[0] + '?gl-window=' + storageKey;
|
|
215
|
+
|
|
216
|
+
// URL contains GET-parameters
|
|
217
|
+
} else {
|
|
218
|
+
return document.location.href + '&gl-window=' + storageKey;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Move the newly created window roughly to
|
|
224
|
+
* where the component used to be.
|
|
225
|
+
*/
|
|
226
|
+
_positionWindow() {
|
|
227
|
+
var _this$_popoutWindow7, _this$_popoutWindow8;
|
|
228
|
+
(_this$_popoutWindow7 = this._popoutWindow) === null || _this$_popoutWindow7 === void 0 ? void 0 : _this$_popoutWindow7.moveTo(this._dimensions.left, this._dimensions.top);
|
|
229
|
+
(_this$_popoutWindow8 = this._popoutWindow) === null || _this$_popoutWindow8 === void 0 ? void 0 : _this$_popoutWindow8.focus();
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Callback when the new window is opened and the GoldenLayout instance
|
|
234
|
+
* within it is initialised
|
|
235
|
+
*/
|
|
236
|
+
_onInitialised() {
|
|
237
|
+
var _this$getGlInstance6;
|
|
238
|
+
this.isInitialised = true;
|
|
239
|
+
(_this$getGlInstance6 = this.getGlInstance()) === null || _this$getGlInstance6 === void 0 ? void 0 : _this$getGlInstance6.on('popIn', this.popIn, this);
|
|
240
|
+
this.emit('initialised');
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Invoked 50ms after the window unload event
|
|
245
|
+
*/
|
|
246
|
+
_onClose() {
|
|
247
|
+
setTimeout(this.emit.bind(this, 'closed'), 50);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
//# sourceMappingURL=BrowserPopout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BrowserPopout.js","names":["$","getUniqueId","minifyConfig","EventEmitter","BrowserPopout","constructor","config","dimensions","parentId","indexInParent","layoutManager","_config","_dimensions","_parentId","_indexInParent","_layoutManager","_createWindow","toConfig","isInitialised","Error","width","getGlInstance","height","left","_popoutWindow","screenX","screenLeft","top","screenY","screenTop","content","__glInstance","getWindow","close","_$closeWindow","e","popIn","index","childConfig","parentItem","extend","root","getItemsById","contentItems","length","addChild","url","_createUrl","title","Math","floor","random","toString","options","_serializeWindowOptions","innerWidth","innerHeight","menubar","toolbar","location","personalbar","resizable","scrollbars","status","window","open","settings","blockedPopoutsThrowError","error","type","on","_positionWindow","bind","_onClose","checkReadyInterval","setInterval","_onInitialised","clearInterval","windowOptions","windowOptionsString","key","push","join","storageKey","localStorage","setItem","JSON","stringify","urlParts","document","href","split","moveTo","focus","emit","setTimeout"],"sources":["../../src/controls/BrowserPopout.ts"],"sourcesContent":["import $ from 'jquery';\nimport type { Config, PopoutConfig, ItemConfigType } from '../config';\nimport type Root from '../items/Root';\nimport type LayoutManager from '../LayoutManager';\nimport { getUniqueId, minifyConfig, EventEmitter } from '../utils';\nimport { AbstractContentItem } from '..';\n\ntype BrowserDimensions = {\n width: number;\n height: number;\n top: number;\n left: number;\n};\n\n/**\n * Pops a content item out into a new browser window.\n * This is achieved by\n *\n * - Creating a new configuration with the content item as root element\n * - Serializing and minifying the configuration\n * - Opening the current window's URL with the configuration as a GET parameter\n * - GoldenLayout when opened in the new window will look for the GET parameter\n * and use it instead of the provided configuration\n *\n * @param config GoldenLayout item config\n * @param dimensions A map with width, height, top and left\n * @param parentId The id of the element the item will be appended to on popIn\n * @param indexInParent The position of this element within its parent\n * @param layoutManager\n */\nexport default class BrowserPopout extends EventEmitter {\n isInitialised = false;\n\n private _config: ItemConfigType[];\n private _dimensions: BrowserDimensions;\n private _parentId: string;\n private _indexInParent: number;\n private _layoutManager: LayoutManager;\n private _popoutWindow:\n | (Window & { __glInstance: LayoutManager })\n | null = null;\n private _id = null;\n\n constructor(\n config: ItemConfigType[],\n dimensions: BrowserDimensions,\n parentId: string,\n indexInParent: number,\n layoutManager: LayoutManager\n ) {\n super();\n\n this._config = config;\n this._dimensions = dimensions;\n this._parentId = parentId;\n this._indexInParent = indexInParent;\n this._layoutManager = layoutManager;\n this._createWindow();\n }\n\n toConfig() {\n if (this.isInitialised === false) {\n throw new Error(\"Can't create config, layout not yet initialised\");\n }\n return ({\n dimensions: {\n width: this.getGlInstance()?.width,\n height: this.getGlInstance()?.height,\n left:\n this._popoutWindow?.screenX ?? this._popoutWindow?.screenLeft ?? 0,\n top: this._popoutWindow?.screenY ?? this._popoutWindow?.screenTop ?? 0,\n },\n content: this.getGlInstance()?.toConfig().content,\n parentId: this._parentId,\n indexInParent: this._indexInParent,\n } as unknown) as PopoutConfig;\n }\n\n getGlInstance() {\n return this._popoutWindow?.__glInstance;\n }\n\n getWindow() {\n return this._popoutWindow;\n }\n\n close() {\n if (this.getGlInstance()) {\n this.getGlInstance()?._$closeWindow();\n } else {\n try {\n this.getWindow()?.close();\n } catch (e) {}\n }\n }\n\n /**\n * Returns the popped out item to its original position. If the original\n * parent isn't available anymore it falls back to the layout's topmost element\n */\n popIn() {\n let index = this._indexInParent;\n let childConfig: ItemConfigType | null = null;\n let parentItem: AbstractContentItem | null = null;\n\n if (this._parentId) {\n /*\n * The $.extend call seems a bit pointless, but it's crucial to\n * copy the config returned by this.getGlInstance().toConfig()\n * onto a new object. Internet Explorer keeps the references\n * to objects on the child window, resulting in the following error\n * once the child window is closed:\n *\n * The callee (server [not server application]) is not available and disappeared\n */\n childConfig = $.extend(true, {}, this.getGlInstance()?.toConfig())\n .content[0];\n parentItem = this._layoutManager.root.getItemsById(\n this._parentId\n )[0] as Root;\n\n /*\n * Fallback if parentItem is not available. Either add it to the topmost\n * item or make it the topmost item if the layout is empty\n */\n if (!parentItem) {\n if ((this._layoutManager.root.contentItems.length ?? 0) > 0) {\n parentItem = this._layoutManager.root.contentItems[0];\n } else {\n parentItem = this._layoutManager.root;\n }\n index = 0;\n }\n }\n\n if (!childConfig) {\n return;\n }\n\n parentItem?.addChild(childConfig, this._indexInParent);\n this.close();\n }\n\n /**\n * Creates the URL and window parameter\n * and opens a new window\n */\n _createWindow() {\n const url = this._createUrl();\n /**\n * Bogus title to prevent re-usage of existing window with the\n * same title. The actual title will be set by the new window's\n * GoldenLayout instance if it detects that it is in subWindowMode\n */\n const title = Math.floor(Math.random() * 1000000).toString(36);\n /**\n * The options as used in the window.open string\n */\n const options = this._serializeWindowOptions({\n width: this._dimensions.width,\n height: this._dimensions.height,\n innerWidth: this._dimensions.width,\n innerHeight: this._dimensions.height,\n menubar: 'no',\n toolbar: 'no',\n location: 'no',\n personalbar: 'no',\n resizable: 'yes',\n scrollbars: 'no',\n status: 'no',\n });\n\n // I'm not entirely sure how __glInstance is mounted to the popout window\n this._popoutWindow = window.open(url, title, options) as Window & {\n __glInstance: LayoutManager;\n };\n\n if (!this._popoutWindow) {\n if (\n this._layoutManager.config.settings.blockedPopoutsThrowError === true\n ) {\n const error = new Error('Popout blocked') as Error & { type: string };\n error.type = 'popoutBlocked';\n throw error;\n } else {\n return;\n }\n }\n\n $(this._popoutWindow)\n .on('load', this._positionWindow.bind(this))\n .on('unload beforeunload', this._onClose.bind(this));\n\n /**\n * Polling the childwindow to find out if GoldenLayout has been initialised\n * doesn't seem optimal, but the alternatives - adding a callback to the parent\n * window or raising an event on the window object - both would introduce knowledge\n * about the parent to the child window which we'd rather avoid\n */\n let checkReadyInterval = window.setInterval(() => {\n if (\n this._popoutWindow?.__glInstance &&\n this._popoutWindow.__glInstance.isInitialised\n ) {\n this._onInitialised();\n window.clearInterval(checkReadyInterval);\n }\n }, 10);\n }\n\n /**\n * Serialises a map of key:values to a window options string\n *\n * @param windowOptions\n *\n * @returns serialised window options\n */\n _serializeWindowOptions(windowOptions: Record<string, unknown>) {\n var windowOptionsString = [],\n key;\n\n for (key in windowOptions) {\n windowOptionsString.push(key + '=' + windowOptions[key]);\n }\n\n return windowOptionsString.join(',');\n }\n\n /**\n * Creates the URL for the new window, including the\n * config GET parameter\n *\n * @returns URL\n */\n _createUrl() {\n var config: Partial<Config> = { content: this._config };\n const storageKey = 'gl-window-config-' + getUniqueId();\n\n config = minifyConfig(config);\n\n try {\n localStorage.setItem(storageKey, JSON.stringify(config));\n } catch (e: any) {\n throw new Error('Error while writing to localStorage ' + e.toString());\n }\n\n const urlParts = document.location.href.split('?');\n\n // URL doesn't contain GET-parameters\n if (urlParts.length === 1) {\n return urlParts[0] + '?gl-window=' + storageKey;\n\n // URL contains GET-parameters\n } else {\n return document.location.href + '&gl-window=' + storageKey;\n }\n }\n\n /**\n * Move the newly created window roughly to\n * where the component used to be.\n */\n _positionWindow() {\n this._popoutWindow?.moveTo(this._dimensions.left, this._dimensions.top);\n this._popoutWindow?.focus();\n }\n\n /**\n * Callback when the new window is opened and the GoldenLayout instance\n * within it is initialised\n */\n _onInitialised() {\n this.isInitialised = true;\n this.getGlInstance()?.on('popIn', this.popIn, this);\n this.emit('initialised');\n }\n\n /**\n * Invoked 50ms after the window unload event\n */\n _onClose() {\n setTimeout(this.emit.bind(this, 'closed'), 50);\n }\n}\n"],"mappings":";;;AAAA,OAAOA,CAAC,M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E,CAAC;EAChD;AACF"}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
3
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
4
|
+
import $ from 'jquery';
|
|
5
|
+
import { stripTags, EventEmitter } from "../utils/index.js";
|
|
6
|
+
/**
|
|
7
|
+
* This class creates a temporary container
|
|
8
|
+
* for the component whilst it is being dragged
|
|
9
|
+
* and handles drag events
|
|
10
|
+
*
|
|
11
|
+
* @param x The initial x position
|
|
12
|
+
* @param y The initial y position
|
|
13
|
+
* @param dragListener
|
|
14
|
+
* @param layoutManager
|
|
15
|
+
* @param contentItem
|
|
16
|
+
* @param originalParent
|
|
17
|
+
*/
|
|
18
|
+
export default class DragProxy extends EventEmitter {
|
|
19
|
+
constructor(x, y, dragListener, layoutManager, contentItem, originalParent) {
|
|
20
|
+
var _this$_contentItem$co, _this$_contentItem$co2, _offset$left, _offset$top, _this$_layoutManager$, _this$_layoutManager$2, _this$element$width, _this$element$height;
|
|
21
|
+
super();
|
|
22
|
+
_defineProperty(this, "_dragListener", void 0);
|
|
23
|
+
_defineProperty(this, "_layoutManager", void 0);
|
|
24
|
+
_defineProperty(this, "_contentItem", void 0);
|
|
25
|
+
_defineProperty(this, "_originalParent", void 0);
|
|
26
|
+
_defineProperty(this, "_area", null);
|
|
27
|
+
_defineProperty(this, "_lastValidArea", null);
|
|
28
|
+
_defineProperty(this, "_minX", void 0);
|
|
29
|
+
_defineProperty(this, "_maxX", void 0);
|
|
30
|
+
_defineProperty(this, "_minY", void 0);
|
|
31
|
+
_defineProperty(this, "_maxY", void 0);
|
|
32
|
+
_defineProperty(this, "_width", void 0);
|
|
33
|
+
_defineProperty(this, "_height", void 0);
|
|
34
|
+
_defineProperty(this, "_sided", void 0);
|
|
35
|
+
_defineProperty(this, "element", void 0);
|
|
36
|
+
_defineProperty(this, "childElementContainer", void 0);
|
|
37
|
+
_defineProperty(this, "_proxyTab", void 0);
|
|
38
|
+
this._dragListener = dragListener;
|
|
39
|
+
this._layoutManager = layoutManager;
|
|
40
|
+
this._contentItem = contentItem;
|
|
41
|
+
this._originalParent = originalParent;
|
|
42
|
+
this._dragListener.on('drag', this._onDrag, this);
|
|
43
|
+
this._dragListener.on('dragStop', this._onDrop, this);
|
|
44
|
+
|
|
45
|
+
// set the inserted drag placeholder to be the size of the tab removed, before its removed
|
|
46
|
+
if (this._contentItem.tab && this._contentItem.tab.element) {
|
|
47
|
+
var _this$_contentItem$ta, _this$_contentItem$ta2;
|
|
48
|
+
this._layoutManager.tabDropPlaceholder.width((_this$_contentItem$ta = this._contentItem.tab.element.outerWidth(true)) !== null && _this$_contentItem$ta !== void 0 ? _this$_contentItem$ta : 0);
|
|
49
|
+
this._layoutManager.tabDropPlaceholder.height((_this$_contentItem$ta2 = this._contentItem.tab.element.outerHeight(true)) !== null && _this$_contentItem$ta2 !== void 0 ? _this$_contentItem$ta2 : 0);
|
|
50
|
+
}
|
|
51
|
+
this.element = $(DragProxy._template);
|
|
52
|
+
if (originalParent && originalParent._side) {
|
|
53
|
+
this._sided = originalParent._sided;
|
|
54
|
+
this.element.addClass('lm_' + originalParent._side);
|
|
55
|
+
if (['right', 'bottom'].indexOf(originalParent._side.toString()) >= 0) this.element.find('.lm_content').after(this.element.find('.lm_header'));
|
|
56
|
+
}
|
|
57
|
+
this.element.css({
|
|
58
|
+
left: x,
|
|
59
|
+
top: y
|
|
60
|
+
});
|
|
61
|
+
this._proxyTab = this.element.find('.lm_tab');
|
|
62
|
+
this._proxyTab.attr('title', stripTags((_this$_contentItem$co = this._contentItem.config.title) !== null && _this$_contentItem$co !== void 0 ? _this$_contentItem$co : ''));
|
|
63
|
+
this.element.find('.lm_title').html((_this$_contentItem$co2 = this._contentItem.config.title) !== null && _this$_contentItem$co2 !== void 0 ? _this$_contentItem$co2 : '');
|
|
64
|
+
this.childElementContainer = this.element.find('.lm_content');
|
|
65
|
+
this.childElementContainer.append(contentItem.element);
|
|
66
|
+
this._updateTree();
|
|
67
|
+
this._layoutManager._$calculateItemAreas();
|
|
68
|
+
$(document.body).append(this.element);
|
|
69
|
+
|
|
70
|
+
// Need to set dimensions after adding the element, or `Component.setSize()` will not pass the `.is('visible')` test and won't update
|
|
71
|
+
this._setDimensions();
|
|
72
|
+
|
|
73
|
+
// there's no content tab to use yet, use the proxy tab size for placeholder sizing, after it's created
|
|
74
|
+
if (!this._contentItem.tab && this._proxyTab.length) {
|
|
75
|
+
var _this$_proxyTab$outer, _this$_proxyTab$outer2;
|
|
76
|
+
this._layoutManager.tabDropPlaceholder.width((_this$_proxyTab$outer = this._proxyTab.outerWidth(true)) !== null && _this$_proxyTab$outer !== void 0 ? _this$_proxyTab$outer : 0);
|
|
77
|
+
this._layoutManager.tabDropPlaceholder.height((_this$_proxyTab$outer2 = this._proxyTab.outerHeight(true)) !== null && _this$_proxyTab$outer2 !== void 0 ? _this$_proxyTab$outer2 : 0);
|
|
78
|
+
}
|
|
79
|
+
var offset = this._layoutManager.container.offset();
|
|
80
|
+
this._minX = (_offset$left = offset === null || offset === void 0 ? void 0 : offset.left) !== null && _offset$left !== void 0 ? _offset$left : 0;
|
|
81
|
+
this._minY = (_offset$top = offset === null || offset === void 0 ? void 0 : offset.top) !== null && _offset$top !== void 0 ? _offset$top : 0;
|
|
82
|
+
this._maxX = ((_this$_layoutManager$ = this._layoutManager.container.width()) !== null && _this$_layoutManager$ !== void 0 ? _this$_layoutManager$ : 0) + this._minX;
|
|
83
|
+
this._maxY = ((_this$_layoutManager$2 = this._layoutManager.container.height()) !== null && _this$_layoutManager$2 !== void 0 ? _this$_layoutManager$2 : 0) + this._minY;
|
|
84
|
+
this._width = (_this$element$width = this.element.width()) !== null && _this$element$width !== void 0 ? _this$element$width : 0;
|
|
85
|
+
this._height = (_this$element$height = this.element.height()) !== null && _this$element$height !== void 0 ? _this$element$height : 0;
|
|
86
|
+
this._setDropPosition(x, y);
|
|
87
|
+
this._layoutManager.emit('itemPickedUp', this._contentItem);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Callback on every mouseMove event during a drag. Determines if the drag is
|
|
92
|
+
* still within the valid drag area and calls the layoutManager to highlight the
|
|
93
|
+
* current drop area
|
|
94
|
+
*
|
|
95
|
+
* @param offsetX The difference from the original x position in px
|
|
96
|
+
* @param offsetY The difference from the original y position in px
|
|
97
|
+
* @param event
|
|
98
|
+
*/
|
|
99
|
+
_onDrag(offsetX, offsetY, event) {
|
|
100
|
+
var _event$pageX, _event$pageY;
|
|
101
|
+
var x = (_event$pageX = event.pageX) !== null && _event$pageX !== void 0 ? _event$pageX : 0;
|
|
102
|
+
var y = (_event$pageY = event.pageY) !== null && _event$pageY !== void 0 ? _event$pageY : 0;
|
|
103
|
+
var isWithinContainer = x > this._minX && x < this._maxX && y > this._minY && y < this._maxY;
|
|
104
|
+
if (!isWithinContainer && this._layoutManager.config.settings.constrainDragToContainer === true) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
this._setDropPosition(x, y);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Sets the target position, highlighting the appropriate area
|
|
112
|
+
*
|
|
113
|
+
* @param x The x position in px
|
|
114
|
+
* @param y The y position in px
|
|
115
|
+
*/
|
|
116
|
+
_setDropPosition(x, y) {
|
|
117
|
+
this.element.css({
|
|
118
|
+
left: x,
|
|
119
|
+
top: y
|
|
120
|
+
});
|
|
121
|
+
this._area = this._layoutManager._$getArea(x, y);
|
|
122
|
+
if (this._area !== null) {
|
|
123
|
+
this._lastValidArea = this._area;
|
|
124
|
+
this._area.contentItem._$highlightDropZone(x, y, this._area);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Callback when the drag has finished. Determines the drop area
|
|
130
|
+
* and adds the child to it
|
|
131
|
+
*/
|
|
132
|
+
_onDrop() {
|
|
133
|
+
var _this$_layoutManager$3;
|
|
134
|
+
(_this$_layoutManager$3 = this._layoutManager.dropTargetIndicator) === null || _this$_layoutManager$3 === void 0 ? void 0 : _this$_layoutManager$3.hide();
|
|
135
|
+
|
|
136
|
+
/*
|
|
137
|
+
* Valid drop area found
|
|
138
|
+
*/
|
|
139
|
+
if (this._area !== null) {
|
|
140
|
+
this._area.contentItem._$onDrop(this._contentItem, this._area);
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* No valid drop area available at present, but one has been found before.
|
|
144
|
+
* Use it
|
|
145
|
+
*/
|
|
146
|
+
} else if (this._lastValidArea !== null) {
|
|
147
|
+
this._lastValidArea.contentItem._$onDrop(this._contentItem, this._lastValidArea);
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* No valid drop area found during the duration of the drag. Return
|
|
151
|
+
* content item to its original position if a original parent is provided.
|
|
152
|
+
* (Which is not the case if the drag had been initiated by createDragSource)
|
|
153
|
+
*/
|
|
154
|
+
} else if (this._originalParent) {
|
|
155
|
+
this._originalParent.addChild(this._contentItem);
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* The drag didn't ultimately end up with adding the content item to
|
|
159
|
+
* any container. In order to ensure clean up happens, destroy the
|
|
160
|
+
* content item.
|
|
161
|
+
*/
|
|
162
|
+
} else {
|
|
163
|
+
this._contentItem._$destroy();
|
|
164
|
+
}
|
|
165
|
+
this._dragListener.off('drag', this._onDrag, this);
|
|
166
|
+
this._dragListener.off('dragStop', this._onDrop, this);
|
|
167
|
+
this.element.remove();
|
|
168
|
+
this._layoutManager.emit('itemDropped', this._contentItem);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Removes the item from its original position within the tree
|
|
173
|
+
*/
|
|
174
|
+
_updateTree() {
|
|
175
|
+
/**
|
|
176
|
+
* parent is null if the drag had been initiated by a external drag source
|
|
177
|
+
*/
|
|
178
|
+
if (this._contentItem.parent) {
|
|
179
|
+
this._contentItem.parent.removeChild(this._contentItem, true);
|
|
180
|
+
}
|
|
181
|
+
this._contentItem._$setParent(null);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Updates the DragProxy's dimensions
|
|
186
|
+
*/
|
|
187
|
+
_setDimensions() {
|
|
188
|
+
var dimensions = this._layoutManager.config.dimensions;
|
|
189
|
+
var width = dimensions.dragProxyWidth;
|
|
190
|
+
var height = dimensions.dragProxyHeight;
|
|
191
|
+
this.element.width(width);
|
|
192
|
+
this.element.height(height);
|
|
193
|
+
width -= this._sided ? dimensions.headerHeight : 0;
|
|
194
|
+
height -= !this._sided ? dimensions.headerHeight : 0;
|
|
195
|
+
this.childElementContainer.width(width);
|
|
196
|
+
this.childElementContainer.height(height);
|
|
197
|
+
this._contentItem.element.width(width);
|
|
198
|
+
this._contentItem.element.height(height);
|
|
199
|
+
this._contentItem.callDownwards('_$show');
|
|
200
|
+
this._contentItem.callDownwards('setSize');
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
_defineProperty(DragProxy, "_template", '<div class="lm_dragProxy">' + '<div class="lm_header">' + '<ul class="lm_tabs">' + '<li class="lm_tab lm_active"><i class="lm_left"></i>' + '<span class="lm_title"></span>' + '<i class="lm_right"></i></li>' + '</ul>' + '</div>' + '<div class="lm_content"></div>' + '</div>');
|
|
204
|
+
//# sourceMappingURL=DragProxy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DragProxy.js","names":["$","stripTags","EventEmitter","DragProxy","constructor","x","y","dragListener","layoutManager","contentItem","originalParent","_dragListener","_layoutManager","_contentItem","_originalParent","on","_onDrag","_onDrop","tab","element","tabDropPlaceholder","width","outerWidth","height","outerHeight","_template","_side","_sided","addClass","indexOf","toString","find","after","css","left","top","_proxyTab","attr","config","title","html","childElementContainer","append","_updateTree","_$calculateItemAreas","document","body","_setDimensions","length","offset","container","_minX","_minY","_maxX","_maxY","_width","_height","_setDropPosition","emit","offsetX","offsetY","event","pageX","pageY","isWithinContainer","settings","constrainDragToContainer","_area","_$getArea","_lastValidArea","_$highlightDropZone","dropTargetIndicator","hide","_$onDrop","addChild","_$destroy","off","remove","parent","removeChild","_$setParent","dimensions","dragProxyWidth","dragProxyHeight","headerHeight","callDownwards"],"sources":["../../src/controls/DragProxy.ts"],"sourcesContent":["import $ from 'jquery';\nimport type { AbstractContentItem, ItemArea, Stack } from '../items';\nimport type LayoutManager from '../LayoutManager';\nimport type { DragListener } from '../utils';\nimport { stripTags, EventEmitter } from '../utils';\n\n/**\n * This class creates a temporary container\n * for the component whilst it is being dragged\n * and handles drag events\n *\n * @param x The initial x position\n * @param y The initial y position\n * @param dragListener\n * @param layoutManager\n * @param contentItem\n * @param originalParent\n */\nexport default class DragProxy extends EventEmitter {\n private static _template =\n '<div class=\"lm_dragProxy\">' +\n '<div class=\"lm_header\">' +\n '<ul class=\"lm_tabs\">' +\n '<li class=\"lm_tab lm_active\"><i class=\"lm_left\"></i>' +\n '<span class=\"lm_title\"></span>' +\n '<i class=\"lm_right\"></i></li>' +\n '</ul>' +\n '</div>' +\n '<div class=\"lm_content\"></div>' +\n '</div>';\n\n private _dragListener: DragListener;\n private _layoutManager: LayoutManager;\n private _contentItem: AbstractContentItem;\n private _originalParent: Stack | null;\n\n private _area: ItemArea | null = null;\n private _lastValidArea: ItemArea | null = null;\n\n private _minX: number;\n private _maxX: number;\n private _minY: number;\n private _maxY: number;\n private _width: number;\n private _height: number;\n private _sided?: boolean;\n\n element: JQuery<HTMLElement>;\n childElementContainer: JQuery<HTMLElement>;\n private _proxyTab: JQuery<HTMLElement>;\n\n constructor(\n x: number,\n y: number,\n dragListener: DragListener,\n layoutManager: LayoutManager,\n contentItem: AbstractContentItem,\n originalParent: Stack | null\n ) {\n super();\n\n this._dragListener = dragListener;\n this._layoutManager = layoutManager;\n this._contentItem = contentItem;\n this._originalParent = originalParent;\n\n this._dragListener.on('drag', this._onDrag, this);\n this._dragListener.on('dragStop', this._onDrop, this);\n\n // set the inserted drag placeholder to be the size of the tab removed, before its removed\n if (this._contentItem.tab && this._contentItem.tab.element) {\n this._layoutManager.tabDropPlaceholder.width(\n this._contentItem.tab.element.outerWidth(true) ?? 0\n );\n this._layoutManager.tabDropPlaceholder.height(\n this._contentItem.tab.element.outerHeight(true) ?? 0\n );\n }\n\n this.element = $(DragProxy._template);\n if (originalParent && originalParent._side) {\n this._sided = originalParent._sided;\n this.element.addClass('lm_' + originalParent._side);\n if (['right', 'bottom'].indexOf(originalParent._side.toString()) >= 0)\n this.element.find('.lm_content').after(this.element.find('.lm_header'));\n }\n this.element.css({ left: x, top: y });\n this._proxyTab = this.element.find('.lm_tab');\n this._proxyTab.attr(\n 'title',\n stripTags(this._contentItem.config.title ?? '')\n );\n this.element.find('.lm_title').html(this._contentItem.config.title ?? '');\n this.childElementContainer = this.element.find('.lm_content');\n this.childElementContainer.append(contentItem.element);\n\n this._updateTree();\n this._layoutManager._$calculateItemAreas();\n\n $(document.body).append(this.element);\n\n // Need to set dimensions after adding the element, or `Component.setSize()` will not pass the `.is('visible')` test and won't update\n this._setDimensions();\n\n // there's no content tab to use yet, use the proxy tab size for placeholder sizing, after it's created\n if (!this._contentItem.tab && this._proxyTab.length) {\n this._layoutManager.tabDropPlaceholder.width(\n this._proxyTab.outerWidth(true) ?? 0\n );\n this._layoutManager.tabDropPlaceholder.height(\n this._proxyTab.outerHeight(true) ?? 0\n );\n }\n\n var offset = this._layoutManager.container.offset();\n\n this._minX = offset?.left ?? 0;\n this._minY = offset?.top ?? 0;\n this._maxX = (this._layoutManager.container.width() ?? 0) + this._minX;\n this._maxY = (this._layoutManager.container.height() ?? 0) + this._minY;\n this._width = this.element.width() ?? 0;\n this._height = this.element.height() ?? 0;\n\n this._setDropPosition(x, y);\n\n this._layoutManager.emit('itemPickedUp', this._contentItem);\n }\n\n /**\n * Callback on every mouseMove event during a drag. Determines if the drag is\n * still within the valid drag area and calls the layoutManager to highlight the\n * current drop area\n *\n * @param offsetX The difference from the original x position in px\n * @param offsetY The difference from the original y position in px\n * @param event\n */\n _onDrag(offsetX: number, offsetY: number, event: JQuery.TriggeredEvent) {\n const x = event.pageX ?? 0;\n const y = event.pageY ?? 0;\n const isWithinContainer =\n x > this._minX && x < this._maxX && y > this._minY && y < this._maxY;\n\n if (\n !isWithinContainer &&\n this._layoutManager.config.settings.constrainDragToContainer === true\n ) {\n return;\n }\n\n this._setDropPosition(x, y);\n }\n\n /**\n * Sets the target position, highlighting the appropriate area\n *\n * @param x The x position in px\n * @param y The y position in px\n */\n _setDropPosition(x: number, y: number) {\n this.element.css({ left: x, top: y });\n this._area = this._layoutManager._$getArea(x, y);\n\n if (this._area !== null) {\n this._lastValidArea = this._area;\n this._area.contentItem._$highlightDropZone(x, y, this._area);\n }\n }\n\n /**\n * Callback when the drag has finished. Determines the drop area\n * and adds the child to it\n */\n _onDrop() {\n this._layoutManager.dropTargetIndicator?.hide();\n\n /*\n * Valid drop area found\n */\n if (this._area !== null) {\n this._area.contentItem._$onDrop(this._contentItem, this._area);\n\n /**\n * No valid drop area available at present, but one has been found before.\n * Use it\n */\n } else if (this._lastValidArea !== null) {\n this._lastValidArea.contentItem._$onDrop(\n this._contentItem,\n this._lastValidArea\n );\n\n /**\n * No valid drop area found during the duration of the drag. Return\n * content item to its original position if a original parent is provided.\n * (Which is not the case if the drag had been initiated by createDragSource)\n */\n } else if (this._originalParent) {\n this._originalParent.addChild(this._contentItem);\n\n /**\n * The drag didn't ultimately end up with adding the content item to\n * any container. In order to ensure clean up happens, destroy the\n * content item.\n */\n } else {\n this._contentItem._$destroy();\n }\n\n this._dragListener.off('drag', this._onDrag, this);\n this._dragListener.off('dragStop', this._onDrop, this);\n\n this.element.remove();\n\n this._layoutManager.emit('itemDropped', this._contentItem);\n }\n\n /**\n * Removes the item from its original position within the tree\n */\n _updateTree() {\n /**\n * parent is null if the drag had been initiated by a external drag source\n */\n if (this._contentItem.parent) {\n this._contentItem.parent.removeChild(this._contentItem, true);\n }\n\n this._contentItem._$setParent(null);\n }\n\n /**\n * Updates the DragProxy's dimensions\n */\n _setDimensions() {\n const dimensions = this._layoutManager.config.dimensions;\n let width = dimensions.dragProxyWidth;\n let height = dimensions.dragProxyHeight;\n\n this.element.width(width);\n this.element.height(height);\n width -= this._sided ? dimensions.headerHeight : 0;\n height -= !this._sided ? dimensions.headerHeight : 0;\n this.childElementContainer.width(width);\n this.childElementContainer.height(height);\n this._contentItem.element.width(width);\n this._contentItem.element.height(height);\n this._contentItem.callDownwards('_$show');\n this._contentItem.callDownwards('setSize');\n }\n}\n"],"mappings":";;;AAAA,OAAOA,CAAC,MAAM,QAAQ;AAAC,SAIdC,SAAS,EAAEC,YAAY;AAEhC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAMC,SAAS,SAASD,YAAY,CAAC;EAiClDE,WAAW,CACTC,CAAS,EACTC,CAAS,EACTC,YAA0B,EAC1BC,aAA4B,EAC5BC,WAAgC,EAChCC,cAA4B,EAC5B;IAAA;IACA,KAAK,EAAE;IAAC;IAAA;IAAA;IAAA;IAAA,+BAvBuB,IAAI;IAAA,wCACK,IAAI;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAwB5C,IAAI,CAACC,aAAa,GAAGJ,YAAY;IACjC,IAAI,CAACK,cAAc,GAAGJ,aAAa;IACnC,IAAI,CAACK,YAAY,GAAGJ,WAAW;IAC/B,IAAI,CAACK,eAAe,GAAGJ,cAAc;IAErC,IAAI,CAACC,aAAa,CAACI,EAAE,CAAC,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CAACV,YAAY,CAACM,OAAO,CAACE,KAAK,CAACA,KAAK,CAAC;IACtC,IAAI,CAACR,YAAY,CAACM,OAAO,CAACI,MAAM,CAACA,MAAM,CAAC;IACxC,IAAI,CAACV,YAAY,CAACwE,aAAa,CAAC,QAAQ,CAAC;IACzC,IAAI,CAACxE,YAAY,CAACwE,aAAa,CAAC,SAAS,CAAC;EAC5C;AACF;AAAC,gBAxOoBlF,SAAS,eAE1B,4BAA4B,GAC5B,yBAAyB,GACzB,sBAAsB,GACtB,sDAAsD,GACtD,gCAAgC,GAChC,+BAA+B,GAC/B,OAAO,GACP,QAAQ,GACR,gCAAgC,GAChC,QAAQ"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
3
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
4
|
+
import $ from 'jquery';
|
|
5
|
+
import { DragListener } from "../utils/index.js";
|
|
6
|
+
import DragProxy from "./DragProxy.js";
|
|
7
|
+
/**
|
|
8
|
+
* Allows for any DOM item to create a component on drag
|
|
9
|
+
* start tobe dragged into the Layout
|
|
10
|
+
*
|
|
11
|
+
* @param element
|
|
12
|
+
* @param itemConfig the configuration for the contentItem that will be created
|
|
13
|
+
* @param layoutManager
|
|
14
|
+
*/
|
|
15
|
+
export default class DragSource {
|
|
16
|
+
constructor(element, itemConfig, layoutManager) {
|
|
17
|
+
_defineProperty(this, "_element", void 0);
|
|
18
|
+
_defineProperty(this, "_itemConfig", void 0);
|
|
19
|
+
_defineProperty(this, "_layoutManager", void 0);
|
|
20
|
+
_defineProperty(this, "_dragListener", void 0);
|
|
21
|
+
this._element = element;
|
|
22
|
+
this._itemConfig = itemConfig;
|
|
23
|
+
this._layoutManager = layoutManager;
|
|
24
|
+
this._dragListener = this._createDragListener();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Called initially and after every drag
|
|
29
|
+
*/
|
|
30
|
+
_createDragListener() {
|
|
31
|
+
this._dragListener = new DragListener(this._element, true);
|
|
32
|
+
this._dragListener.on('dragStart', this._onDragStart, this);
|
|
33
|
+
this._dragListener.on('dragStop', this._createDragListener, this);
|
|
34
|
+
return this._dragListener;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Callback for the DragListener's dragStart event
|
|
39
|
+
*
|
|
40
|
+
* @param x the x position of the mouse on dragStart
|
|
41
|
+
* @param y the x position of the mouse on dragStart
|
|
42
|
+
*/
|
|
43
|
+
_onDragStart(x, y) {
|
|
44
|
+
var itemConfig = this._itemConfig;
|
|
45
|
+
if (typeof itemConfig === 'function') {
|
|
46
|
+
itemConfig = itemConfig();
|
|
47
|
+
}
|
|
48
|
+
var contentItem = this._layoutManager._$normalizeContentItem($.extend(true, {}, itemConfig)),
|
|
49
|
+
dragProxy = new DragProxy(x, y, this._dragListener, this._layoutManager, contentItem, null);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=DragSource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DragSource.js","names":["$","DragListener","DragProxy","DragSource","constructor","element","itemConfig","layoutManager","_element","_itemConfig","_layoutManager","_dragListener","_createDragListener","on","_onDragStart","x","y","contentItem","_$normalizeContentItem","extend","dragProxy"],"sources":["../../src/controls/DragSource.ts"],"sourcesContent":["import $ from 'jquery';\nimport type { ItemConfigType } from '../config';\nimport type LayoutManager from '../LayoutManager';\nimport { DragListener } from '../utils';\nimport DragProxy from './DragProxy';\n\n/**\n * Allows for any DOM item to create a component on drag\n * start tobe dragged into the Layout\n *\n * @param element\n * @param itemConfig the configuration for the contentItem that will be created\n * @param layoutManager\n */\nexport default class DragSource {\n _element: JQuery<HTMLElement>;\n _itemConfig: ItemConfigType | (() => ItemConfigType);\n _layoutManager: LayoutManager;\n _dragListener: DragListener;\n\n constructor(\n element: JQuery<HTMLElement>,\n itemConfig: ItemConfigType | (() => ItemConfigType),\n layoutManager: LayoutManager\n ) {\n this._element = element;\n this._itemConfig = itemConfig;\n this._layoutManager = layoutManager;\n\n this._dragListener = this._createDragListener();\n }\n\n /**\n * Called initially and after every drag\n */\n _createDragListener() {\n this._dragListener = new DragListener(this._element, true);\n this._dragListener.on('dragStart', this._onDragStart, this);\n this._dragListener.on('dragStop', this._createDragListener, this);\n return this._dragListener;\n }\n\n /**\n * Callback for the DragListener's dragStart event\n *\n * @param x the x position of the mouse on dragStart\n * @param y the x position of the mouse on dragStart\n */\n _onDragStart(x: number, y: number) {\n let itemConfig = this._itemConfig;\n if (typeof itemConfig === 'function') {\n itemConfig = itemConfig();\n }\n const contentItem = this._layoutManager._$normalizeContentItem(\n $.extend(true, {}, itemConfig)\n ),\n dragProxy = new DragProxy(\n x,\n y,\n this._dragListener,\n this._layoutManager,\n contentItem,\n null\n );\n }\n}\n"],"mappings":";;;AAAA,OAAOA,CAAC,MAAM,QAAQ;AAAC,SAGdC,YAAY;AAAA,OACdC,SAAS;AAEhB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAMC,UAAU,CAAC;EAM9BC,WAAW,CACTC,OAA4B,EAC5BC,UAAmD,EACnDC,aAA4B,EAC5B;IAAA;IAAA;IAAA;IAAA;IACA,IAAI,CAACC,QAAQ,GAAGH,OAAO;IACvB,IAAI,CAACI,WAAW,GAAGH,UAAU;IAC7B,IAAI,CAACI,cAAc,GAAGH,aAAa;IAEnC,IAAI,CAACI,aAAa,GAAG,IAAI,CAACC,mBAAm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