@deephaven/golden-layout 0.19.2-beta.5 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/dist/LayoutManager.d.ts +313 -0
  2. package/dist/LayoutManager.d.ts.map +1 -0
  3. package/dist/LayoutManager.js +468 -450
  4. package/dist/LayoutManager.js.map +1 -1
  5. package/dist/base.d.ts +16 -0
  6. package/dist/base.d.ts.map +1 -0
  7. package/dist/base.js +6 -6
  8. package/dist/base.js.map +1 -1
  9. package/dist/config/Config.d.ts +146 -0
  10. package/dist/config/Config.d.ts.map +1 -0
  11. package/dist/config/{defaultConfig.js → Config.js} +6 -6
  12. package/dist/config/Config.js.map +1 -0
  13. package/dist/config/ItemConfig.d.ts +66 -0
  14. package/dist/config/ItemConfig.d.ts.map +1 -0
  15. package/dist/config/ItemConfig.js +14 -0
  16. package/dist/config/ItemConfig.js.map +1 -0
  17. package/dist/config/index.d.ts +3 -0
  18. package/dist/config/index.d.ts.map +1 -0
  19. package/dist/config/index.js +2 -6
  20. package/dist/config/index.js.map +1 -1
  21. package/dist/container/ItemContainer.d.ts +91 -0
  22. package/dist/container/ItemContainer.d.ts.map +1 -0
  23. package/dist/container/ItemContainer.js +110 -85
  24. package/dist/container/ItemContainer.js.map +1 -1
  25. package/dist/container/index.d.ts +3 -0
  26. package/dist/container/index.d.ts.map +1 -0
  27. package/dist/container/index.js +2 -4
  28. package/dist/container/index.js.map +1 -1
  29. package/dist/controls/BrowserPopout.d.ts +83 -0
  30. package/dist/controls/BrowserPopout.d.ts.map +1 -0
  31. package/dist/controls/BrowserPopout.js +135 -101
  32. package/dist/controls/BrowserPopout.js.map +1 -1
  33. package/dist/controls/DragProxy.d.ts +67 -0
  34. package/dist/controls/DragProxy.d.ts.map +1 -0
  35. package/dist/controls/DragProxy.js +135 -110
  36. package/dist/controls/DragProxy.js.map +1 -1
  37. package/dist/controls/DragSource.d.ts +30 -0
  38. package/dist/controls/DragSource.d.ts.map +1 -0
  39. package/dist/controls/DragSource.js +37 -29
  40. package/dist/controls/DragSource.js.map +1 -1
  41. package/dist/controls/DragSourceFromEvent.d.ts +30 -0
  42. package/dist/controls/DragSourceFromEvent.d.ts.map +1 -0
  43. package/dist/controls/DragSourceFromEvent.js +49 -36
  44. package/dist/controls/DragSourceFromEvent.js.map +1 -1
  45. package/dist/controls/DropTargetIndicator.d.ts +14 -0
  46. package/dist/controls/DropTargetIndicator.d.ts.map +1 -0
  47. package/dist/controls/DropTargetIndicator.js +18 -14
  48. package/dist/controls/DropTargetIndicator.js.map +1 -1
  49. package/dist/controls/Header.d.ts +145 -0
  50. package/dist/controls/Header.d.ts.map +1 -0
  51. package/dist/controls/Header.js +414 -271
  52. package/dist/controls/Header.js.map +1 -1
  53. package/dist/controls/HeaderButton.d.ts +9 -0
  54. package/dist/controls/HeaderButton.d.ts.map +1 -0
  55. package/dist/controls/HeaderButton.js +19 -13
  56. package/dist/controls/HeaderButton.js.map +1 -1
  57. package/dist/controls/Splitter.d.ts +12 -0
  58. package/dist/controls/Splitter.d.ts.map +1 -0
  59. package/dist/controls/Splitter.js +36 -20
  60. package/dist/controls/Splitter.js.map +1 -1
  61. package/dist/controls/Tab.d.ts +91 -0
  62. package/dist/controls/Tab.d.ts.map +1 -0
  63. package/dist/controls/Tab.js +131 -119
  64. package/dist/controls/Tab.js.map +1 -1
  65. package/dist/controls/TransitionIndicator.d.ts +25 -0
  66. package/dist/controls/TransitionIndicator.d.ts.map +1 -0
  67. package/dist/controls/TransitionIndicator.js +53 -39
  68. package/dist/controls/TransitionIndicator.js.map +1 -1
  69. package/dist/controls/index.d.ts +11 -0
  70. package/dist/controls/index.d.ts.map +1 -0
  71. package/dist/controls/index.js +10 -22
  72. package/dist/controls/index.js.map +1 -1
  73. package/dist/errors/ConfigurationError.d.ts +6 -0
  74. package/dist/errors/ConfigurationError.d.ts.map +1 -0
  75. package/dist/errors/ConfigurationError.js +15 -8
  76. package/dist/errors/ConfigurationError.js.map +1 -1
  77. package/dist/errors/index.d.ts +2 -0
  78. package/dist/errors/index.d.ts.map +1 -0
  79. package/dist/errors/index.js +1 -4
  80. package/dist/errors/index.js.map +1 -1
  81. package/dist/index.d.ts +9 -0
  82. package/dist/index.d.ts.map +1 -0
  83. package/dist/index.js +7 -1
  84. package/dist/index.js.map +1 -1
  85. package/dist/items/AbstractContentItem.d.ts +233 -0
  86. package/dist/items/AbstractContentItem.d.ts.map +1 -0
  87. package/dist/items/AbstractContentItem.js +284 -242
  88. package/dist/items/AbstractContentItem.js.map +1 -1
  89. package/dist/items/Component.d.ts +30 -0
  90. package/dist/items/Component.d.ts.map +1 -0
  91. package/dist/items/Component.js +61 -42
  92. package/dist/items/Component.js.map +1 -1
  93. package/dist/items/Root.d.ts +18 -0
  94. package/dist/items/Root.d.ts.map +1 -0
  95. package/dist/items/Root.js +68 -38
  96. package/dist/items/Root.js.map +1 -1
  97. package/dist/items/RowOrColumn.d.ts +157 -0
  98. package/dist/items/RowOrColumn.d.ts.map +1 -0
  99. package/dist/items/RowOrColumn.js +219 -187
  100. package/dist/items/RowOrColumn.js.map +1 -1
  101. package/dist/items/Stack.d.ts +108 -0
  102. package/dist/items/Stack.d.ts.map +1 -0
  103. package/dist/items/Stack.js +218 -151
  104. package/dist/items/Stack.js.map +1 -1
  105. package/dist/items/index.d.ts +8 -0
  106. package/dist/items/index.d.ts.map +1 -0
  107. package/dist/items/index.js +7 -12
  108. package/dist/items/index.js.map +1 -1
  109. package/dist/utils/BubblingEvent.d.ts +8 -0
  110. package/dist/utils/BubblingEvent.d.ts.map +1 -0
  111. package/dist/utils/BubblingEvent.js +18 -9
  112. package/dist/utils/BubblingEvent.js.map +1 -1
  113. package/dist/utils/ConfigMinifier.d.ts +21 -0
  114. package/dist/utils/ConfigMinifier.d.ts.map +1 -0
  115. package/dist/utils/ConfigMinifier.js +121 -121
  116. package/dist/utils/ConfigMinifier.js.map +1 -1
  117. package/dist/utils/DragListener.d.ts +34 -0
  118. package/dist/utils/DragListener.d.ts.map +1 -0
  119. package/dist/utils/DragListener.js +103 -70
  120. package/dist/utils/DragListener.js.map +1 -1
  121. package/dist/utils/EventEmitter.d.ts +59 -0
  122. package/dist/utils/EventEmitter.d.ts.map +1 -0
  123. package/dist/utils/EventEmitter.js +64 -70
  124. package/dist/utils/EventEmitter.js.map +1 -1
  125. package/dist/utils/EventHub.d.ts +55 -0
  126. package/dist/utils/EventHub.d.ts.map +1 -0
  127. package/dist/utils/EventHub.js +83 -105
  128. package/dist/utils/EventHub.js.map +1 -1
  129. package/dist/utils/ReactComponentHandler.d.ts +54 -0
  130. package/dist/utils/ReactComponentHandler.d.ts.map +1 -0
  131. package/dist/utils/ReactComponentHandler.js +58 -56
  132. package/dist/utils/ReactComponentHandler.js.map +1 -1
  133. package/dist/utils/index.d.ts +8 -0
  134. package/dist/utils/index.d.ts.map +1 -0
  135. package/dist/utils/index.js +7 -21
  136. package/dist/utils/index.js.map +1 -1
  137. package/dist/utils/utils.d.ts +25 -0
  138. package/dist/utils/utils.d.ts.map +1 -0
  139. package/dist/utils/utils.js +21 -145
  140. package/dist/utils/utils.js.map +1 -1
  141. package/package.json +9 -5
  142. package/dist/config/ItemDefaultConfig.js +0 -8
  143. package/dist/config/ItemDefaultConfig.js.map +0 -1
  144. package/dist/config/defaultConfig.js.map +0 -1
