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