@itwin/appui-react 3.4.0-dev.36 → 3.4.0-dev.40
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
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
import * as React from "react";
|
|
11
11
|
import { IModelApp } from "@itwin/core-frontend";
|
|
12
12
|
import { StagePanelLocation, StageUsage, UiError, WidgetState } from "@itwin/appui-abstract";
|
|
13
|
-
import {
|
|
13
|
+
import { Rectangle } from "@itwin/core-react";
|
|
14
|
+
import { dockWidgetContainer, floatWidget, getTabLocation, getWidgetLocation, isFloatingTabLocation, isPanelTabLocation, isPopoutTabLocation, isPopoutWidgetLocation, panelSides, popoutWidgetToChildWindow, setFloatingWidgetContainerBounds, } from "@itwin/appui-layout-react";
|
|
14
15
|
import { ContentGroupProvider } from "../content/ContentGroup";
|
|
15
16
|
import { ContentLayoutManager } from "../content/ContentLayoutManager";
|
|
16
17
|
import { ContentViewManager } from "../content/ContentViewManager";
|
|
@@ -21,8 +22,7 @@ import { Frontstage } from "./Frontstage";
|
|
|
21
22
|
import { FrontstageManager } from "./FrontstageManager";
|
|
22
23
|
import { TimeTracker } from "../configurableui/TimeTracker";
|
|
23
24
|
import { PopoutWidget } from "../childwindow/PopoutWidget";
|
|
24
|
-
import {
|
|
25
|
-
import { BentleyStatus } from "@itwin/core-bentley";
|
|
25
|
+
import { assert, BentleyStatus, ProcessDetector } from "@itwin/core-bentley";
|
|
26
26
|
import { ContentDialogManager } from "../dialog/ContentDialogManager";
|
|
27
27
|
/** FrontstageDef class provides an API for a Frontstage.
|
|
28
28
|
* @public
|
|
@@ -183,6 +183,11 @@ export class FrontstageDef {
|
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
185
|
/** @internal */
|
|
186
|
+
get savedWidgetDefs() { return this._savedWidgetDefs; }
|
|
187
|
+
set savedWidgetDefs(widgets) {
|
|
188
|
+
this._savedWidgetDefs = widgets;
|
|
189
|
+
}
|
|
190
|
+
/** @internal */
|
|
186
191
|
get timeTracker() { return this._timeTracker; }
|
|
187
192
|
/** Created a [[FrontstageDef]] and initialize it */
|
|
188
193
|
static async create(provider) {
|
|
@@ -552,17 +557,12 @@ export class FrontstageDef {
|
|
|
552
557
|
}
|
|
553
558
|
/** @beta */
|
|
554
559
|
restoreLayout() {
|
|
555
|
-
for (const zoneDef of this.zoneDefs) {
|
|
556
|
-
for (const widgetDef of zoneDef.widgetDefs) {
|
|
557
|
-
widgetDef.setWidgetState(widgetDef.defaultState);
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
560
|
for (const panelDef of this.panelDefs) {
|
|
561
561
|
panelDef.size = panelDef.defaultSize;
|
|
562
562
|
panelDef.panelState = panelDef.defaultState;
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
563
|
+
}
|
|
564
|
+
for (const widgetDef of this.widgetDefs) {
|
|
565
|
+
widgetDef.setWidgetState(widgetDef.defaultState);
|
|
566
566
|
}
|
|
567
567
|
FrontstageManager.onFrontstageRestoreLayoutEvent.emit({ frontstageDef: this });
|
|
568
568
|
}
|
|
@@ -572,11 +572,11 @@ export class FrontstageDef {
|
|
|
572
572
|
getWidgetCurrentState(widgetDef) {
|
|
573
573
|
// istanbul ignore else
|
|
574
574
|
if (this.nineZoneState) {
|
|
575
|
-
const location =
|
|
575
|
+
const location = getTabLocation(this.nineZoneState, widgetDef.id);
|
|
576
576
|
// istanbul ignore next
|
|
577
577
|
if (!location)
|
|
578
578
|
return WidgetState.Hidden;
|
|
579
|
-
if (
|
|
579
|
+
if (isFloatingTabLocation(location)) {
|
|
580
580
|
const floatingWidget = this.nineZoneState.floatingWidgets.byId[location.floatingWidgetId];
|
|
581
581
|
if (floatingWidget && floatingWidget.hidden)
|
|
582
582
|
return WidgetState.Hidden;
|
|
@@ -615,20 +615,20 @@ export class FrontstageDef {
|
|
|
615
615
|
isPopoutWidget(widgetId) {
|
|
616
616
|
// istanbul ignore else
|
|
617
617
|
if (this.nineZoneState) {
|
|
618
|
-
const location =
|
|
618
|
+
const location = getTabLocation(this.nineZoneState, widgetId);
|
|
619
619
|
// istanbul ignore else
|
|
620
620
|
if (location)
|
|
621
|
-
return
|
|
621
|
+
return isPopoutTabLocation(location);
|
|
622
622
|
}
|
|
623
623
|
return false;
|
|
624
624
|
}
|
|
625
625
|
isFloatingWidget(widgetId) {
|
|
626
626
|
// istanbul ignore else
|
|
627
627
|
if (this.nineZoneState) {
|
|
628
|
-
const location =
|
|
628
|
+
const location = getTabLocation(this.nineZoneState, widgetId);
|
|
629
629
|
// istanbul ignore else
|
|
630
630
|
if (location)
|
|
631
|
-
return
|
|
631
|
+
return isFloatingTabLocation(location);
|
|
632
632
|
}
|
|
633
633
|
return false;
|
|
634
634
|
}
|
|
@@ -643,10 +643,10 @@ export class FrontstageDef {
|
|
|
643
643
|
floatWidget(widgetId, point, size) {
|
|
644
644
|
// istanbul ignore else
|
|
645
645
|
if (this.nineZoneState) {
|
|
646
|
-
const location =
|
|
646
|
+
const location = getTabLocation(this.nineZoneState, widgetId);
|
|
647
647
|
if (location) {
|
|
648
648
|
let popoutWidgetContainerId;
|
|
649
|
-
if (
|
|
649
|
+
if (isPopoutTabLocation(location)) {
|
|
650
650
|
popoutWidgetContainerId = location.popoutWidgetId;
|
|
651
651
|
}
|
|
652
652
|
const state = floatWidget(this.nineZoneState, widgetId, point, size);
|
|
@@ -668,21 +668,21 @@ export class FrontstageDef {
|
|
|
668
668
|
let widgetIsVisible = false;
|
|
669
669
|
// istanbul ignore else
|
|
670
670
|
if (this.nineZoneState) {
|
|
671
|
-
const tabLocation =
|
|
671
|
+
const tabLocation = getTabLocation(this.nineZoneState, widgetId);
|
|
672
672
|
// istanbul ignore else
|
|
673
673
|
if (tabLocation) {
|
|
674
|
-
if (
|
|
674
|
+
if (isFloatingTabLocation(tabLocation)) {
|
|
675
675
|
const floatingWidget = this.nineZoneState.floatingWidgets.byId[tabLocation.floatingWidgetId];
|
|
676
676
|
// istanbul ignore else
|
|
677
677
|
if (!!!floatingWidget.hidden)
|
|
678
678
|
widgetIsVisible = true;
|
|
679
679
|
}
|
|
680
|
-
else if (
|
|
680
|
+
else if (isPopoutTabLocation(tabLocation)) {
|
|
681
681
|
widgetIsVisible = true;
|
|
682
682
|
}
|
|
683
683
|
else {
|
|
684
684
|
// istanbul ignore else
|
|
685
|
-
if (
|
|
685
|
+
if (isPanelTabLocation(tabLocation)) {
|
|
686
686
|
const panel = this.nineZoneState.panels[tabLocation.side];
|
|
687
687
|
const widgetDef = this.findWidgetDef(widgetId);
|
|
688
688
|
if (widgetDef && widgetDef.state === WidgetState.Open && !panel.collapsed)
|
|
@@ -696,25 +696,33 @@ export class FrontstageDef {
|
|
|
696
696
|
/** Opens window for specified PopoutWidget container. Used to reopen popout when running in Electron.
|
|
697
697
|
* @internal */
|
|
698
698
|
openPopoutWidgetContainer(state, widgetContainerId) {
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
}
|
|
699
|
+
const location = getWidgetLocation(state, widgetContainerId);
|
|
700
|
+
// istanbul ignore next
|
|
701
|
+
if (!location)
|
|
702
|
+
return;
|
|
703
|
+
// istanbul ignore next
|
|
704
|
+
if (!isPopoutWidgetLocation(location))
|
|
705
|
+
return;
|
|
706
|
+
const widget = state.widgets[widgetContainerId];
|
|
707
|
+
const popoutWidget = state.popoutWidgets.byId[location.popoutWidgetId];
|
|
708
|
+
// Popout widget should only contain a single tab.
|
|
709
|
+
// istanbul ignore next
|
|
710
|
+
if (widget.tabs.length !== 1)
|
|
711
|
+
return;
|
|
712
|
+
const tabId = widget.tabs[0];
|
|
713
|
+
const widgetDef = this.findWidgetDef(tabId);
|
|
714
|
+
// istanbul ignore next
|
|
715
|
+
if (!widgetDef)
|
|
716
|
+
return;
|
|
717
|
+
const popoutContent = (React.createElement(PopoutWidget, { widgetContainerId: widgetContainerId, widgetDef: widgetDef }));
|
|
718
|
+
const bounds = Rectangle.create(popoutWidget.bounds);
|
|
719
|
+
const position = {
|
|
720
|
+
width: bounds.getWidth(),
|
|
721
|
+
height: bounds.getHeight(),
|
|
722
|
+
left: bounds.left,
|
|
723
|
+
top: bounds.top,
|
|
724
|
+
};
|
|
725
|
+
UiFramework.childWindowManager.openChildWindow(widgetContainerId, widgetDef.label, popoutContent, position, UiFramework.useDefaultPopoutUrl);
|
|
718
726
|
}
|
|
719
727
|
/** Create a new popout/child window that contains the widget specified by its Id. Supported only when in
|
|
720
728
|
* UI 2.0 or higher.
|
|
@@ -725,42 +733,43 @@ export class FrontstageDef {
|
|
|
725
733
|
* @beta
|
|
726
734
|
*/
|
|
727
735
|
popoutWidget(widgetId, point, size) {
|
|
728
|
-
// istanbul ignore
|
|
729
|
-
if (this.nineZoneState)
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
}
|
|
763
|
-
|
|
736
|
+
// istanbul ignore next
|
|
737
|
+
if (!this.nineZoneState)
|
|
738
|
+
return;
|
|
739
|
+
let location = getTabLocation(this.nineZoneState, widgetId);
|
|
740
|
+
if (!location || isPopoutTabLocation(location))
|
|
741
|
+
return;
|
|
742
|
+
const widgetDef = this.findWidgetDef(widgetId);
|
|
743
|
+
// istanbul ignore next
|
|
744
|
+
if (!widgetDef)
|
|
745
|
+
return;
|
|
746
|
+
// get the state to apply that will pop-out the specified WidgetTab to child window.
|
|
747
|
+
let preferredBounds = Rectangle.createFromSize({ height: 800, width: 600 });
|
|
748
|
+
// istanbul ignore next
|
|
749
|
+
if (widgetDef.popoutBounds)
|
|
750
|
+
preferredBounds = widgetDef.popoutBounds;
|
|
751
|
+
if (size)
|
|
752
|
+
preferredBounds = preferredBounds.setSize(size);
|
|
753
|
+
if (point)
|
|
754
|
+
preferredBounds = preferredBounds.setPosition(point);
|
|
755
|
+
const state = popoutWidgetToChildWindow(this.nineZoneState, widgetId, preferredBounds);
|
|
756
|
+
this.nineZoneState = state;
|
|
757
|
+
// now that the state is updated get the id of the container that houses the widgetTab/widgetId
|
|
758
|
+
location = getTabLocation(state, widgetId);
|
|
759
|
+
assert(!!location && isPopoutTabLocation(location));
|
|
760
|
+
const widgetContainerId = location.widgetId;
|
|
761
|
+
const popoutWidget = state.popoutWidgets.byId[widgetContainerId];
|
|
762
|
+
const bounds = Rectangle.create(popoutWidget.bounds);
|
|
763
|
+
setTimeout(() => {
|
|
764
|
+
const popoutContent = (React.createElement(PopoutWidget, { widgetContainerId: widgetContainerId, widgetDef: widgetDef }));
|
|
765
|
+
const position = {
|
|
766
|
+
width: bounds.getWidth(),
|
|
767
|
+
height: bounds.getHeight(),
|
|
768
|
+
left: bounds.left,
|
|
769
|
+
top: bounds.top,
|
|
770
|
+
};
|
|
771
|
+
UiFramework.childWindowManager.openChildWindow(widgetContainerId, widgetDef.label, popoutContent, position, UiFramework.useDefaultPopoutUrl);
|
|
772
|
+
});
|
|
764
773
|
}
|
|
765
774
|
get isStageClosing() {
|
|
766
775
|
return this._isStageClosing;
|
|
@@ -772,12 +781,23 @@ export class FrontstageDef {
|
|
|
772
781
|
return this._isReady;
|
|
773
782
|
}
|
|
774
783
|
/** @internal */
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
784
|
+
saveChildWindowSizeAndPosition(childWindowId, childWindow) {
|
|
785
|
+
if (!this.nineZoneState)
|
|
786
|
+
return;
|
|
787
|
+
const location = getWidgetLocation(this.nineZoneState, childWindowId);
|
|
788
|
+
if (!location || !isPopoutWidgetLocation(location))
|
|
789
|
+
return;
|
|
790
|
+
const widget = this.nineZoneState.widgets[location.popoutWidgetId];
|
|
791
|
+
const tabId = widget.tabs[0];
|
|
792
|
+
const widgetDef = this.findWidgetDef(tabId);
|
|
793
|
+
if (!widgetDef)
|
|
794
|
+
return;
|
|
795
|
+
const adjustmentWidth = ProcessDetector.isElectronAppFrontend ? 16 : 0;
|
|
796
|
+
const adjustmentHeight = ProcessDetector.isElectronAppFrontend ? 39 : 0;
|
|
797
|
+
const width = childWindow.innerWidth + adjustmentWidth;
|
|
798
|
+
const height = childWindow.innerHeight + adjustmentHeight;
|
|
799
|
+
const bounds = Rectangle.createFromSize({ width, height }).offset({ x: childWindow.screenX, y: childWindow.screenY });
|
|
800
|
+
widgetDef.popoutBounds = bounds;
|
|
781
801
|
}
|
|
782
802
|
/** @internal */
|
|
783
803
|
setFloatingWidgetBoundsInternal(floatingWidgetId, bounds, inhibitNineZoneStateChangedEvent = false) {
|
|
@@ -795,16 +815,16 @@ export class FrontstageDef {
|
|
|
795
815
|
* @internal
|
|
796
816
|
*/
|
|
797
817
|
dockPopoutWidgetContainer(widgetContainerId) {
|
|
798
|
-
if (this.nineZoneState)
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
818
|
+
if (!this.nineZoneState)
|
|
819
|
+
return;
|
|
820
|
+
// Make sure the widgetContainerId is still in popout state. We don't want to set it to docked if the window is being closed because
|
|
821
|
+
// an API call has moved the widget from a popout state to a floating state.
|
|
822
|
+
// istanbul ignore else
|
|
823
|
+
const location = getWidgetLocation(this.nineZoneState, widgetContainerId);
|
|
824
|
+
if (!location || !isPopoutWidgetLocation(location))
|
|
825
|
+
return;
|
|
826
|
+
const state = dockWidgetContainer(this.nineZoneState, widgetContainerId, true);
|
|
827
|
+
this.nineZoneState = state;
|
|
808
828
|
}
|
|
809
829
|
/** Finds the container with the specified widget and re-docks all widgets
|
|
810
830
|
* back to the panel zone location that was used when the floating container
|
|
@@ -815,12 +835,12 @@ export class FrontstageDef {
|
|
|
815
835
|
dockWidgetContainer(widgetId) {
|
|
816
836
|
// istanbul ignore else
|
|
817
837
|
if (this.nineZoneState) {
|
|
818
|
-
const location =
|
|
838
|
+
const location = getTabLocation(this.nineZoneState, widgetId);
|
|
819
839
|
if (location) {
|
|
820
840
|
const widgetContainerId = location.widgetId;
|
|
821
841
|
const state = dockWidgetContainer(this.nineZoneState, widgetContainerId, true);
|
|
822
842
|
state && (this.nineZoneState = state);
|
|
823
|
-
if (
|
|
843
|
+
if (isPopoutTabLocation(location)) {
|
|
824
844
|
UiFramework.childWindowManager.closeChildWindow(location.widgetId, true);
|
|
825
845
|
}
|
|
826
846
|
}
|
|
@@ -840,9 +860,9 @@ export class FrontstageDef {
|
|
|
840
860
|
getFloatingWidgetContainerIdByWidgetId(widgetId) {
|
|
841
861
|
if (!this.nineZoneState)
|
|
842
862
|
return undefined;
|
|
843
|
-
const location =
|
|
863
|
+
const location = getTabLocation(this.nineZoneState, widgetId);
|
|
844
864
|
// istanbul ignore else
|
|
845
|
-
if (location &&
|
|
865
|
+
if (location && isFloatingTabLocation(location)) {
|
|
846
866
|
return location.floatingWidgetId;
|
|
847
867
|
}
|
|
848
868
|
// istanbul ignore next
|
|
@@ -863,5 +883,29 @@ export class FrontstageDef {
|
|
|
863
883
|
}
|
|
864
884
|
return undefined;
|
|
865
885
|
}
|
|
886
|
+
*_widgetDefs() {
|
|
887
|
+
for (const zoneDef of this.zoneDefs) {
|
|
888
|
+
for (const widgetDef of zoneDef.widgetDefs) {
|
|
889
|
+
yield widgetDef;
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
for (const panelDef of this.panelDefs) {
|
|
893
|
+
for (const widgetDef of panelDef.widgetDefs) {
|
|
894
|
+
yield widgetDef;
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
return undefined;
|
|
898
|
+
}
|
|
899
|
+
/** Iterable of all widget definitions in a frontstage.
|
|
900
|
+
* @internal
|
|
901
|
+
*/
|
|
902
|
+
get widgetDefs() {
|
|
903
|
+
const defs = this._widgetDefs();
|
|
904
|
+
return {
|
|
905
|
+
[Symbol.iterator]() {
|
|
906
|
+
return defs;
|
|
907
|
+
},
|
|
908
|
+
};
|
|
909
|
+
}
|
|
866
910
|
}
|
|
867
911
|
//# sourceMappingURL=FrontstageDef.js.map
|