@itwin/appui-react 3.4.0-dev.9 → 3.5.0-dev.5
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/CHANGELOG.md +43 -1
- package/lib/cjs/appui-react/childwindow/ChildWindowManager.d.ts.map +1 -1
- package/lib/cjs/appui-react/childwindow/ChildWindowManager.js +4 -5
- package/lib/cjs/appui-react/childwindow/ChildWindowManager.js.map +1 -1
- package/lib/cjs/appui-react/dialog/DialogManagerBase.d.ts +7 -0
- package/lib/cjs/appui-react/dialog/DialogManagerBase.d.ts.map +1 -1
- package/lib/cjs/appui-react/dialog/DialogManagerBase.js +23 -0
- package/lib/cjs/appui-react/dialog/DialogManagerBase.js.map +1 -1
- package/lib/cjs/appui-react/dialog/ModelessDialogManager.d.ts +0 -2
- package/lib/cjs/appui-react/dialog/ModelessDialogManager.d.ts.map +1 -1
- package/lib/cjs/appui-react/dialog/ModelessDialogManager.js +6 -18
- package/lib/cjs/appui-react/dialog/ModelessDialogManager.js.map +1 -1
- package/lib/cjs/appui-react/dialog/StandardMessageBox.d.ts.map +1 -1
- package/lib/cjs/appui-react/dialog/StandardMessageBox.js +2 -1
- package/lib/cjs/appui-react/dialog/StandardMessageBox.js.map +1 -1
- package/lib/cjs/appui-react/frontstage/FrontstageDef.d.ts +13 -1
- package/lib/cjs/appui-react/frontstage/FrontstageDef.d.ts.map +1 -1
- package/lib/cjs/appui-react/frontstage/FrontstageDef.js +140 -96
- package/lib/cjs/appui-react/frontstage/FrontstageDef.js.map +1 -1
- package/lib/cjs/appui-react/imodel-components/category-tree/Categories.json +2 -2
- package/lib/cjs/appui-react/imodel-components/models-tree/Hierarchy.GroupedByClass.json +1 -0
- package/lib/cjs/appui-react/imodel-components/models-tree/Hierarchy.json +1 -0
- package/lib/cjs/appui-react/imodel-components/models-tree/ModelsTree.d.ts +1 -1
- package/lib/cjs/appui-react/imodel-components/models-tree/ModelsTree.d.ts.map +1 -1
- package/lib/cjs/appui-react/imodel-components/models-tree/ModelsTree.js +11 -8
- package/lib/cjs/appui-react/imodel-components/models-tree/ModelsTree.js.map +1 -1
- package/lib/cjs/appui-react/imodel-components/models-tree/ModelsVisibilityHandler.d.ts +15 -1
- package/lib/cjs/appui-react/imodel-components/models-tree/ModelsVisibilityHandler.d.ts.map +1 -1
- package/lib/cjs/appui-react/imodel-components/models-tree/ModelsVisibilityHandler.js +5 -2
- package/lib/cjs/appui-react/imodel-components/models-tree/ModelsVisibilityHandler.js.map +1 -1
- package/lib/cjs/appui-react/stagepanels/StagePanelDef.d.ts +0 -6
- package/lib/cjs/appui-react/stagepanels/StagePanelDef.d.ts.map +1 -1
- package/lib/cjs/appui-react/tools/CoreToolDefinitions.d.ts +1 -0
- package/lib/cjs/appui-react/tools/CoreToolDefinitions.d.ts.map +1 -1
- package/lib/cjs/appui-react/tools/CoreToolDefinitions.js +23 -4
- package/lib/cjs/appui-react/tools/CoreToolDefinitions.js.map +1 -1
- package/lib/cjs/appui-react/ui-items-provider/StandardNavigationToolsProvider.d.ts.map +1 -1
- package/lib/cjs/appui-react/ui-items-provider/StandardNavigationToolsProvider.js +2 -0
- package/lib/cjs/appui-react/ui-items-provider/StandardNavigationToolsProvider.js.map +1 -1
- package/lib/cjs/appui-react/ui-items-provider/StandardNavigationToolsUiItemsProvider.d.ts +1 -0
- package/lib/cjs/appui-react/ui-items-provider/StandardNavigationToolsUiItemsProvider.d.ts.map +1 -1
- package/lib/cjs/appui-react/ui-items-provider/StandardNavigationToolsUiItemsProvider.js +2 -0
- package/lib/cjs/appui-react/ui-items-provider/StandardNavigationToolsUiItemsProvider.js.map +1 -1
- package/lib/cjs/appui-react/widget-panels/Frontstage.d.ts +20 -697
- package/lib/cjs/appui-react/widget-panels/Frontstage.d.ts.map +1 -1
- package/lib/cjs/appui-react/widget-panels/Frontstage.js +294 -270
- package/lib/cjs/appui-react/widget-panels/Frontstage.js.map +1 -1
- package/lib/cjs/appui-react/widget-panels/useWidgetDirection.js +1 -1
- package/lib/cjs/appui-react/widget-panels/useWidgetDirection.js.map +1 -1
- package/lib/cjs/appui-react/widgets/WidgetDef.d.ts +13 -6
- package/lib/cjs/appui-react/widgets/WidgetDef.d.ts.map +1 -1
- package/lib/cjs/appui-react/widgets/WidgetDef.js +6 -1
- package/lib/cjs/appui-react/widgets/WidgetDef.js.map +1 -1
- package/lib/esm/appui-react/childwindow/ChildWindowManager.d.ts.map +1 -1
- package/lib/esm/appui-react/childwindow/ChildWindowManager.js +4 -5
- package/lib/esm/appui-react/childwindow/ChildWindowManager.js.map +1 -1
- package/lib/esm/appui-react/dialog/DialogManagerBase.d.ts +7 -0
- package/lib/esm/appui-react/dialog/DialogManagerBase.d.ts.map +1 -1
- package/lib/esm/appui-react/dialog/DialogManagerBase.js +23 -0
- package/lib/esm/appui-react/dialog/DialogManagerBase.js.map +1 -1
- package/lib/esm/appui-react/dialog/ModelessDialogManager.d.ts +0 -2
- package/lib/esm/appui-react/dialog/ModelessDialogManager.d.ts.map +1 -1
- package/lib/esm/appui-react/dialog/ModelessDialogManager.js +6 -18
- package/lib/esm/appui-react/dialog/ModelessDialogManager.js.map +1 -1
- package/lib/esm/appui-react/dialog/StandardMessageBox.d.ts.map +1 -1
- package/lib/esm/appui-react/dialog/StandardMessageBox.js +2 -1
- package/lib/esm/appui-react/dialog/StandardMessageBox.js.map +1 -1
- package/lib/esm/appui-react/frontstage/FrontstageDef.d.ts +13 -1
- package/lib/esm/appui-react/frontstage/FrontstageDef.d.ts.map +1 -1
- package/lib/esm/appui-react/frontstage/FrontstageDef.js +142 -98
- package/lib/esm/appui-react/frontstage/FrontstageDef.js.map +1 -1
- package/lib/esm/appui-react/imodel-components/category-tree/Categories.json +2 -2
- package/lib/esm/appui-react/imodel-components/models-tree/Hierarchy.GroupedByClass.json +1 -0
- package/lib/esm/appui-react/imodel-components/models-tree/Hierarchy.json +1 -0
- package/lib/esm/appui-react/imodel-components/models-tree/ModelsTree.d.ts +1 -1
- package/lib/esm/appui-react/imodel-components/models-tree/ModelsTree.d.ts.map +1 -1
- package/lib/esm/appui-react/imodel-components/models-tree/ModelsTree.js +12 -9
- package/lib/esm/appui-react/imodel-components/models-tree/ModelsTree.js.map +1 -1
- package/lib/esm/appui-react/imodel-components/models-tree/ModelsVisibilityHandler.d.ts +15 -1
- package/lib/esm/appui-react/imodel-components/models-tree/ModelsVisibilityHandler.d.ts.map +1 -1
- package/lib/esm/appui-react/imodel-components/models-tree/ModelsVisibilityHandler.js +4 -2
- package/lib/esm/appui-react/imodel-components/models-tree/ModelsVisibilityHandler.js.map +1 -1
- package/lib/esm/appui-react/stagepanels/StagePanelDef.d.ts +0 -6
- package/lib/esm/appui-react/stagepanels/StagePanelDef.d.ts.map +1 -1
- package/lib/esm/appui-react/tools/CoreToolDefinitions.d.ts +1 -0
- package/lib/esm/appui-react/tools/CoreToolDefinitions.d.ts.map +1 -1
- package/lib/esm/appui-react/tools/CoreToolDefinitions.js +25 -6
- package/lib/esm/appui-react/tools/CoreToolDefinitions.js.map +1 -1
- package/lib/esm/appui-react/ui-items-provider/StandardNavigationToolsProvider.d.ts.map +1 -1
- package/lib/esm/appui-react/ui-items-provider/StandardNavigationToolsProvider.js +2 -0
- package/lib/esm/appui-react/ui-items-provider/StandardNavigationToolsProvider.js.map +1 -1
- package/lib/esm/appui-react/ui-items-provider/StandardNavigationToolsUiItemsProvider.d.ts +1 -0
- package/lib/esm/appui-react/ui-items-provider/StandardNavigationToolsUiItemsProvider.d.ts.map +1 -1
- package/lib/esm/appui-react/ui-items-provider/StandardNavigationToolsUiItemsProvider.js +2 -0
- package/lib/esm/appui-react/ui-items-provider/StandardNavigationToolsUiItemsProvider.js.map +1 -1
- package/lib/esm/appui-react/widget-panels/Frontstage.d.ts +20 -697
- package/lib/esm/appui-react/widget-panels/Frontstage.d.ts.map +1 -1
- package/lib/esm/appui-react/widget-panels/Frontstage.js +285 -264
- package/lib/esm/appui-react/widget-panels/Frontstage.js.map +1 -1
- package/lib/esm/appui-react/widget-panels/useWidgetDirection.js +2 -2
- package/lib/esm/appui-react/widget-panels/useWidgetDirection.js.map +1 -1
- package/lib/esm/appui-react/widgets/WidgetDef.d.ts +13 -6
- package/lib/esm/appui-react/widgets/WidgetDef.d.ts.map +1 -1
- package/lib/esm/appui-react/widgets/WidgetDef.js +6 -1
- package/lib/esm/appui-react/widgets/WidgetDef.js.map +1 -1
- package/lib/public/locales/en/UiFramework.json +3 -1
- package/package.json +36 -34
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
*/
|
|
9
9
|
// cSpell:ignore popout
|
|
10
10
|
import "./Frontstage.scss";
|
|
11
|
-
import produce
|
|
11
|
+
import produce from "immer";
|
|
12
12
|
import * as React from "react";
|
|
13
13
|
import { assert, Logger, ProcessDetector } from "@itwin/core-bentley";
|
|
14
14
|
import { StagePanelLocation, UiItemsManager, WidgetState } from "@itwin/appui-abstract";
|
|
15
|
-
import { Size, UiStateStorageStatus } from "@itwin/core-react";
|
|
15
|
+
import { Rectangle, Size, UiStateStorageStatus } from "@itwin/core-react";
|
|
16
16
|
import { ToolbarPopupAutoHideContext } from "@itwin/components-react";
|
|
17
|
-
import { addPanelWidget, addTab,
|
|
17
|
+
import { addFloatingWidget, addPanelWidget, addTab, addTabToWidget, convertAllPopupWidgetContainersToFloating, createNineZoneState, floatingWidgetBringToFront, FloatingWidgets, getTabLocation, getUniqueId, getWidgetPanelSectionId, insertPanelWidget, insertTabToWidget, isFloatingTabLocation, isHorizontalPanelSide, isPanelTabLocation, isPopoutTabLocation, NineZone, NineZoneStateReducer, panelSides, removeTab, removeTabFromWidget, toolSettingsTabId, WidgetPanels, } from "@itwin/appui-layout-react";
|
|
18
18
|
import { useActiveFrontstageDef } from "../frontstage/Frontstage";
|
|
19
19
|
import { FrontstageManager } from "../frontstage/FrontstageManager";
|
|
20
20
|
import { StagePanelState } from "../stagepanels/StagePanelDef";
|
|
@@ -259,7 +259,6 @@ export function appendWidgets(state, widgetDefs, side, preferredWidgetIndex) {
|
|
|
259
259
|
const saveTab = state.tabs[widgetDef.id];
|
|
260
260
|
const preferredPanelWidgetSize = saveTab ? saveTab.preferredPanelWidgetSize : widgetDef.preferredPanelSize;
|
|
261
261
|
const preferredFloatingWidgetSize = saveTab ? saveTab.preferredFloatingWidgetSize : widgetDef.defaultFloatingSize;
|
|
262
|
-
const preferredPopoutWidgetSize = saveTab ? saveTab.preferredPopoutWidgetSize : undefined;
|
|
263
262
|
// if a defaultFloatingSize is specified then this mean the widget can't determine its intrinsic size and must be explicitly sized
|
|
264
263
|
const userSized = saveTab ? (saveTab.userSized || !!widgetDef.defaultFloatingSize && !!saveTab.preferredFloatingWidgetSize)
|
|
265
264
|
: !!widgetDef.defaultFloatingSize;
|
|
@@ -269,7 +268,6 @@ export function appendWidgets(state, widgetDefs, side, preferredWidgetIndex) {
|
|
|
269
268
|
canPopout: widgetDef.canPopout,
|
|
270
269
|
preferredPanelWidgetSize,
|
|
271
270
|
preferredFloatingWidgetSize,
|
|
272
|
-
preferredPopoutWidgetSize,
|
|
273
271
|
userSized,
|
|
274
272
|
isFloatingStateWindowResizable: widgetDef.isFloatingStateWindowResizable,
|
|
275
273
|
hideWithUiWhenFloating: !!widgetDef.hideWithUiWhenFloating,
|
|
@@ -277,13 +275,43 @@ export function appendWidgets(state, widgetDefs, side, preferredWidgetIndex) {
|
|
|
277
275
|
if (widgetDef.isFloatingStateSupported && widgetDef.defaultState === WidgetState.Floating) {
|
|
278
276
|
const floatingContainerId = (_a = widgetDef.floatingContainerId) !== null && _a !== void 0 ? _a : getUniqueId();
|
|
279
277
|
const widgetContainerId = getWidgetId(side, panelZoneKeys[preferredWidgetIndex]);
|
|
280
|
-
const
|
|
278
|
+
const home = { side, widgetId: widgetContainerId, widgetIndex: 0 };
|
|
281
279
|
const preferredPosition = widgetDef.defaultFloatingPosition;
|
|
282
|
-
|
|
280
|
+
if (floatingContainerId in state.widgets) {
|
|
281
|
+
state = addTabToWidget(state, widgetDef.id, floatingContainerId);
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
const tab = state.tabs[widgetDef.id];
|
|
285
|
+
const size = { height: 200, width: 300, ...tab.preferredFloatingWidgetSize };
|
|
286
|
+
const preferredPoint = preferredPosition !== null && preferredPosition !== void 0 ? preferredPosition : { x: (state.size.width - size.width) / 2, y: (state.size.height - size.height) / 2 };
|
|
287
|
+
const nzBounds = Rectangle.createFromSize(state.size);
|
|
288
|
+
const bounds = Rectangle.createFromSize(size).offset(preferredPoint);
|
|
289
|
+
const containedBounds = bounds.containIn(nzBounds);
|
|
290
|
+
state = addFloatingWidget(state, floatingContainerId, [widgetDef.id], {
|
|
291
|
+
bounds: containedBounds.toProps(),
|
|
292
|
+
home,
|
|
293
|
+
userSized,
|
|
294
|
+
}, {
|
|
295
|
+
isFloatingStateWindowResizable: widgetDef.isFloatingStateWindowResizable,
|
|
296
|
+
});
|
|
297
|
+
}
|
|
283
298
|
}
|
|
284
299
|
else {
|
|
285
300
|
const widgetPanelSectionId = getWidgetPanelSectionId(side, preferredWidgetIndex);
|
|
286
|
-
|
|
301
|
+
if (widgetPanelSectionId in state.widgets) {
|
|
302
|
+
state = addTabToWidget(state, widgetDef.id, widgetPanelSectionId);
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
const panel = state.panels[side];
|
|
306
|
+
if (panel.widgets.length < panel.maxWidgetCount) {
|
|
307
|
+
state = addPanelWidget(state, side, widgetPanelSectionId, [widgetDef.id]);
|
|
308
|
+
}
|
|
309
|
+
else {
|
|
310
|
+
const widgetIndex = Math.min(preferredWidgetIndex, panel.widgets.length - 1);
|
|
311
|
+
const widgetId = panel.widgets[widgetIndex];
|
|
312
|
+
state = addTabToWidget(state, widgetDef.id, widgetId);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
287
315
|
}
|
|
288
316
|
}
|
|
289
317
|
return state;
|
|
@@ -329,17 +357,15 @@ export function addMissingWidgets(frontstageDef, initialState) {
|
|
|
329
357
|
state = appendWidgets(state, determineNewWidgets((_t = frontstageDef.bottomPanel) === null || _t === void 0 ? void 0 : _t.panelZones.end.widgetDefs, state), "bottom", 1);
|
|
330
358
|
return state;
|
|
331
359
|
}
|
|
332
|
-
/**
|
|
333
|
-
function
|
|
360
|
+
/** Hide widgets with Hidden defaultState. */
|
|
361
|
+
function hideWidgets(state, frontstageDef) {
|
|
334
362
|
const tabs = Object.values(state.tabs);
|
|
335
363
|
for (const tab of tabs) {
|
|
336
364
|
const widgetDef = frontstageDef.findWidgetDef(tab.id);
|
|
337
365
|
if (!widgetDef)
|
|
338
366
|
continue;
|
|
339
367
|
if (widgetDef.defaultState === WidgetState.Hidden) {
|
|
340
|
-
state =
|
|
341
|
-
hideWidget(draft, widgetDef);
|
|
342
|
-
});
|
|
368
|
+
state = hideWidget(state, widgetDef);
|
|
343
369
|
}
|
|
344
370
|
}
|
|
345
371
|
return state;
|
|
@@ -348,16 +374,15 @@ function removeHiddenWidgets(state, frontstageDef) {
|
|
|
348
374
|
* @internal
|
|
349
375
|
*/
|
|
350
376
|
export function removeMissingWidgets(frontstageDef, initialState) {
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
});
|
|
377
|
+
let state = initialState;
|
|
378
|
+
for (const [, tab] of Object.entries(state.tabs)) {
|
|
379
|
+
if (tab.id === toolSettingsTabId)
|
|
380
|
+
continue;
|
|
381
|
+
const widgetDef = frontstageDef.findWidgetDef(tab.id);
|
|
382
|
+
if (widgetDef)
|
|
383
|
+
continue;
|
|
384
|
+
state = removeTab(state, tab.id);
|
|
385
|
+
}
|
|
361
386
|
return state;
|
|
362
387
|
}
|
|
363
388
|
function getWidgetLabel(label) {
|
|
@@ -508,23 +533,23 @@ export function isFrontstageStateSettingResult(settingsResult) {
|
|
|
508
533
|
return false;
|
|
509
534
|
}
|
|
510
535
|
/** @internal */
|
|
511
|
-
export function initializePanel(
|
|
512
|
-
|
|
536
|
+
export function initializePanel(state, frontstageDef, panelSide) {
|
|
537
|
+
state = addPanelWidgets(state, frontstageDef, panelSide);
|
|
513
538
|
const location = toStagePanelLocation(panelSide);
|
|
514
539
|
const panelDef = frontstageDef.getStagePanelDef(location);
|
|
515
|
-
|
|
540
|
+
state = produce(state, (draft) => {
|
|
516
541
|
var _a, _b, _c;
|
|
517
542
|
const panel = draft.panels[panelSide];
|
|
518
543
|
panel.minSize = (_a = panelDef === null || panelDef === void 0 ? void 0 : panelDef.minSize) !== null && _a !== void 0 ? _a : panel.minSize;
|
|
519
544
|
panel.pinned = (_b = panelDef === null || panelDef === void 0 ? void 0 : panelDef.pinned) !== null && _b !== void 0 ? _b : panel.pinned;
|
|
520
545
|
panel.resizable = (_c = panelDef === null || panelDef === void 0 ? void 0 : panelDef.resizable) !== null && _c !== void 0 ? _c : panel.resizable;
|
|
521
546
|
if (panelDef === null || panelDef === void 0 ? void 0 : panelDef.maxSizeSpec) {
|
|
522
|
-
panel.maxSize = getPanelMaxSize(panelDef.maxSizeSpec, panelSide,
|
|
547
|
+
panel.maxSize = getPanelMaxSize(panelDef.maxSizeSpec, panelSide, state.size);
|
|
523
548
|
}
|
|
524
549
|
const size = panelDef === null || panelDef === void 0 ? void 0 : panelDef.size;
|
|
525
550
|
panel.size = size === undefined ? size : Math.min(Math.max(size, panel.minSize), panel.maxSize);
|
|
526
551
|
});
|
|
527
|
-
return
|
|
552
|
+
return state;
|
|
528
553
|
}
|
|
529
554
|
function getPanelMaxSize(maxSizeSpec, panel, nineZoneSize) {
|
|
530
555
|
if (typeof maxSizeSpec === "number") {
|
|
@@ -533,7 +558,7 @@ function getPanelMaxSize(maxSizeSpec, panel, nineZoneSize) {
|
|
|
533
558
|
const size = isHorizontalPanelSide(panel) ? nineZoneSize.height : nineZoneSize.width;
|
|
534
559
|
return maxSizeSpec.percentage / 100 * size;
|
|
535
560
|
}
|
|
536
|
-
const stateVersion =
|
|
561
|
+
const stateVersion = 13; // this needs to be bumped when NineZoneState is changed (to recreate the layout).
|
|
537
562
|
/** @internal */
|
|
538
563
|
export function initializeNineZoneState(frontstageDef) {
|
|
539
564
|
let nineZone = defaultNineZone;
|
|
@@ -555,6 +580,7 @@ export function initializeNineZoneState(frontstageDef) {
|
|
|
555
580
|
for (const [, panel] of Object.entries(stateDraft.panels)) {
|
|
556
581
|
const expanded = panel.widgets.find((widgetId) => stateDraft.widgets[widgetId].minimized === false);
|
|
557
582
|
const firstWidget = panel.widgets.length > 0 ? stateDraft.widgets[panel.widgets[0]] : undefined;
|
|
583
|
+
// istanbul ignore next
|
|
558
584
|
if (!expanded && firstWidget) {
|
|
559
585
|
firstWidget.minimized = false;
|
|
560
586
|
}
|
|
@@ -583,7 +609,7 @@ export function initializeNineZoneState(frontstageDef) {
|
|
|
583
609
|
}
|
|
584
610
|
});
|
|
585
611
|
nineZone = addMissingWidgets(frontstageDef, nineZone);
|
|
586
|
-
nineZone =
|
|
612
|
+
nineZone = hideWidgets(nineZone, frontstageDef);
|
|
587
613
|
nineZone = processPopoutWidgets(nineZone, frontstageDef);
|
|
588
614
|
return nineZone;
|
|
589
615
|
}
|
|
@@ -595,29 +621,32 @@ export function initializeNineZoneState(frontstageDef) {
|
|
|
595
621
|
export function restoreNineZoneState(frontstageDef, saved) {
|
|
596
622
|
let restored = {
|
|
597
623
|
...saved,
|
|
598
|
-
tabs:
|
|
624
|
+
tabs: defaultNineZone.tabs,
|
|
599
625
|
};
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
626
|
+
for (const [, tab] of Object.entries(saved.tabs)) {
|
|
627
|
+
// Re-add the placeholder tab in order to correctly remove it from the state if WidgetDef is not found.
|
|
628
|
+
restored = addTab(restored, tab.id);
|
|
629
|
+
const widgetDef = frontstageDef.findWidgetDef(tab.id);
|
|
630
|
+
if (!widgetDef) {
|
|
631
|
+
Logger.logInfo(UiFramework.loggerCategory(restoreNineZoneState), "WidgetDef is not found for saved tab.", () => ({
|
|
632
|
+
frontstageId: frontstageDef.id,
|
|
633
|
+
tabId: tab.id,
|
|
634
|
+
}));
|
|
635
|
+
restored = removeTab(restored, tab.id);
|
|
636
|
+
continue;
|
|
637
|
+
}
|
|
638
|
+
restored = produce(restored, (draft) => {
|
|
612
639
|
draft.tabs[tab.id] = {
|
|
613
640
|
...tab,
|
|
614
|
-
label: getWidgetLabel(
|
|
615
|
-
hideWithUiWhenFloating: widgetDef
|
|
616
|
-
iconSpec: widgetDef
|
|
617
|
-
canPopout: widgetDef
|
|
618
|
-
isFloatingStateWindowResizable: widgetDef
|
|
641
|
+
label: getWidgetLabel(widgetDef.label),
|
|
642
|
+
hideWithUiWhenFloating: widgetDef.hideWithUiWhenFloating,
|
|
643
|
+
iconSpec: widgetDef.iconSpec,
|
|
644
|
+
canPopout: widgetDef.canPopout,
|
|
645
|
+
isFloatingStateWindowResizable: widgetDef.isFloatingStateWindowResizable,
|
|
619
646
|
};
|
|
620
|
-
}
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
restored = produce(restored, (draft) => {
|
|
621
650
|
// remove center panel section if one is found in left or right panels
|
|
622
651
|
const oldLeftMiddleIndex = saved.panels.left.widgets.findIndex((value) => value === "leftMiddle");
|
|
623
652
|
// istanbul ignore next
|
|
@@ -656,20 +685,6 @@ export function restoreNineZoneState(frontstageDef, saved) {
|
|
|
656
685
|
}
|
|
657
686
|
return restored;
|
|
658
687
|
}
|
|
659
|
-
/**
|
|
660
|
-
* Checks to see whether a widget id is one of our generated uuids
|
|
661
|
-
* @param uuid the string value to test
|
|
662
|
-
* @returns boolean
|
|
663
|
-
*/
|
|
664
|
-
function isUUID(uuid) {
|
|
665
|
-
const s = `${uuid}`;
|
|
666
|
-
const result = s.match("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$");
|
|
667
|
-
// istanbul ignore else
|
|
668
|
-
if (result === null) {
|
|
669
|
-
return false;
|
|
670
|
-
}
|
|
671
|
-
return true;
|
|
672
|
-
}
|
|
673
688
|
/** Prepares NineZoneState to be saved.
|
|
674
689
|
* @note Removes toolSettings tab.
|
|
675
690
|
* @note Removes tab labels and iconSpec.
|
|
@@ -684,31 +699,60 @@ export function packNineZoneState(state) {
|
|
|
684
699
|
for (const [, tab] of Object.entries(state.tabs)) {
|
|
685
700
|
if (tab.id === toolSettingsTabId)
|
|
686
701
|
continue;
|
|
687
|
-
// istanbul ignore else
|
|
688
|
-
if (isUUID(tab.id))
|
|
689
|
-
continue;
|
|
690
702
|
draft.tabs[tab.id] = {
|
|
691
703
|
id: tab.id,
|
|
692
704
|
preferredFloatingWidgetSize: tab.preferredFloatingWidgetSize,
|
|
693
|
-
preferredPopoutWidgetSize: tab.preferredPopoutWidgetSize,
|
|
694
705
|
allowedPanelTargets: tab.allowedPanelTargets,
|
|
695
706
|
userSized: tab.userSized,
|
|
696
707
|
};
|
|
697
708
|
}
|
|
698
709
|
});
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
710
|
+
return packed;
|
|
711
|
+
}
|
|
712
|
+
// TODO: clean-up of saved widgets.
|
|
713
|
+
// istanbul ignore next
|
|
714
|
+
function packSavedWidgets(savedWidgets, frontstageDef) {
|
|
715
|
+
for (const widgetDef of frontstageDef.widgetDefs) {
|
|
716
|
+
const id = widgetDef.id;
|
|
717
|
+
const initialWidget = {
|
|
718
|
+
id,
|
|
719
|
+
};
|
|
720
|
+
const widget = produce(initialWidget, (draft) => {
|
|
721
|
+
if (widgetDef.tabLocation) {
|
|
722
|
+
draft.tabLocation = { ...widgetDef.tabLocation };
|
|
723
|
+
}
|
|
724
|
+
if (widgetDef.popoutBounds) {
|
|
725
|
+
draft.popoutBounds = widgetDef.popoutBounds.toProps();
|
|
708
726
|
}
|
|
727
|
+
});
|
|
728
|
+
if (widget === initialWidget)
|
|
729
|
+
continue;
|
|
730
|
+
savedWidgets = produce(savedWidgets, (draft) => {
|
|
731
|
+
draft.push(widget);
|
|
732
|
+
});
|
|
733
|
+
}
|
|
734
|
+
return savedWidgets;
|
|
735
|
+
}
|
|
736
|
+
// istanbul ignore next
|
|
737
|
+
function restoreSavedWidgets(savedWidgets, frontstage) {
|
|
738
|
+
let i = savedWidgets.length;
|
|
739
|
+
while (i--) {
|
|
740
|
+
const savedWidget = savedWidgets[i];
|
|
741
|
+
const widgetId = savedWidget.id;
|
|
742
|
+
const widgetDef = frontstage.findWidgetDef(widgetId);
|
|
743
|
+
if (!widgetDef)
|
|
744
|
+
continue;
|
|
745
|
+
if (savedWidget.tabLocation) {
|
|
746
|
+
widgetDef.tabLocation = { ...savedWidget.tabLocation };
|
|
709
747
|
}
|
|
710
|
-
|
|
711
|
-
|
|
748
|
+
if (savedWidget.popoutBounds) {
|
|
749
|
+
widgetDef.popoutBounds = Rectangle.create(savedWidget.popoutBounds);
|
|
750
|
+
}
|
|
751
|
+
savedWidgets = produce(savedWidgets, (draft) => {
|
|
752
|
+
draft.splice(i, 1);
|
|
753
|
+
});
|
|
754
|
+
}
|
|
755
|
+
return savedWidgets;
|
|
712
756
|
}
|
|
713
757
|
/** @internal */
|
|
714
758
|
export function isPanelCollapsed(zoneStates, panelStates) {
|
|
@@ -716,121 +760,127 @@ export function isPanelCollapsed(zoneStates, panelStates) {
|
|
|
716
760
|
const openPanel = panelStates.find((panelState) => panelState === StagePanelState.Open);
|
|
717
761
|
return !openZone && !openPanel;
|
|
718
762
|
}
|
|
719
|
-
function
|
|
720
|
-
|
|
721
|
-
const
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
isFloatingStateWindowResizable: widgetDef.isFloatingStateWindowResizable,
|
|
727
|
-
hideWithUiWhenFloating: !!widgetDef.hideWithUiWhenFloating,
|
|
728
|
-
});
|
|
729
|
-
nineZone.tabs[newTab.id] = newTab;
|
|
730
|
-
if (widgetDef.tabLocation.widgetId in nineZone.widgets) {
|
|
731
|
-
// Add to existing widget (by widget id).
|
|
732
|
-
const widgetId = widgetDef.tabLocation.widgetId;
|
|
733
|
-
const newTabWidget = nineZone.widgets[widgetId];
|
|
734
|
-
newTabWidget.tabs.splice(widgetDef.tabLocation.tabIndex, 0, newTab.id);
|
|
763
|
+
function addHiddenWidget(state, widgetDef) {
|
|
764
|
+
const tabLocation = widgetDef.tabLocation || widgetDef.defaultTabLocation;
|
|
765
|
+
const tabId = widgetDef.id;
|
|
766
|
+
const { widgetId, tabIndex } = tabLocation;
|
|
767
|
+
if (widgetId in state.widgets) {
|
|
768
|
+
// Add to an existing widget (by widget id).
|
|
769
|
+
return insertTabToWidget(state, tabId, widgetId, tabIndex);
|
|
735
770
|
}
|
|
736
|
-
else if (
|
|
737
|
-
const
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
}
|
|
771
|
+
else if (tabLocation.floatingWidget) {
|
|
772
|
+
const floatingWidget = tabLocation.floatingWidget;
|
|
773
|
+
assert(widgetId === floatingWidget.id);
|
|
774
|
+
// Add to a new floating widget.
|
|
775
|
+
const nzBounds = Rectangle.createFromSize(state.size);
|
|
776
|
+
const bounds = Rectangle.create(floatingWidget.bounds).containIn(nzBounds);
|
|
777
|
+
return addFloatingWidget(state, floatingWidget.id, [tabId], {
|
|
778
|
+
...floatingWidget,
|
|
779
|
+
bounds: bounds.toProps(),
|
|
780
|
+
});
|
|
747
781
|
}
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
newTabWidget.tabs.splice(widgetDef.tabLocation.tabIndex, 0, newTab.id);
|
|
756
|
-
}
|
|
757
|
-
else {
|
|
758
|
-
// Create a new panel widget.
|
|
759
|
-
const newWidget = createWidgetState(getUniqueId(), [newTab.id]);
|
|
760
|
-
nineZone.widgets[newWidget.id] = castDraft(newWidget);
|
|
761
|
-
newTabPanel.widgets.splice(widgetDef.tabLocation.widgetIndex, 0, newWidget.id);
|
|
762
|
-
}
|
|
782
|
+
// Add to a panel section.
|
|
783
|
+
const panel = state.panels[tabLocation.side];
|
|
784
|
+
// Add to existing panel section.
|
|
785
|
+
if (panel.widgets.length >= panel.maxWidgetCount) {
|
|
786
|
+
const sectionIndex = Math.min(panel.maxWidgetCount - 1, tabLocation.widgetIndex);
|
|
787
|
+
const sectionId = panel.widgets[sectionIndex];
|
|
788
|
+
return insertTabToWidget(state, tabId, sectionId, tabLocation.tabIndex);
|
|
763
789
|
}
|
|
790
|
+
// Create a new panel section.
|
|
791
|
+
const newSectionId = getUniqueId();
|
|
792
|
+
return insertPanelWidget(state, panel.side, newSectionId, [tabId], tabLocation.widgetIndex);
|
|
764
793
|
}
|
|
765
794
|
/** @internal */
|
|
766
|
-
export
|
|
795
|
+
export function setWidgetState(state, widgetDef, widgetState) {
|
|
767
796
|
var _a, _b;
|
|
768
|
-
if (
|
|
797
|
+
if (widgetState === WidgetState.Hidden) {
|
|
798
|
+
return hideWidget(state, widgetDef);
|
|
799
|
+
}
|
|
800
|
+
else if (widgetState === WidgetState.Open) {
|
|
769
801
|
const id = widgetDef.id;
|
|
770
|
-
let location =
|
|
802
|
+
let location = getTabLocation(state, id);
|
|
771
803
|
if (!location) {
|
|
772
|
-
|
|
773
|
-
location =
|
|
774
|
-
assert(!!location);
|
|
775
|
-
}
|
|
776
|
-
if (!!widgetDef.tabLocation.floating) {
|
|
777
|
-
nineZone.floatingWidgets.byId[(_a = widgetDef.floatingContainerId) !== null && _a !== void 0 ? _a : widgetDef.id].hidden = false;
|
|
804
|
+
state = addHiddenWidget(state, widgetDef);
|
|
805
|
+
location = getTabLocation(state, id);
|
|
778
806
|
}
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
panel.size = (_b = panel.minSize) !== null && _b !== void 0 ? _b : 200;
|
|
807
|
+
return produce(state, (draft) => {
|
|
808
|
+
var _a;
|
|
809
|
+
assert(!!location);
|
|
810
|
+
const widget = draft.widgets[location.widgetId];
|
|
811
|
+
widget.minimized = false;
|
|
812
|
+
widget.activeTabId = id;
|
|
813
|
+
if (isFloatingTabLocation(location)) {
|
|
814
|
+
const floatingWidget = draft.floatingWidgets.byId[location.floatingWidgetId];
|
|
815
|
+
floatingWidget.hidden = false;
|
|
816
|
+
// istanbul ignore else
|
|
790
817
|
}
|
|
791
|
-
|
|
818
|
+
else if (isPanelTabLocation(location)) {
|
|
819
|
+
const panel = draft.panels[location.side];
|
|
820
|
+
panel.collapsed = false;
|
|
821
|
+
if (undefined === panel.size || 0 === panel.size) {
|
|
822
|
+
// istanbul ignore next
|
|
823
|
+
panel.size = (_a = panel.minSize) !== null && _a !== void 0 ? _a : 200;
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
});
|
|
792
827
|
}
|
|
793
|
-
else if (
|
|
828
|
+
else if (widgetState === WidgetState.Closed) {
|
|
794
829
|
const id = widgetDef.id;
|
|
795
|
-
let location =
|
|
830
|
+
let location = getTabLocation(state, id);
|
|
796
831
|
if (!location) {
|
|
797
|
-
|
|
798
|
-
location =
|
|
799
|
-
assert(!!location);
|
|
800
|
-
}
|
|
801
|
-
if (isFloatingLocation(location)) {
|
|
802
|
-
const widget = nineZone.widgets[location.widgetId];
|
|
803
|
-
if (id !== widget.activeTabId)
|
|
804
|
-
return;
|
|
805
|
-
widget.minimized = true;
|
|
832
|
+
state = addHiddenWidget(state, widgetDef);
|
|
833
|
+
location = getTabLocation(state, id);
|
|
806
834
|
}
|
|
835
|
+
// TODO: should change activeTabId of a widget with multiple tabs.
|
|
836
|
+
return produce(state, (draft) => {
|
|
837
|
+
assert(!!location);
|
|
838
|
+
const widget = draft.widgets[location.widgetId];
|
|
839
|
+
if (isFloatingTabLocation(location)) {
|
|
840
|
+
if (id === widget.activeTabId) {
|
|
841
|
+
widget.minimized = true;
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
});
|
|
807
845
|
}
|
|
808
|
-
else if (
|
|
809
|
-
|
|
846
|
+
else if (widgetState === WidgetState.Floating) {
|
|
847
|
+
const id = widgetDef.id;
|
|
848
|
+
let location = getTabLocation(state, id);
|
|
849
|
+
if (!location) {
|
|
850
|
+
state = addHiddenWidget(state, widgetDef);
|
|
851
|
+
location = getTabLocation(state, id);
|
|
852
|
+
}
|
|
853
|
+
assert(!!location);
|
|
854
|
+
if (isFloatingTabLocation(location))
|
|
855
|
+
return state;
|
|
856
|
+
// Widget is not floating.
|
|
857
|
+
state = removeTabFromWidget(state, id);
|
|
858
|
+
const bounds = (_b = (_a = widgetDef.tabLocation) === null || _a === void 0 ? void 0 : _a.floatingWidget) === null || _b === void 0 ? void 0 : _b.bounds;
|
|
859
|
+
state = addFloatingWidget(state, getUniqueId(), [id], { bounds });
|
|
810
860
|
}
|
|
811
|
-
|
|
861
|
+
return state;
|
|
862
|
+
}
|
|
812
863
|
/** Stores widget location and hides it in the UI. */
|
|
813
864
|
function hideWidget(state, widgetDef) {
|
|
814
|
-
const location =
|
|
865
|
+
const location = getTabLocation(state, widgetDef.id);
|
|
815
866
|
if (!location)
|
|
816
|
-
return;
|
|
817
|
-
|
|
818
|
-
|
|
867
|
+
return state;
|
|
868
|
+
// istanbul ignore else
|
|
869
|
+
if (isFloatingTabLocation(location)) {
|
|
870
|
+
const floatingWidget = state.floatingWidgets.byId[location.widgetId];
|
|
819
871
|
widgetDef.setFloatingContainerId(location.floatingWidgetId);
|
|
820
872
|
widgetDef.tabLocation = {
|
|
821
|
-
side:
|
|
822
|
-
tabIndex:
|
|
823
|
-
widgetId:
|
|
824
|
-
widgetIndex:
|
|
825
|
-
|
|
873
|
+
side: floatingWidget.home.side,
|
|
874
|
+
tabIndex: floatingWidget.home.widgetIndex,
|
|
875
|
+
widgetId: floatingWidget.id,
|
|
876
|
+
widgetIndex: floatingWidget.home.widgetIndex,
|
|
877
|
+
floatingWidget,
|
|
826
878
|
};
|
|
827
879
|
}
|
|
828
|
-
else
|
|
829
|
-
// istanbul ignore else
|
|
830
|
-
if (!isPopoutLocation(location)) {
|
|
880
|
+
else if (!isPopoutTabLocation(location)) {
|
|
831
881
|
const widgetId = location.widgetId;
|
|
832
|
-
const side =
|
|
833
|
-
const widgetIndex =
|
|
882
|
+
const side = isPanelTabLocation(location) ? location.side : "left";
|
|
883
|
+
const widgetIndex = isPanelTabLocation(location) ? state.panels[side].widgets.indexOf(widgetId) : 0;
|
|
834
884
|
const tabIndex = state.widgets[location.widgetId].tabs.indexOf(widgetDef.id);
|
|
835
885
|
widgetDef.tabLocation = {
|
|
836
886
|
side,
|
|
@@ -839,50 +889,53 @@ function hideWidget(state, widgetDef) {
|
|
|
839
889
|
widgetIndex,
|
|
840
890
|
};
|
|
841
891
|
}
|
|
842
|
-
|
|
892
|
+
return removeTabFromWidget(state, widgetDef.id);
|
|
843
893
|
}
|
|
844
894
|
/** @internal */
|
|
845
|
-
export
|
|
846
|
-
const location =
|
|
895
|
+
export function showWidget(state, id) {
|
|
896
|
+
const location = getTabLocation(state, id);
|
|
847
897
|
if (!location)
|
|
848
|
-
return;
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
const panel = nineZone.panels[location.side];
|
|
852
|
-
panel.collapsed = false;
|
|
853
|
-
widget.minimized = false;
|
|
898
|
+
return state;
|
|
899
|
+
state = produce(state, (draft) => {
|
|
900
|
+
const widget = draft.widgets[location.widgetId];
|
|
854
901
|
widget.activeTabId = id;
|
|
855
|
-
|
|
902
|
+
widget.minimized = false;
|
|
903
|
+
if (isPanelTabLocation(location)) {
|
|
904
|
+
const panel = draft.panels[location.side];
|
|
905
|
+
panel.collapsed = false;
|
|
906
|
+
}
|
|
907
|
+
});
|
|
908
|
+
if (isFloatingTabLocation(location)) {
|
|
909
|
+
state = floatingWidgetBringToFront(state, location.floatingWidgetId);
|
|
856
910
|
}
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
isFloatingLocation(location) && floatingWidgetBringToFront(nineZone, location.floatingWidgetId);
|
|
860
|
-
});
|
|
911
|
+
return state;
|
|
912
|
+
}
|
|
861
913
|
/** @internal */
|
|
862
|
-
export
|
|
863
|
-
const location =
|
|
914
|
+
export function expandWidget(state, id) {
|
|
915
|
+
const location = getTabLocation(state, id);
|
|
864
916
|
if (!location)
|
|
865
|
-
return;
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
917
|
+
return state;
|
|
918
|
+
return produce(state, (draft) => {
|
|
919
|
+
const widget = draft.widgets[location.widgetId];
|
|
920
|
+
if (isPanelTabLocation(location)) {
|
|
921
|
+
const panel = draft.panels[location.side];
|
|
922
|
+
panel.widgets.forEach((wId) => {
|
|
923
|
+
const w = draft.widgets[wId];
|
|
924
|
+
w.minimized = true;
|
|
925
|
+
});
|
|
926
|
+
}
|
|
873
927
|
widget.minimized = false;
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
widget.minimized = false;
|
|
877
|
-
return;
|
|
878
|
-
});
|
|
928
|
+
});
|
|
929
|
+
}
|
|
879
930
|
/** @internal */
|
|
880
|
-
export
|
|
881
|
-
if (!(id in
|
|
882
|
-
return;
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
931
|
+
export function setWidgetLabel(state, id, label) {
|
|
932
|
+
if (!(id in state.tabs))
|
|
933
|
+
return state;
|
|
934
|
+
return produce(state, (draft) => {
|
|
935
|
+
const tab = draft.tabs[id];
|
|
936
|
+
tab.label = label;
|
|
937
|
+
});
|
|
938
|
+
}
|
|
886
939
|
/** @internal */
|
|
887
940
|
export function useSavedFrontstageState(frontstageDef) {
|
|
888
941
|
const uiStateStorage = useUiStateStorageHandler();
|
|
@@ -903,20 +956,23 @@ export function useSavedFrontstageState(frontstageDef) {
|
|
|
903
956
|
}
|
|
904
957
|
const id = frontstageDef.id;
|
|
905
958
|
const version = frontstageDef.version;
|
|
906
|
-
const
|
|
907
|
-
if (isMountedRef.current)
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
959
|
+
const settingResult = await uiStateStorageRef.current.getSetting(FRONTSTAGE_SETTINGS_NAMESPACE, getFrontstageStateSettingName(id));
|
|
960
|
+
if (!isMountedRef.current)
|
|
961
|
+
return;
|
|
962
|
+
if (isFrontstageStateSettingResult(settingResult)) {
|
|
963
|
+
const setting = settingResult.setting;
|
|
964
|
+
if (setting.version >= version && setting.stateVersion >= stateVersion) {
|
|
965
|
+
const restored = restoreNineZoneState(frontstageDef, setting.nineZone);
|
|
966
|
+
const savedWidgets = restoreSavedWidgets(setting.widgets, frontstageDef);
|
|
912
967
|
let state = addMissingWidgets(frontstageDef, restored);
|
|
913
|
-
state =
|
|
968
|
+
state = hideWidgets(state, frontstageDef);
|
|
914
969
|
state = processPopoutWidgets(state, frontstageDef);
|
|
915
970
|
frontstageDef.nineZoneState = state;
|
|
971
|
+
frontstageDef.savedWidgetDefs = savedWidgets;
|
|
916
972
|
return;
|
|
917
973
|
}
|
|
918
|
-
frontstageDef.nineZoneState = initializeNineZoneState(frontstageDef);
|
|
919
974
|
}
|
|
975
|
+
frontstageDef.nineZoneState = initializeNineZoneState(frontstageDef);
|
|
920
976
|
}
|
|
921
977
|
fetchFrontstageState(); // eslint-disable-line @typescript-eslint/no-floating-promises
|
|
922
978
|
}, [frontstageDef]);
|
|
@@ -925,16 +981,19 @@ export function useSavedFrontstageState(frontstageDef) {
|
|
|
925
981
|
export function useSaveFrontstageSettings(frontstageDef) {
|
|
926
982
|
const nineZone = useNineZoneState(frontstageDef);
|
|
927
983
|
const uiSettingsStorage = useUiStateStorageHandler();
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
984
|
+
const saveSetting = React.useMemo(() => {
|
|
985
|
+
return debounce(async (frontstage, state, savedWidgets) => {
|
|
986
|
+
const id = frontstage.id;
|
|
987
|
+
const setting = {
|
|
988
|
+
id,
|
|
989
|
+
version: frontstage.version,
|
|
990
|
+
stateVersion,
|
|
991
|
+
nineZone: packNineZoneState(state),
|
|
992
|
+
widgets: packSavedWidgets(savedWidgets, frontstage),
|
|
993
|
+
};
|
|
994
|
+
await uiSettingsStorage.saveSetting(FRONTSTAGE_SETTINGS_NAMESPACE, getFrontstageStateSettingName(id), setting);
|
|
995
|
+
}, 1000);
|
|
996
|
+
}, [uiSettingsStorage]);
|
|
938
997
|
React.useEffect(() => {
|
|
939
998
|
return () => {
|
|
940
999
|
saveSetting.cancel();
|
|
@@ -943,7 +1002,8 @@ export function useSaveFrontstageSettings(frontstageDef) {
|
|
|
943
1002
|
React.useEffect(() => {
|
|
944
1003
|
if (!nineZone || nineZone.draggedTab)
|
|
945
1004
|
return;
|
|
946
|
-
|
|
1005
|
+
const savedWidgets = frontstageDef.savedWidgetDefs || [];
|
|
1006
|
+
saveSetting(frontstageDef, nineZone, savedWidgets);
|
|
947
1007
|
}, [frontstageDef, nineZone, saveSetting]);
|
|
948
1008
|
}
|
|
949
1009
|
/** @internal */
|
|
@@ -1077,7 +1137,7 @@ export function useItemsManager(frontstageDef) {
|
|
|
1077
1137
|
return;
|
|
1078
1138
|
state = addMissingWidgets(def, state);
|
|
1079
1139
|
state = removeMissingWidgets(def, state);
|
|
1080
|
-
state =
|
|
1140
|
+
state = hideWidgets(state, def); // TODO: should only apply to widgets provided by registered provider in onUiProviderRegisteredEvent.
|
|
1081
1141
|
def.nineZoneState = state;
|
|
1082
1142
|
};
|
|
1083
1143
|
React.useEffect(() => {
|
|
@@ -1090,47 +1150,8 @@ export function useItemsManager(frontstageDef) {
|
|
|
1090
1150
|
return remove;
|
|
1091
1151
|
}, [frontstageDef]);
|
|
1092
1152
|
}
|
|
1093
|
-
function tabShownInCurrentWidget(def, state) {
|
|
1094
|
-
for (const [, widget] of Object.entries(state.widgets)) {
|
|
1095
|
-
const foundTab = widget.tabs.find((tabId) => tabId === def.id);
|
|
1096
|
-
// istanbul ignore else
|
|
1097
|
-
if (foundTab)
|
|
1098
|
-
return true;
|
|
1099
|
-
}
|
|
1100
|
-
return false;
|
|
1101
|
-
}
|
|
1102
1153
|
// istanbul ignore next
|
|
1103
1154
|
function determineNewWidgets(defs, state) {
|
|
1104
|
-
|
|
1105
|
-
return (defs || []).filter((def) => !(def.id in state.tabs) || !tabShownInCurrentWidget(def, state));
|
|
1106
|
-
}
|
|
1107
|
-
/** @internal */
|
|
1108
|
-
export async function saveFrontstagePopoutWidgetSizeAndPosition(state, stageId, stageVersion, childWindowId, childWindow) {
|
|
1109
|
-
const location = findWidget(state, childWindowId);
|
|
1110
|
-
// istanbul ignore else
|
|
1111
|
-
if (location) {
|
|
1112
|
-
const adjustmentWidth = ProcessDetector.isElectronAppFrontend ? 16 : 0;
|
|
1113
|
-
const adjustmentHeight = ProcessDetector.isElectronAppFrontend ? 39 : 0;
|
|
1114
|
-
const newState = produce(state, (draft) => {
|
|
1115
|
-
const widget = draft.widgets[childWindowId];
|
|
1116
|
-
const tab = draft.tabs[widget.activeTabId];
|
|
1117
|
-
tab.preferredPopoutWidgetSize = {
|
|
1118
|
-
x: childWindow.screenX,
|
|
1119
|
-
y: childWindow.screenY,
|
|
1120
|
-
width: childWindow.innerWidth + adjustmentWidth,
|
|
1121
|
-
height: childWindow.innerHeight + adjustmentHeight,
|
|
1122
|
-
};
|
|
1123
|
-
});
|
|
1124
|
-
const setting = {
|
|
1125
|
-
id: stageId,
|
|
1126
|
-
nineZone: packNineZoneState(newState),
|
|
1127
|
-
stateVersion,
|
|
1128
|
-
version: stageVersion,
|
|
1129
|
-
};
|
|
1130
|
-
await UiFramework.getUiStateStorage().saveSetting(FRONTSTAGE_SETTINGS_NAMESPACE, getFrontstageStateSettingName(stageId), setting);
|
|
1131
|
-
return newState;
|
|
1132
|
-
}
|
|
1133
|
-
// istanbul ignore next
|
|
1134
|
-
return state;
|
|
1155
|
+
return (defs || []).filter((def) => !(def.id in state.tabs));
|
|
1135
1156
|
}
|
|
1136
1157
|
//# sourceMappingURL=Frontstage.js.map
|