@itwin/appui-react 3.4.0-dev.35 → 3.4.0-dev.39
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/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/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/stagepanels/StagePanelDef.d.ts +0 -6
- package/lib/cjs/appui-react/stagepanels/StagePanelDef.d.ts.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 +286 -278
- 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/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/stagepanels/StagePanelDef.d.ts +0 -6
- package/lib/esm/appui-react/stagepanels/StagePanelDef.d.ts.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 +277 -272
- 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/package.json +32 -32
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
6
|
/* eslint-disable deprecation/deprecation */
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.
|
|
8
|
+
exports.useItemsManager = exports.useFrontstageManager = exports.getFrontstageStateSettingName = exports.FRONTSTAGE_SETTINGS_NAMESPACE = exports.useSaveFrontstageSettings = exports.useSavedFrontstageState = exports.setWidgetLabel = exports.expandWidget = exports.showWidget = exports.setWidgetState = exports.isPanelCollapsed = exports.packNineZoneState = exports.restoreNineZoneState = exports.initializeNineZoneState = exports.initializePanel = exports.isFrontstageStateSettingResult = exports.addPanelWidgets = exports.getPanelZoneWidgets = exports.getWidgetId = exports.removeMissingWidgets = exports.addMissingWidgets = exports.appendWidgets = exports.addWidgets = exports.useLabels = exports.ActiveFrontstageDefProvider = exports.WidgetPanelsFrontstage = exports.useNineZoneDispatch = exports.useUpdateNineZoneSize = exports.useNineZoneState = void 0;
|
|
9
9
|
/** @packageDocumentation
|
|
10
10
|
* @module Frontstage
|
|
11
11
|
*/
|
|
@@ -268,7 +268,6 @@ function appendWidgets(state, widgetDefs, side, preferredWidgetIndex) {
|
|
|
268
268
|
const saveTab = state.tabs[widgetDef.id];
|
|
269
269
|
const preferredPanelWidgetSize = saveTab ? saveTab.preferredPanelWidgetSize : widgetDef.preferredPanelSize;
|
|
270
270
|
const preferredFloatingWidgetSize = saveTab ? saveTab.preferredFloatingWidgetSize : widgetDef.defaultFloatingSize;
|
|
271
|
-
const preferredPopoutWidgetSize = saveTab ? saveTab.preferredPopoutWidgetSize : undefined;
|
|
272
271
|
// if a defaultFloatingSize is specified then this mean the widget can't determine its intrinsic size and must be explicitly sized
|
|
273
272
|
const userSized = saveTab ? (saveTab.userSized || !!widgetDef.defaultFloatingSize && !!saveTab.preferredFloatingWidgetSize)
|
|
274
273
|
: !!widgetDef.defaultFloatingSize;
|
|
@@ -278,7 +277,6 @@ function appendWidgets(state, widgetDefs, side, preferredWidgetIndex) {
|
|
|
278
277
|
canPopout: widgetDef.canPopout,
|
|
279
278
|
preferredPanelWidgetSize,
|
|
280
279
|
preferredFloatingWidgetSize,
|
|
281
|
-
preferredPopoutWidgetSize,
|
|
282
280
|
userSized,
|
|
283
281
|
isFloatingStateWindowResizable: widgetDef.isFloatingStateWindowResizable,
|
|
284
282
|
hideWithUiWhenFloating: !!widgetDef.hideWithUiWhenFloating,
|
|
@@ -286,13 +284,35 @@ function appendWidgets(state, widgetDefs, side, preferredWidgetIndex) {
|
|
|
286
284
|
if (widgetDef.isFloatingStateSupported && widgetDef.defaultState === appui_abstract_1.WidgetState.Floating) {
|
|
287
285
|
const floatingContainerId = (_a = widgetDef.floatingContainerId) !== null && _a !== void 0 ? _a : (0, appui_layout_react_1.getUniqueId)();
|
|
288
286
|
const widgetContainerId = getWidgetId(side, panelZoneKeys[preferredWidgetIndex]);
|
|
289
|
-
const
|
|
287
|
+
const home = { side, widgetId: widgetContainerId, widgetIndex: 0 };
|
|
290
288
|
const preferredPosition = widgetDef.defaultFloatingPosition;
|
|
291
|
-
|
|
289
|
+
if (floatingContainerId in state.widgets) {
|
|
290
|
+
state = (0, appui_layout_react_1.addTabToWidget)(state, widgetDef.id, floatingContainerId);
|
|
291
|
+
}
|
|
292
|
+
else {
|
|
293
|
+
const tab = state.tabs[widgetDef.id];
|
|
294
|
+
const size = { height: 200, width: 300, ...tab.preferredFloatingWidgetSize };
|
|
295
|
+
const preferredPoint = preferredPosition !== null && preferredPosition !== void 0 ? preferredPosition : { x: (state.size.width - size.width) / 2, y: (state.size.height - size.height) / 2 };
|
|
296
|
+
const nzBounds = core_react_1.Rectangle.createFromSize(state.size);
|
|
297
|
+
const bounds = core_react_1.Rectangle.createFromSize(size).offset(preferredPoint);
|
|
298
|
+
const containedBounds = bounds.containIn(nzBounds);
|
|
299
|
+
state = (0, appui_layout_react_1.addFloatingWidget)(state, floatingContainerId, [widgetDef.id], {
|
|
300
|
+
bounds: containedBounds.toProps(),
|
|
301
|
+
home,
|
|
302
|
+
userSized,
|
|
303
|
+
}, {
|
|
304
|
+
isFloatingStateWindowResizable: widgetDef.isFloatingStateWindowResizable,
|
|
305
|
+
});
|
|
306
|
+
}
|
|
292
307
|
}
|
|
293
308
|
else {
|
|
294
309
|
const widgetPanelSectionId = (0, appui_layout_react_1.getWidgetPanelSectionId)(side, preferredWidgetIndex);
|
|
295
|
-
|
|
310
|
+
if (widgetPanelSectionId in state.widgets) {
|
|
311
|
+
state = (0, appui_layout_react_1.addTabToWidget)(state, widgetDef.id, widgetPanelSectionId);
|
|
312
|
+
}
|
|
313
|
+
else {
|
|
314
|
+
state = (0, appui_layout_react_1.addPanelWidget)(state, side, widgetPanelSectionId, [widgetDef.id]);
|
|
315
|
+
}
|
|
296
316
|
}
|
|
297
317
|
}
|
|
298
318
|
return state;
|
|
@@ -340,17 +360,15 @@ function addMissingWidgets(frontstageDef, initialState) {
|
|
|
340
360
|
return state;
|
|
341
361
|
}
|
|
342
362
|
exports.addMissingWidgets = addMissingWidgets;
|
|
343
|
-
/**
|
|
344
|
-
function
|
|
363
|
+
/** Hide widgets with Hidden defaultState. */
|
|
364
|
+
function hideWidgets(state, frontstageDef) {
|
|
345
365
|
const tabs = Object.values(state.tabs);
|
|
346
366
|
for (const tab of tabs) {
|
|
347
367
|
const widgetDef = frontstageDef.findWidgetDef(tab.id);
|
|
348
368
|
if (!widgetDef)
|
|
349
369
|
continue;
|
|
350
370
|
if (widgetDef.defaultState === appui_abstract_1.WidgetState.Hidden) {
|
|
351
|
-
state = (
|
|
352
|
-
hideWidget(draft, widgetDef);
|
|
353
|
-
});
|
|
371
|
+
state = hideWidget(state, widgetDef);
|
|
354
372
|
}
|
|
355
373
|
}
|
|
356
374
|
return state;
|
|
@@ -359,16 +377,15 @@ function removeHiddenWidgets(state, frontstageDef) {
|
|
|
359
377
|
* @internal
|
|
360
378
|
*/
|
|
361
379
|
function removeMissingWidgets(frontstageDef, initialState) {
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
});
|
|
380
|
+
let state = initialState;
|
|
381
|
+
for (const [, tab] of Object.entries(state.tabs)) {
|
|
382
|
+
if (tab.id === appui_layout_react_1.toolSettingsTabId)
|
|
383
|
+
continue;
|
|
384
|
+
const widgetDef = frontstageDef.findWidgetDef(tab.id);
|
|
385
|
+
if (widgetDef)
|
|
386
|
+
continue;
|
|
387
|
+
state = (0, appui_layout_react_1.removeTab)(state, tab.id);
|
|
388
|
+
}
|
|
372
389
|
return state;
|
|
373
390
|
}
|
|
374
391
|
exports.removeMissingWidgets = removeMissingWidgets;
|
|
@@ -524,23 +541,23 @@ function isFrontstageStateSettingResult(settingsResult) {
|
|
|
524
541
|
}
|
|
525
542
|
exports.isFrontstageStateSettingResult = isFrontstageStateSettingResult;
|
|
526
543
|
/** @internal */
|
|
527
|
-
function initializePanel(
|
|
528
|
-
|
|
544
|
+
function initializePanel(state, frontstageDef, panelSide) {
|
|
545
|
+
state = addPanelWidgets(state, frontstageDef, panelSide);
|
|
529
546
|
const location = toStagePanelLocation(panelSide);
|
|
530
547
|
const panelDef = frontstageDef.getStagePanelDef(location);
|
|
531
|
-
|
|
548
|
+
state = (0, immer_1.default)(state, (draft) => {
|
|
532
549
|
var _a, _b, _c;
|
|
533
550
|
const panel = draft.panels[panelSide];
|
|
534
551
|
panel.minSize = (_a = panelDef === null || panelDef === void 0 ? void 0 : panelDef.minSize) !== null && _a !== void 0 ? _a : panel.minSize;
|
|
535
552
|
panel.pinned = (_b = panelDef === null || panelDef === void 0 ? void 0 : panelDef.pinned) !== null && _b !== void 0 ? _b : panel.pinned;
|
|
536
553
|
panel.resizable = (_c = panelDef === null || panelDef === void 0 ? void 0 : panelDef.resizable) !== null && _c !== void 0 ? _c : panel.resizable;
|
|
537
554
|
if (panelDef === null || panelDef === void 0 ? void 0 : panelDef.maxSizeSpec) {
|
|
538
|
-
panel.maxSize = getPanelMaxSize(panelDef.maxSizeSpec, panelSide,
|
|
555
|
+
panel.maxSize = getPanelMaxSize(panelDef.maxSizeSpec, panelSide, state.size);
|
|
539
556
|
}
|
|
540
557
|
const size = panelDef === null || panelDef === void 0 ? void 0 : panelDef.size;
|
|
541
558
|
panel.size = size === undefined ? size : Math.min(Math.max(size, panel.minSize), panel.maxSize);
|
|
542
559
|
});
|
|
543
|
-
return
|
|
560
|
+
return state;
|
|
544
561
|
}
|
|
545
562
|
exports.initializePanel = initializePanel;
|
|
546
563
|
function getPanelMaxSize(maxSizeSpec, panel, nineZoneSize) {
|
|
@@ -550,7 +567,7 @@ function getPanelMaxSize(maxSizeSpec, panel, nineZoneSize) {
|
|
|
550
567
|
const size = (0, appui_layout_react_1.isHorizontalPanelSide)(panel) ? nineZoneSize.height : nineZoneSize.width;
|
|
551
568
|
return maxSizeSpec.percentage / 100 * size;
|
|
552
569
|
}
|
|
553
|
-
const stateVersion =
|
|
570
|
+
const stateVersion = 13; // this needs to be bumped when NineZoneState is changed (to recreate the layout).
|
|
554
571
|
/** @internal */
|
|
555
572
|
function initializeNineZoneState(frontstageDef) {
|
|
556
573
|
let nineZone = defaultNineZone;
|
|
@@ -572,6 +589,7 @@ function initializeNineZoneState(frontstageDef) {
|
|
|
572
589
|
for (const [, panel] of Object.entries(stateDraft.panels)) {
|
|
573
590
|
const expanded = panel.widgets.find((widgetId) => stateDraft.widgets[widgetId].minimized === false);
|
|
574
591
|
const firstWidget = panel.widgets.length > 0 ? stateDraft.widgets[panel.widgets[0]] : undefined;
|
|
592
|
+
// istanbul ignore next
|
|
575
593
|
if (!expanded && firstWidget) {
|
|
576
594
|
firstWidget.minimized = false;
|
|
577
595
|
}
|
|
@@ -600,7 +618,7 @@ function initializeNineZoneState(frontstageDef) {
|
|
|
600
618
|
}
|
|
601
619
|
});
|
|
602
620
|
nineZone = addMissingWidgets(frontstageDef, nineZone);
|
|
603
|
-
nineZone =
|
|
621
|
+
nineZone = hideWidgets(nineZone, frontstageDef);
|
|
604
622
|
nineZone = processPopoutWidgets(nineZone, frontstageDef);
|
|
605
623
|
return nineZone;
|
|
606
624
|
}
|
|
@@ -613,29 +631,32 @@ exports.initializeNineZoneState = initializeNineZoneState;
|
|
|
613
631
|
function restoreNineZoneState(frontstageDef, saved) {
|
|
614
632
|
let restored = {
|
|
615
633
|
...saved,
|
|
616
|
-
tabs:
|
|
634
|
+
tabs: defaultNineZone.tabs,
|
|
617
635
|
};
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
636
|
+
for (const [, tab] of Object.entries(saved.tabs)) {
|
|
637
|
+
// Re-add the placeholder tab in order to correctly remove it from the state if WidgetDef is not found.
|
|
638
|
+
restored = (0, appui_layout_react_1.addTab)(restored, tab.id);
|
|
639
|
+
const widgetDef = frontstageDef.findWidgetDef(tab.id);
|
|
640
|
+
if (!widgetDef) {
|
|
641
|
+
core_bentley_1.Logger.logInfo(UiFramework_1.UiFramework.loggerCategory(restoreNineZoneState), "WidgetDef is not found for saved tab.", () => ({
|
|
642
|
+
frontstageId: frontstageDef.id,
|
|
643
|
+
tabId: tab.id,
|
|
644
|
+
}));
|
|
645
|
+
restored = (0, appui_layout_react_1.removeTab)(restored, tab.id);
|
|
646
|
+
continue;
|
|
647
|
+
}
|
|
648
|
+
restored = (0, immer_1.default)(restored, (draft) => {
|
|
630
649
|
draft.tabs[tab.id] = {
|
|
631
650
|
...tab,
|
|
632
|
-
label: getWidgetLabel(
|
|
633
|
-
hideWithUiWhenFloating: widgetDef
|
|
634
|
-
iconSpec: widgetDef
|
|
635
|
-
canPopout: widgetDef
|
|
636
|
-
isFloatingStateWindowResizable: widgetDef
|
|
651
|
+
label: getWidgetLabel(widgetDef.label),
|
|
652
|
+
hideWithUiWhenFloating: widgetDef.hideWithUiWhenFloating,
|
|
653
|
+
iconSpec: widgetDef.iconSpec,
|
|
654
|
+
canPopout: widgetDef.canPopout,
|
|
655
|
+
isFloatingStateWindowResizable: widgetDef.isFloatingStateWindowResizable,
|
|
637
656
|
};
|
|
638
|
-
}
|
|
657
|
+
});
|
|
658
|
+
}
|
|
659
|
+
restored = (0, immer_1.default)(restored, (draft) => {
|
|
639
660
|
// remove center panel section if one is found in left or right panels
|
|
640
661
|
const oldLeftMiddleIndex = saved.panels.left.widgets.findIndex((value) => value === "leftMiddle");
|
|
641
662
|
// istanbul ignore next
|
|
@@ -663,14 +684,6 @@ function restoreNineZoneState(frontstageDef, saved) {
|
|
|
663
684
|
}
|
|
664
685
|
return;
|
|
665
686
|
});
|
|
666
|
-
// TODO: remove when isUUID check is refactored.
|
|
667
|
-
restored = (0, immer_1.default)(restored, (draft) => {
|
|
668
|
-
// Floating widget might have been removed when saving, dock tool settings if tab is not found.
|
|
669
|
-
const location = (0, appui_layout_react_1.findTab)(draft, appui_layout_react_1.toolSettingsTabId);
|
|
670
|
-
if (!location) {
|
|
671
|
-
draft.toolSettings.type = "docked";
|
|
672
|
-
}
|
|
673
|
-
});
|
|
674
687
|
if (FrontstageManager_1.FrontstageManager.nineZoneSize && (0 !== FrontstageManager_1.FrontstageManager.nineZoneSize.height || 0 !== FrontstageManager_1.FrontstageManager.nineZoneSize.width)) {
|
|
675
688
|
restored = FrameworkStateReducer(restored, {
|
|
676
689
|
type: "RESIZE",
|
|
@@ -683,20 +696,6 @@ function restoreNineZoneState(frontstageDef, saved) {
|
|
|
683
696
|
return restored;
|
|
684
697
|
}
|
|
685
698
|
exports.restoreNineZoneState = restoreNineZoneState;
|
|
686
|
-
/**
|
|
687
|
-
* Checks to see whether a widget id is one of our generated uuids
|
|
688
|
-
* @param uuid the string value to test
|
|
689
|
-
* @returns boolean
|
|
690
|
-
*/
|
|
691
|
-
function isUUID(uuid) {
|
|
692
|
-
const s = `${uuid}`;
|
|
693
|
-
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}$");
|
|
694
|
-
// istanbul ignore else
|
|
695
|
-
if (result === null) {
|
|
696
|
-
return false;
|
|
697
|
-
}
|
|
698
|
-
return true;
|
|
699
|
-
}
|
|
700
699
|
/** Prepares NineZoneState to be saved.
|
|
701
700
|
* @note Removes toolSettings tab.
|
|
702
701
|
* @note Removes tab labels and iconSpec.
|
|
@@ -711,33 +710,62 @@ function packNineZoneState(state) {
|
|
|
711
710
|
for (const [, tab] of Object.entries(state.tabs)) {
|
|
712
711
|
if (tab.id === appui_layout_react_1.toolSettingsTabId)
|
|
713
712
|
continue;
|
|
714
|
-
// istanbul ignore else
|
|
715
|
-
if (isUUID(tab.id))
|
|
716
|
-
continue;
|
|
717
713
|
draft.tabs[tab.id] = {
|
|
718
714
|
id: tab.id,
|
|
719
715
|
preferredFloatingWidgetSize: tab.preferredFloatingWidgetSize,
|
|
720
|
-
preferredPopoutWidgetSize: tab.preferredPopoutWidgetSize,
|
|
721
716
|
allowedPanelTargets: tab.allowedPanelTargets,
|
|
722
717
|
userSized: tab.userSized,
|
|
723
718
|
};
|
|
724
719
|
}
|
|
725
720
|
});
|
|
726
|
-
packed = (0, immer_1.default)(packed, (draft) => {
|
|
727
|
-
for (const [, floatingWidget] of Object.entries(state.floatingWidgets.byId)) {
|
|
728
|
-
const widgetId = floatingWidget.id;
|
|
729
|
-
// istanbul ignore else
|
|
730
|
-
if (isUUID(widgetId)) {
|
|
731
|
-
const idIndex = draft.floatingWidgets.allIds.indexOf(widgetId);
|
|
732
|
-
draft.floatingWidgets.allIds.splice(idIndex, 1);
|
|
733
|
-
delete draft.floatingWidgets.byId[widgetId];
|
|
734
|
-
delete draft.widgets[widgetId];
|
|
735
|
-
}
|
|
736
|
-
}
|
|
737
|
-
});
|
|
738
721
|
return packed;
|
|
739
722
|
}
|
|
740
723
|
exports.packNineZoneState = packNineZoneState;
|
|
724
|
+
// TODO: clean-up of saved widgets.
|
|
725
|
+
// istanbul ignore next
|
|
726
|
+
function packSavedWidgets(savedWidgets, frontstageDef) {
|
|
727
|
+
for (const widgetDef of frontstageDef.widgetDefs) {
|
|
728
|
+
const id = widgetDef.id;
|
|
729
|
+
const initialWidget = {
|
|
730
|
+
id,
|
|
731
|
+
};
|
|
732
|
+
const widget = (0, immer_1.default)(initialWidget, (draft) => {
|
|
733
|
+
if (widgetDef.tabLocation) {
|
|
734
|
+
draft.tabLocation = { ...widgetDef.tabLocation };
|
|
735
|
+
}
|
|
736
|
+
if (widgetDef.popoutBounds) {
|
|
737
|
+
draft.popoutBounds = widgetDef.popoutBounds.toProps();
|
|
738
|
+
}
|
|
739
|
+
});
|
|
740
|
+
if (widget === initialWidget)
|
|
741
|
+
continue;
|
|
742
|
+
savedWidgets = (0, immer_1.default)(savedWidgets, (draft) => {
|
|
743
|
+
draft.push(widget);
|
|
744
|
+
});
|
|
745
|
+
}
|
|
746
|
+
return savedWidgets;
|
|
747
|
+
}
|
|
748
|
+
// istanbul ignore next
|
|
749
|
+
function restoreSavedWidgets(savedWidgets, frontstage) {
|
|
750
|
+
let i = savedWidgets.length;
|
|
751
|
+
while (i--) {
|
|
752
|
+
const savedWidget = savedWidgets[i];
|
|
753
|
+
const widgetId = savedWidget.id;
|
|
754
|
+
const widgetDef = frontstage.findWidgetDef(widgetId);
|
|
755
|
+
if (!widgetDef)
|
|
756
|
+
continue;
|
|
757
|
+
if (savedWidget.tabLocation) {
|
|
758
|
+
widgetDef.tabLocation = { ...savedWidget.tabLocation };
|
|
759
|
+
}
|
|
760
|
+
if (savedWidget.popoutBounds) {
|
|
761
|
+
widgetDef.popoutBounds = core_react_1.Rectangle.create(savedWidget.popoutBounds);
|
|
762
|
+
}
|
|
763
|
+
savedWidgets = (0, immer_1.default)(savedWidgets, (draft) => {
|
|
764
|
+
draft.splice(i, 1);
|
|
765
|
+
});
|
|
766
|
+
}
|
|
767
|
+
return savedWidgets;
|
|
768
|
+
}
|
|
741
769
|
/** @internal */
|
|
742
770
|
function isPanelCollapsed(zoneStates, panelStates) {
|
|
743
771
|
const openZone = zoneStates.find((zoneState) => zoneState === ZoneDef_1.ZoneState.Open);
|
|
@@ -745,121 +773,128 @@ function isPanelCollapsed(zoneStates, panelStates) {
|
|
|
745
773
|
return !openZone && !openPanel;
|
|
746
774
|
}
|
|
747
775
|
exports.isPanelCollapsed = isPanelCollapsed;
|
|
748
|
-
function
|
|
749
|
-
|
|
750
|
-
const
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
isFloatingStateWindowResizable: widgetDef.isFloatingStateWindowResizable,
|
|
756
|
-
hideWithUiWhenFloating: !!widgetDef.hideWithUiWhenFloating,
|
|
757
|
-
});
|
|
758
|
-
nineZone.tabs[newTab.id] = newTab;
|
|
759
|
-
if (widgetDef.tabLocation.widgetId in nineZone.widgets) {
|
|
760
|
-
// Add to existing widget (by widget id).
|
|
761
|
-
const widgetId = widgetDef.tabLocation.widgetId;
|
|
762
|
-
const newTabWidget = nineZone.widgets[widgetId];
|
|
763
|
-
newTabWidget.tabs.splice(widgetDef.tabLocation.tabIndex, 0, newTab.id);
|
|
776
|
+
function addHiddenWidget(state, widgetDef) {
|
|
777
|
+
const tabLocation = widgetDef.tabLocation || widgetDef.defaultTabLocation;
|
|
778
|
+
const tabId = widgetDef.id;
|
|
779
|
+
const { widgetId, tabIndex } = tabLocation;
|
|
780
|
+
if (widgetId in state.widgets) {
|
|
781
|
+
// Add to an existing widget (by widget id).
|
|
782
|
+
return (0, appui_layout_react_1.insertTabToWidget)(state, tabId, widgetId, tabIndex);
|
|
764
783
|
}
|
|
765
|
-
else if (
|
|
766
|
-
const
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
}
|
|
784
|
+
else if (tabLocation.floatingWidget) {
|
|
785
|
+
const floatingWidget = tabLocation.floatingWidget;
|
|
786
|
+
(0, core_bentley_1.assert)(widgetId === floatingWidget.id);
|
|
787
|
+
// Add to a new floating widget.
|
|
788
|
+
const nzBounds = core_react_1.Rectangle.createFromSize(state.size);
|
|
789
|
+
const bounds = core_react_1.Rectangle.create(floatingWidget.bounds).containIn(nzBounds);
|
|
790
|
+
return (0, appui_layout_react_1.addFloatingWidget)(state, floatingWidget.id, [tabId], {
|
|
791
|
+
...floatingWidget,
|
|
792
|
+
bounds: bounds.toProps(),
|
|
793
|
+
});
|
|
776
794
|
}
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
newTabWidget.tabs.splice(widgetDef.tabLocation.tabIndex, 0, newTab.id);
|
|
785
|
-
}
|
|
786
|
-
else {
|
|
787
|
-
// Create a new panel widget.
|
|
788
|
-
const newWidget = (0, appui_layout_react_1.createWidgetState)((0, appui_layout_react_1.getUniqueId)(), [newTab.id]);
|
|
789
|
-
nineZone.widgets[newWidget.id] = (0, immer_1.castDraft)(newWidget);
|
|
790
|
-
newTabPanel.widgets.splice(widgetDef.tabLocation.widgetIndex, 0, newWidget.id);
|
|
791
|
-
}
|
|
795
|
+
// Add to a panel section.
|
|
796
|
+
const panel = state.panels[tabLocation.side];
|
|
797
|
+
// Add to existing panel section.
|
|
798
|
+
if (panel.widgets.length >= panel.maxWidgetCount) {
|
|
799
|
+
const sectionIndex = Math.min(panel.maxWidgetCount - 1, tabLocation.widgetIndex);
|
|
800
|
+
const sectionId = panel.widgets[sectionIndex];
|
|
801
|
+
return (0, appui_layout_react_1.insertTabToWidget)(state, tabId, sectionId, tabLocation.tabIndex);
|
|
792
802
|
}
|
|
803
|
+
// Create a new panel section.
|
|
804
|
+
const newSectionId = (0, appui_layout_react_1.getUniqueId)();
|
|
805
|
+
return (0, appui_layout_react_1.insertPanelWidget)(state, panel.side, newSectionId, [tabId], tabLocation.widgetIndex);
|
|
793
806
|
}
|
|
794
807
|
/** @internal */
|
|
795
|
-
|
|
808
|
+
function setWidgetState(state, widgetDef, widgetState) {
|
|
796
809
|
var _a, _b;
|
|
797
|
-
if (
|
|
810
|
+
if (widgetState === appui_abstract_1.WidgetState.Hidden) {
|
|
811
|
+
return hideWidget(state, widgetDef);
|
|
812
|
+
}
|
|
813
|
+
else if (widgetState === appui_abstract_1.WidgetState.Open) {
|
|
798
814
|
const id = widgetDef.id;
|
|
799
|
-
let location = (0, appui_layout_react_1.
|
|
815
|
+
let location = (0, appui_layout_react_1.getTabLocation)(state, id);
|
|
800
816
|
if (!location) {
|
|
801
|
-
|
|
802
|
-
location = (0, appui_layout_react_1.
|
|
803
|
-
(0, core_bentley_1.assert)(!!location);
|
|
804
|
-
}
|
|
805
|
-
if (!!widgetDef.tabLocation.floating) {
|
|
806
|
-
nineZone.floatingWidgets.byId[(_a = widgetDef.floatingContainerId) !== null && _a !== void 0 ? _a : widgetDef.id].hidden = false;
|
|
817
|
+
state = addHiddenWidget(state, widgetDef);
|
|
818
|
+
location = (0, appui_layout_react_1.getTabLocation)(state, id);
|
|
807
819
|
}
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
panel.size = (_b = panel.minSize) !== null && _b !== void 0 ? _b : 200;
|
|
820
|
+
return (0, immer_1.default)(state, (draft) => {
|
|
821
|
+
var _a;
|
|
822
|
+
(0, core_bentley_1.assert)(!!location);
|
|
823
|
+
const widget = draft.widgets[location.widgetId];
|
|
824
|
+
widget.minimized = false;
|
|
825
|
+
widget.activeTabId = id;
|
|
826
|
+
if ((0, appui_layout_react_1.isFloatingTabLocation)(location)) {
|
|
827
|
+
const floatingWidget = draft.floatingWidgets.byId[location.floatingWidgetId];
|
|
828
|
+
floatingWidget.hidden = false;
|
|
829
|
+
// istanbul ignore else
|
|
819
830
|
}
|
|
820
|
-
|
|
831
|
+
else if ((0, appui_layout_react_1.isPanelTabLocation)(location)) {
|
|
832
|
+
const panel = draft.panels[location.side];
|
|
833
|
+
panel.collapsed = false;
|
|
834
|
+
if (undefined === panel.size || 0 === panel.size) {
|
|
835
|
+
// istanbul ignore next
|
|
836
|
+
panel.size = (_a = panel.minSize) !== null && _a !== void 0 ? _a : 200;
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
});
|
|
821
840
|
}
|
|
822
|
-
else if (
|
|
841
|
+
else if (widgetState === appui_abstract_1.WidgetState.Closed) {
|
|
823
842
|
const id = widgetDef.id;
|
|
824
|
-
let location = (0, appui_layout_react_1.
|
|
843
|
+
let location = (0, appui_layout_react_1.getTabLocation)(state, id);
|
|
825
844
|
if (!location) {
|
|
826
|
-
|
|
827
|
-
location = (0, appui_layout_react_1.
|
|
828
|
-
(0, core_bentley_1.assert)(!!location);
|
|
829
|
-
}
|
|
830
|
-
if ((0, appui_layout_react_1.isFloatingLocation)(location)) {
|
|
831
|
-
const widget = nineZone.widgets[location.widgetId];
|
|
832
|
-
if (id !== widget.activeTabId)
|
|
833
|
-
return;
|
|
834
|
-
widget.minimized = true;
|
|
845
|
+
state = addHiddenWidget(state, widgetDef);
|
|
846
|
+
location = (0, appui_layout_react_1.getTabLocation)(state, id);
|
|
835
847
|
}
|
|
848
|
+
// TODO: should change activeTabId of a widget with multiple tabs.
|
|
849
|
+
return (0, immer_1.default)(state, (draft) => {
|
|
850
|
+
(0, core_bentley_1.assert)(!!location);
|
|
851
|
+
const widget = draft.widgets[location.widgetId];
|
|
852
|
+
if ((0, appui_layout_react_1.isFloatingTabLocation)(location)) {
|
|
853
|
+
if (id === widget.activeTabId) {
|
|
854
|
+
widget.minimized = true;
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
});
|
|
836
858
|
}
|
|
837
|
-
else if (
|
|
838
|
-
|
|
859
|
+
else if (widgetState === appui_abstract_1.WidgetState.Floating) {
|
|
860
|
+
const id = widgetDef.id;
|
|
861
|
+
let location = (0, appui_layout_react_1.getTabLocation)(state, id);
|
|
862
|
+
if (!location) {
|
|
863
|
+
state = addHiddenWidget(state, widgetDef);
|
|
864
|
+
location = (0, appui_layout_react_1.getTabLocation)(state, id);
|
|
865
|
+
}
|
|
866
|
+
(0, core_bentley_1.assert)(!!location);
|
|
867
|
+
if ((0, appui_layout_react_1.isFloatingTabLocation)(location))
|
|
868
|
+
return state;
|
|
869
|
+
// Widget is not floating.
|
|
870
|
+
state = (0, appui_layout_react_1.removeTabFromWidget)(state, id);
|
|
871
|
+
const bounds = (_b = (_a = widgetDef.tabLocation) === null || _a === void 0 ? void 0 : _a.floatingWidget) === null || _b === void 0 ? void 0 : _b.bounds;
|
|
872
|
+
state = (0, appui_layout_react_1.addFloatingWidget)(state, (0, appui_layout_react_1.getUniqueId)(), [id], { bounds });
|
|
839
873
|
}
|
|
840
|
-
|
|
874
|
+
return state;
|
|
875
|
+
}
|
|
876
|
+
exports.setWidgetState = setWidgetState;
|
|
841
877
|
/** Stores widget location and hides it in the UI. */
|
|
842
878
|
function hideWidget(state, widgetDef) {
|
|
843
|
-
const location = (0, appui_layout_react_1.
|
|
879
|
+
const location = (0, appui_layout_react_1.getTabLocation)(state, widgetDef.id);
|
|
844
880
|
if (!location)
|
|
845
|
-
return;
|
|
846
|
-
|
|
847
|
-
|
|
881
|
+
return state;
|
|
882
|
+
// istanbul ignore else
|
|
883
|
+
if ((0, appui_layout_react_1.isFloatingTabLocation)(location)) {
|
|
884
|
+
const floatingWidget = state.floatingWidgets.byId[location.widgetId];
|
|
848
885
|
widgetDef.setFloatingContainerId(location.floatingWidgetId);
|
|
849
886
|
widgetDef.tabLocation = {
|
|
850
|
-
side:
|
|
851
|
-
tabIndex:
|
|
852
|
-
widgetId:
|
|
853
|
-
widgetIndex:
|
|
854
|
-
|
|
887
|
+
side: floatingWidget.home.side,
|
|
888
|
+
tabIndex: floatingWidget.home.widgetIndex,
|
|
889
|
+
widgetId: floatingWidget.id,
|
|
890
|
+
widgetIndex: floatingWidget.home.widgetIndex,
|
|
891
|
+
floatingWidget,
|
|
855
892
|
};
|
|
856
893
|
}
|
|
857
|
-
else
|
|
858
|
-
// istanbul ignore else
|
|
859
|
-
if (!(0, appui_layout_react_1.isPopoutLocation)(location)) {
|
|
894
|
+
else if (!(0, appui_layout_react_1.isPopoutTabLocation)(location)) {
|
|
860
895
|
const widgetId = location.widgetId;
|
|
861
|
-
const side =
|
|
862
|
-
const widgetIndex =
|
|
896
|
+
const side = (0, appui_layout_react_1.isPanelTabLocation)(location) ? location.side : "left";
|
|
897
|
+
const widgetIndex = (0, appui_layout_react_1.isPanelTabLocation)(location) ? state.panels[side].widgets.indexOf(widgetId) : 0;
|
|
863
898
|
const tabIndex = state.widgets[location.widgetId].tabs.indexOf(widgetDef.id);
|
|
864
899
|
widgetDef.tabLocation = {
|
|
865
900
|
side,
|
|
@@ -868,50 +903,56 @@ function hideWidget(state, widgetDef) {
|
|
|
868
903
|
widgetIndex,
|
|
869
904
|
};
|
|
870
905
|
}
|
|
871
|
-
(0, appui_layout_react_1.
|
|
906
|
+
return (0, appui_layout_react_1.removeTabFromWidget)(state, widgetDef.id);
|
|
872
907
|
}
|
|
873
908
|
/** @internal */
|
|
874
|
-
|
|
875
|
-
const location = (0, appui_layout_react_1.
|
|
909
|
+
function showWidget(state, id) {
|
|
910
|
+
const location = (0, appui_layout_react_1.getTabLocation)(state, id);
|
|
876
911
|
if (!location)
|
|
877
|
-
return;
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
const panel = nineZone.panels[location.side];
|
|
881
|
-
panel.collapsed = false;
|
|
882
|
-
widget.minimized = false;
|
|
912
|
+
return state;
|
|
913
|
+
state = (0, immer_1.default)(state, (draft) => {
|
|
914
|
+
const widget = draft.widgets[location.widgetId];
|
|
883
915
|
widget.activeTabId = id;
|
|
884
|
-
|
|
916
|
+
widget.minimized = false;
|
|
917
|
+
if ((0, appui_layout_react_1.isPanelTabLocation)(location)) {
|
|
918
|
+
const panel = draft.panels[location.side];
|
|
919
|
+
panel.collapsed = false;
|
|
920
|
+
}
|
|
921
|
+
});
|
|
922
|
+
if ((0, appui_layout_react_1.isFloatingTabLocation)(location)) {
|
|
923
|
+
state = (0, appui_layout_react_1.floatingWidgetBringToFront)(state, location.floatingWidgetId);
|
|
885
924
|
}
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
});
|
|
925
|
+
return state;
|
|
926
|
+
}
|
|
927
|
+
exports.showWidget = showWidget;
|
|
890
928
|
/** @internal */
|
|
891
|
-
|
|
892
|
-
const location = (0, appui_layout_react_1.
|
|
929
|
+
function expandWidget(state, id) {
|
|
930
|
+
const location = (0, appui_layout_react_1.getTabLocation)(state, id);
|
|
893
931
|
if (!location)
|
|
894
|
-
return;
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
932
|
+
return state;
|
|
933
|
+
return (0, immer_1.default)(state, (draft) => {
|
|
934
|
+
const widget = draft.widgets[location.widgetId];
|
|
935
|
+
if ((0, appui_layout_react_1.isPanelTabLocation)(location)) {
|
|
936
|
+
const panel = draft.panels[location.side];
|
|
937
|
+
panel.widgets.forEach((wId) => {
|
|
938
|
+
const w = draft.widgets[wId];
|
|
939
|
+
w.minimized = true;
|
|
940
|
+
});
|
|
941
|
+
}
|
|
902
942
|
widget.minimized = false;
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
return;
|
|
907
|
-
});
|
|
943
|
+
});
|
|
944
|
+
}
|
|
945
|
+
exports.expandWidget = expandWidget;
|
|
908
946
|
/** @internal */
|
|
909
|
-
|
|
910
|
-
if (!(id in
|
|
911
|
-
return;
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
947
|
+
function setWidgetLabel(state, id, label) {
|
|
948
|
+
if (!(id in state.tabs))
|
|
949
|
+
return state;
|
|
950
|
+
return (0, immer_1.default)(state, (draft) => {
|
|
951
|
+
const tab = draft.tabs[id];
|
|
952
|
+
tab.label = label;
|
|
953
|
+
});
|
|
954
|
+
}
|
|
955
|
+
exports.setWidgetLabel = setWidgetLabel;
|
|
915
956
|
/** @internal */
|
|
916
957
|
function useSavedFrontstageState(frontstageDef) {
|
|
917
958
|
const uiStateStorage = (0, useUiStateStorage_1.useUiStateStorageHandler)();
|
|
@@ -932,20 +973,23 @@ function useSavedFrontstageState(frontstageDef) {
|
|
|
932
973
|
}
|
|
933
974
|
const id = frontstageDef.id;
|
|
934
975
|
const version = frontstageDef.version;
|
|
935
|
-
const
|
|
936
|
-
if (isMountedRef.current)
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
976
|
+
const settingResult = await uiStateStorageRef.current.getSetting(exports.FRONTSTAGE_SETTINGS_NAMESPACE, getFrontstageStateSettingName(id));
|
|
977
|
+
if (!isMountedRef.current)
|
|
978
|
+
return;
|
|
979
|
+
if (isFrontstageStateSettingResult(settingResult)) {
|
|
980
|
+
const setting = settingResult.setting;
|
|
981
|
+
if (setting.version >= version && setting.stateVersion >= stateVersion) {
|
|
982
|
+
const restored = restoreNineZoneState(frontstageDef, setting.nineZone);
|
|
983
|
+
const savedWidgets = restoreSavedWidgets(setting.widgets, frontstageDef);
|
|
941
984
|
let state = addMissingWidgets(frontstageDef, restored);
|
|
942
|
-
state =
|
|
985
|
+
state = hideWidgets(state, frontstageDef);
|
|
943
986
|
state = processPopoutWidgets(state, frontstageDef);
|
|
944
987
|
frontstageDef.nineZoneState = state;
|
|
988
|
+
frontstageDef.savedWidgetDefs = savedWidgets;
|
|
945
989
|
return;
|
|
946
990
|
}
|
|
947
|
-
frontstageDef.nineZoneState = initializeNineZoneState(frontstageDef);
|
|
948
991
|
}
|
|
992
|
+
frontstageDef.nineZoneState = initializeNineZoneState(frontstageDef);
|
|
949
993
|
}
|
|
950
994
|
fetchFrontstageState(); // eslint-disable-line @typescript-eslint/no-floating-promises
|
|
951
995
|
}, [frontstageDef]);
|
|
@@ -955,16 +999,19 @@ exports.useSavedFrontstageState = useSavedFrontstageState;
|
|
|
955
999
|
function useSaveFrontstageSettings(frontstageDef) {
|
|
956
1000
|
const nineZone = useNineZoneState(frontstageDef);
|
|
957
1001
|
const uiSettingsStorage = (0, useUiStateStorage_1.useUiStateStorageHandler)();
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
1002
|
+
const saveSetting = React.useMemo(() => {
|
|
1003
|
+
return debounce(async (frontstage, state, savedWidgets) => {
|
|
1004
|
+
const id = frontstage.id;
|
|
1005
|
+
const setting = {
|
|
1006
|
+
id,
|
|
1007
|
+
version: frontstage.version,
|
|
1008
|
+
stateVersion,
|
|
1009
|
+
nineZone: packNineZoneState(state),
|
|
1010
|
+
widgets: packSavedWidgets(savedWidgets, frontstage),
|
|
1011
|
+
};
|
|
1012
|
+
await uiSettingsStorage.saveSetting(exports.FRONTSTAGE_SETTINGS_NAMESPACE, getFrontstageStateSettingName(id), setting);
|
|
1013
|
+
}, 1000);
|
|
1014
|
+
}, [uiSettingsStorage]);
|
|
968
1015
|
React.useEffect(() => {
|
|
969
1016
|
return () => {
|
|
970
1017
|
saveSetting.cancel();
|
|
@@ -973,7 +1020,8 @@ function useSaveFrontstageSettings(frontstageDef) {
|
|
|
973
1020
|
React.useEffect(() => {
|
|
974
1021
|
if (!nineZone || nineZone.draggedTab)
|
|
975
1022
|
return;
|
|
976
|
-
|
|
1023
|
+
const savedWidgets = frontstageDef.savedWidgetDefs || [];
|
|
1024
|
+
saveSetting(frontstageDef, nineZone, savedWidgets);
|
|
977
1025
|
}, [frontstageDef, nineZone, saveSetting]);
|
|
978
1026
|
}
|
|
979
1027
|
exports.useSaveFrontstageSettings = useSaveFrontstageSettings;
|
|
@@ -1012,7 +1060,7 @@ function useFrontstageManager(frontstageDef, useToolAsToolSettingsLabel) {
|
|
|
1012
1060
|
React.useEffect(() => {
|
|
1013
1061
|
const listener = createListener(frontstageDef, ({ widgetDef, widgetState }) => {
|
|
1014
1062
|
(0, core_bentley_1.assert)(!!frontstageDef.nineZoneState);
|
|
1015
|
-
frontstageDef.nineZoneState =
|
|
1063
|
+
frontstageDef.nineZoneState = setWidgetState(frontstageDef.nineZoneState, widgetDef, widgetState);
|
|
1016
1064
|
});
|
|
1017
1065
|
FrontstageManager_1.FrontstageManager.onWidgetStateChangedEvent.addListener(listener);
|
|
1018
1066
|
return () => {
|
|
@@ -1022,7 +1070,7 @@ function useFrontstageManager(frontstageDef, useToolAsToolSettingsLabel) {
|
|
|
1022
1070
|
React.useEffect(() => {
|
|
1023
1071
|
const listener = createListener(frontstageDef, ({ widgetDef }) => {
|
|
1024
1072
|
(0, core_bentley_1.assert)(!!frontstageDef.nineZoneState);
|
|
1025
|
-
frontstageDef.nineZoneState =
|
|
1073
|
+
frontstageDef.nineZoneState = showWidget(frontstageDef.nineZoneState, widgetDef.id);
|
|
1026
1074
|
});
|
|
1027
1075
|
FrontstageManager_1.FrontstageManager.onWidgetShowEvent.addListener(listener);
|
|
1028
1076
|
return () => {
|
|
@@ -1032,8 +1080,8 @@ function useFrontstageManager(frontstageDef, useToolAsToolSettingsLabel) {
|
|
|
1032
1080
|
React.useEffect(() => {
|
|
1033
1081
|
const listener = createListener(frontstageDef, ({ widgetDef }) => {
|
|
1034
1082
|
(0, core_bentley_1.assert)(!!frontstageDef.nineZoneState);
|
|
1035
|
-
let nineZoneState =
|
|
1036
|
-
nineZoneState =
|
|
1083
|
+
let nineZoneState = showWidget(frontstageDef.nineZoneState, widgetDef.id);
|
|
1084
|
+
nineZoneState = expandWidget(nineZoneState, widgetDef.id);
|
|
1037
1085
|
frontstageDef.nineZoneState = nineZoneState;
|
|
1038
1086
|
});
|
|
1039
1087
|
FrontstageManager_1.FrontstageManager.onWidgetExpandEvent.addListener(listener);
|
|
@@ -1062,7 +1110,7 @@ function useFrontstageManager(frontstageDef, useToolAsToolSettingsLabel) {
|
|
|
1062
1110
|
const listener = createListener(frontstageDef, ({ widgetDef }) => {
|
|
1063
1111
|
(0, core_bentley_1.assert)(!!frontstageDef.nineZoneState);
|
|
1064
1112
|
const label = widgetDef.label;
|
|
1065
|
-
frontstageDef.nineZoneState =
|
|
1113
|
+
frontstageDef.nineZoneState = setWidgetLabel(frontstageDef.nineZoneState, widgetDef.id, label);
|
|
1066
1114
|
});
|
|
1067
1115
|
FrontstageManager_1.FrontstageManager.onWidgetLabelChangedEvent.addListener(listener);
|
|
1068
1116
|
return () => {
|
|
@@ -1077,7 +1125,7 @@ function useFrontstageManager(frontstageDef, useToolAsToolSettingsLabel) {
|
|
|
1077
1125
|
(0, core_bentley_1.assert)(!!frontstageDef.nineZoneState);
|
|
1078
1126
|
const label = useToolAsToolSettingsLabel ?
|
|
1079
1127
|
((_a = core_frontend_1.IModelApp.tools.find(toolId)) === null || _a === void 0 ? void 0 : _a.flyover) || defaultLabel : defaultLabel;
|
|
1080
|
-
frontstageDef.nineZoneState =
|
|
1128
|
+
frontstageDef.nineZoneState = setWidgetLabel(frontstageDef.nineZoneState, appui_layout_react_1.toolSettingsTabId, label);
|
|
1081
1129
|
});
|
|
1082
1130
|
// Whenever the frontstageDef or the useTool... changes, keep the label up to date.
|
|
1083
1131
|
updateLabel();
|
|
@@ -1110,7 +1158,7 @@ function useItemsManager(frontstageDef) {
|
|
|
1110
1158
|
return;
|
|
1111
1159
|
state = addMissingWidgets(def, state);
|
|
1112
1160
|
state = removeMissingWidgets(def, state);
|
|
1113
|
-
state =
|
|
1161
|
+
state = hideWidgets(state, def); // TODO: should only apply to widgets provided by registered provider in onUiProviderRegisteredEvent.
|
|
1114
1162
|
def.nineZoneState = state;
|
|
1115
1163
|
};
|
|
1116
1164
|
React.useEffect(() => {
|
|
@@ -1124,48 +1172,8 @@ function useItemsManager(frontstageDef) {
|
|
|
1124
1172
|
}, [frontstageDef]);
|
|
1125
1173
|
}
|
|
1126
1174
|
exports.useItemsManager = useItemsManager;
|
|
1127
|
-
function tabShownInCurrentWidget(def, state) {
|
|
1128
|
-
for (const [, widget] of Object.entries(state.widgets)) {
|
|
1129
|
-
const foundTab = widget.tabs.find((tabId) => tabId === def.id);
|
|
1130
|
-
// istanbul ignore else
|
|
1131
|
-
if (foundTab)
|
|
1132
|
-
return true;
|
|
1133
|
-
}
|
|
1134
|
-
return false;
|
|
1135
|
-
}
|
|
1136
1175
|
// istanbul ignore next
|
|
1137
1176
|
function determineNewWidgets(defs, state) {
|
|
1138
|
-
|
|
1139
|
-
return (defs || []).filter((def) => !(def.id in state.tabs) || !tabShownInCurrentWidget(def, state));
|
|
1140
|
-
}
|
|
1141
|
-
/** @internal */
|
|
1142
|
-
async function saveFrontstagePopoutWidgetSizeAndPosition(state, stageId, stageVersion, childWindowId, childWindow) {
|
|
1143
|
-
const location = (0, appui_layout_react_1.findWidget)(state, childWindowId);
|
|
1144
|
-
// istanbul ignore else
|
|
1145
|
-
if (location) {
|
|
1146
|
-
const adjustmentWidth = core_bentley_1.ProcessDetector.isElectronAppFrontend ? 16 : 0;
|
|
1147
|
-
const adjustmentHeight = core_bentley_1.ProcessDetector.isElectronAppFrontend ? 39 : 0;
|
|
1148
|
-
const newState = (0, immer_1.default)(state, (draft) => {
|
|
1149
|
-
const widget = draft.widgets[childWindowId];
|
|
1150
|
-
const tab = draft.tabs[widget.activeTabId];
|
|
1151
|
-
tab.preferredPopoutWidgetSize = {
|
|
1152
|
-
x: childWindow.screenX,
|
|
1153
|
-
y: childWindow.screenY,
|
|
1154
|
-
width: childWindow.innerWidth + adjustmentWidth,
|
|
1155
|
-
height: childWindow.innerHeight + adjustmentHeight,
|
|
1156
|
-
};
|
|
1157
|
-
});
|
|
1158
|
-
const setting = {
|
|
1159
|
-
id: stageId,
|
|
1160
|
-
nineZone: packNineZoneState(newState),
|
|
1161
|
-
stateVersion,
|
|
1162
|
-
version: stageVersion,
|
|
1163
|
-
};
|
|
1164
|
-
await UiFramework_1.UiFramework.getUiStateStorage().saveSetting(exports.FRONTSTAGE_SETTINGS_NAMESPACE, getFrontstageStateSettingName(stageId), setting);
|
|
1165
|
-
return newState;
|
|
1166
|
-
}
|
|
1167
|
-
// istanbul ignore next
|
|
1168
|
-
return state;
|
|
1177
|
+
return (defs || []).filter((def) => !(def.id in state.tabs));
|
|
1169
1178
|
}
|
|
1170
|
-
exports.saveFrontstagePopoutWidgetSizeAndPosition = saveFrontstagePopoutWidgetSizeAndPosition;
|
|
1171
1179
|
//# sourceMappingURL=Frontstage.js.map
|