@deephaven/golden-layout 0.19.2-beta.10 → 0.19.2-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/LayoutManager.d.ts +313 -0
- package/dist/LayoutManager.d.ts.map +1 -0
- package/dist/LayoutManager.js +468 -450
- package/dist/LayoutManager.js.map +1 -1
- package/dist/base.d.ts +16 -0
- package/dist/base.d.ts.map +1 -0
- package/dist/base.js +6 -6
- package/dist/base.js.map +1 -1
- package/dist/config/Config.d.ts +146 -0
- package/dist/config/Config.d.ts.map +1 -0
- package/dist/config/{defaultConfig.js → Config.js} +6 -6
- package/dist/config/Config.js.map +1 -0
- package/dist/config/ItemConfig.d.ts +66 -0
- package/dist/config/ItemConfig.d.ts.map +1 -0
- package/dist/config/ItemConfig.js +14 -0
- package/dist/config/ItemConfig.js.map +1 -0
- package/dist/config/index.d.ts +3 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +2 -6
- package/dist/config/index.js.map +1 -1
- package/dist/container/ItemContainer.d.ts +91 -0
- package/dist/container/ItemContainer.d.ts.map +1 -0
- package/dist/container/ItemContainer.js +110 -85
- package/dist/container/ItemContainer.js.map +1 -1
- package/dist/container/index.d.ts +3 -0
- package/dist/container/index.d.ts.map +1 -0
- package/dist/container/index.js +2 -4
- package/dist/container/index.js.map +1 -1
- package/dist/controls/BrowserPopout.d.ts +83 -0
- package/dist/controls/BrowserPopout.d.ts.map +1 -0
- package/dist/controls/BrowserPopout.js +135 -101
- package/dist/controls/BrowserPopout.js.map +1 -1
- package/dist/controls/DragProxy.d.ts +67 -0
- package/dist/controls/DragProxy.d.ts.map +1 -0
- package/dist/controls/DragProxy.js +135 -110
- package/dist/controls/DragProxy.js.map +1 -1
- package/dist/controls/DragSource.d.ts +30 -0
- package/dist/controls/DragSource.d.ts.map +1 -0
- package/dist/controls/DragSource.js +37 -29
- package/dist/controls/DragSource.js.map +1 -1
- package/dist/controls/DragSourceFromEvent.d.ts +30 -0
- package/dist/controls/DragSourceFromEvent.d.ts.map +1 -0
- package/dist/controls/DragSourceFromEvent.js +49 -36
- package/dist/controls/DragSourceFromEvent.js.map +1 -1
- package/dist/controls/DropTargetIndicator.d.ts +14 -0
- package/dist/controls/DropTargetIndicator.d.ts.map +1 -0
- package/dist/controls/DropTargetIndicator.js +18 -14
- package/dist/controls/DropTargetIndicator.js.map +1 -1
- package/dist/controls/Header.d.ts +145 -0
- package/dist/controls/Header.d.ts.map +1 -0
- package/dist/controls/Header.js +414 -271
- package/dist/controls/Header.js.map +1 -1
- package/dist/controls/HeaderButton.d.ts +9 -0
- package/dist/controls/HeaderButton.d.ts.map +1 -0
- package/dist/controls/HeaderButton.js +19 -13
- package/dist/controls/HeaderButton.js.map +1 -1
- package/dist/controls/Splitter.d.ts +12 -0
- package/dist/controls/Splitter.d.ts.map +1 -0
- package/dist/controls/Splitter.js +36 -20
- package/dist/controls/Splitter.js.map +1 -1
- package/dist/controls/Tab.d.ts +91 -0
- package/dist/controls/Tab.d.ts.map +1 -0
- package/dist/controls/Tab.js +131 -119
- package/dist/controls/Tab.js.map +1 -1
- package/dist/controls/TransitionIndicator.d.ts +25 -0
- package/dist/controls/TransitionIndicator.d.ts.map +1 -0
- package/dist/controls/TransitionIndicator.js +53 -39
- package/dist/controls/TransitionIndicator.js.map +1 -1
- package/dist/controls/index.d.ts +11 -0
- package/dist/controls/index.d.ts.map +1 -0
- package/dist/controls/index.js +10 -22
- package/dist/controls/index.js.map +1 -1
- package/dist/errors/ConfigurationError.d.ts +6 -0
- package/dist/errors/ConfigurationError.d.ts.map +1 -0
- package/dist/errors/ConfigurationError.js +15 -8
- package/dist/errors/ConfigurationError.js.map +1 -1
- package/dist/errors/index.d.ts +2 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +1 -4
- package/dist/errors/index.js.map +1 -1
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/items/AbstractContentItem.d.ts +233 -0
- package/dist/items/AbstractContentItem.d.ts.map +1 -0
- package/dist/items/AbstractContentItem.js +284 -242
- package/dist/items/AbstractContentItem.js.map +1 -1
- package/dist/items/Component.d.ts +30 -0
- package/dist/items/Component.d.ts.map +1 -0
- package/dist/items/Component.js +61 -42
- package/dist/items/Component.js.map +1 -1
- package/dist/items/Root.d.ts +18 -0
- package/dist/items/Root.d.ts.map +1 -0
- package/dist/items/Root.js +68 -38
- package/dist/items/Root.js.map +1 -1
- package/dist/items/RowOrColumn.d.ts +157 -0
- package/dist/items/RowOrColumn.d.ts.map +1 -0
- package/dist/items/RowOrColumn.js +219 -187
- package/dist/items/RowOrColumn.js.map +1 -1
- package/dist/items/Stack.d.ts +108 -0
- package/dist/items/Stack.d.ts.map +1 -0
- package/dist/items/Stack.js +218 -151
- package/dist/items/Stack.js.map +1 -1
- package/dist/items/index.d.ts +8 -0
- package/dist/items/index.d.ts.map +1 -0
- package/dist/items/index.js +7 -12
- package/dist/items/index.js.map +1 -1
- package/dist/utils/BubblingEvent.d.ts +8 -0
- package/dist/utils/BubblingEvent.d.ts.map +1 -0
- package/dist/utils/BubblingEvent.js +18 -9
- package/dist/utils/BubblingEvent.js.map +1 -1
- package/dist/utils/ConfigMinifier.d.ts +21 -0
- package/dist/utils/ConfigMinifier.d.ts.map +1 -0
- package/dist/utils/ConfigMinifier.js +121 -121
- package/dist/utils/ConfigMinifier.js.map +1 -1
- package/dist/utils/DragListener.d.ts +34 -0
- package/dist/utils/DragListener.d.ts.map +1 -0
- package/dist/utils/DragListener.js +103 -70
- package/dist/utils/DragListener.js.map +1 -1
- package/dist/utils/EventEmitter.d.ts +59 -0
- package/dist/utils/EventEmitter.d.ts.map +1 -0
- package/dist/utils/EventEmitter.js +64 -70
- package/dist/utils/EventEmitter.js.map +1 -1
- package/dist/utils/EventHub.d.ts +55 -0
- package/dist/utils/EventHub.d.ts.map +1 -0
- package/dist/utils/EventHub.js +83 -105
- package/dist/utils/EventHub.js.map +1 -1
- package/dist/utils/ReactComponentHandler.d.ts +54 -0
- package/dist/utils/ReactComponentHandler.d.ts.map +1 -0
- package/dist/utils/ReactComponentHandler.js +58 -56
- package/dist/utils/ReactComponentHandler.js.map +1 -1
- package/dist/utils/index.d.ts +8 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +7 -21
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/utils.d.ts +25 -0
- package/dist/utils/utils.d.ts.map +1 -0
- package/dist/utils/utils.js +21 -145
- package/dist/utils/utils.js.map +1 -1
- package/package.json +9 -5
- package/dist/config/ItemDefaultConfig.js +0 -8
- package/dist/config/ItemDefaultConfig.js.map +0 -1
- package/dist/config/defaultConfig.js.map +0 -1
|
@@ -1,9 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
+
|
|
3
|
+
import { animFrame, BubblingEvent, EventEmitter } from "../utils/index.js";
|
|
4
|
+
import { ConfigurationError } from "../errors/index.js";
|
|
5
|
+
import { itemDefaultConfig } from "../config/index.js";
|
|
6
|
+
export function isStack(item) {
|
|
7
|
+
return item.isStack;
|
|
8
|
+
}
|
|
9
|
+
export function isComponent(item) {
|
|
10
|
+
return item.isComponent;
|
|
11
|
+
}
|
|
12
|
+
export function isRoot(item) {
|
|
13
|
+
return item.isRoot;
|
|
14
|
+
}
|
|
15
|
+
|
|
7
16
|
/**
|
|
8
17
|
* This is the baseclass that all content items inherit from.
|
|
9
18
|
* Most methods provide a subset of what the sub-classes do.
|
|
@@ -25,79 +34,109 @@ var {
|
|
|
25
34
|
*
|
|
26
35
|
* @constructor
|
|
27
36
|
*/
|
|
37
|
+
export default class AbstractContentItem extends EventEmitter {
|
|
38
|
+
constructor(layoutManager, config, parent, element) {
|
|
39
|
+
super();
|
|
40
|
+
|
|
41
|
+
_defineProperty(this, "config", void 0);
|
|
42
|
+
|
|
43
|
+
_defineProperty(this, "type", void 0);
|
|
44
|
+
|
|
45
|
+
_defineProperty(this, "contentItems", void 0);
|
|
46
|
+
|
|
47
|
+
_defineProperty(this, "parent", void 0);
|
|
48
|
+
|
|
49
|
+
_defineProperty(this, "layoutManager", void 0);
|
|
50
|
+
|
|
51
|
+
_defineProperty(this, "element", void 0);
|
|
52
|
+
|
|
53
|
+
_defineProperty(this, "childElementContainer", void 0);
|
|
54
|
+
|
|
55
|
+
_defineProperty(this, "componentName", void 0);
|
|
56
|
+
|
|
57
|
+
_defineProperty(this, "isInitialised", false);
|
|
58
|
+
|
|
59
|
+
_defineProperty(this, "isMaximised", false);
|
|
60
|
+
|
|
61
|
+
_defineProperty(this, "isRoot", false);
|
|
62
|
+
|
|
63
|
+
_defineProperty(this, "isRow", false);
|
|
64
|
+
|
|
65
|
+
_defineProperty(this, "isColumn", false);
|
|
66
|
+
|
|
67
|
+
_defineProperty(this, "isStack", false);
|
|
68
|
+
|
|
69
|
+
_defineProperty(this, "isComponent", false);
|
|
70
|
+
|
|
71
|
+
_defineProperty(this, "tab", void 0);
|
|
72
|
+
|
|
73
|
+
_defineProperty(this, "_pendingEventPropagations", void 0);
|
|
74
|
+
|
|
75
|
+
_defineProperty(this, "_throttledEvents", void 0);
|
|
76
|
+
|
|
77
|
+
this.element = element; // Some GL things expect this config to not change
|
|
78
|
+
|
|
79
|
+
this.config = this._extendItemNode(config);
|
|
80
|
+
this.type = config.type;
|
|
81
|
+
this.contentItems = [];
|
|
82
|
+
this.parent = parent;
|
|
83
|
+
this.layoutManager = layoutManager;
|
|
84
|
+
this._pendingEventPropagations = {};
|
|
85
|
+
this._throttledEvents = ['stateChanged'];
|
|
86
|
+
this.on(EventEmitter.ALL_EVENT, this._propagateEvent, this);
|
|
28
87
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
this.contentItems = [];
|
|
34
|
-
this.parent = parent;
|
|
35
|
-
this.isInitialised = false;
|
|
36
|
-
this.isMaximised = false;
|
|
37
|
-
this.isRoot = false;
|
|
38
|
-
this.isRow = false;
|
|
39
|
-
this.isColumn = false;
|
|
40
|
-
this.isStack = false;
|
|
41
|
-
this.isComponent = false;
|
|
42
|
-
this.layoutManager = layoutManager;
|
|
43
|
-
this._pendingEventPropagations = {};
|
|
44
|
-
this._throttledEvents = ['stateChanged'];
|
|
45
|
-
this.on(utils.EventEmitter.ALL_EVENT, this._propagateEvent, this);
|
|
46
|
-
|
|
47
|
-
if (config.content) {
|
|
48
|
-
this._createContentItems(config);
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
utils.copy(AbstractContentItem.prototype, {
|
|
88
|
+
if (config.content) {
|
|
89
|
+
this._createContentItems(config);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
53
92
|
/**
|
|
54
93
|
* Set the size of the component and its children, called recursively
|
|
55
94
|
*
|
|
56
95
|
* @abstract
|
|
57
|
-
* @returns void
|
|
58
96
|
*/
|
|
59
|
-
|
|
60
|
-
throw new Error('Abstract Method');
|
|
61
|
-
},
|
|
97
|
+
|
|
62
98
|
|
|
63
99
|
/**
|
|
64
100
|
* Calls a method recursively downwards on the tree
|
|
65
101
|
*
|
|
66
|
-
* @param
|
|
67
|
-
* @param
|
|
68
|
-
* @param
|
|
69
|
-
* @param
|
|
70
|
-
*
|
|
71
|
-
* @returns {void}
|
|
102
|
+
* @param functionName the name of the function to be called
|
|
103
|
+
* @param functionArguments optional arguments that are passed to every function
|
|
104
|
+
* @param bottomUp Call methods from bottom to top, defaults to false
|
|
105
|
+
* @param skipSelf Don't invoke the method on the class that calls it, defaults to false
|
|
72
106
|
*/
|
|
73
|
-
callDownwards
|
|
74
|
-
var
|
|
107
|
+
callDownwards(functionName) {
|
|
108
|
+
var functionArguments = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
109
|
+
var bottomUp = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
110
|
+
var skipSelf = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
75
111
|
|
|
76
112
|
if (bottomUp !== true && skipSelf !== true) {
|
|
77
|
-
this[functionName].apply(this, functionArguments
|
|
113
|
+
this[functionName].apply(this, functionArguments);
|
|
78
114
|
}
|
|
79
115
|
|
|
80
|
-
for (i = 0; i < this.contentItems.length; i++) {
|
|
116
|
+
for (var i = 0; i < this.contentItems.length; i++) {
|
|
81
117
|
this.contentItems[i].callDownwards(functionName, functionArguments, bottomUp);
|
|
82
118
|
}
|
|
83
119
|
|
|
84
120
|
if (bottomUp === true && skipSelf !== true) {
|
|
85
|
-
this[functionName].apply(this, functionArguments
|
|
121
|
+
this[functionName].apply(this, functionArguments);
|
|
86
122
|
}
|
|
87
|
-
}
|
|
88
|
-
|
|
123
|
+
}
|
|
89
124
|
/**
|
|
90
125
|
* Removes a child node (and its children) from the tree
|
|
91
126
|
*
|
|
92
|
-
* @param
|
|
93
|
-
*
|
|
94
|
-
* @returns {void}
|
|
127
|
+
* @param contentItem
|
|
95
128
|
*/
|
|
96
|
-
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
removeChild(contentItem) {
|
|
132
|
+
var _this$config$content;
|
|
133
|
+
|
|
134
|
+
var keepChild = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
135
|
+
|
|
97
136
|
/*
|
|
98
137
|
* Get the position of the item that's to be removed within all content items this node contains
|
|
99
138
|
*/
|
|
100
|
-
var index =
|
|
139
|
+
var index = this.contentItems.indexOf(contentItem);
|
|
101
140
|
/*
|
|
102
141
|
* Make sure the content item to be removed is actually a child of this item
|
|
103
142
|
*/
|
|
@@ -123,7 +162,7 @@ utils.copy(AbstractContentItem.prototype, {
|
|
|
123
162
|
* Remove the item from the configuration
|
|
124
163
|
*/
|
|
125
164
|
|
|
126
|
-
this.config.content.splice(index, 1);
|
|
165
|
+
(_this$config$content = this.config.content) === null || _this$config$content === void 0 ? void 0 : _this$config$content.splice(index, 1);
|
|
127
166
|
/**
|
|
128
167
|
* If this node still contains other content items, adjust their size
|
|
129
168
|
*/
|
|
@@ -134,19 +173,24 @@ utils.copy(AbstractContentItem.prototype, {
|
|
|
134
173
|
* If this was the last content item, remove this node as well
|
|
135
174
|
*/
|
|
136
175
|
} else if (this.type !== 'root' && this.config.isClosable) {
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
},
|
|
176
|
+
var _this$parent;
|
|
140
177
|
|
|
178
|
+
(_this$parent = this.parent) === null || _this$parent === void 0 ? void 0 : _this$parent.removeChild(this);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
141
181
|
/**
|
|
142
182
|
* Sets up the tree structure for the newly added child
|
|
143
183
|
* The responsibility for the actual DOM manipulations lies
|
|
144
184
|
* with the concrete item
|
|
145
185
|
*
|
|
146
|
-
* @param
|
|
147
|
-
* @param
|
|
186
|
+
* @param contentItem
|
|
187
|
+
* @param index If omitted item will be appended
|
|
148
188
|
*/
|
|
149
|
-
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
addChild(contentItem, index) {
|
|
192
|
+
contentItem = this.layoutManager._$normalizeContentItem(contentItem, this);
|
|
193
|
+
|
|
150
194
|
if (index === undefined) {
|
|
151
195
|
index = this.contentItems.length;
|
|
152
196
|
}
|
|
@@ -163,27 +207,28 @@ utils.copy(AbstractContentItem.prototype, {
|
|
|
163
207
|
if (contentItem.parent.isInitialised === true && contentItem.isInitialised === false) {
|
|
164
208
|
contentItem._$init();
|
|
165
209
|
}
|
|
166
|
-
}
|
|
167
|
-
|
|
210
|
+
}
|
|
168
211
|
/**
|
|
169
212
|
* Replaces oldChild with newChild. This used to use jQuery.replaceWith... which for
|
|
170
213
|
* some reason removes all event listeners, so isn't really an option.
|
|
171
214
|
*
|
|
172
|
-
* @param
|
|
173
|
-
* @param
|
|
174
|
-
*
|
|
175
|
-
* @returns {void}
|
|
215
|
+
* @param oldChild
|
|
216
|
+
* @param newChild
|
|
176
217
|
*/
|
|
177
|
-
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
replaceChild(oldChild, newChild) {
|
|
221
|
+
var _$destroyOldChild = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
222
|
+
|
|
178
223
|
newChild = this.layoutManager._$normalizeContentItem(newChild);
|
|
179
|
-
var index =
|
|
180
|
-
|
|
224
|
+
var index = this.contentItems.indexOf(oldChild);
|
|
225
|
+
var parentNode = oldChild.element[0].parentNode;
|
|
181
226
|
|
|
182
227
|
if (index === -1) {
|
|
183
228
|
throw new Error("Can't replace child. oldChild is not child of this");
|
|
184
229
|
}
|
|
185
230
|
|
|
186
|
-
parentNode.replaceChild(newChild.element[0], oldChild.element[0]);
|
|
231
|
+
parentNode === null || parentNode === void 0 ? void 0 : parentNode.replaceChild(newChild.element[0], oldChild.element[0]);
|
|
187
232
|
/*
|
|
188
233
|
* Optionally destroy the old content item
|
|
189
234
|
*/
|
|
@@ -204,7 +249,7 @@ utils.copy(AbstractContentItem.prototype, {
|
|
|
204
249
|
* Update tab reference
|
|
205
250
|
*/
|
|
206
251
|
|
|
207
|
-
if (this
|
|
252
|
+
if (isStack(this)) {
|
|
208
253
|
this.header.tabs[index].contentItem = newChild;
|
|
209
254
|
} //TODO This doesn't update the config... refactor to leave item nodes untouched after creation
|
|
210
255
|
|
|
@@ -214,36 +259,35 @@ utils.copy(AbstractContentItem.prototype, {
|
|
|
214
259
|
}
|
|
215
260
|
|
|
216
261
|
this.callDownwards('setSize');
|
|
217
|
-
}
|
|
218
|
-
|
|
262
|
+
}
|
|
219
263
|
/**
|
|
220
264
|
* Convenience method.
|
|
221
265
|
* Shorthand for this.parent.removeChild( this )
|
|
222
|
-
*
|
|
223
|
-
* @returns {void}
|
|
224
266
|
*/
|
|
225
|
-
remove: function remove() {
|
|
226
|
-
this.parent.removeChild(this);
|
|
227
|
-
},
|
|
228
267
|
|
|
268
|
+
|
|
269
|
+
remove() {
|
|
270
|
+
var _this$parent2;
|
|
271
|
+
|
|
272
|
+
(_this$parent2 = this.parent) === null || _this$parent2 === void 0 ? void 0 : _this$parent2.removeChild(this);
|
|
273
|
+
}
|
|
229
274
|
/**
|
|
230
275
|
* Removes the component from the layout and creates a new
|
|
231
276
|
* browser window with the component and its children inside
|
|
232
|
-
*
|
|
233
|
-
* @returns {lm.controls.BrowserPopout}
|
|
234
277
|
*/
|
|
235
|
-
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
popout() {
|
|
236
281
|
var browserPopout = this.layoutManager.createPopout(this);
|
|
237
282
|
this.emitBubblingEvent('stateChanged');
|
|
238
283
|
return browserPopout;
|
|
239
|
-
}
|
|
240
|
-
|
|
284
|
+
}
|
|
241
285
|
/**
|
|
242
286
|
* Maximises the Item or minimises it if it is already maximised
|
|
243
|
-
*
|
|
244
|
-
* @returns {void}
|
|
245
287
|
*/
|
|
246
|
-
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
toggleMaximise(e) {
|
|
247
291
|
e && e.preventDefault();
|
|
248
292
|
|
|
249
293
|
if (this.isMaximised === true) {
|
|
@@ -254,74 +298,64 @@ utils.copy(AbstractContentItem.prototype, {
|
|
|
254
298
|
|
|
255
299
|
this.isMaximised = !this.isMaximised;
|
|
256
300
|
this.emitBubblingEvent('stateChanged');
|
|
257
|
-
}
|
|
258
|
-
|
|
301
|
+
}
|
|
259
302
|
/**
|
|
260
303
|
* Selects the item if it is not already selected
|
|
261
|
-
*
|
|
262
|
-
* @returns {void}
|
|
263
304
|
*/
|
|
264
|
-
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
select() {
|
|
265
308
|
if (this.layoutManager.selectedItem !== this) {
|
|
266
309
|
this.layoutManager.selectItem(this, true);
|
|
267
310
|
this.element.addClass('lm_selected');
|
|
268
311
|
}
|
|
269
|
-
}
|
|
270
|
-
|
|
312
|
+
}
|
|
271
313
|
/**
|
|
272
314
|
* De-selects the item if it is selected
|
|
273
|
-
*
|
|
274
|
-
* @returns {void}
|
|
275
315
|
*/
|
|
276
|
-
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
deselect() {
|
|
277
319
|
if (this.layoutManager.selectedItem === this) {
|
|
278
320
|
this.layoutManager.selectedItem = null;
|
|
279
321
|
this.element.removeClass('lm_selected');
|
|
280
322
|
}
|
|
281
|
-
}
|
|
282
|
-
|
|
323
|
+
}
|
|
283
324
|
/**
|
|
284
325
|
* Set this component's title
|
|
285
|
-
*
|
|
286
|
-
* @public
|
|
287
|
-
* @param {String} title
|
|
288
|
-
*
|
|
289
|
-
* @returns {void}
|
|
326
|
+
* @param title
|
|
290
327
|
*/
|
|
291
|
-
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
setTitle(title) {
|
|
292
331
|
this.config.title = title;
|
|
293
332
|
this.emit('titleChanged', title);
|
|
294
333
|
this.emitBubblingEvent('stateChanged');
|
|
295
|
-
}
|
|
296
|
-
|
|
334
|
+
}
|
|
297
335
|
/**
|
|
298
336
|
* Checks whether a provided id is present
|
|
299
|
-
*
|
|
300
|
-
* @
|
|
301
|
-
* @param {String} id
|
|
302
|
-
*
|
|
303
|
-
* @returns {Boolean} isPresent
|
|
337
|
+
* @param id
|
|
338
|
+
* @returns isPresent
|
|
304
339
|
*/
|
|
305
|
-
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
hasId(id) {
|
|
306
343
|
if (!this.config.id) {
|
|
307
344
|
return false;
|
|
308
345
|
} else if (typeof this.config.id === 'string') {
|
|
309
346
|
return this.config.id === id;
|
|
310
347
|
} else if (this.config.id instanceof Array) {
|
|
311
|
-
return
|
|
348
|
+
return this.config.id.indexOf(id) !== -1;
|
|
312
349
|
}
|
|
313
|
-
}
|
|
314
|
-
|
|
350
|
+
}
|
|
315
351
|
/**
|
|
316
352
|
* Adds an id. Adds it as a string if the component doesn't
|
|
317
353
|
* have an id yet or creates/uses an array
|
|
318
|
-
*
|
|
319
|
-
* @public
|
|
320
|
-
* @param {String} id
|
|
321
|
-
*
|
|
322
|
-
* @returns {void}
|
|
354
|
+
* @param id
|
|
323
355
|
*/
|
|
324
|
-
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
addId(id) {
|
|
325
359
|
if (this.hasId(id)) {
|
|
326
360
|
return;
|
|
327
361
|
}
|
|
@@ -333,18 +367,15 @@ utils.copy(AbstractContentItem.prototype, {
|
|
|
333
367
|
} else if (this.config.id instanceof Array) {
|
|
334
368
|
this.config.id.push(id);
|
|
335
369
|
}
|
|
336
|
-
}
|
|
337
|
-
|
|
370
|
+
}
|
|
338
371
|
/**
|
|
339
372
|
* Removes an existing id. Throws an error
|
|
340
373
|
* if the id is not present
|
|
341
|
-
*
|
|
342
|
-
* @public
|
|
343
|
-
* @param {String} id
|
|
344
|
-
*
|
|
345
|
-
* @returns {void}
|
|
374
|
+
* @param id
|
|
346
375
|
*/
|
|
347
|
-
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
removeId(id) {
|
|
348
379
|
if (!this.hasId(id)) {
|
|
349
380
|
throw new Error('Id not found');
|
|
350
381
|
}
|
|
@@ -352,17 +383,19 @@ utils.copy(AbstractContentItem.prototype, {
|
|
|
352
383
|
if (typeof this.config.id === 'string') {
|
|
353
384
|
delete this.config.id;
|
|
354
385
|
} else if (this.config.id instanceof Array) {
|
|
355
|
-
var index =
|
|
386
|
+
var index = this.config.id.indexOf(id);
|
|
356
387
|
this.config.id.splice(index, 1);
|
|
357
388
|
}
|
|
358
|
-
}
|
|
359
|
-
|
|
389
|
+
}
|
|
360
390
|
/****************************************
|
|
361
391
|
* SELECTOR
|
|
362
392
|
****************************************/
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
getItemsByFilter(filter) {
|
|
396
|
+
var result = [];
|
|
397
|
+
|
|
398
|
+
var next = function next(contentItem) {
|
|
366
399
|
for (var i = 0; i < contentItem.contentItems.length; i++) {
|
|
367
400
|
if (filter(contentItem.contentItems[i]) === true) {
|
|
368
401
|
result.push(contentItem.contentItems[i]);
|
|
@@ -374,197 +407,210 @@ utils.copy(AbstractContentItem.prototype, {
|
|
|
374
407
|
|
|
375
408
|
next(this);
|
|
376
409
|
return result;
|
|
377
|
-
}
|
|
378
|
-
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
getItemsById(id) {
|
|
379
413
|
return this.getItemsByFilter(function (item) {
|
|
380
414
|
if (item.config.id instanceof Array) {
|
|
381
|
-
return
|
|
415
|
+
return item.config.id.indexOf(id) !== -1;
|
|
382
416
|
} else {
|
|
383
417
|
return item.config.id === id;
|
|
384
418
|
}
|
|
385
419
|
});
|
|
386
|
-
}
|
|
387
|
-
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
getItemsByType(type) {
|
|
388
423
|
return this._$getItemsByProperty('type', type);
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
i;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
getComponentsByName(componentName) {
|
|
427
|
+
var components = this._$getItemsByProperty('componentName', componentName);
|
|
394
428
|
|
|
395
|
-
|
|
429
|
+
var instances = [];
|
|
430
|
+
|
|
431
|
+
for (var i = 0; i < components.length; i++) {
|
|
396
432
|
instances.push(components[i].instance);
|
|
397
433
|
}
|
|
398
434
|
|
|
399
435
|
return instances;
|
|
400
|
-
}
|
|
401
|
-
|
|
436
|
+
}
|
|
402
437
|
/****************************************
|
|
403
438
|
* PACKAGE PRIVATE
|
|
404
439
|
****************************************/
|
|
405
|
-
|
|
440
|
+
|
|
441
|
+
|
|
442
|
+
_$getItemsByProperty(key, value) {
|
|
406
443
|
return this.getItemsByFilter(function (item) {
|
|
407
444
|
return item[key] === value;
|
|
408
445
|
});
|
|
409
|
-
}
|
|
410
|
-
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
_$setParent(parent) {
|
|
411
449
|
this.parent = parent;
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
_$highlightDropZone(x, y, area) {
|
|
453
|
+
var _this$layoutManager$d;
|
|
454
|
+
|
|
455
|
+
(_this$layoutManager$d = this.layoutManager.dropTargetIndicator) === null || _this$layoutManager$d === void 0 ? void 0 : _this$layoutManager$d.highlightArea(area);
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
_$onDrop(contentItem, area) {
|
|
417
459
|
this.addChild(contentItem);
|
|
418
|
-
}
|
|
419
|
-
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
_$hide() {
|
|
420
463
|
this._callOnActiveComponents('hide');
|
|
421
464
|
|
|
422
465
|
this.element.hide();
|
|
423
466
|
this.layoutManager.updateSize();
|
|
424
|
-
}
|
|
425
|
-
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
_$show() {
|
|
426
470
|
this._callOnActiveComponents('show');
|
|
427
471
|
|
|
428
472
|
this.element.show();
|
|
429
473
|
this.layoutManager.updateSize();
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
_callOnActiveComponents(methodName) {
|
|
477
|
+
var stacks = this.getItemsByType('stack');
|
|
478
|
+
var activeContentItem = null;
|
|
435
479
|
|
|
436
|
-
for (i = 0; i < stacks.length; i++) {
|
|
480
|
+
for (var i = 0; i < stacks.length; i++) {
|
|
437
481
|
activeContentItem = stacks[i].getActiveContentItem();
|
|
438
482
|
|
|
439
|
-
if (activeContentItem && activeContentItem
|
|
483
|
+
if (activeContentItem && isComponent(activeContentItem)) {
|
|
440
484
|
activeContentItem.container[methodName]();
|
|
441
485
|
}
|
|
442
486
|
}
|
|
443
|
-
}
|
|
444
|
-
|
|
487
|
+
}
|
|
445
488
|
/**
|
|
446
489
|
* Destroys this item ands its children
|
|
447
|
-
*
|
|
448
|
-
* @returns {void}
|
|
449
490
|
*/
|
|
450
|
-
|
|
491
|
+
|
|
492
|
+
|
|
493
|
+
_$destroy() {
|
|
451
494
|
this.emitBubblingEvent('beforeItemDestroyed');
|
|
452
495
|
this.callDownwards('_$destroy', [], true, true);
|
|
453
496
|
this.element.remove();
|
|
454
497
|
this.emitBubblingEvent('itemDestroyed');
|
|
455
|
-
}
|
|
456
|
-
|
|
498
|
+
}
|
|
457
499
|
/**
|
|
458
500
|
* Returns the area the component currently occupies in the format
|
|
459
501
|
*
|
|
460
502
|
* {
|
|
461
503
|
* x1: int
|
|
462
|
-
*
|
|
504
|
+
* x2: int
|
|
463
505
|
* y1: int
|
|
464
506
|
* y2: int
|
|
465
507
|
* contentItem: contentItem
|
|
466
508
|
* }
|
|
467
509
|
*/
|
|
468
|
-
|
|
510
|
+
|
|
511
|
+
|
|
512
|
+
_$getArea(element) {
|
|
513
|
+
var _element$offset, _element$width, _element$height;
|
|
514
|
+
|
|
469
515
|
element = element || this.element;
|
|
470
|
-
var offset = element.offset()
|
|
471
|
-
|
|
472
|
-
|
|
516
|
+
var offset = (_element$offset = element.offset()) !== null && _element$offset !== void 0 ? _element$offset : {
|
|
517
|
+
left: 0,
|
|
518
|
+
top: 0
|
|
519
|
+
};
|
|
520
|
+
var width = (_element$width = element.width()) !== null && _element$width !== void 0 ? _element$width : 0;
|
|
521
|
+
var height = (_element$height = element.height()) !== null && _element$height !== void 0 ? _element$height : 0;
|
|
473
522
|
return {
|
|
474
523
|
x1: offset.left,
|
|
475
524
|
y1: offset.top,
|
|
476
525
|
x2: offset.left + width,
|
|
477
526
|
y2: offset.top + height,
|
|
478
527
|
surface: width * height,
|
|
479
|
-
contentItem: this
|
|
528
|
+
contentItem: this,
|
|
529
|
+
side: ''
|
|
480
530
|
};
|
|
481
|
-
}
|
|
482
|
-
|
|
531
|
+
}
|
|
483
532
|
/**
|
|
484
533
|
* The tree of content items is created in two steps: First all content items are instantiated,
|
|
485
534
|
* then init is called recursively from top to bottem. This is the basic init function,
|
|
486
535
|
* it can be used, extended or overwritten by the content items
|
|
487
536
|
*
|
|
488
537
|
* Its behaviour depends on the content item
|
|
489
|
-
*
|
|
490
|
-
* @package private
|
|
491
|
-
*
|
|
492
|
-
* @returns {void}
|
|
493
538
|
*/
|
|
494
|
-
|
|
495
|
-
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
_$init() {
|
|
496
542
|
this.setSize();
|
|
497
543
|
|
|
498
|
-
for (i = 0; i < this.contentItems.length; i++) {
|
|
499
|
-
|
|
544
|
+
for (var i = 0; i < this.contentItems.length; i++) {
|
|
545
|
+
var _this$childElementCon;
|
|
546
|
+
|
|
547
|
+
(_this$childElementCon = this.childElementContainer) === null || _this$childElementCon === void 0 ? void 0 : _this$childElementCon.append(this.contentItems[i].element);
|
|
500
548
|
}
|
|
501
549
|
|
|
502
550
|
this.isInitialised = true;
|
|
503
551
|
this.emitBubblingEvent('itemCreated');
|
|
504
552
|
this.emitBubblingEvent(this.type + 'Created');
|
|
505
|
-
}
|
|
506
|
-
|
|
553
|
+
}
|
|
507
554
|
/**
|
|
508
555
|
* Emit an event that bubbles up the item tree.
|
|
509
556
|
*
|
|
510
|
-
* @param
|
|
511
|
-
*
|
|
512
|
-
* @returns {void}
|
|
557
|
+
* @param name The name of the event
|
|
513
558
|
*/
|
|
514
|
-
emitBubblingEvent: function emitBubblingEvent(name) {
|
|
515
|
-
var event = new utils.BubblingEvent(name, this);
|
|
516
|
-
this.emit(name, event);
|
|
517
|
-
},
|
|
518
559
|
|
|
560
|
+
|
|
561
|
+
emitBubblingEvent(name) {
|
|
562
|
+
var event = new BubblingEvent(name, this);
|
|
563
|
+
this.emit(name, event);
|
|
564
|
+
}
|
|
519
565
|
/**
|
|
520
566
|
* Private method, creates all content items for this node at initialisation time
|
|
521
567
|
* PLEASE NOTE, please see addChild for adding contentItems add runtime
|
|
522
|
-
* @private
|
|
523
568
|
* @param {configuration item node} config
|
|
524
|
-
*
|
|
525
|
-
* @returns {void}
|
|
526
569
|
*/
|
|
527
|
-
|
|
528
|
-
|
|
570
|
+
|
|
571
|
+
|
|
572
|
+
_createContentItems(config) {
|
|
573
|
+
var oContentItem;
|
|
529
574
|
|
|
530
575
|
if (!(config.content instanceof Array)) {
|
|
531
|
-
throw new
|
|
576
|
+
throw new ConfigurationError('content must be an Array', config);
|
|
532
577
|
}
|
|
533
578
|
|
|
534
|
-
for (i = 0; i < config.content.length; i++) {
|
|
579
|
+
for (var i = 0; i < config.content.length; i++) {
|
|
535
580
|
oContentItem = this.layoutManager.createContentItem(config.content[i], this);
|
|
536
581
|
this.contentItems.push(oContentItem);
|
|
537
582
|
}
|
|
538
|
-
}
|
|
539
|
-
|
|
583
|
+
}
|
|
540
584
|
/**
|
|
541
585
|
* Extends an item configuration node with default settings
|
|
542
|
-
* @
|
|
543
|
-
* @
|
|
544
|
-
*
|
|
545
|
-
* @returns {configuration item node} extended config
|
|
586
|
+
* @param config
|
|
587
|
+
* @returns extended config
|
|
546
588
|
*/
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
589
|
+
|
|
590
|
+
|
|
591
|
+
_extendItemNode(config) {
|
|
592
|
+
for (var [key, value] of Object.entries(itemDefaultConfig)) {
|
|
593
|
+
// This just appeases TS
|
|
594
|
+
var k = key;
|
|
595
|
+
|
|
596
|
+
if (config[k] === undefined) {
|
|
597
|
+
config[k] = value;
|
|
551
598
|
}
|
|
552
599
|
}
|
|
553
600
|
|
|
554
601
|
return config;
|
|
555
|
-
}
|
|
556
|
-
|
|
602
|
+
}
|
|
557
603
|
/**
|
|
558
604
|
* Called for every event on the item tree. Decides whether the event is a bubbling
|
|
559
605
|
* event and propagates it to its parent
|
|
560
606
|
*
|
|
561
|
-
* @param
|
|
562
|
-
* @param
|
|
563
|
-
*
|
|
564
|
-
* @returns {void}
|
|
607
|
+
* @param name the name of the event
|
|
608
|
+
* @param event
|
|
565
609
|
*/
|
|
566
|
-
|
|
567
|
-
|
|
610
|
+
|
|
611
|
+
|
|
612
|
+
_propagateEvent(name, event) {
|
|
613
|
+
if (event instanceof BubblingEvent && event.isPropagationStopped === false && this.isInitialised === true) {
|
|
568
614
|
/**
|
|
569
615
|
* In some cases (e.g. if an element is created from a DragSource) it
|
|
570
616
|
* doesn't have a parent and is not below root. If that's the case
|
|
@@ -572,46 +618,42 @@ utils.copy(AbstractContentItem.prototype, {
|
|
|
572
618
|
* to the layoutManager
|
|
573
619
|
*/
|
|
574
620
|
if (this.isRoot === false && this.parent) {
|
|
575
|
-
this.parent.emit.apply(this.parent,
|
|
621
|
+
this.parent.emit.apply(this.parent, [name, event]);
|
|
576
622
|
} else {
|
|
577
623
|
this._scheduleEventPropagationToLayoutManager(name, event);
|
|
578
624
|
}
|
|
579
625
|
}
|
|
580
|
-
}
|
|
581
|
-
|
|
626
|
+
}
|
|
582
627
|
/**
|
|
583
628
|
* All raw events bubble up to the root element. Some events that
|
|
584
629
|
* are propagated to - and emitted by - the layoutManager however are
|
|
585
630
|
* only string-based, batched and sanitized to make them more usable
|
|
586
631
|
*
|
|
587
|
-
* @param
|
|
588
|
-
*
|
|
589
|
-
* @private
|
|
590
|
-
* @returns {void}
|
|
632
|
+
* @param name the name of the event
|
|
591
633
|
*/
|
|
592
|
-
|
|
593
|
-
|
|
634
|
+
|
|
635
|
+
|
|
636
|
+
_scheduleEventPropagationToLayoutManager(name, event) {
|
|
637
|
+
if (this._throttledEvents.indexOf(name) === -1) {
|
|
594
638
|
this.layoutManager.emit(name, event.origin);
|
|
595
639
|
} else {
|
|
596
640
|
if (this._pendingEventPropagations[name] !== true) {
|
|
597
641
|
this._pendingEventPropagations[name] = true;
|
|
598
|
-
|
|
642
|
+
animFrame(this._propagateEventToLayoutManager.bind(this, name, event));
|
|
599
643
|
}
|
|
600
644
|
}
|
|
601
|
-
}
|
|
602
|
-
|
|
645
|
+
}
|
|
603
646
|
/**
|
|
604
647
|
* Callback for events scheduled by _scheduleEventPropagationToLayoutManager
|
|
605
648
|
*
|
|
606
|
-
* @param
|
|
607
|
-
*
|
|
608
|
-
* @private
|
|
609
|
-
* @returns {void}
|
|
649
|
+
* @param name the name of the event
|
|
610
650
|
*/
|
|
611
|
-
|
|
651
|
+
|
|
652
|
+
|
|
653
|
+
_propagateEventToLayoutManager(name, event) {
|
|
612
654
|
this._pendingEventPropagations[name] = false;
|
|
613
655
|
this.layoutManager.emit(name, event);
|
|
614
656
|
}
|
|
615
|
-
|
|
616
|
-
|
|
657
|
+
|
|
658
|
+
}
|
|
617
659
|
//# sourceMappingURL=AbstractContentItem.js.map
|