@@ -1,5 +1,8 @@
1
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
+
1
3
  import $ from 'jquery';
2
- import utils from '../utils/index.js';
4
+ import { getUniqueId, minifyConfig, EventEmitter } from "../utils/index.js";
5
+
3
6
  /**
4
7
  * Pops a content item out into a new browser window.
5
8
  * This is achieved by
@@ -10,72 +13,100 @@ import utils from '../utils/index.js';
10
13
  * - GoldenLayout when opened in the new window will look for the GET parameter
11
14
  * and use it instead of the provided configuration
12
15
  *
13
- * @param {Object} config GoldenLayout item config
14
- * @param {Object} dimensions A map with width, height, top and left
15
- * @param {String} parentId The id of the element the item will be appended to on popIn
16
- * @param {Number} indexInParent The position of this element within its parent
17
- * @param {lm.LayoutManager} layoutManager
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
18
21
  */
22
+ export default class BrowserPopout extends EventEmitter {
23
+ constructor(config, dimensions, parentId, indexInParent, layoutManager) {
24
+ super();
25
+
26
+ _defineProperty(this, "isInitialised", false);
27
+
28
+ _defineProperty(this, "_config", void 0);
29
+
30
+ _defineProperty(this, "_dimensions", void 0);
31
+
32
+ _defineProperty(this, "_parentId", void 0);
33
+
34
+ _defineProperty(this, "_indexInParent", void 0);
35
+
36
+ _defineProperty(this, "_layoutManager", void 0);
37
+
38
+ _defineProperty(this, "_popoutWindow", null);
39
+
40
+ _defineProperty(this, "_id", null);
41
+
42
+ this._config = config;
43
+ this._dimensions = dimensions;
44
+ this._parentId = parentId;
45
+ this._indexInParent = indexInParent;
46
+ this._layoutManager = layoutManager;
47
+
48
+ this._createWindow();
49
+ }
50
+
51
+ toConfig() {
52
+ var _this$getGlInstance, _this$getGlInstance2, _ref, _this$_popoutWindow$s, _this$_popoutWindow, _this$_popoutWindow2, _ref2, _this$_popoutWindow$s2, _this$_popoutWindow3, _this$_popoutWindow4, _this$getGlInstance3;
19
53
 
20
- var BrowserPopout = function BrowserPopout(config, dimensions, parentId, indexInParent, layoutManager) {
21
- utils.EventEmitter.call(this);
22
- this.isInitialised = false;
23
- this._config = config;
24
- this._dimensions = dimensions;
25
- this._parentId = parentId;
26
- this._indexInParent = indexInParent;
27
- this._layoutManager = layoutManager;
28
- this._popoutWindow = null;
29
- this._id = null;
30
-
31
- this._createWindow();
32
- };
33
-
34
- utils.copy(BrowserPopout.prototype, {
35
- toConfig: function toConfig() {
36
54
  if (this.isInitialised === false) {
37
55
  throw new Error("Can't create config, layout not yet initialised");
38
- return;
39
56
  }
40
57
 
41
58
  return {
42
59
  dimensions: {
43
- width: this.getGlInstance().width,
44
- height: this.getGlInstance().height,
45
- left: this._popoutWindow.screenX || this._popoutWindow.screenLeft,
46
- top: this._popoutWindow.screenY || this._popoutWindow.screenTop
60
+ width: (_this$getGlInstance = this.getGlInstance()) === null || _this$getGlInstance === void 0 ? void 0 : _this$getGlInstance.width,
61
+ height: (_this$getGlInstance2 = this.getGlInstance()) === null || _this$getGlInstance2 === void 0 ? void 0 : _this$getGlInstance2.height,
62
+ 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,
63
+ 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
47
64
  },
48
- content: this.getGlInstance().toConfig().content,
65
+ content: (_this$getGlInstance3 = this.getGlInstance()) === null || _this$getGlInstance3 === void 0 ? void 0 : _this$getGlInstance3.toConfig().content,
49
66
  parentId: this._parentId,
50
67
  indexInParent: this._indexInParent
51
68
  };
52
- },
53
- getGlInstance: function getGlInstance() {
54
- return this._popoutWindow.__glInstance;
55
- },
56
- getWindow: function getWindow() {
69
+ }
70
+
71
+ getGlInstance() {
72
+ var _this$_popoutWindow5;
73
+
74
+ return (_this$_popoutWindow5 = this._popoutWindow) === null || _this$_popoutWindow5 === void 0 ? void 0 : _this$_popoutWindow5.__glInstance;
75
+ }
76
+
77
+ getWindow() {
57
78
  return this._popoutWindow;
58
- },
59
- close: function close() {
79
+ }
80
+
81
+ close() {
60
82
  if (this.getGlInstance()) {
61
- this.getGlInstance()._$closeWindow();
83
+ var _this$getGlInstance4;
84
+
85
+ (_this$getGlInstance4 = this.getGlInstance()) === null || _this$getGlInstance4 === void 0 ? void 0 : _this$getGlInstance4._$closeWindow();
62
86
  } else {
63
87
  try {
64
- this.getWindow().close();
88
+ var _this$getWindow;
89
+
90
+ (_this$getWindow = this.getWindow()) === null || _this$getWindow === void 0 ? void 0 : _this$getWindow.close();
65
91
  } catch (e) {}
66
92
  }
67
- },
68
-
93
+ }
69
94
  /**
70
95
  * Returns the popped out item to its original position. If the original
71
96
  * parent isn't available anymore it falls back to the layout's topmost element
72
97
  */
73
- popIn: function popIn() {
74
- var childConfig,
75
- parentItem,
76
- index = this._indexInParent;
98
+
99
+
100
+ popIn() {
101
+ var _parentItem;
102
+
103
+ var index = this._indexInParent;
104
+ var childConfig = null;
105
+ var parentItem = null;
77
106
 
78
107
  if (this._parentId) {
108
+ var _this$getGlInstance5;
109
+
79
110
  /*
80
111
  * The $.extend call seems a bit pointless, but it's crucial to
81
112
  * copy the config returned by this.getGlInstance().toConfig()
@@ -85,7 +116,7 @@ utils.copy(BrowserPopout.prototype, {
85
116
  *
86
117
  * The callee (server [not server application]) is not available and disappeared
87
118
  */
88
- childConfig = $.extend(true, {}, this.getGlInstance().toConfig()).content[0];
119
+ childConfig = $.extend(true, {}, (_this$getGlInstance5 = this.getGlInstance()) === null || _this$getGlInstance5 === void 0 ? void 0 : _this$getGlInstance5.toConfig()).content[0];
89
120
  parentItem = this._layoutManager.root.getItemsById(this._parentId)[0];
90
121
  /*
91
122
  * Fallback if parentItem is not available. Either add it to the topmost
@@ -93,7 +124,9 @@ utils.copy(BrowserPopout.prototype, {
93
124
  */
94
125
 
95
126
  if (!parentItem) {
96
- if (this._layoutManager.root.contentItems.length > 0) {
127
+ var _this$_layoutManager$;
128
+
129
+ if (((_this$_layoutManager$ = this._layoutManager.root.contentItems.length) !== null && _this$_layoutManager$ !== void 0 ? _this$_layoutManager$ : 0) > 0) {
97
130
  parentItem = this._layoutManager.root.contentItems[0];
98
131
  } else {
99
132
  parentItem = this._layoutManager.root;
@@ -103,33 +136,34 @@ utils.copy(BrowserPopout.prototype, {
103
136
  }
104
137
  }
105
138
 
106
- parentItem.addChild(childConfig, this._indexInParent);
107
- this.close();
108
- },
139
+ if (!childConfig) {
140
+ return;
141
+ }
109
142
 
143
+ (_parentItem = parentItem) === null || _parentItem === void 0 ? void 0 : _parentItem.addChild(childConfig, this._indexInParent);
144
+ this.close();
145
+ }
110
146
  /**
111
147
  * Creates the URL and window parameter
112
148
  * and opens a new window
113
- *
114
- * @private
115
- *
116
- * @returns {void}
117
149
  */
118
- _createWindow: function _createWindow() {
119
- var checkReadyInterval,
120
- url = this._createUrl(),
121
150
 
151
+
152
+ _createWindow() {
153
+ var url = this._createUrl();
122
154
  /**
123
155
  * Bogus title to prevent re-usage of existing window with the
124
156
  * same title. The actual title will be set by the new window's
125
157
  * GoldenLayout instance if it detects that it is in subWindowMode
126
158
  */
127
- title = Math.floor(Math.random() * 1000000).toString(36),
128
159
 
160
+
161
+ var title = Math.floor(Math.random() * 1000000).toString(36);
129
162
  /**
130
163
  * The options as used in the window.open string
131
164
  */
132
- options = this._serializeWindowOptions({
165
+
166
+ var options = this._serializeWindowOptions({
133
167
  width: this._dimensions.width,
134
168
  height: this._dimensions.height,
135
169
  innerWidth: this._dimensions.width,
@@ -141,7 +175,8 @@ utils.copy(BrowserPopout.prototype, {
141
175
  resizable: 'yes',
142
176
  scrollbars: 'no',
143
177
  status: 'no'
144
- });
178
+ }); // I'm not entirely sure how __glInstance is mounted to the popout window
179
+
145
180
 
146
181
  this._popoutWindow = window.open(url, title, options);
147
182
 
@@ -155,7 +190,7 @@ utils.copy(BrowserPopout.prototype, {
155
190
  }
156
191
  }
157
192
 
158
- $(this._popoutWindow).on('load', utils.fnBind(this._positionWindow, this)).on('unload beforeunload', utils.fnBind(this._onClose, this));
193
+ $(this._popoutWindow).on('load', this._positionWindow.bind(this)).on('unload beforeunload', this._onClose.bind(this));
159
194
  /**
160
195
  * Polling the childwindow to find out if GoldenLayout has been initialised
161
196
  * doesn't seem optimal, but the alternatives - adding a callback to the parent
@@ -163,23 +198,26 @@ utils.copy(BrowserPopout.prototype, {
163
198
  * about the parent to the child window which we'd rather avoid
164
199
  */
165
200
 
166
- checkReadyInterval = setInterval(utils.fnBind(function () {
167
- if (this._popoutWindow.__glInstance && this._popoutWindow.__glInstance.isInitialised) {
201
+ var checkReadyInterval = window.setInterval(() => {
202
+ var _this$_popoutWindow6;
203
+
204
+ if ((_this$_popoutWindow6 = this._popoutWindow) !== null && _this$_popoutWindow6 !== void 0 && _this$_popoutWindow6.__glInstance && this._popoutWindow.__glInstance.isInitialised) {
168
205
  this._onInitialised();
169
206
 
170
- clearInterval(checkReadyInterval);
207
+ window.clearInterval(checkReadyInterval);
171
208
  }
172
- }, this), 10);
173
- },
174
-
209
+ }, 10);
210
+ }
175
211
  /**
176
212
  * Serialises a map of key:values to a window options string
177
213
  *
178
- * @param {Object} windowOptions
214
+ * @param windowOptions
179
215
  *
180
- * @returns {String} serialised window options
216
+ * @returns serialised window options
181
217
  */
182
- _serializeWindowOptions: function _serializeWindowOptions(windowOptions) {
218
+
219
+
220
+ _serializeWindowOptions(windowOptions) {
183
221
  var windowOptionsString = [],
184
222
  key;
185
223
 
@@ -188,21 +226,21 @@ utils.copy(BrowserPopout.prototype, {
188
226
  }
189
227
 
190
228
  return windowOptionsString.join(',');
191
- },
192
-
229
+ }
193
230
  /**
194
231
  * Creates the URL for the new window, including the
195
232
  * config GET parameter
196
233
  *
197
- * @returns {String} URL
234
+ * @returns URL
198
235
  */
199
- _createUrl: function _createUrl() {
236
+
237
+
238
+ _createUrl() {
200
239
  var config = {
201
240
  content: this._config
202
- },
203
- storageKey = 'gl-window-config-' + utils.getUniqueId(),
204
- urlParts;
205
- config = new utils.ConfigMinifier().minifyConfig(config);
241
+ };
242
+ var storageKey = 'gl-window-config-' + getUniqueId();
243
+ config = minifyConfig(config);
206
244
 
207
245
  try {
208
246
  localStorage.setItem(storageKey, JSON.stringify(config));
@@ -210,51 +248,47 @@ utils.copy(BrowserPopout.prototype, {
210
248
  throw new Error('Error while writing to localStorage ' + e.toString());
211
249
  }
212
250
 
213
- urlParts = document.location.href.split('?'); // URL doesn't contain GET-parameters
251
+ var urlParts = document.location.href.split('?'); // URL doesn't contain GET-parameters
214
252
 
215
253
  if (urlParts.length === 1) {
216
254
  return urlParts[0] + '?gl-window=' + storageKey; // URL contains GET-parameters
217
255
  } else {
218
256
  return document.location.href + '&gl-window=' + storageKey;
219
257
  }
220
- },
221
-
258
+ }
222
259
  /**
223
260
  * Move the newly created window roughly to
224
261
  * where the component used to be.
225
- *
226
- * @private
227
- *
228
- * @returns {void}
229
262
  */
230
- _positionWindow: function _positionWindow() {
231
- this._popoutWindow.moveTo(this._dimensions.left, this._dimensions.top);
232
263
 
233
- this._popoutWindow.focus();
234
- },
235
264
 
265
+ _positionWindow() {
266
+ var _this$_popoutWindow7, _this$_popoutWindow8;
267
+
268
+ (_this$_popoutWindow7 = this._popoutWindow) === null || _this$_popoutWindow7 === void 0 ? void 0 : _this$_popoutWindow7.moveTo(this._dimensions.left, this._dimensions.top);
269
+ (_this$_popoutWindow8 = this._popoutWindow) === null || _this$_popoutWindow8 === void 0 ? void 0 : _this$_popoutWindow8.focus();
270
+ }
236
271
  /**
237
272
  * Callback when the new window is opened and the GoldenLayout instance
238
273
  * within it is initialised
239
- *
240
- * @returns {void}
241
274
  */
242
- _onInitialised: function _onInitialised() {
275
+
276
+
277
+ _onInitialised() {
278
+ var _this$getGlInstance6;
279
+
243
280
  this.isInitialised = true;
244
- this.getGlInstance().on('popIn', this.popIn, this);
281
+ (_this$getGlInstance6 = this.getGlInstance()) === null || _this$getGlInstance6 === void 0 ? void 0 : _this$getGlInstance6.on('popIn', this.popIn, this);
245
282
  this.emit('initialised');
246
- },
247
-
283
+ }
248
284
  /**
249
285
  * Invoked 50ms after the window unload event
250
- *
251
- * @private
252
- *
253
- * @returns {void}
254
286
  */
255
- _onClose: function _onClose() {
256
- setTimeout(utils.fnBind(this.emit, this, ['closed']), 50);
287
+
288
+
289
+ _onClose() {
290
+ setTimeout(this.emit.bind(this, 'closed'), 50);
257
291
  }
258
- });
259
- export default BrowserPopout;
292
+
293
+ }
260
294
  //# sourceMappingURL=BrowserPopout.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BrowserPopout.js","names":["$","utils","BrowserPopout","config","dimensions","parentId","indexInParent","layoutManager","EventEmitter","call","isInitialised","_config","_dimensions","_parentId","_indexInParent","_layoutManager","_popoutWindow","_id","_createWindow","copy","prototype","toConfig","Error","width","getGlInstance","height","left","screenX","screenLeft","top","screenY","screenTop","content","__glInstance","getWindow","close","_$closeWindow","e","popIn","childConfig","parentItem","index","extend","root","getItemsById","contentItems","length","addChild","checkReadyInterval","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","fnBind","_positionWindow","_onClose","setInterval","_onInitialised","clearInterval","windowOptions","windowOptionsString","key","push","join","storageKey","getUniqueId","urlParts","ConfigMinifier","minifyConfig","localStorage","setItem","JSON","stringify","document","href","split","moveTo","focus","emit","setTimeout"],"sources":["../../src/controls/BrowserPopout.js"],"sourcesContent":["import $ from 'jquery';\nimport utils from '../utils/index.js';\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 {Object} config GoldenLayout item config\n * @param {Object} dimensions A map with width, height, top and left\n * @param {String} parentId The id of the element the item will be appended to on popIn\n * @param {Number} indexInParent The position of this element within its parent\n * @param {lm.LayoutManager} layoutManager\n */\nconst BrowserPopout = function (\n config,\n dimensions,\n parentId,\n indexInParent,\n layoutManager\n) {\n utils.EventEmitter.call(this);\n this.isInitialised = false;\n\n this._config = config;\n this._dimensions = dimensions;\n this._parentId = parentId;\n this._indexInParent = indexInParent;\n this._layoutManager = layoutManager;\n this._popoutWindow = null;\n this._id = null;\n this._createWindow();\n};\n\nutils.copy(BrowserPopout.prototype, {\n toConfig: function () {\n if (this.isInitialised === false) {\n throw new Error(\"Can't create config, layout not yet initialised\");\n return;\n }\n return {\n dimensions: {\n width: this.getGlInstance().width,\n height: this.getGlInstance().height,\n left: this._popoutWindow.screenX || this._popoutWindow.screenLeft,\n top: this._popoutWindow.screenY || this._popoutWindow.screenTop,\n },\n content: this.getGlInstance().toConfig().content,\n parentId: this._parentId,\n indexInParent: this._indexInParent,\n };\n },\n\n getGlInstance: function () {\n return this._popoutWindow.__glInstance;\n },\n\n getWindow: function () {\n return this._popoutWindow;\n },\n\n close: function () {\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: function () {\n var childConfig,\n parentItem,\n index = this._indexInParent;\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(this._parentId)[0];\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) {\n parentItem = this._layoutManager.root.contentItems[0];\n } else {\n parentItem = this._layoutManager.root;\n }\n index = 0;\n }\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 * @private\n *\n * @returns {void}\n */\n _createWindow: function () {\n var checkReadyInterval,\n 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 title = Math.floor(Math.random() * 1000000).toString(36),\n /**\n * The options as used in the window.open string\n */\n 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 this._popoutWindow = window.open(url, title, options);\n\n if (!this._popoutWindow) {\n if (\n this._layoutManager.config.settings.blockedPopoutsThrowError === true\n ) {\n var error = new Error('Popout blocked');\n error.type = 'popoutBlocked';\n throw error;\n } else {\n return;\n }\n }\n\n $(this._popoutWindow)\n .on('load', utils.fnBind(this._positionWindow, this))\n .on('unload beforeunload', utils.fnBind(this._onClose, 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 checkReadyInterval = setInterval(\n utils.fnBind(function () {\n if (\n this._popoutWindow.__glInstance &&\n this._popoutWindow.__glInstance.isInitialised\n ) {\n this._onInitialised();\n clearInterval(checkReadyInterval);\n }\n }, this),\n 10\n );\n },\n\n /**\n * Serialises a map of key:values to a window options string\n *\n * @param {Object} windowOptions\n *\n * @returns {String} serialised window options\n */\n _serializeWindowOptions: function (windowOptions) {\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 {String} URL\n */\n _createUrl: function () {\n var config = { content: this._config },\n storageKey = 'gl-window-config-' + utils.getUniqueId(),\n urlParts;\n\n config = new utils.ConfigMinifier().minifyConfig(config);\n\n try {\n localStorage.setItem(storageKey, JSON.stringify(config));\n } catch (e) {\n throw new Error('Error while writing to localStorage ' + e.toString());\n }\n\n 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 * @private\n *\n * @returns {void}\n */\n _positionWindow: function () {\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 * @returns {void}\n */\n _onInitialised: function () {\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 * @private\n *\n * @returns {void}\n */\n _onClose: function () {\n setTimeout(utils.fnBind(this.emit, this, ['closed']), 50);\n },\n});\n\nexport default BrowserPopout;\n"],"mappings":"AAAA,OAAOA,CAAP,MAAc,QAAd;AACA,OAAOC,KAAP,MAAkB,mBAAlB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,IAAMC,aAAa,GAAG,SAAhBA,aAAgB,CACpBC,MADoB,EAEpBC,UAFoB,EAGpBC,QAHoB,EAIpBC,aAJoB,EAKpBC,aALoB,EAMpB;EACAN,KAAK,CAACO,YAAN,CAAmBC,IAAnB,CAAwB,IAAxB;EACA,KAAKC,aAAL,GAAqB,KAArB;EAEA,KAAKC,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ACL,OAAOS,QAAQ,CAAChC,QAAT,CAAkBiC,IAAlB,GAAyB,aAAzB,GAAyCV,UAAhD;IACD;EACF,CArMiC;;EAuMlC;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACEV,eAAe,EAAE,2BAAY;IAC3B,KAAK3D,aAAL,CAAmBiF,MAAnB,CAA0B,KAAKrF,WAAL,CAAiBc,IAA3C,EAAiD,KAAKd,WAAL,CAAiBiB,GAAlE;;IACA,KAAKb,aAAL,CAAmBkF,KAAnB;EACD,CAlNiC;;EAoNlC;AACF;AACA;AACA;AACA;AACA;EACEpB,cAAc,EAAE,0BAAY;IAC1B,KAAKpE,aAAL,GAAqB,IAArB;IACA,KAAKc,aAAL,GAAqBiD,EAArB,CAAwB,OAAxB,EAAiC,KAAKnC,KAAtC,EAA6C,IAA7C;IACA,KAAK6D,IAAL,CAAU,aAAV;EACD,CA9NiC;;EAgOlC;AACF;AACA;AACA;AACA;AACA;AACA;EACEvB,QAAQ,EAAE,oBAAY;IACpBwB,UAAU,CAACnG,KAAK,CAACyE,MAAN,CAAa,KAAKyB,IAAlB,EAAwB,IAAxB,EAA8B,CAAC,QAAD,CAA9B,CAAD,EAA4C,EAA5C,CAAV;EACD;AAzOiC,CAApC;AA4OA,eAAejG,aAAf"}
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,CAAP,MAAc,QAAd;SAISC,W,EAAaC,Y,EAAcC,Y;;AAUpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAMC,aAAN,SAA4BD,YAA5B,CAAyC;EAatDE,WAAW,CACTC,MADS,EAETC,UAFS,EAGTC,QAHS,EAITC,aAJS,EAKTC,aALS,EAMT;IACA;;IADA,uCAlBc,KAkBd;;IAAA;;IAAA;;IAAA;;IAAA;;IAAA;;IAAA,uCATS,IAST;;IAAA,6BARY,IAQZ;;IAGA,KAAKC,OAAL,GAAeL,MAAf;IACA,KAAKM,WAAL,GAAmBL,UAAnB;IACA,KAAKM,SAAL,GAAiBL,QAAjB;IACA,KAAKM,cAAL,GAAsBL,aAAtB;IACA,KAAKM,cAAL,GAAsBL,aAAtB;;IACA,KAAKM,aAAL;EACD;;EAEDC,QAAQ,GAAG;IAAA;;IACT,IAAI,KAAKC,aAAL,KAAuB,KAA3B,EAAkC;MAChC,MAAM,IAAIC,KAAJ,CAAU,iDAAV,CAAN;IACD;;IACD,OAAQ;MACNZ,UAAU,EAAE;QACVa,KAAK,yBAAE,KAAKC,aAAL,EAAF,wDAAE,oBAAsBD,KADnB;QAEVE,MAAM,0BAAE,KAAKD,aAAL,EAAF,yDAAE,qBAAsBC,MAFpB;QAGVC,IAAI,0DACF,KAAKC,aADH,wDACF,oBAAoBC,OADlB,iGAC6B,KAAKD,aADlC,yDA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C,CAAV;EACD;;AA5PqD"}
@@ -0,0 +1,67 @@
1
+ import type { AbstractContentItem, Stack } from '../items';
2
+ import type LayoutManager from '../LayoutManager';
3
+ import type { DragListener } from '../utils';
4
+ import { EventEmitter } from '../utils';
5
+ /**
6
+ * This class creates a temporary container
7
+ * for the component whilst it is being dragged
8
+ * and handles drag events
9
+ *
10
+ * @param x The initial x position
11
+ * @param y The initial y position
12
+ * @param dragListener
13
+ * @param layoutManager
14
+ * @param contentItem
15
+ * @param originalParent
16
+ */
17
+ export default class DragProxy extends EventEmitter {
18
+ private static _template;
19
+ private _dragListener;
20
+ private _layoutManager;
21
+ private _contentItem;
22
+ private _originalParent;
23
+ private _area;
24
+ private _lastValidArea;
25
+ private _minX;
26
+ private _maxX;
27
+ private _minY;
28
+ private _maxY;
29
+ private _width;
30
+ private _height;
31
+ private _sided?;
32
+ element: JQuery<HTMLElement>;
33
+ childElementContainer: JQuery<HTMLElement>;
34
+ private _proxyTab;
35
+ constructor(x: number, y: number, dragListener: DragListener, layoutManager: LayoutManager, contentItem: AbstractContentItem, originalParent: Stack | null);
36
+ /**
37
+ * Callback on every mouseMove event during a drag. Determines if the drag is
38
+ * still within the valid drag area and calls the layoutManager to highlight the
39
+ * current drop area
40
+ *
41
+ * @param offsetX The difference from the original x position in px
42
+ * @param offsetY The difference from the original y position in px
43
+ * @param event
44
+ */
45
+ _onDrag(offsetX: number, offsetY: number, event: JQuery.TriggeredEvent): void;
46
+ /**
47
+ * Sets the target position, highlighting the appropriate area
48
+ *
49
+ * @param x The x position in px
50
+ * @param y The y position in px
51
+ */
52
+ _setDropPosition(x: number, y: number): void;
53
+ /**
54
+ * Callback when the drag has finished. Determines the drop area
55
+ * and adds the child to it
56
+ */
57
+ _onDrop(): void;
58
+ /**
59
+ * Removes the item from its original position within the tree
60
+ */
61
+ _updateTree(): void;
62
+ /**
63
+ * Updates the DragProxy's dimensions
64
+ */
65
+ _setDimensions(): void;
66
+ }
67
+ //# sourceMappingURL=DragProxy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