@deephaven/dashboard 0.15.1 → 0.15.2
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/Dashboard.d.ts +2 -2
- package/dist/Dashboard.d.ts.map +1 -1
- package/dist/Dashboard.js.map +1 -1
- package/dist/DashboardLayout.d.ts.map +1 -1
- package/dist/DashboardLayout.js +2 -2
- package/dist/DashboardLayout.js.map +1 -1
- package/dist/PanelErrorBoundary.d.ts +17 -30
- package/dist/PanelErrorBoundary.d.ts.map +1 -1
- package/dist/PanelErrorBoundary.js +1 -8
- package/dist/PanelErrorBoundary.js.map +1 -1
- package/dist/PanelEvent.d.ts +4 -1
- package/dist/PanelEvent.d.ts.map +1 -1
- package/dist/PanelEvent.js.map +1 -1
- package/dist/PanelManager.d.ts +9 -9
- package/dist/PanelManager.d.ts.map +1 -1
- package/dist/PanelManager.js +6 -7
- package/dist/PanelManager.js.map +1 -1
- package/dist/PanelPlaceholder.d.ts +5 -3
- package/dist/PanelPlaceholder.d.ts.map +1 -1
- package/dist/PanelPlaceholder.js +1 -1
- package/dist/PanelPlaceholder.js.map +1 -1
- package/dist/declaration.d.js +2 -0
- package/dist/declaration.d.js.map +1 -0
- package/dist/layout/GLPropTypes.d.ts +2 -2
- package/dist/layout/GLPropTypes.d.ts.map +1 -1
- package/dist/layout/GLPropTypes.js.map +1 -1
- package/dist/layout/GoldenLayoutThemeExport.d.ts +1 -1
- package/dist/layout/GoldenLayoutThemeExport.d.ts.map +1 -1
- package/dist/layout/GoldenLayoutThemeExport.js.map +1 -1
- package/dist/layout/LayoutUtils.d.ts +121 -103
- package/dist/layout/LayoutUtils.d.ts.map +1 -1
- package/dist/layout/LayoutUtils.js +159 -102
- package/dist/layout/LayoutUtils.js.map +1 -1
- package/dist/layout/ReactDOM.d.ts.map +1 -1
- package/dist/layout/ReactDOM.js.map +1 -1
- package/dist/layout/golden-layout.d.ts +6 -1
- package/dist/layout/golden-layout.d.ts.map +1 -1
- package/dist/layout/golden-layout.js.map +1 -1
- package/dist/layout/hooks.d.ts +0 -1
- package/dist/layout/hooks.d.ts.map +1 -1
- package/dist/layout/jquery.d.ts.map +1 -1
- package/dist/layout/jquery.js.map +1 -1
- package/dist/redux/actionTypes.d.ts +1 -1
- package/dist/redux/actionTypes.d.ts.map +1 -1
- package/dist/redux/actionTypes.js.map +1 -1
- package/dist/redux/actions.d.ts +17 -2
- package/dist/redux/actions.d.ts.map +1 -1
- package/dist/redux/actions.js +4 -4
- package/dist/redux/actions.js.map +1 -1
- package/dist/redux/reducers/dashboardData.d.ts +1 -1
- package/dist/redux/reducers/dashboardData.d.ts.map +1 -1
- package/dist/redux/reducers/dashboardData.js.map +1 -1
- package/dist/redux/reducers/index.d.ts +3 -4
- package/dist/redux/reducers/index.d.ts.map +1 -1
- package/dist/redux/reducers/index.js.map +1 -1
- package/dist/redux/selectors.d.ts +28 -4
- package/dist/redux/selectors.d.ts.map +1 -1
- package/dist/redux/selectors.js +10 -10
- package/dist/redux/selectors.js.map +1 -1
- package/package.json +10 -8
|
@@ -8,8 +8,31 @@ import deepEqual from 'deep-equal';
|
|
|
8
8
|
import shortid from 'shortid';
|
|
9
9
|
import isMatch from 'lodash.ismatch';
|
|
10
10
|
import Log from '@deephaven/log';
|
|
11
|
+
import { assertNotNull } from '@deephaven/utils';
|
|
11
12
|
import GoldenLayoutThemeExport from "./GoldenLayoutThemeExport.js";
|
|
12
13
|
var log = Log.module('LayoutUtils');
|
|
14
|
+
export function isReactComponentConfig(config) {
|
|
15
|
+
var reactConfig = config;
|
|
16
|
+
return reactConfig.type === 'react-component' && reactConfig.component !== undefined;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function isComponentConfig(config) {
|
|
20
|
+
return config.componentName !== undefined;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function isHTMLElement(element) {
|
|
24
|
+
return element.focus !== undefined;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function assertReactComponentConfig(config) {
|
|
28
|
+
if (!isReactComponentConfig(config)) {
|
|
29
|
+
throw new Error('config is not react component config');
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function isStackItemConfig(config) {
|
|
34
|
+
return config.type === 'stack';
|
|
35
|
+
}
|
|
13
36
|
|
|
14
37
|
class LayoutUtils {
|
|
15
38
|
static activateTab(root, config) {
|
|
@@ -22,13 +45,16 @@ class LayoutUtils {
|
|
|
22
45
|
|
|
23
46
|
|
|
24
47
|
var contentItem = LayoutUtils.getContentItemInStack(stack, config);
|
|
25
|
-
|
|
48
|
+
|
|
49
|
+
if (contentItem) {
|
|
50
|
+
stack.setActiveContentItem(contentItem);
|
|
51
|
+
}
|
|
26
52
|
}
|
|
27
53
|
/**
|
|
28
54
|
* Is the tab with the given config active
|
|
29
|
-
* @param
|
|
30
|
-
* @param
|
|
31
|
-
* @returns
|
|
55
|
+
* @param root A GoldenLayout content item with the tab
|
|
56
|
+
* @param config Tab config to match
|
|
57
|
+
* @returns True if the tab is active
|
|
32
58
|
*/
|
|
33
59
|
|
|
34
60
|
|
|
@@ -47,7 +73,7 @@ class LayoutUtils {
|
|
|
47
73
|
}
|
|
48
74
|
/**
|
|
49
75
|
* Adds a stack to the root layout specified. Adds to the first row/column with only one item
|
|
50
|
-
* @param
|
|
76
|
+
* @param parent A GoldenLayout content item to add the stack to
|
|
51
77
|
* @returns The newly created stack.
|
|
52
78
|
*/
|
|
53
79
|
|
|
@@ -76,7 +102,10 @@ class LayoutUtils {
|
|
|
76
102
|
|
|
77
103
|
var maintainFocusElement = document.activeElement;
|
|
78
104
|
parent.contentItems[0].addChild(child);
|
|
79
|
-
|
|
105
|
+
|
|
106
|
+
if (maintainFocusElement && maintainFocusElement.focus) {
|
|
107
|
+
maintainFocusElement.focus();
|
|
108
|
+
}
|
|
80
109
|
}
|
|
81
110
|
|
|
82
111
|
return this.addStack(parent.contentItems[0], columnPreferred);
|
|
@@ -105,8 +134,8 @@ class LayoutUtils {
|
|
|
105
134
|
}
|
|
106
135
|
/**
|
|
107
136
|
* Gets the first stack which contains a contentItem with the given config values
|
|
108
|
-
* @param
|
|
109
|
-
* @param
|
|
137
|
+
* @param item Golden layout content item to search for the stack
|
|
138
|
+
* @param config The item properties to match
|
|
110
139
|
*/
|
|
111
140
|
|
|
112
141
|
|
|
@@ -142,10 +171,11 @@ class LayoutUtils {
|
|
|
142
171
|
}
|
|
143
172
|
/**
|
|
144
173
|
* Gets a stack matching the specified config
|
|
145
|
-
* @param
|
|
146
|
-
* @param
|
|
147
|
-
* @param
|
|
148
|
-
* @param
|
|
174
|
+
* @param root The root GoldenLayout element
|
|
175
|
+
* @param config The item config type to match, eg. { component: 'IrisGridPanel', title: 'Table Name' }
|
|
176
|
+
* @param createIfNecessary Whether to create the stack if it does not exist.
|
|
177
|
+
* @param matchComponentType If the config doesn't match exactly, just find another one of the same component type
|
|
178
|
+
* @param allowEmptyStack If no configs match, search for an empty stack that can be used
|
|
149
179
|
*/
|
|
150
180
|
|
|
151
181
|
|
|
@@ -169,11 +199,11 @@ class LayoutUtils {
|
|
|
169
199
|
}
|
|
170
200
|
/**
|
|
171
201
|
* Gets a stack matching one of the specified types, creates new stack if necessary
|
|
172
|
-
* @param
|
|
173
|
-
* @param
|
|
174
|
-
* @param
|
|
175
|
-
* @param
|
|
176
|
-
* @param
|
|
202
|
+
* @param root The GoldenLayout root to find or create the stack in
|
|
203
|
+
* @param types The array of component types to match
|
|
204
|
+
* @param createIfNecessary Whether to create the stack if it does not exist
|
|
205
|
+
* @param matchComponentType If the config doesn't match exactly, just find another one of the same component type
|
|
206
|
+
* @param allowEmptyStack If no configs match, search for an empty stack that can be used
|
|
177
207
|
*/
|
|
178
208
|
|
|
179
209
|
|
|
@@ -198,13 +228,17 @@ class LayoutUtils {
|
|
|
198
228
|
}
|
|
199
229
|
/**
|
|
200
230
|
* Gets first content item with the specified config in stack.
|
|
201
|
-
* @param
|
|
202
|
-
* @param
|
|
203
|
-
* @returns
|
|
231
|
+
* @param stack The stack to search for the item
|
|
232
|
+
* @param config The item config type to match, eg. { component: 'IrisGridPanel', title: 'Table Name' }
|
|
233
|
+
* @returns Returns the found content item, null if not found.
|
|
204
234
|
*/
|
|
205
235
|
|
|
206
236
|
|
|
207
237
|
static getContentItemInStack(stack, config) {
|
|
238
|
+
if (!stack) {
|
|
239
|
+
return null;
|
|
240
|
+
}
|
|
241
|
+
|
|
208
242
|
for (var i = 0; i < stack.contentItems.length; i += 1) {
|
|
209
243
|
var contentItem = stack.contentItems[i];
|
|
210
244
|
|
|
@@ -219,9 +253,8 @@ class LayoutUtils {
|
|
|
219
253
|
}
|
|
220
254
|
/**
|
|
221
255
|
* Removes dynamic props from components in the given config so this config could be serialized
|
|
222
|
-
* @param
|
|
223
|
-
* @
|
|
224
|
-
* @returns {Array} Dehydrated config
|
|
256
|
+
* @param config Config objec
|
|
257
|
+
* @returns Dehydrated config
|
|
225
258
|
*/
|
|
226
259
|
|
|
227
260
|
|
|
@@ -267,7 +300,7 @@ class LayoutUtils {
|
|
|
267
300
|
} = glContainer;
|
|
268
301
|
|
|
269
302
|
if (tab == null) {
|
|
270
|
-
throw new Error(
|
|
303
|
+
throw new Error("Cannot get tab for panel container ".concat(glContainer));
|
|
271
304
|
}
|
|
272
305
|
|
|
273
306
|
var tabRect = tab.element[0].getBoundingClientRect();
|
|
@@ -275,7 +308,7 @@ class LayoutUtils {
|
|
|
275
308
|
}
|
|
276
309
|
/**
|
|
277
310
|
* Drop minor changes in Layout Configuration for deep comparison
|
|
278
|
-
* @param
|
|
311
|
+
* @param config Layout Configuration
|
|
279
312
|
*
|
|
280
313
|
* minor changes:
|
|
281
314
|
* 1. sorts in grid
|
|
@@ -290,18 +323,16 @@ class LayoutUtils {
|
|
|
290
323
|
for (var i = 0; i < config.length; i += 1) {
|
|
291
324
|
var itemConfig = config[i];
|
|
292
325
|
var {
|
|
293
|
-
|
|
294
|
-
content,
|
|
295
|
-
activeItemIndex
|
|
326
|
+
content
|
|
296
327
|
} = itemConfig;
|
|
297
328
|
|
|
298
|
-
if (content) {
|
|
299
|
-
if (
|
|
329
|
+
if (content !== undefined) {
|
|
330
|
+
if (isStackItemConfig(itemConfig)) {
|
|
300
331
|
delete itemConfig.activeItemIndex;
|
|
301
332
|
}
|
|
302
333
|
|
|
303
334
|
LayoutUtils.dropLayoutMinorChange(content);
|
|
304
|
-
} else if (component === 'IrisGridPanel') {
|
|
335
|
+
} else if (isReactComponentConfig(itemConfig) && itemConfig.component === 'IrisGridPanel') {
|
|
305
336
|
if (itemConfig.props.panelState) {
|
|
306
337
|
delete itemConfig.id;
|
|
307
338
|
itemConfig.props.panelState.irisGridState.sorts = [];
|
|
@@ -312,9 +343,9 @@ class LayoutUtils {
|
|
|
312
343
|
}
|
|
313
344
|
/**
|
|
314
345
|
* Compare two layouts to see if they are equivalent
|
|
315
|
-
* @param
|
|
316
|
-
* @param
|
|
317
|
-
* @param
|
|
346
|
+
* @param layout1 A Golden Layout config object
|
|
347
|
+
* @param layout2 Another Golden layout config object
|
|
348
|
+
* @param major When true, will ignore "minor" property differences (eg. sorts)
|
|
318
349
|
*/
|
|
319
350
|
|
|
320
351
|
|
|
@@ -337,9 +368,9 @@ class LayoutUtils {
|
|
|
337
368
|
}
|
|
338
369
|
/**
|
|
339
370
|
* Adds dynamic props to components in the given config so this config could be used to initialize a layout
|
|
340
|
-
* @param
|
|
341
|
-
* @param
|
|
342
|
-
* @returns
|
|
371
|
+
* @param config Dehydrated config object
|
|
372
|
+
* @param hydrateComponent Function to hydrate the component
|
|
373
|
+
* @returns Hydrated config
|
|
343
374
|
*/
|
|
344
375
|
|
|
345
376
|
|
|
@@ -352,24 +383,22 @@ class LayoutUtils {
|
|
|
352
383
|
|
|
353
384
|
for (var i = 0; i < config.length; i += 1) {
|
|
354
385
|
var itemConfig = config[i];
|
|
355
|
-
var {
|
|
356
|
-
component,
|
|
357
|
-
content,
|
|
358
|
-
props = {},
|
|
359
|
-
type
|
|
360
|
-
} = itemConfig;
|
|
361
386
|
|
|
362
|
-
if (
|
|
387
|
+
if (isReactComponentConfig(itemConfig)) {
|
|
363
388
|
var _itemConfig$id;
|
|
364
389
|
|
|
390
|
+
var {
|
|
391
|
+
component,
|
|
392
|
+
props = {}
|
|
393
|
+
} = itemConfig;
|
|
365
394
|
hydratedConfig.push(_objectSpread(_objectSpread({}, itemConfig), {}, {
|
|
366
395
|
id: (_itemConfig$id = itemConfig === null || itemConfig === void 0 ? void 0 : itemConfig.id) !== null && _itemConfig$id !== void 0 ? _itemConfig$id : shortid(),
|
|
367
396
|
props: hydrateComponent(component, props)
|
|
368
397
|
}));
|
|
369
|
-
} else if (content) {
|
|
370
|
-
var contentConfig = LayoutUtils.hydrateLayoutConfig(content, hydrateComponent);
|
|
398
|
+
} else if (itemConfig.content !== undefined) {
|
|
399
|
+
var contentConfig = LayoutUtils.hydrateLayoutConfig(itemConfig.content, hydrateComponent);
|
|
371
400
|
|
|
372
|
-
if (itemConfig.activeItemIndex != null && itemConfig.activeItemIndex >= contentConfig.length) {
|
|
401
|
+
if (isStackItemConfig(itemConfig) && itemConfig.activeItemIndex != null && itemConfig.activeItemIndex >= contentConfig.length) {
|
|
373
402
|
log.warn('Fixing bad activeItemIndex!', itemConfig.activeItemIndex, itemConfig);
|
|
374
403
|
itemConfig.activeItemIndex = 0;
|
|
375
404
|
}
|
|
@@ -388,13 +417,13 @@ class LayoutUtils {
|
|
|
388
417
|
* Opens a component. It will try and open the component in an existing stack of the same component.
|
|
389
418
|
* If `replaceExisting` is true and there is a component found with the same `config.id`, it will replace that component with this one.
|
|
390
419
|
* If `allowStack` is true and there is a component of the same type found, it will open in that stack (potentially covering up a panel).
|
|
391
|
-
* @param
|
|
392
|
-
* @param
|
|
393
|
-
* @param
|
|
394
|
-
* @param
|
|
395
|
-
* @param
|
|
396
|
-
* @param
|
|
397
|
-
* @param
|
|
420
|
+
* @param root The GoldenLayout root to open the component in
|
|
421
|
+
* @param config The component config definition to open
|
|
422
|
+
* @param replaceExisting Whether it should replace the existing one matching component type and id, or open a new one
|
|
423
|
+
* @param replaceConfig The component config to replace
|
|
424
|
+
* @param createNewStack True to force opening in a new stack, false to try and open in a stack with the same type of component.
|
|
425
|
+
* @param focusElement The element to focus on
|
|
426
|
+
* @param dragEvent Whether component is being created with a drag, mouse event is initial position for drag proxy
|
|
398
427
|
*/
|
|
399
428
|
|
|
400
429
|
|
|
@@ -403,10 +432,10 @@ class LayoutUtils {
|
|
|
403
432
|
root,
|
|
404
433
|
config: configParam,
|
|
405
434
|
replaceExisting = true,
|
|
406
|
-
replaceConfig =
|
|
435
|
+
replaceConfig = undefined,
|
|
407
436
|
createNewStack = false,
|
|
408
|
-
focusElement =
|
|
409
|
-
dragEvent =
|
|
437
|
+
focusElement = undefined,
|
|
438
|
+
dragEvent = undefined
|
|
410
439
|
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
411
440
|
// attempt to retain focus after dom manipulation, which can break focus
|
|
412
441
|
var maintainFocusElement = document.activeElement;
|
|
@@ -418,7 +447,7 @@ class LayoutUtils {
|
|
|
418
447
|
}
|
|
419
448
|
|
|
420
449
|
if (dragEvent) {
|
|
421
|
-
root.layoutManager.createDragSourceFromEvent(config, dragEvent);
|
|
450
|
+
root === null || root === void 0 ? void 0 : root.layoutManager.createDragSourceFromEvent(config, dragEvent);
|
|
422
451
|
return;
|
|
423
452
|
}
|
|
424
453
|
|
|
@@ -426,7 +455,9 @@ class LayoutUtils {
|
|
|
426
455
|
id: config.id,
|
|
427
456
|
component: config.component
|
|
428
457
|
};
|
|
458
|
+
assertNotNull(root);
|
|
429
459
|
var stack = createNewStack ? LayoutUtils.addStack(root) : LayoutUtils.getStackForRoot(root, searchConfig);
|
|
460
|
+
assertNotNull(stack);
|
|
430
461
|
var oldContentItem = LayoutUtils.getContentItemInStack(stack, searchConfig);
|
|
431
462
|
|
|
432
463
|
if (focusElement) {
|
|
@@ -457,16 +488,16 @@ class LayoutUtils {
|
|
|
457
488
|
stack.addChild(config);
|
|
458
489
|
}
|
|
459
490
|
|
|
460
|
-
if (!focusElement && maintainFocusElement) {
|
|
491
|
+
if (!focusElement && maintainFocusElement && isHTMLElement(maintainFocusElement)) {
|
|
461
492
|
maintainFocusElement.focus();
|
|
462
493
|
}
|
|
463
494
|
}
|
|
464
495
|
/**
|
|
465
496
|
* Opens a component in an given stack.
|
|
466
497
|
* If `replaceExisting` is true and there is a component found with the same `config.id`, it will replace that component with this one
|
|
467
|
-
* @param
|
|
468
|
-
* @param
|
|
469
|
-
* @param
|
|
498
|
+
* @param stack The GoldenLayout stack to open the component in
|
|
499
|
+
* @param config The component config definition to open
|
|
500
|
+
* @param replaceExisting Whether it should replace the existing one matching component type and id, or open a new one
|
|
470
501
|
*/
|
|
471
502
|
|
|
472
503
|
|
|
@@ -479,23 +510,25 @@ class LayoutUtils {
|
|
|
479
510
|
};
|
|
480
511
|
var oldContentItem = LayoutUtils.getContentItemInStack(stack, searchConfig);
|
|
481
512
|
|
|
482
|
-
if (replaceExisting && oldContentItem) {
|
|
483
|
-
var index = stack.contentItems.indexOf(oldContentItem); // Using remove/add here instead of replaceChild because I was getting errors with replaceChild... should be the same.
|
|
513
|
+
if (replaceExisting && oldContentItem && stack) {
|
|
514
|
+
var index = stack === null || stack === void 0 ? void 0 : stack.contentItems.indexOf(oldContentItem); // Using remove/add here instead of replaceChild because I was getting errors with replaceChild... should be the same.
|
|
484
515
|
// Add first so that the stack doesn't get screwed up
|
|
485
516
|
|
|
486
517
|
stack.addChild(config, index + 1);
|
|
487
518
|
stack.removeChild(oldContentItem);
|
|
488
519
|
stack.setActiveContentItem(stack.contentItems[index]);
|
|
489
520
|
} else {
|
|
490
|
-
stack.addChild(config);
|
|
521
|
+
stack === null || stack === void 0 ? void 0 : stack.addChild(config);
|
|
491
522
|
}
|
|
492
523
|
|
|
493
|
-
if (maintainFocusElement
|
|
524
|
+
if (maintainFocusElement && isHTMLElement(maintainFocusElement)) {
|
|
525
|
+
maintainFocusElement.focus();
|
|
526
|
+
}
|
|
494
527
|
}
|
|
495
528
|
/**
|
|
496
529
|
* Close the specified component and remove it from the stack it's currently in
|
|
497
|
-
* @param
|
|
498
|
-
* @param
|
|
530
|
+
* @param root The GoldenLayout root to search and close the component in
|
|
531
|
+
* @param config The GoldenLayout component config definition to close, eg. { component: 'IrisGridPanel', id: 'table-t' }
|
|
499
532
|
*/
|
|
500
533
|
|
|
501
534
|
|
|
@@ -512,14 +545,18 @@ class LayoutUtils {
|
|
|
512
545
|
var oldContentItem = LayoutUtils.getContentItemInStack(stack, config);
|
|
513
546
|
var maintainFocusElement = document.activeElement; // attempt to retain focus after dom manipulation, which can break focus
|
|
514
547
|
|
|
515
|
-
if (oldContentItem
|
|
516
|
-
oldContentItem.
|
|
517
|
-
|
|
518
|
-
|
|
548
|
+
if (oldContentItem) {
|
|
549
|
+
if (oldContentItem.isComponent) {
|
|
550
|
+
// container property exists on a contentItem if contentItem is a component,
|
|
551
|
+
// however, this is not included in the types for a contentitem, thus the casting
|
|
552
|
+
oldContentItem.container.close();
|
|
553
|
+
} else {
|
|
554
|
+
stack.removeChild(oldContentItem);
|
|
555
|
+
}
|
|
519
556
|
} // if focused element is still in dom restore focus, note it could have been in the removed panel so check first
|
|
520
557
|
|
|
521
558
|
|
|
522
|
-
if (maintainFocusElement && document.contains(maintainFocusElement)) {
|
|
559
|
+
if (maintainFocusElement && document.contains(maintainFocusElement) && isHTMLElement(maintainFocusElement)) {
|
|
523
560
|
maintainFocusElement.focus();
|
|
524
561
|
}
|
|
525
562
|
}
|
|
@@ -534,13 +571,16 @@ class LayoutUtils {
|
|
|
534
571
|
|
|
535
572
|
|
|
536
573
|
var contentItem = LayoutUtils.getContentItemInStack(stack, config);
|
|
537
|
-
|
|
574
|
+
|
|
575
|
+
if (contentItem) {
|
|
576
|
+
contentItem.setTitle(newTitle);
|
|
577
|
+
}
|
|
538
578
|
}
|
|
539
579
|
/**
|
|
540
580
|
* Create a component clone based on the given config
|
|
541
|
-
* @param
|
|
542
|
-
* @param
|
|
543
|
-
* @returns
|
|
581
|
+
* @param root The GoldenLayout root to clone the component in
|
|
582
|
+
* @param config The config to clone
|
|
583
|
+
* @returns Clone config
|
|
544
584
|
*/
|
|
545
585
|
|
|
546
586
|
|
|
@@ -570,17 +610,25 @@ class LayoutUtils {
|
|
|
570
610
|
}
|
|
571
611
|
/**
|
|
572
612
|
* Get panel component state for the given config
|
|
573
|
-
* @param
|
|
574
|
-
* @returns
|
|
613
|
+
* @param config Panel config
|
|
614
|
+
* @returns Panel state
|
|
575
615
|
*/
|
|
576
616
|
|
|
577
617
|
|
|
578
618
|
static getPanelComponentState(config) {
|
|
579
|
-
|
|
619
|
+
if (isComponentConfig(config)) {
|
|
620
|
+
var _config$componentStat;
|
|
621
|
+
|
|
622
|
+
return (_config$componentStat = config.componentState) === null || _config$componentStat === void 0 ? void 0 : _config$componentStat.panelState;
|
|
623
|
+
}
|
|
580
624
|
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
625
|
+
if (isReactComponentConfig(config)) {
|
|
626
|
+
var _config$props;
|
|
627
|
+
|
|
628
|
+
return (_config$props = config.props) === null || _config$props === void 0 ? void 0 : _config$props.panelState;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
return null;
|
|
584
632
|
}
|
|
585
633
|
|
|
586
634
|
static makeDefaultLayout() {
|
|
@@ -599,7 +647,7 @@ class LayoutUtils {
|
|
|
599
647
|
}
|
|
600
648
|
/**
|
|
601
649
|
* Gets a containers root node
|
|
602
|
-
* @param
|
|
650
|
+
* @param container The Golden Layout container to get the root for
|
|
603
651
|
*/
|
|
604
652
|
|
|
605
653
|
|
|
@@ -608,7 +656,7 @@ class LayoutUtils {
|
|
|
608
656
|
}
|
|
609
657
|
/**
|
|
610
658
|
* Gets the config for the panel component given a glContainer
|
|
611
|
-
* @param
|
|
659
|
+
* @param container The Golden Layout container to get the config for
|
|
612
660
|
*/
|
|
613
661
|
|
|
614
662
|
|
|
@@ -617,6 +665,8 @@ class LayoutUtils {
|
|
|
617
665
|
if (container.tab && container.tab.contentItem) {
|
|
618
666
|
return container.tab.contentItem.config;
|
|
619
667
|
} // If the container hasn't populated the tab yet, just get the config directly from the container
|
|
668
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
669
|
+
// @ts-ignore private api usage
|
|
620
670
|
// eslint-disable-next-line no-underscore-dangle
|
|
621
671
|
|
|
622
672
|
|
|
@@ -643,8 +693,8 @@ class LayoutUtils {
|
|
|
643
693
|
}
|
|
644
694
|
/**
|
|
645
695
|
* Retrieve the panel ID for the provided golden layout container
|
|
646
|
-
* @param
|
|
647
|
-
* @returns
|
|
696
|
+
* @param glContainer The container to get the panel ID for
|
|
697
|
+
* @returns Panel ID
|
|
648
698
|
*/
|
|
649
699
|
|
|
650
700
|
|
|
@@ -659,8 +709,8 @@ class LayoutUtils {
|
|
|
659
709
|
}
|
|
660
710
|
/**
|
|
661
711
|
* Retrieve the ID of the panel provided
|
|
662
|
-
* @param
|
|
663
|
-
* @returns
|
|
712
|
+
* @param panel The panel to get the ID for
|
|
713
|
+
* @returns Panel ID
|
|
664
714
|
*/
|
|
665
715
|
|
|
666
716
|
|
|
@@ -672,24 +722,28 @@ class LayoutUtils {
|
|
|
672
722
|
}
|
|
673
723
|
/**
|
|
674
724
|
* Get component name from the panel instance
|
|
675
|
-
* @param
|
|
676
|
-
* @returns
|
|
725
|
+
* @param panel Panel to get component name for
|
|
726
|
+
* @returns Component name or null if unable to retrieve name
|
|
677
727
|
*/
|
|
678
728
|
|
|
679
729
|
|
|
680
730
|
static getComponentNameFromPanel(panel) {
|
|
681
|
-
var _config$component;
|
|
682
|
-
|
|
683
731
|
var {
|
|
684
732
|
glContainer
|
|
685
733
|
} = panel.props;
|
|
686
734
|
var config = LayoutUtils.getComponentConfigFromContainer(glContainer);
|
|
687
|
-
|
|
735
|
+
|
|
736
|
+
if (config) {
|
|
737
|
+
assertReactComponentConfig(config);
|
|
738
|
+
return config.component;
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
return null;
|
|
688
742
|
}
|
|
689
743
|
/**
|
|
690
744
|
* Get component name for wrapped and un-wrapped components
|
|
691
|
-
* @param
|
|
692
|
-
* @returns
|
|
745
|
+
* @param component Component to get name for
|
|
746
|
+
* @returns Component name
|
|
693
747
|
* @throws If displayName for the component is not defined
|
|
694
748
|
*/
|
|
695
749
|
|
|
@@ -700,7 +754,7 @@ class LayoutUtils {
|
|
|
700
754
|
var name = (_component$WrappedCom = (_component$WrappedCom2 = component.WrappedComponent) === null || _component$WrappedCom2 === void 0 ? void 0 : _component$WrappedCom2.displayName) !== null && _component$WrappedCom !== void 0 ? _component$WrappedCom : component.displayName;
|
|
701
755
|
|
|
702
756
|
if (name == null) {
|
|
703
|
-
throw new Error(
|
|
757
|
+
throw new Error("Component displayName not defined ".concat(component));
|
|
704
758
|
}
|
|
705
759
|
|
|
706
760
|
return name;
|
|
@@ -708,9 +762,9 @@ class LayoutUtils {
|
|
|
708
762
|
/**
|
|
709
763
|
* Put focus on the first "input" element (input, button, select, textarea) within an element
|
|
710
764
|
* If element is null or input element not found, does nothing
|
|
711
|
-
* @param
|
|
712
|
-
* @param
|
|
713
|
-
* @returns
|
|
765
|
+
* @param element The element to put focus in.
|
|
766
|
+
* @param selector The first element matching this selector will be focused.
|
|
767
|
+
* @returns The element that was focused, null if not focused
|
|
714
768
|
*/
|
|
715
769
|
|
|
716
770
|
|
|
@@ -727,12 +781,15 @@ class LayoutUtils {
|
|
|
727
781
|
return null;
|
|
728
782
|
}
|
|
729
783
|
|
|
730
|
-
focusElement
|
|
784
|
+
if (isHTMLElement(focusElement)) {
|
|
785
|
+
focusElement.focus();
|
|
786
|
+
}
|
|
787
|
+
|
|
731
788
|
return focusElement;
|
|
732
789
|
}
|
|
733
790
|
/**
|
|
734
791
|
* Get a promise that initializes when layout is initialized
|
|
735
|
-
* @param
|
|
792
|
+
* @param layout The layout to await initialization on
|
|
736
793
|
* @returns Promise that resolves when layout is initialized
|
|
737
794
|
*/
|
|
738
795
|
|