@deephaven/golden-layout 0.19.2-beta.4 → 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,106 +1,130 @@
1
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
+
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
+
5
+ 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; }
6
+
1
7
  import $ from 'jquery';
2
- import lm from './base.js';
8
+ import lm from "./base.js";
9
+ import { defaultConfig } from "./config/index.js";
10
+ import { BrowserPopout, DragSource, DragSourceFromEvent, DropTargetIndicator, TransitionIndicator } from "./controls/index.js";
11
+ import { ConfigurationError } from "./errors/index.js";
12
+ import { AbstractContentItem, isStack, Component, Root, RowOrColumn, Stack } from "./items/index.js";
13
+ import { minifyConfig, unminifyConfig, EventEmitter, EventHub, ReactComponentHandler, getQueryStringParam, getUniqueId, stripTags } from "./utils/index.js";
14
+
3
15
  /**
4
16
  * The main class that will be exposed as GoldenLayout.
5
17
  *
6
- * @public
7
- * @constructor
8
- * @param {GoldenLayout config} config
9
- * @param {[DOM element container]} container Can be a jQuery selector string or a Dom element. Defaults to body
10
- *
11
- * @returns {VOID}
18
+ * @param config
19
+ * @param container Can be a jQuery selector string or a Dom element. Defaults to body
12
20
  */
21
+ export default class LayoutManager extends EventEmitter {
22
+ /**
23
+ * Hook that allows to access private classes
24
+ */
13
25
 
14
- var LayoutManager = function LayoutManager(config, container) {
15
- if (!$ || typeof $.noConflict !== 'function') {
16
- var errorMsg = 'jQuery is missing as dependency for GoldenLayout. ';
17
- errorMsg += 'Please either expose $ on GoldenLayout\'s scope (e.g. window) or add "jquery" to ';
18
- errorMsg += 'your paths when using RequireJS/AMD';
19
- throw new Error(errorMsg);
26
+ /**
27
+ * Takes a GoldenLayout configuration object and
28
+ * replaces its keys and values recursively with
29
+ * one letter codes
30
+ *
31
+ * @param config A GoldenLayout config object
32
+ * @returns minified config
33
+ */
34
+ static minifyConfig(config) {
35
+ return minifyConfig(config);
20
36
  }
37
+ /**
38
+ * Takes a configuration Object that was previously minified
39
+ * using minifyConfig and returns its original version
40
+ *
41
+ * @param minifiedConfig
42
+ * @returns the original configuration
43
+ */
44
+
21
45
 
22
- lm.utils.EventEmitter.call(this);
23
- this.isInitialised = false;
24
- this._isFullPage = false;
25
- this._resizeTimeoutId = null;
26
- this._components = {
27
- 'lm-react-component': lm.utils.ReactComponentHandler
28
- };
29
- this._fallbackComponent = undefined;
30
- this._itemAreas = [];
31
- this._resizeFunction = lm.utils.fnBind(this._onResize, this);
32
- this._unloadFunction = lm.utils.fnBind(this._onUnload, this);
33
- this._windowBlur = this._windowBlur.bind(this);
34
- this._windowFocus = this._windowFocus.bind(this);
35
- this._maximisedItem = null;
36
- this._maximisePlaceholder = $('<div class="lm_maximise_place"></div>');
37
- this._creationTimeoutPassed = false;
38
- this._subWindowsCreated = false;
39
- this._dragSources = [];
40
- this._updatingColumnsResponsive = false;
41
- this._firstLoad = true;
42
- this.width = null;
43
- this.height = null;
44
- this.root = null;
45
- this.openPopouts = [];
46
- this.selectedItem = null;
47
- this.isSubWindow = false;
48
- this.eventHub = new lm.utils.EventHub(this);
49
- this.config = this._createConfig(config);
50
- this.container = container;
51
- this.dropTargetIndicator = null;
52
- this.transitionIndicator = null;
53
- this.tabDropPlaceholder = $('<div class="lm_drop_tab_placeholder"></div>');
54
-
55
- if (this.isSubWindow === true) {
56
- $('body').css('visibility', 'hidden');
46
+ static unminifyConfig(config) {
47
+ return unminifyConfig(config);
57
48
  }
58
49
 
59
- this._typeToItem = {
60
- column: lm.utils.fnBind(lm.items.RowOrColumn, this, [true]),
61
- row: lm.utils.fnBind(lm.items.RowOrColumn, this, [false]),
62
- stack: lm.items.Stack,
63
- component: lm.items.Component
64
- };
65
- };
66
- /**
67
- * Hook that allows to access private classes
68
- */
50
+ constructor(config, container) {
51
+ super();
69
52
 
53
+ _defineProperty(this, "isInitialised", false);
70
54
 
71
- LayoutManager.__lm = lm;
72
- /**
73
- * Takes a GoldenLayout configuration object and
74
- * replaces its keys and values recursively with
75
- * one letter codes
76
- *
77
- * @static
78
- * @public
79
- * @param {Object} config A GoldenLayout config object
80
- *
81
- * @returns {Object} minified config
82
- */
55
+ _defineProperty(this, "_isFullPage", false);
83
56
 
84
- LayoutManager.minifyConfig = function (config) {
85
- return new lm.utils.ConfigMinifier().minifyConfig(config);
86
- };
87
- /**
88
- * Takes a configuration Object that was previously minified
89
- * using minifyConfig and returns its original version
90
- *
91
- * @static
92
- * @public
93
- * @param {Object} minifiedConfig
94
- *
95
- * @returns {Object} the original configuration
96
- */
57
+ _defineProperty(this, "_resizeTimeoutId", void 0);
58
+
59
+ _defineProperty(this, "_components", {
60
+ 'lm-react-component': ReactComponentHandler
61
+ });
62
+
63
+ _defineProperty(this, "_fallbackComponent", void 0);
64
+
65
+ _defineProperty(this, "_itemAreas", []);
66
+
67
+ _defineProperty(this, "_maximisedItem", null);
68
+
69
+ _defineProperty(this, "_maximisePlaceholder", $('<div class="lm_maximise_place"></div>'));
70
+
71
+ _defineProperty(this, "_creationTimeoutPassed", false);
72
+
73
+ _defineProperty(this, "_subWindowsCreated", false);
74
+
75
+ _defineProperty(this, "_dragSources", []);
76
+
77
+ _defineProperty(this, "_updatingColumnsResponsive", false);
78
+
79
+ _defineProperty(this, "_firstLoad", true);
80
+
81
+ _defineProperty(this, "width", null);
97
82
 
83
+ _defineProperty(this, "height", null);
98
84
 
99
- LayoutManager.unminifyConfig = function (config) {
100
- return new lm.utils.ConfigMinifier().unminifyConfig(config);
101
- };
85
+ _defineProperty(this, "root", void 0);
102
86
 
103
- lm.utils.copy(LayoutManager.prototype, {
87
+ _defineProperty(this, "openPopouts", []);
88
+
89
+ _defineProperty(this, "selectedItem", null);
90
+
91
+ _defineProperty(this, "isSubWindow", false);
92
+
93
+ _defineProperty(this, "eventHub", new EventHub(this));
94
+
95
+ _defineProperty(this, "config", void 0);
96
+
97
+ _defineProperty(this, "container", void 0);
98
+
99
+ _defineProperty(this, "_originalContainer", void 0);
100
+
101
+ _defineProperty(this, "dropTargetIndicator", null);
102
+
103
+ _defineProperty(this, "transitionIndicator", null);
104
+
105
+ _defineProperty(this, "tabDropPlaceholder", $('<div class="lm_drop_tab_placeholder"></div>'));
106
+
107
+ _defineProperty(this, "_typeToItem", void 0);
108
+
109
+ this._onResize = this._onResize.bind(this);
110
+ this._onUnload = this._onUnload.bind(this);
111
+ this._windowBlur = this._windowBlur.bind(this);
112
+ this._windowFocus = this._windowFocus.bind(this);
113
+ this.config = this._createConfig(config);
114
+ this._originalContainer = container;
115
+ this.container = this._getContainer();
116
+
117
+ if (this.isSubWindow) {
118
+ $('body').css('visibility', 'hidden');
119
+ }
120
+
121
+ this._typeToItem = {
122
+ column: RowOrColumn.bind(this, true),
123
+ row: RowOrColumn.bind(this, false),
124
+ stack: Stack,
125
+ component: Component
126
+ };
127
+ }
104
128
  /**
105
129
  * Register a component with the layout manager. If a configuration node
106
130
  * of type component is reached it will look up componentName and create the
@@ -112,13 +136,13 @@ lm.utils.copy(LayoutManager.prototype, {
112
136
  * componentState: { "feedTopic": "us-bluechips" }
113
137
  * }
114
138
  *
115
- * @public
116
- * @param {String} name
117
- * @param {Function} constructor
118
- *
119
- * @returns {Function} cleanup function to deregister component
139
+ * @param name
140
+ * @param constructor
141
+ * @returns cleanup function to deregister component
120
142
  */
121
- registerComponent: function registerComponent(name, constructor) {
143
+
144
+
145
+ registerComponent(name, constructor) {
122
146
  if (typeof constructor !== 'function' && (constructor == null || constructor.render == null || typeof constructor.render !== 'function')) {
123
147
  throw new Error('Please register a constructor function');
124
148
  }
@@ -129,43 +153,38 @@ lm.utils.copy(LayoutManager.prototype, {
129
153
 
130
154
  this._components[name] = constructor;
131
155
 
132
- function cleanup() {
156
+ var cleanup = () => {
133
157
  if (this._components[name] === undefined) {
134
158
  throw new Error('Component ' + name + ' is not registered');
135
159
  }
136
160
 
137
161
  delete this._components[name];
138
- }
139
-
140
- return cleanup.bind(this);
141
- },
162
+ };
142
163
 
164
+ return cleanup;
165
+ }
143
166
  /**
144
167
  * Set a fallback component to be rendered in place of unregistered components
145
- *
146
- * @public
147
- * @param {Function} constructor
148
- *
149
- * @returns {void}
168
+ * @param constructor
150
169
  */
151
- setFallbackComponent: function setFallbackComponent(constructor) {
152
- this._fallbackComponent = constructor;
153
- },
154
170
 
171
+
172
+ setFallbackComponent(constructor) {
173
+ this._fallbackComponent = constructor;
174
+ }
155
175
  /**
156
176
  * Creates a layout configuration object based on the the current state
157
- *
158
- * @public
159
- * @returns {Object} GoldenLayout configuration
177
+ * @param root
178
+ * @returns GoldenLayout configuration
160
179
  */
161
- toConfig: function toConfig(root) {
162
- var config, _next, i;
163
180
 
181
+
182
+ toConfig(root) {
164
183
  if (this.isInitialised === false) {
165
184
  throw new Error("Can't create config, layout not yet initialised");
166
185
  }
167
186
 
168
- if (root && !(root instanceof lm.items.AbstractContentItem)) {
187
+ if (root && !(root instanceof AbstractContentItem)) {
169
188
  throw new Error('Root must be a ContentItem');
170
189
  }
171
190
  /*
@@ -173,23 +192,20 @@ lm.utils.copy(LayoutManager.prototype, {
173
192
  */
174
193
 
175
194
 
176
- config = {
177
- settings: lm.utils.copy({}, this.config.settings),
178
- dimensions: lm.utils.copy({}, this.config.dimensions),
179
- labels: lm.utils.copy({}, this.config.labels)
195
+ var config = {
196
+ settings: _objectSpread({}, this.config.settings),
197
+ dimensions: _objectSpread({}, this.config.dimensions),
198
+ labels: _objectSpread({}, this.config.labels),
199
+ content: []
180
200
  };
181
201
  /*
182
202
  * Content
183
203
  */
184
204
 
185
- config.content = [];
186
-
187
- _next = function next(configNode, item) {
188
- var key, i;
189
-
190
- for (key in item.config) {
191
- if (key !== 'content') {
192
- configNode[key] = item.config[key];
205
+ var next = function next(configNode, item) {
206
+ for (var _key in item.config) {
207
+ if (_key !== 'content') {
208
+ configNode[_key] = item.config[_key];
193
209
  }
194
210
  }
195
211
 
@@ -201,20 +217,19 @@ lm.utils.copy(LayoutManager.prototype, {
201
217
  if (item.contentItems.length) {
202
218
  configNode.content = [];
203
219
 
204
- for (i = 0; i < item.contentItems.length; i++) {
220
+ for (var i = 0; i < item.contentItems.length; i++) {
205
221
  configNode.content[i] = {};
206
-
207
- _next(configNode.content[i], item.contentItems[i]);
222
+ next(configNode.content[i], item.contentItems[i]);
208
223
  }
209
224
  }
210
225
  };
211
226
 
212
227
  if (root) {
213
- _next(config, {
228
+ next(config, {
214
229
  contentItems: [root]
215
230
  });
216
231
  } else {
217
- _next(config, this.root);
232
+ next(config, this.root);
218
233
  }
219
234
  /*
220
235
  * Retrieve config for subwindows
@@ -225,7 +240,7 @@ lm.utils.copy(LayoutManager.prototype, {
225
240
 
226
241
  config.openPopouts = [];
227
242
 
228
- for (i = 0; i < this.openPopouts.length; i++) {
243
+ for (var i = 0; i < this.openPopouts.length; i++) {
229
244
  config.openPopouts.push(this.openPopouts[i].toConfig());
230
245
  }
231
246
  /*
@@ -233,22 +248,18 @@ lm.utils.copy(LayoutManager.prototype, {
233
248
  */
234
249
 
235
250
 
236
- config.maximisedItemId = this._maximisedItem ? '__glMaximised' : null;
251
+ config.maximisedItemId = this._maximisedItem ? '__glMaximised' : undefined;
237
252
  return config;
238
- },
239
-
253
+ }
240
254
  /**
241
255
  * Returns a previously registered component
242
- *
243
- * @public
244
- * @param {String} name The name used
245
- *
246
- * @returns {Function}
256
+ * @param name The name used
247
257
  */
248
- getComponent: function getComponent(name) {
249
- return this._components[name];
250
- },
251
258
 
259
+
260
+ getComponent(name) {
261
+ return this._components[name];
262
+ }
252
263
  /**
253
264
  * Returns a fallback component to render in place of unregistered components
254
265
  *
@@ -256,10 +267,11 @@ lm.utils.copy(LayoutManager.prototype, {
256
267
  *
257
268
  * @returns {Function}
258
269
  */
259
- getFallbackComponent: function getFallbackComponent() {
260
- return this._fallbackComponent;
261
- },
262
270
 
271
+
272
+ getFallbackComponent() {
273
+ return this._fallbackComponent;
274
+ }
263
275
  /**
264
276
  * Creates the actual layout. Must be called after all initial components
265
277
  * are registered. Recurses through the configuration and sets up
@@ -267,12 +279,10 @@ lm.utils.copy(LayoutManager.prototype, {
267
279
  *
268
280
  * If called before the document is ready it adds itself as a listener
269
281
  * to the document.ready event
270
- *
271
- * @public
272
- *
273
- * @returns {void}
274
282
  */
275
- init: function init() {
283
+
284
+
285
+ init() {
276
286
  /**
277
287
  * Create the popout windows straight away. If popouts are blocked
278
288
  * an error is thrown on the same 'thread' rather than a timeout and can
@@ -289,7 +299,7 @@ lm.utils.copy(LayoutManager.prototype, {
289
299
 
290
300
 
291
301
  if (document.readyState === 'loading' || document.body === null) {
292
- $(document).ready(lm.utils.fnBind(this.init, this));
302
+ $(document).ready(this.init.bind(this));
293
303
  return;
294
304
  }
295
305
  /**
@@ -300,7 +310,7 @@ lm.utils.copy(LayoutManager.prototype, {
300
310
 
301
311
 
302
312
  if (this.isSubWindow === true && this._creationTimeoutPassed === false) {
303
- setTimeout(lm.utils.fnBind(this.init, this), 7);
313
+ setTimeout(this.init.bind(this), 7);
304
314
  this._creationTimeoutPassed = true;
305
315
  return;
306
316
  }
@@ -311,8 +321,8 @@ lm.utils.copy(LayoutManager.prototype, {
311
321
 
312
322
  this._setContainer();
313
323
 
314
- this.dropTargetIndicator = new lm.controls.DropTargetIndicator(this.container);
315
- this.transitionIndicator = new lm.controls.TransitionIndicator();
324
+ this.dropTargetIndicator = new DropTargetIndicator();
325
+ this.transitionIndicator = new TransitionIndicator();
316
326
  this.updateSize();
317
327
 
318
328
  this._create(this.config);
@@ -324,91 +334,84 @@ lm.utils.copy(LayoutManager.prototype, {
324
334
  this._adjustColumnsResponsive();
325
335
 
326
336
  this.emit('initialised');
327
- },
328
-
337
+ }
329
338
  /**
330
339
  * Updates the layout managers size
331
- *
332
- * @public
333
- * @param {[int]} width height in pixels
334
- * @param {[int]} height width in pixels
335
- *
336
- * @returns {void}
340
+ * @param width width in pixels
341
+ * @param height height in pixels
337
342
  */
338
- updateSize: function updateSize(width, height) {
339
- if (arguments.length === 2) {
340
- this.width = width;
341
- this.height = height;
342
- } else {
343
- this.width = this.container.width();
344
- this.height = this.container.height();
345
- }
343
+
344
+
345
+ updateSize(width, height) {
346
+ var _ref, _ref2;
347
+
348
+ this.width = (_ref = width !== null && width !== void 0 ? width : this.container.width()) !== null && _ref !== void 0 ? _ref : 0;
349
+ this.height = (_ref2 = height !== null && height !== void 0 ? height : this.container.height()) !== null && _ref2 !== void 0 ? _ref2 : 0;
346
350
 
347
351
  if (this.isInitialised === true) {
348
352
  this.root.callDownwards('setSize', [this.width, this.height]);
349
353
 
350
354
  if (this._maximisedItem) {
351
- this._maximisedItem.element.width(this.container.width());
355
+ var _this$container$width, _this$container$heigh;
352
356
 
353
- this._maximisedItem.element.height(this.container.height());
357
+ this._maximisedItem.element.width((_this$container$width = this.container.width()) !== null && _this$container$width !== void 0 ? _this$container$width : 0);
358
+
359
+ this._maximisedItem.element.height((_this$container$heigh = this.container.height()) !== null && _this$container$heigh !== void 0 ? _this$container$heigh : 0);
354
360
 
355
361
  this._maximisedItem.callDownwards('setSize');
356
362
  }
357
363
 
358
364
  this._adjustColumnsResponsive();
359
365
  }
360
- },
361
-
366
+ }
362
367
  /**
363
368
  * Destroys the LayoutManager instance itself as well as every ContentItem
364
369
  * within it. After this is called nothing should be left of the LayoutManager.
365
- *
366
- * @public
367
- * @returns {void}
368
370
  */
369
- destroy: function destroy() {
370
- if (this.isInitialised === false) {
371
+
372
+
373
+ destroy() {
374
+ var _this$dropTargetIndic, _this$transitionIndic;
375
+
376
+ if (this.isInitialised === false || !this.root) {
371
377
  return;
372
378
  }
373
379
 
374
380
  this._onUnload();
375
381
 
376
- $(window).off('resize', this._resizeFunction);
377
- $(window).off('unload beforeunload', this._unloadFunction);
382
+ $(window).off('resize', this._onResize);
383
+ $(window).off('unload beforeunload', this._onUnload);
378
384
  $(window).off('blur.lm').off('focus.lm');
379
385
  this.root.callDownwards('_$destroy', [], true);
380
386
  this.root.contentItems = [];
381
387
  this.tabDropPlaceholder.remove();
382
- this.dropTargetIndicator.destroy();
383
- this.transitionIndicator.destroy();
388
+ (_this$dropTargetIndic = this.dropTargetIndicator) === null || _this$dropTargetIndic === void 0 ? void 0 : _this$dropTargetIndic.destroy();
389
+ (_this$transitionIndic = this.transitionIndicator) === null || _this$transitionIndic === void 0 ? void 0 : _this$transitionIndic.destroy();
384
390
  this.eventHub.destroy();
385
391
 
386
392
  this._dragSources.forEach(function (dragSource) {
387
393
  dragSource._dragListener.destroy();
388
-
389
- dragSource._element = null;
390
- dragSource._itemConfig = null;
391
- dragSource._dragListener = null;
392
394
  });
393
395
 
394
396
  this._dragSources = [];
395
- },
396
-
397
+ }
397
398
  /**
398
399
  * Recursively creates new item tree structures based on a provided
399
400
  * ItemConfiguration object
400
401
  *
401
402
  * @public
402
- * @param {Object} config ItemConfig
403
- * @param {[ContentItem]} parent The item the newly created item should be a child of
403
+ * @param config ItemConfig
404
+ * @param parent The item the newly created item should be a child of
404
405
  *
405
- * @returns {lm.items.ContentItem}
406
+ * @returns Created item
406
407
  */
407
- createContentItem: function createContentItem(config, parent) {
408
+
409
+
410
+ createContentItem(config, parent) {
408
411
  var typeErrorMsg, contentItem;
409
412
 
410
413
  if (typeof config.type !== 'string') {
411
- throw new lm.errors.ConfigurationError("Missing parameter 'type'", config);
414
+ throw new ConfigurationError("Missing parameter 'type'", config);
412
415
  }
413
416
 
414
417
  if (config.type === 'react-component') {
@@ -417,8 +420,8 @@ lm.utils.copy(LayoutManager.prototype, {
417
420
  }
418
421
 
419
422
  if (!this._typeToItem[config.type]) {
420
- typeErrorMsg = "Unknown type '" + config.type + "'. " + 'Valid types are ' + lm.utils.objectKeys(this._typeToItem).join(',');
421
- throw new lm.errors.ConfigurationError(typeErrorMsg);
423
+ typeErrorMsg = "Unknown type '" + config.type + "'. " + 'Valid types are ' + Object.keys(this._typeToItem).join(',');
424
+ throw new ConfigurationError(typeErrorMsg);
422
425
  }
423
426
  /**
424
427
  * We add an additional stack around every component that's not within a stack anyways.
@@ -427,9 +430,9 @@ lm.utils.copy(LayoutManager.prototype, {
427
430
 
428
431
  if ( // If this is a component
429
432
  config.type === 'component' && // and it's not already within a stack
430
- !(parent instanceof lm.items.Stack) && // and we have a parent
433
+ !(parent instanceof Stack) && // and we have a parent
431
434
  !!parent && // and it's not the topmost item in a new window
432
- !(this.isSubWindow === true && parent instanceof lm.items.Root)) {
435
+ !(this.isSubWindow === true && parent instanceof Root)) {
433
436
  config = {
434
437
  type: 'stack',
435
438
  width: config.width,
@@ -440,33 +443,30 @@ lm.utils.copy(LayoutManager.prototype, {
440
443
 
441
444
  contentItem = new this._typeToItem[config.type](this, config, parent);
442
445
  return contentItem;
443
- },
444
-
446
+ }
445
447
  /**
446
448
  * Creates a popout window with the specified content and dimensions
447
449
  *
448
- * @param {Object|lm.itemsAbstractContentItem} configOrContentItem
449
- * @param {[Object]} dimensions A map with width, height, left and top
450
- * @param {[String]} parentId the id of the element this item will be appended to
450
+ * @param configOrContentItem
451
+ * @param dimensions A map with width, height, left and top
452
+ * @param parentId the id of the element this item will be appended to
451
453
  * when popIn is called
452
- * @param {[Number]} indexInParent The position of this item within its parent element
453
- * @returns {lm.controls.BrowserPopout}
454
+ * @param indexInParent The position of this item within its parent element
455
+ * @returns Created popout
454
456
  */
455
- createPopout: function createPopout(configOrContentItem, dimensions, parentId, indexInParent) {
456
- var config = configOrContentItem,
457
- isItem = configOrContentItem instanceof lm.items.AbstractContentItem,
458
- self = this,
459
- windowLeft,
460
- windowTop,
461
- offset,
462
- parent,
463
- child,
464
- browserPopout;
465
- parentId = parentId || null;
457
+
458
+
459
+ createPopout(configOrContentItem, dimensions, parentId, indexInParent) {
460
+ var config = configOrContentItem;
461
+ var configArray = [];
462
+ var isItem = configOrContentItem instanceof AbstractContentItem;
463
+ var self = this;
466
464
 
467
465
  if (isItem) {
468
- config = this.toConfig(configOrContentItem).content;
469
- parentId = lm.utils.getUniqueId();
466
+ var _parent2;
467
+
468
+ configArray = this.toConfig(configOrContentItem).content;
469
+ parentId = getUniqueId();
470
470
  /**
471
471
  * If the item is the only component within a stack or for some
472
472
  * other reason the only child of its parent the parent will be destroyed
@@ -476,34 +476,45 @@ lm.utils.copy(LayoutManager.prototype, {
476
476
  * that will remain after the item is being popped out
477
477
  */
478
478
 
479
- parent = configOrContentItem.parent;
480
- child = configOrContentItem;
479
+ var parent = configOrContentItem.parent;
480
+ var child = configOrContentItem;
481
+
482
+ while (((_parent = parent) === null || _parent === void 0 ? void 0 : _parent.contentItems.length) === 1 && !parent.isRoot) {
483
+ var _parent;
481
484
 
482
- while (parent.contentItems.length === 1 && !parent.isRoot) {
485
+ child = parent;
483
486
  parent = parent.parent;
484
- child = child.parent;
485
487
  }
486
488
 
487
- parent.addId(parentId);
489
+ (_parent2 = parent) === null || _parent2 === void 0 ? void 0 : _parent2.addId(parentId);
488
490
 
489
- if (isNaN(indexInParent)) {
490
- indexInParent = lm.utils.indexOf(child, parent.contentItems);
491
+ if (indexInParent == undefined || Number.isNaN(indexInParent)) {
492
+ var _parent3;
493
+
494
+ indexInParent = (_parent3 = parent) === null || _parent3 === void 0 ? void 0 : _parent3.contentItems.indexOf(child);
491
495
  }
492
496
  } else {
493
- if (!(config instanceof Array)) {
494
- config = [config];
497
+ if (!(configOrContentItem instanceof Array)) {
498
+ configArray = [configOrContentItem];
499
+ } else {
500
+ configArray = configOrContentItem;
495
501
  }
496
502
  }
497
503
 
498
504
  if (!dimensions && isItem) {
499
- windowLeft = window.screenX || window.screenLeft;
500
- windowTop = window.screenY || window.screenTop;
501
- offset = configOrContentItem.element.offset();
505
+ var _configOrContentItem$, _configOrContentItem$2, _configOrContentItem$3;
506
+
507
+ var windowLeft = window.screenX || window.screenLeft;
508
+ var windowTop = window.screenY || window.screenTop;
509
+ var offset = (_configOrContentItem$ = configOrContentItem.element.offset()) !== null && _configOrContentItem$ !== void 0 ? _configOrContentItem$ : {
510
+ left: 0,
511
+ top: 0
512
+ };
502
513
  dimensions = {
503
514
  left: windowLeft + offset.left,
504
515
  top: windowTop + offset.top,
505
- width: configOrContentItem.element.width(),
506
- height: configOrContentItem.element.height()
516
+ width: (_configOrContentItem$2 = configOrContentItem.element.width()) !== null && _configOrContentItem$2 !== void 0 ? _configOrContentItem$2 : 0,
517
+ height: (_configOrContentItem$3 = configOrContentItem.element.height()) !== null && _configOrContentItem$3 !== void 0 ? _configOrContentItem$3 : 0
507
518
  };
508
519
  }
509
520
 
@@ -520,7 +531,11 @@ lm.utils.copy(LayoutManager.prototype, {
520
531
  configOrContentItem.remove();
521
532
  }
522
533
 
523
- browserPopout = new lm.controls.BrowserPopout(config, dimensions, parentId, indexInParent, this);
534
+ if (!dimensions || !parentId || indexInParent === undefined) {
535
+ return;
536
+ }
537
+
538
+ var browserPopout = new BrowserPopout(configArray, dimensions, parentId, indexInParent, this);
524
539
  browserPopout.on('initialised', function () {
525
540
  self.emit('windowOpened', browserPopout);
526
541
  });
@@ -529,52 +544,48 @@ lm.utils.copy(LayoutManager.prototype, {
529
544
  });
530
545
  this.openPopouts.push(browserPopout);
531
546
  return browserPopout;
532
- },
533
-
547
+ }
534
548
  /**
535
549
  * Attaches DragListener to any given DOM element
536
550
  * and turns it into a way of creating new ContentItems
537
551
  * by 'dragging' the DOM element into the layout
538
552
  *
539
- * @param {jQuery DOM element} element
540
- * @param {Object|Function} itemConfig for the new item to be created, or a function which will provide it
541
- *
542
- * @returns {void}
553
+ * @param element
554
+ * @param itemConfig for the new item to be created, or a function which will provide it
543
555
  */
544
- createDragSource: function createDragSource(element, itemConfig) {
556
+
557
+
558
+ createDragSource(element, itemConfig) {
545
559
  this.config.settings.constrainDragToContainer = false;
546
- var dragSource = new lm.controls.DragSource($(element), itemConfig, this);
560
+ var dragSource = new DragSource(element, itemConfig, this);
547
561
 
548
562
  this._dragSources.push(dragSource);
549
563
 
550
564
  return dragSource;
551
- },
552
-
565
+ }
553
566
  /**
554
567
  * Create a new item in a dragging state, given a starting mouse event to act as the initial position
555
568
  *
556
- * @param {Object|Function} itemConfig for the new item to be created, or a function which will provide it
557
- * @param {MouseEvent} event used as the starting position for the dragProxy
558
- *
559
- * @returns {void}
569
+ * @param itemConfig for the new item to be created, or a function which will provide it
570
+ * @param event used as the starting position for the dragProxy
560
571
  */
561
- createDragSourceFromEvent: function createDragSourceFromEvent(itemConfig, event) {
562
- this.config.settings.constrainDragToContainer = false;
563
- return new lm.controls.DragSourceFromEvent(itemConfig, this, event);
564
- },
565
572
 
573
+
574
+ createDragSourceFromEvent(itemConfig, event) {
575
+ this.config.settings.constrainDragToContainer = false;
576
+ return new DragSourceFromEvent(itemConfig, this, event);
577
+ }
566
578
  /**
567
579
  * Programmatically selects an item. This deselects
568
580
  * the currently selected item, selects the specified item
569
581
  * and emits a selectionChanged event
570
582
  *
571
- * @param {lm.item.AbstractContentItem} item#
572
- * @param {[Boolean]} _$silent Wheather to notify the item of its selection
573
- * @event selectionChanged
574
- *
575
- * @returns {VOID}
583
+ * @param item
584
+ * @param _$silent Wheather to notify the item of its selection
576
585
  */
577
- selectItem: function selectItem(item, _$silent) {
586
+
587
+
588
+ selectItem(item, _$silent) {
578
589
  if (this.config.settings.selectionEnabled !== true) {
579
590
  throw new Error('Please set selectionEnabled to true to use this feature');
580
591
  }
@@ -593,12 +604,15 @@ lm.utils.copy(LayoutManager.prototype, {
593
604
 
594
605
  this.selectedItem = item;
595
606
  this.emit('selectionChanged', item);
596
- },
597
-
607
+ }
598
608
  /*************************
599
609
  * PACKAGE PRIVATE
600
610
  *************************/
601
- _$maximiseItem: function _$maximiseItem(contentItem) {
611
+
612
+
613
+ _$maximiseItem(contentItem) {
614
+ var _this$container$width2, _this$container$heigh2;
615
+
602
616
  if (this._maximisedItem !== null) {
603
617
  this._$minimiseItem(this._maximisedItem);
604
618
  }
@@ -610,15 +624,18 @@ lm.utils.copy(LayoutManager.prototype, {
610
624
  contentItem.element.addClass('lm_maximised');
611
625
  contentItem.element.after(this._maximisePlaceholder);
612
626
  this.root.element.prepend(contentItem.element);
613
- contentItem.element.width(this.container.width());
614
- contentItem.element.height(this.container.height());
627
+ contentItem.element.width((_this$container$width2 = this.container.width()) !== null && _this$container$width2 !== void 0 ? _this$container$width2 : 0);
628
+ contentItem.element.height((_this$container$heigh2 = this.container.height()) !== null && _this$container$heigh2 !== void 0 ? _this$container$heigh2 : 0);
615
629
  contentItem.callDownwards('setSize');
616
630
 
617
631
  this._maximisedItem.emit('maximised');
618
632
 
619
633
  this.emit('stateChanged');
620
- },
621
- _$minimiseItem: function _$minimiseItem(contentItem) {
634
+ }
635
+
636
+ _$minimiseItem(contentItem) {
637
+ var _contentItem$parent;
638
+
622
639
  contentItem.element.removeClass('lm_maximised');
623
640
  contentItem.removeId('__glMaximised');
624
641
 
@@ -626,12 +643,11 @@ lm.utils.copy(LayoutManager.prototype, {
626
643
 
627
644
  this._maximisePlaceholder.remove();
628
645
 
629
- contentItem.parent.callDownwards('setSize');
646
+ (_contentItem$parent = contentItem.parent) === null || _contentItem$parent === void 0 ? void 0 : _contentItem$parent.callDownwards('setSize');
630
647
  this._maximisedItem = null;
631
648
  contentItem.emit('minimised');
632
649
  this.emit('stateChanged');
633
- },
634
-
650
+ }
635
651
  /**
636
652
  * This method is used to get around sandboxed iframe restrictions.
637
653
  * If 'allow-top-navigation' is not specified in the iframe's 'sandbox' attribute
@@ -641,24 +657,21 @@ lm.utils.copy(LayoutManager.prototype, {
641
657
  * This prevented GoldenLayout popouts from popping in in codepens. The fix is to call
642
658
  * _$closeWindow on the child window's gl instance which (after a timeout to disconnect
643
659
  * the invoking method from the close call) closes itself.
644
- *
645
- * @packagePrivate
646
- *
647
- * @returns {void}
648
660
  */
649
- _$closeWindow: function _$closeWindow() {
661
+
662
+
663
+ _$closeWindow() {
650
664
  window.setTimeout(function () {
651
665
  window.close();
652
666
  }, 1);
653
- },
654
- _$getArea: function _$getArea(x, y) {
655
- var i,
656
- area,
657
- smallestSurface = Infinity,
658
- mathingArea = null;
667
+ }
659
668
 
660
- for (i = 0; i < this._itemAreas.length; i++) {
661
- area = this._itemAreas[i];
669
+ _$getArea(x, y) {
670
+ var smallestSurface = Infinity;
671
+ var mathingArea = null;
672
+
673
+ for (var i = 0; i < this._itemAreas.length; i++) {
674
+ var area = this._itemAreas[i];
662
675
 
663
676
  if (x > area.x1 && x < area.x2 && y > area.y1 && y < area.y2 && smallestSurface > area.surface) {
664
677
  smallestSurface = area.surface;
@@ -667,32 +680,39 @@ lm.utils.copy(LayoutManager.prototype, {
667
680
  }
668
681
 
669
682
  return mathingArea;
670
- },
671
- _$createRootItemAreas: function _$createRootItemAreas() {
672
- var areaSize = 50;
673
- var sides = {
674
- y2: 'y1',
675
- x2: 'x1',
676
- y1: 'y2',
677
- x1: 'x2'
678
- };
683
+ }
684
+ /**
685
+ * Creates the drop zones at the edges of the screen
686
+ */
679
687
 
680
- for (var side in sides) {
681
- var area = this.root._$getArea();
682
688
 
683
- area.side = side;
684
- if (sides[side][1] == '2') area[side] = area[sides[side]] - areaSize;else {
685
- area[side] = area[sides[side]] + areaSize;
686
- }
689
+ _$createRootItemAreas() {
690
+ var areaSize = 50;
691
+
692
+ var rootArea = _objectSpread({}, this.root._$getArea());
693
+
694
+ var areas = [_objectSpread(_objectSpread({}, rootArea), {}, {
695
+ side: 'left',
696
+ x2: rootArea.x1 + areaSize
697
+ }), _objectSpread(_objectSpread({}, rootArea), {}, {
698
+ side: 'right',
699
+ x1: rootArea.x2 - areaSize
700
+ }), _objectSpread(_objectSpread({}, rootArea), {}, {
701
+ side: 'top',
702
+ y2: rootArea.y1 + areaSize
703
+ }), _objectSpread(_objectSpread({}, rootArea), {}, {
704
+ side: 'bottom',
705
+ y1: rootArea.y2 - areaSize
706
+ })];
707
+ areas.forEach(area => {
687
708
  area.surface = (area.x2 - area.x1) * (area.y2 - area.y1);
709
+ });
688
710
 
689
- this._itemAreas.push(area);
690
- }
691
- },
692
- _$calculateItemAreas: function _$calculateItemAreas() {
693
- var i,
694
- area,
695
- allContentItems = this._getAllContentItems();
711
+ this._itemAreas.push(...areas);
712
+ }
713
+
714
+ _$calculateItemAreas() {
715
+ var allContentItems = this._getAllContentItems();
696
716
 
697
717
  this._itemAreas = [];
698
718
  /**
@@ -711,52 +731,52 @@ lm.utils.copy(LayoutManager.prototype, {
711
731
 
712
732
  this._$createRootItemAreas();
713
733
 
714
- for (i = 0; i < allContentItems.length; i++) {
715
- if (!allContentItems[i].isStack) {
734
+ for (var i = 0; i < allContentItems.length; i++) {
735
+ var item = allContentItems[i];
736
+
737
+ if (!isStack(item)) {
716
738
  continue;
717
739
  }
718
740
 
719
- area = allContentItems[i]._$getArea();
741
+ var area = item._$getArea();
720
742
 
721
743
  if (area === null) {
722
744
  continue;
723
745
  } else if (area instanceof Array) {
724
746
  this._itemAreas = this._itemAreas.concat(area);
725
747
  } else {
748
+ var _area$contentItem$_co;
749
+
726
750
  this._itemAreas.push(area);
727
751
 
728
- var header = {};
729
- lm.utils.copy(header, area);
730
- lm.utils.copy(header, area.contentItem._contentAreaDimensions.header.highlightArea);
752
+ var header = _objectSpread(_objectSpread({}, area), (_area$contentItem$_co = area.contentItem._contentAreaDimensions) === null || _area$contentItem$_co === void 0 ? void 0 : _area$contentItem$_co.header.highlightArea);
753
+
731
754
  header.surface = (header.x2 - header.x1) * (header.y2 - header.y1);
732
755
 
733
756
  this._itemAreas.push(header);
734
757
  }
735
758
  }
736
- },
737
-
759
+ }
738
760
  /**
739
761
  * Takes a contentItem or a configuration and optionally a parent
740
762
  * item and returns an initialised instance of the contentItem.
741
763
  * If the contentItem is a function, it is first called
742
764
  *
743
- * @packagePrivate
744
- *
745
- * @param {lm.items.AbtractContentItem|Object|Function} contentItemOrConfig
746
- * @param {lm.items.AbtractContentItem} parent Only necessary when passing in config
747
- *
748
- * @returns {lm.items.AbtractContentItem}
765
+ * @param contentItemOrConfig
766
+ * @param parent Only necessary when passing in config
749
767
  */
750
- _$normalizeContentItem: function _$normalizeContentItem(contentItemOrConfig, parent) {
768
+
769
+
770
+ _$normalizeContentItem(contentItemOrConfig, parent) {
751
771
  if (!contentItemOrConfig) {
752
772
  throw new Error('No content item defined');
753
773
  }
754
774
 
755
- if (lm.utils.isFunction(contentItemOrConfig)) {
775
+ if (typeof contentItemOrConfig === 'function') {
756
776
  contentItemOrConfig = contentItemOrConfig();
757
777
  }
758
778
 
759
- if (contentItemOrConfig instanceof lm.items.AbstractContentItem) {
779
+ if (contentItemOrConfig instanceof AbstractContentItem) {
760
780
  return contentItemOrConfig;
761
781
  }
762
782
 
@@ -767,23 +787,21 @@ lm.utils.copy(LayoutManager.prototype, {
767
787
  } else {
768
788
  throw new Error('Invalid contentItem');
769
789
  }
770
- },
771
-
790
+ }
772
791
  /**
773
792
  * Iterates through the array of open popout windows and removes the ones
774
793
  * that are effectively closed. This is necessary due to the lack of reliably
775
794
  * listening for window.close / unload events in a cross browser compatible fashion.
776
- *
777
- * @packagePrivate
778
- *
779
- * @returns {void}
780
795
  */
781
- _$reconcilePopoutWindows: function _$reconcilePopoutWindows() {
782
- var openPopouts = [],
783
- i;
784
796
 
785
- for (i = 0; i < this.openPopouts.length; i++) {
786
- if (this.openPopouts[i].getWindow().closed === false) {
797
+
798
+ _$reconcilePopoutWindows() {
799
+ var openPopouts = [];
800
+
801
+ for (var i = 0; i < this.openPopouts.length; i++) {
802
+ var _this$openPopouts$i$g;
803
+
804
+ if (((_this$openPopouts$i$g = this.openPopouts[i].getWindow()) === null || _this$openPopouts$i$g === void 0 ? void 0 : _this$openPopouts$i$g.closed) === false) {
787
805
  openPopouts.push(this.openPopouts[i]);
788
806
  } else {
789
807
  this.emit('windowClosed', this.openPopouts[i]);
@@ -794,8 +812,7 @@ lm.utils.copy(LayoutManager.prototype, {
794
812
  this.emit('stateChanged');
795
813
  this.openPopouts = openPopouts;
796
814
  }
797
- },
798
-
815
+ }
799
816
  /***************************
800
817
  * PRIVATE
801
818
  ***************************/
@@ -803,15 +820,14 @@ lm.utils.copy(LayoutManager.prototype, {
803
820
  /**
804
821
  * Returns a flattened array of all content items,
805
822
  * regardles of level or type
806
- *
807
- * @private
808
- *
809
- * @returns {void}
823
+ * @return Flattened array of content items
810
824
  */
811
- _getAllContentItems: function _getAllContentItems() {
825
+
826
+
827
+ _getAllContentItems() {
812
828
  var allContentItems = [];
813
829
 
814
- var addChildren = function addChildren(contentItem) {
830
+ var addChildren = contentItem => {
815
831
  allContentItems.push(contentItem);
816
832
 
817
833
  if (contentItem.contentItems instanceof Array) {
@@ -823,72 +839,71 @@ lm.utils.copy(LayoutManager.prototype, {
823
839
 
824
840
  addChildren(this.root);
825
841
  return allContentItems;
826
- },
827
-
842
+ }
828
843
  /**
829
844
  * Binds to DOM/BOM events on init
830
- *
831
- * @private
832
- *
833
- * @returns {void}
834
845
  */
835
- _bindEvents: function _bindEvents() {
846
+
847
+
848
+ _bindEvents() {
836
849
  if (this._isFullPage) {
837
- $(window).resize(this._resizeFunction);
850
+ $(window).resize(this._onResize);
838
851
  }
839
852
 
840
- $(window).on('unload beforeunload', this._unloadFunction).on('blur.lm', this._windowBlur).on('focus.lm', this._windowFocus);
841
- },
842
-
853
+ $(window).on('unload beforeunload', this._onUnload).on('blur.lm', this._windowBlur).on('focus.lm', this._windowFocus);
854
+ }
843
855
  /**
844
856
  * Handles setting a class based on window focus, useful for focus indicators
845
857
  */
846
- _windowBlur: function _windowBlur() {
858
+
859
+
860
+ _windowBlur() {
847
861
  this.root.element.addClass('lm_window_blur');
848
- },
849
- _windowFocus: function _windowFocus() {
850
- this.root.element.removeClass('lm_window_blur');
851
- },
862
+ }
852
863
 
864
+ _windowFocus() {
865
+ this.root.element.removeClass('lm_window_blur');
866
+ }
853
867
  /**
854
868
  * Debounces resize events
855
- *
856
- * @private
857
- *
858
- * @returns {void}
859
869
  */
860
- _onResize: function _onResize() {
861
- clearTimeout(this._resizeTimeoutId);
862
- this._resizeTimeoutId = setTimeout(lm.utils.fnBind(this.updateSize, this), 100);
863
- },
864
870
 
871
+
872
+ _onResize() {
873
+ clearTimeout(this._resizeTimeoutId);
874
+ this._resizeTimeoutId = window.setTimeout(this.updateSize.bind(this), 100);
875
+ }
865
876
  /**
866
877
  * Extends the default config with the user specific settings and applies
867
878
  * derivations. Please note that there's a seperate method (AbstractContentItem._extendItemNode)
868
879
  * that deals with the extension of item configs
869
880
  *
870
- * @param {Object} config
871
- * @static
872
- * @returns {Object} config
881
+ * @param config
882
+ * @returns config
873
883
  */
874
- _createConfig: function _createConfig(config) {
875
- var windowConfigKey = lm.utils.getQueryStringParam('gl-window');
884
+
885
+
886
+ _createConfig(config) {
887
+ var _config$settings;
888
+
889
+ var windowConfigKey = getQueryStringParam('gl-window');
876
890
 
877
891
  if (windowConfigKey) {
878
892
  this.isSubWindow = true;
879
- config = localStorage.getItem(windowConfigKey);
880
- config = JSON.parse(config);
881
- config = new lm.utils.ConfigMinifier().unminifyConfig(config);
893
+ config = JSON.parse(localStorage.getItem(windowConfigKey) || '{}');
894
+ config = unminifyConfig(config);
882
895
  localStorage.removeItem(windowConfigKey);
883
896
  }
884
897
 
885
- config = $.extend(true, {}, lm.config.defaultConfig, config);
898
+ config = $.extend(true, {}, defaultConfig, config);
886
899
 
887
900
  var nextNode = function nextNode(node) {
888
901
  for (var key in node) {
889
- if (key !== 'props' && typeof node[key] === 'object') {
890
- nextNode(node[key]);
891
- } else if (key === 'type' && node[key] === 'react-component') {
902
+ var value = node[key];
903
+
904
+ if (key !== 'props' && typeof value === 'object' && value != null) {
905
+ nextNode(value);
906
+ } else if (key === 'type' && value === 'react-component') {
892
907
  node.type = 'component';
893
908
  node.componentName = 'lm-react-component';
894
909
  }
@@ -897,27 +912,26 @@ lm.utils.copy(LayoutManager.prototype, {
897
912
 
898
913
  nextNode(config);
899
914
 
900
- if (config.settings.hasHeaders === false) {
915
+ if (((_config$settings = config.settings) === null || _config$settings === void 0 ? void 0 : _config$settings.hasHeaders) === false) {
901
916
  config.dimensions.headerHeight = 0;
902
917
  }
903
918
 
904
919
  return config;
905
- },
906
-
920
+ }
907
921
  /**
908
922
  * This is executed when GoldenLayout detects that it is run
909
923
  * within a previously opened popout window.
910
- *
911
- * @private
912
- *
913
- * @returns {void}
914
924
  */
915
- _adjustToWindowMode: function _adjustToWindowMode() {
925
+
926
+
927
+ _adjustToWindowMode() {
928
+ var _this$config$content$;
929
+
916
930
  var popInButton = $('<div class="lm_popin" title="' + this.config.labels.popin + '">' + '<div class="lm_icon"></div>' + '<div class="lm_bg"></div>' + '</div>');
917
- popInButton.click(lm.utils.fnBind(function () {
931
+ popInButton.click(() => {
918
932
  this.emit('popIn');
919
- }, this));
920
- document.title = lm.utils.stripTags(this.config.content[0].title);
933
+ });
934
+ document.title = stripTags((_this$config$content$ = this.config.content[0].title) !== null && _this$config$content$ !== void 0 ? _this$config$content$ : '');
921
935
  $('head').append($('body link, body style, template, .gl_keep'));
922
936
  this.container = $('body').html('').css('visibility', 'visible').append(popInButton);
923
937
  /*
@@ -934,32 +948,26 @@ lm.utils.copy(LayoutManager.prototype, {
934
948
  */
935
949
 
936
950
  window.__glInstance = this;
937
- },
938
-
951
+ }
939
952
  /**
940
953
  * Creates Subwindows (if there are any). Throws an error
941
954
  * if popouts are blocked.
942
- *
943
- * @returns {void}
944
955
  */
945
- _createSubWindows: function _createSubWindows() {
946
- var i, popout;
947
956
 
948
- for (i = 0; i < this.config.openPopouts.length; i++) {
949
- popout = this.config.openPopouts[i];
957
+
958
+ _createSubWindows() {
959
+ if (!this.config.openPopouts) {
960
+ return;
961
+ }
962
+
963
+ for (var i = 0; i < this.config.openPopouts.length; i++) {
964
+ var popout = this.config.openPopouts[i];
950
965
  this.createPopout(popout.content, popout.dimensions, popout.parentId, popout.indexInParent);
951
966
  }
952
- },
967
+ }
953
968
 
954
- /**
955
- * Determines what element the layout will be created in
956
- *
957
- * @private
958
- *
959
- * @returns {void}
960
- */
961
- _setContainer: function _setContainer() {
962
- var container = $(this.container || 'body');
969
+ _getContainer() {
970
+ var container = this._originalContainer ? $(this._originalContainer) : $('body');
963
971
 
964
972
  if (container.length === 0) {
965
973
  throw new Error('GoldenLayout container not found');
@@ -969,6 +977,16 @@ lm.utils.copy(LayoutManager.prototype, {
969
977
  throw new Error('GoldenLayout more than one container element specified');
970
978
  }
971
979
 
980
+ return container;
981
+ }
982
+ /**
983
+ * Determines what element the layout will be created in
984
+ */
985
+
986
+
987
+ _setContainer() {
988
+ var container = this._getContainer();
989
+
972
990
  if (container[0] === document.body) {
973
991
  this._isFullPage = true;
974
992
  $('html, body').css({
@@ -980,16 +998,15 @@ lm.utils.copy(LayoutManager.prototype, {
980
998
  }
981
999
 
982
1000
  this.container = container;
983
- },
984
-
1001
+ }
985
1002
  /**
986
1003
  * Kicks of the initial, recursive creation chain
987
1004
  *
988
- * @param {Object} config GoldenLayout Config
989
- *
990
- * @returns {void}
1005
+ * @param config GoldenLayout Config
991
1006
  */
992
- _create: function _create(config) {
1007
+
1008
+
1009
+ _create(config) {
993
1010
  var errorMsg;
994
1011
 
995
1012
  if (!(config.content instanceof Array)) {
@@ -999,15 +1016,15 @@ lm.utils.copy(LayoutManager.prototype, {
999
1016
  errorMsg = "Configuration parameter 'content' must be an array";
1000
1017
  }
1001
1018
 
1002
- throw new lm.errors.ConfigurationError(errorMsg, config);
1019
+ throw new ConfigurationError(errorMsg, config);
1003
1020
  }
1004
1021
 
1005
1022
  if (config.content.length > 1) {
1006
1023
  errorMsg = "Top level content can't contain more then one element.";
1007
- throw new lm.errors.ConfigurationError(errorMsg, config);
1024
+ throw new ConfigurationError(errorMsg, config);
1008
1025
  }
1009
1026
 
1010
- this.root = new lm.items.Root(this, {
1027
+ this.root = new Root(this, {
1011
1028
  content: config.content
1012
1029
  }, this.container);
1013
1030
  this.root.callDownwards('_$init');
@@ -1015,28 +1032,26 @@ lm.utils.copy(LayoutManager.prototype, {
1015
1032
  if (config.maximisedItemId === '__glMaximised') {
1016
1033
  this.root.getItemsById(config.maximisedItemId)[0].toggleMaximise();
1017
1034
  }
1018
- },
1019
-
1035
+ }
1020
1036
  /**
1021
1037
  * Called when the window is closed or the user navigates away
1022
1038
  * from the page
1023
- *
1024
- * @returns {void}
1025
1039
  */
1026
- _onUnload: function _onUnload() {
1040
+
1041
+
1042
+ _onUnload() {
1027
1043
  if (this.config.settings.closePopoutsOnUnload === true) {
1028
1044
  for (var i = 0; i < this.openPopouts.length; i++) {
1029
1045
  this.openPopouts[i].close();
1030
1046
  }
1031
1047
  }
1032
- },
1033
-
1048
+ }
1034
1049
  /**
1035
1050
  * Adjusts the number of columns to be lower to fit the screen and still maintain minItemWidth.
1036
- *
1037
- * @returns {void}
1038
1051
  */
1039
- _adjustColumnsResponsive: function _adjustColumnsResponsive() {
1052
+
1053
+
1054
+ _adjustColumnsResponsive() {
1040
1055
  // If there is no min width set, or not content items, do nothing.
1041
1056
  if (!this._useResponsiveLayout() || this._updatingColumnsResponsive || !this.config.dimensions || !this.config.dimensions.minItemWidth || this.root.contentItems.length === 0 || !this.root.contentItems[0].isRow) {
1042
1057
  this._firstLoad = false;
@@ -1055,7 +1070,7 @@ lm.utils.copy(LayoutManager.prototype, {
1055
1070
  var minItemWidth = this.config.dimensions.minItemWidth;
1056
1071
  var totalMinWidth = columnCount * minItemWidth;
1057
1072
 
1058
- if (totalMinWidth <= this.width) {
1073
+ if (this.width == null || totalMinWidth <= this.width) {
1059
1074
  return;
1060
1075
  } // Prevent updates while it is already happening.
1061
1076
 
@@ -1076,65 +1091,68 @@ lm.utils.copy(LayoutManager.prototype, {
1076
1091
  }
1077
1092
 
1078
1093
  this._updatingColumnsResponsive = false;
1079
- },
1080
-
1094
+ }
1081
1095
  /**
1082
1096
  * Determines if responsive layout should be used.
1083
1097
  *
1084
- * @returns {bool} - True if responsive layout should be used; otherwise false.
1098
+ * @returns True if responsive layout should be used; otherwise false.
1085
1099
  */
1086
- _useResponsiveLayout: function _useResponsiveLayout() {
1087
- return this.config.settings && (this.config.settings.responsiveMode == 'always' || this.config.settings.responsiveMode == 'onload' && this._firstLoad);
1088
- },
1089
1100
 
1101
+
1102
+ _useResponsiveLayout() {
1103
+ return this.config.settings && (this.config.settings.responsiveMode == 'always' || this.config.settings.responsiveMode == 'onload' && this._firstLoad);
1104
+ }
1090
1105
  /**
1091
1106
  * Adds all children of a node to another container recursively.
1092
- * @param {object} container - Container to add child content items to.
1093
- * @param {object} node - Node to search for content items.
1094
- * @returns {void}
1107
+ * @param container - Container to add child content items to.
1108
+ * @param node - Node to search for content items.
1095
1109
  */
1096
- _addChildContentItemsToContainer: function _addChildContentItemsToContainer(container, node) {
1110
+
1111
+
1112
+ _addChildContentItemsToContainer(container, node) {
1097
1113
  if (node.type === 'stack') {
1098
1114
  node.contentItems.forEach(function (item) {
1099
1115
  container.addChild(item);
1100
1116
  node.removeChild(item, true);
1101
1117
  });
1102
1118
  } else {
1103
- node.contentItems.forEach(lm.utils.fnBind(function (item) {
1119
+ node.contentItems.forEach(item => {
1104
1120
  this._addChildContentItemsToContainer(container, item);
1105
- }, this));
1121
+ });
1106
1122
  }
1107
- },
1108
-
1123
+ }
1109
1124
  /**
1110
1125
  * Finds all the stack containers.
1111
- * @returns {array} - The found stack containers.
1126
+ * @returns The found stack containers.
1112
1127
  */
1113
- _findAllStackContainers: function _findAllStackContainers() {
1128
+
1129
+
1130
+ _findAllStackContainers() {
1114
1131
  var stackContainers = [];
1115
1132
 
1116
1133
  this._findAllStackContainersRecursive(stackContainers, this.root);
1117
1134
 
1118
1135
  return stackContainers;
1119
- },
1120
-
1136
+ }
1121
1137
  /**
1122
1138
  * Finds all the stack containers.
1123
1139
  *
1124
- * @param {array} - Set of containers to populate.
1125
- * @param {object} - Current node to process.
1126
- *
1127
- * @returns {void}
1140
+ * @param stackContainers Set of containers to populate.
1141
+ * @param node Current node to process.
1128
1142
  */
1129
- _findAllStackContainersRecursive: function _findAllStackContainersRecursive(stackContainers, node) {
1130
- node.contentItems.forEach(lm.utils.fnBind(function (item) {
1131
- if (item.type == 'stack') {
1143
+
1144
+
1145
+ _findAllStackContainersRecursive(stackContainers, node) {
1146
+ node.contentItems.forEach(item => {
1147
+ if (isStack(item)) {
1132
1148
  stackContainers.push(item);
1133
1149
  } else if (!item.isComponent) {
1134
1150
  this._findAllStackContainersRecursive(stackContainers, item);
1135
1151
  }
1136
- }, this));
1152
+ });
1137
1153
  }
1138
- });
1139
- export default LayoutManager;
1154
+
1155
+ }
1156
+
1157
+ _defineProperty(LayoutManager, "__lm", lm);
1140
1158
  //# sourceMappingURL=LayoutManager.js.map