@itwin/appui-react 4.5.1 → 4.6.1

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.
Files changed (194) hide show
  1. package/CHANGELOG.md +20 -1
  2. package/lib/cjs/appui-react/accudraw/MenuButton.d.ts +2 -2
  3. package/lib/cjs/appui-react/accudraw/MenuButton.d.ts.map +1 -1
  4. package/lib/cjs/appui-react/accudraw/MenuButton.js.map +1 -1
  5. package/lib/cjs/appui-react/backstage/BackstageComposer.d.ts.map +1 -1
  6. package/lib/cjs/appui-react/backstage/BackstageComposer.js.map +1 -1
  7. package/lib/cjs/appui-react/childwindow/CopyStyles.d.ts.map +1 -1
  8. package/lib/cjs/appui-react/childwindow/CopyStyles.js +3 -1
  9. package/lib/cjs/appui-react/childwindow/CopyStyles.js.map +1 -1
  10. package/lib/cjs/appui-react/childwindow/InternalChildWindowManager.d.ts.map +1 -1
  11. package/lib/cjs/appui-react/childwindow/InternalChildWindowManager.js +2 -1
  12. package/lib/cjs/appui-react/childwindow/InternalChildWindowManager.js.map +1 -1
  13. package/lib/cjs/appui-react/cursor/CursorInformation.d.ts +6 -6
  14. package/lib/cjs/appui-react/cursor/CursorInformation.d.ts.map +1 -1
  15. package/lib/cjs/appui-react/cursor/CursorInformation.js.map +1 -1
  16. package/lib/cjs/appui-react/cursor/cursormenu/CursorMenu.d.ts.map +1 -1
  17. package/lib/cjs/appui-react/cursor/cursormenu/CursorMenu.js.map +1 -1
  18. package/lib/cjs/appui-react/cursor/cursorpopup/CursorPopup.d.ts +4 -4
  19. package/lib/cjs/appui-react/cursor/cursorpopup/CursorPopup.d.ts.map +1 -1
  20. package/lib/cjs/appui-react/cursor/cursorpopup/CursorPopup.js.map +1 -1
  21. package/lib/cjs/appui-react/cursor/cursorpopup/CursorPopupManager.d.ts +5 -5
  22. package/lib/cjs/appui-react/cursor/cursorpopup/CursorPopupManager.d.ts.map +1 -1
  23. package/lib/cjs/appui-react/cursor/cursorpopup/CursorPopupManager.js.map +1 -1
  24. package/lib/cjs/appui-react/cursor/cursorprompt/CursorPrompt.d.ts +2 -2
  25. package/lib/cjs/appui-react/cursor/cursorprompt/CursorPrompt.d.ts.map +1 -1
  26. package/lib/cjs/appui-react/cursor/cursorprompt/CursorPrompt.js.map +1 -1
  27. package/lib/cjs/appui-react/dialog/ContentDialog.js.map +1 -1
  28. package/lib/cjs/appui-react/feedback/ElementTooltip.d.ts +1 -2
  29. package/lib/cjs/appui-react/feedback/ElementTooltip.d.ts.map +1 -1
  30. package/lib/cjs/appui-react/feedback/ElementTooltip.js.map +1 -1
  31. package/lib/cjs/appui-react/frontstage/FrontstageDef.d.ts +22 -26
  32. package/lib/cjs/appui-react/frontstage/FrontstageDef.d.ts.map +1 -1
  33. package/lib/cjs/appui-react/frontstage/FrontstageDef.js +185 -254
  34. package/lib/cjs/appui-react/frontstage/FrontstageDef.js.map +1 -1
  35. package/lib/cjs/appui-react/frontstage/InternalFrontstageManager.d.ts +1 -7
  36. package/lib/cjs/appui-react/frontstage/InternalFrontstageManager.d.ts.map +1 -1
  37. package/lib/cjs/appui-react/frontstage/InternalFrontstageManager.js +0 -6
  38. package/lib/cjs/appui-react/frontstage/InternalFrontstageManager.js.map +1 -1
  39. package/lib/cjs/appui-react/hooks/useActiveIModelConnection.d.ts.map +1 -1
  40. package/lib/cjs/appui-react/hooks/useActiveIModelConnection.js.map +1 -1
  41. package/lib/cjs/appui-react/hooks/useActiveViewport.d.ts.map +1 -1
  42. package/lib/cjs/appui-react/hooks/useActiveViewport.js.map +1 -1
  43. package/lib/cjs/appui-react/keyboardshortcut/InternalKeyboardShortcut.d.ts.map +1 -1
  44. package/lib/cjs/appui-react/keyboardshortcut/InternalKeyboardShortcut.js.map +1 -1
  45. package/lib/cjs/appui-react/messages/MessageManager.d.ts +0 -1
  46. package/lib/cjs/appui-react/messages/MessageManager.d.ts.map +1 -1
  47. package/lib/cjs/appui-react/messages/MessageManager.js +1 -2
  48. package/lib/cjs/appui-react/messages/MessageManager.js.map +1 -1
  49. package/lib/cjs/appui-react/messages/Pointer.d.ts +1 -2
  50. package/lib/cjs/appui-react/messages/Pointer.d.ts.map +1 -1
  51. package/lib/cjs/appui-react/messages/Pointer.js +1 -1
  52. package/lib/cjs/appui-react/messages/Pointer.js.map +1 -1
  53. package/lib/cjs/appui-react/popup/PositionPopup.d.ts +2 -2
  54. package/lib/cjs/appui-react/popup/PositionPopup.d.ts.map +1 -1
  55. package/lib/cjs/appui-react/popup/PositionPopup.js.map +1 -1
  56. package/lib/cjs/appui-react/settings/ui/UiSettingsPage.js.map +1 -1
  57. package/lib/cjs/appui-react/stagepanels/StagePanelDef.d.ts +16 -20
  58. package/lib/cjs/appui-react/stagepanels/StagePanelDef.d.ts.map +1 -1
  59. package/lib/cjs/appui-react/stagepanels/StagePanelDef.js +80 -115
  60. package/lib/cjs/appui-react/stagepanels/StagePanelDef.js.map +1 -1
  61. package/lib/cjs/appui-react/statusfields/MessageCenter.d.ts.map +1 -1
  62. package/lib/cjs/appui-react/statusfields/MessageCenter.js +1 -2
  63. package/lib/cjs/appui-react/statusfields/MessageCenter.js.map +1 -1
  64. package/lib/cjs/appui-react/syncui/InternalSyncUiEventDispatcher.d.ts +36 -0
  65. package/lib/cjs/appui-react/syncui/InternalSyncUiEventDispatcher.d.ts.map +1 -0
  66. package/lib/cjs/appui-react/syncui/InternalSyncUiEventDispatcher.js +134 -0
  67. package/lib/cjs/appui-react/syncui/InternalSyncUiEventDispatcher.js.map +1 -0
  68. package/lib/cjs/appui-react/syncui/SyncUiEventDispatcher.d.ts +1 -1
  69. package/lib/cjs/appui-react/syncui/SyncUiEventDispatcher.d.ts.map +1 -1
  70. package/lib/cjs/appui-react/syncui/SyncUiEventDispatcher.js +2 -2
  71. package/lib/cjs/appui-react/syncui/SyncUiEventDispatcher.js.map +1 -1
  72. package/lib/cjs/appui-react/syncui/UiSyncEvent.d.ts +16 -0
  73. package/lib/cjs/appui-react/syncui/UiSyncEvent.d.ts.map +1 -0
  74. package/lib/cjs/appui-react/syncui/UiSyncEvent.js +18 -0
  75. package/lib/cjs/appui-react/syncui/UiSyncEvent.js.map +1 -0
  76. package/lib/cjs/appui-react/uistate/AppUiSettings.d.ts.map +1 -1
  77. package/lib/cjs/appui-react/uistate/AppUiSettings.js.map +1 -1
  78. package/lib/cjs/appui-react/uistate/useUiStateStorage.d.ts.map +1 -1
  79. package/lib/cjs/appui-react/uistate/useUiStateStorage.js.map +1 -1
  80. package/lib/cjs/appui-react/widget-panels/Frontstage.d.ts +7 -29
  81. package/lib/cjs/appui-react/widget-panels/Frontstage.d.ts.map +1 -1
  82. package/lib/cjs/appui-react/widget-panels/Frontstage.js +101 -434
  83. package/lib/cjs/appui-react/widget-panels/Frontstage.js.map +1 -1
  84. package/lib/cjs/appui-react/widget-panels/ToolSettings.d.ts.map +1 -1
  85. package/lib/cjs/appui-react/widget-panels/ToolSettings.js +16 -3
  86. package/lib/cjs/appui-react/widget-panels/ToolSettings.js.map +1 -1
  87. package/lib/cjs/appui-react/widgets/Widget.d.ts +10 -4
  88. package/lib/cjs/appui-react/widgets/Widget.d.ts.map +1 -1
  89. package/lib/cjs/appui-react/widgets/Widget.js.map +1 -1
  90. package/lib/cjs/appui-react/widgets/WidgetDef.d.ts +9 -29
  91. package/lib/cjs/appui-react/widgets/WidgetDef.d.ts.map +1 -1
  92. package/lib/cjs/appui-react/widgets/WidgetDef.js +89 -46
  93. package/lib/cjs/appui-react/widgets/WidgetDef.js.map +1 -1
  94. package/lib/cjs/appui-react.d.ts +1 -0
  95. package/lib/cjs/appui-react.d.ts.map +1 -1
  96. package/lib/cjs/appui-react.js +1 -0
  97. package/lib/cjs/appui-react.js.map +1 -1
  98. package/lib/esm/appui-react/accudraw/MenuButton.d.ts +2 -2
  99. package/lib/esm/appui-react/accudraw/MenuButton.d.ts.map +1 -1
  100. package/lib/esm/appui-react/accudraw/MenuButton.js.map +1 -1
  101. package/lib/esm/appui-react/backstage/BackstageComposer.d.ts.map +1 -1
  102. package/lib/esm/appui-react/backstage/BackstageComposer.js.map +1 -1
  103. package/lib/esm/appui-react/childwindow/CopyStyles.d.ts.map +1 -1
  104. package/lib/esm/appui-react/childwindow/CopyStyles.js +3 -1
  105. package/lib/esm/appui-react/childwindow/CopyStyles.js.map +1 -1
  106. package/lib/esm/appui-react/childwindow/InternalChildWindowManager.d.ts.map +1 -1
  107. package/lib/esm/appui-react/childwindow/InternalChildWindowManager.js +2 -1
  108. package/lib/esm/appui-react/childwindow/InternalChildWindowManager.js.map +1 -1
  109. package/lib/esm/appui-react/cursor/CursorInformation.d.ts +6 -6
  110. package/lib/esm/appui-react/cursor/CursorInformation.d.ts.map +1 -1
  111. package/lib/esm/appui-react/cursor/CursorInformation.js.map +1 -1
  112. package/lib/esm/appui-react/cursor/cursormenu/CursorMenu.d.ts.map +1 -1
  113. package/lib/esm/appui-react/cursor/cursormenu/CursorMenu.js.map +1 -1
  114. package/lib/esm/appui-react/cursor/cursorpopup/CursorPopup.d.ts +4 -4
  115. package/lib/esm/appui-react/cursor/cursorpopup/CursorPopup.d.ts.map +1 -1
  116. package/lib/esm/appui-react/cursor/cursorpopup/CursorPopup.js.map +1 -1
  117. package/lib/esm/appui-react/cursor/cursorpopup/CursorPopupManager.d.ts +5 -5
  118. package/lib/esm/appui-react/cursor/cursorpopup/CursorPopupManager.d.ts.map +1 -1
  119. package/lib/esm/appui-react/cursor/cursorpopup/CursorPopupManager.js.map +1 -1
  120. package/lib/esm/appui-react/cursor/cursorprompt/CursorPrompt.d.ts +2 -2
  121. package/lib/esm/appui-react/cursor/cursorprompt/CursorPrompt.d.ts.map +1 -1
  122. package/lib/esm/appui-react/cursor/cursorprompt/CursorPrompt.js.map +1 -1
  123. package/lib/esm/appui-react/dialog/ContentDialog.js.map +1 -1
  124. package/lib/esm/appui-react/feedback/ElementTooltip.d.ts +1 -2
  125. package/lib/esm/appui-react/feedback/ElementTooltip.d.ts.map +1 -1
  126. package/lib/esm/appui-react/feedback/ElementTooltip.js.map +1 -1
  127. package/lib/esm/appui-react/frontstage/FrontstageDef.d.ts +22 -26
  128. package/lib/esm/appui-react/frontstage/FrontstageDef.d.ts.map +1 -1
  129. package/lib/esm/appui-react/frontstage/FrontstageDef.js +189 -258
  130. package/lib/esm/appui-react/frontstage/FrontstageDef.js.map +1 -1
  131. package/lib/esm/appui-react/frontstage/InternalFrontstageManager.d.ts +1 -7
  132. package/lib/esm/appui-react/frontstage/InternalFrontstageManager.d.ts.map +1 -1
  133. package/lib/esm/appui-react/frontstage/InternalFrontstageManager.js +0 -6
  134. package/lib/esm/appui-react/frontstage/InternalFrontstageManager.js.map +1 -1
  135. package/lib/esm/appui-react/hooks/useActiveIModelConnection.d.ts.map +1 -1
  136. package/lib/esm/appui-react/hooks/useActiveIModelConnection.js.map +1 -1
  137. package/lib/esm/appui-react/hooks/useActiveViewport.d.ts.map +1 -1
  138. package/lib/esm/appui-react/hooks/useActiveViewport.js.map +1 -1
  139. package/lib/esm/appui-react/keyboardshortcut/InternalKeyboardShortcut.d.ts.map +1 -1
  140. package/lib/esm/appui-react/keyboardshortcut/InternalKeyboardShortcut.js.map +1 -1
  141. package/lib/esm/appui-react/messages/MessageManager.d.ts +0 -1
  142. package/lib/esm/appui-react/messages/MessageManager.d.ts.map +1 -1
  143. package/lib/esm/appui-react/messages/MessageManager.js +1 -2
  144. package/lib/esm/appui-react/messages/MessageManager.js.map +1 -1
  145. package/lib/esm/appui-react/messages/Pointer.d.ts +1 -2
  146. package/lib/esm/appui-react/messages/Pointer.d.ts.map +1 -1
  147. package/lib/esm/appui-react/messages/Pointer.js +1 -1
  148. package/lib/esm/appui-react/messages/Pointer.js.map +1 -1
  149. package/lib/esm/appui-react/popup/PositionPopup.d.ts +2 -2
  150. package/lib/esm/appui-react/popup/PositionPopup.d.ts.map +1 -1
  151. package/lib/esm/appui-react/popup/PositionPopup.js.map +1 -1
  152. package/lib/esm/appui-react/settings/ui/UiSettingsPage.js.map +1 -1
  153. package/lib/esm/appui-react/stagepanels/StagePanelDef.d.ts +16 -20
  154. package/lib/esm/appui-react/stagepanels/StagePanelDef.d.ts.map +1 -1
  155. package/lib/esm/appui-react/stagepanels/StagePanelDef.js +78 -114
  156. package/lib/esm/appui-react/stagepanels/StagePanelDef.js.map +1 -1
  157. package/lib/esm/appui-react/statusfields/MessageCenter.d.ts.map +1 -1
  158. package/lib/esm/appui-react/statusfields/MessageCenter.js +1 -2
  159. package/lib/esm/appui-react/statusfields/MessageCenter.js.map +1 -1
  160. package/lib/esm/appui-react/syncui/InternalSyncUiEventDispatcher.d.ts +36 -0
  161. package/lib/esm/appui-react/syncui/InternalSyncUiEventDispatcher.d.ts.map +1 -0
  162. package/lib/esm/appui-react/syncui/InternalSyncUiEventDispatcher.js +130 -0
  163. package/lib/esm/appui-react/syncui/InternalSyncUiEventDispatcher.js.map +1 -0
  164. package/lib/esm/appui-react/syncui/SyncUiEventDispatcher.d.ts +1 -1
  165. package/lib/esm/appui-react/syncui/SyncUiEventDispatcher.d.ts.map +1 -1
  166. package/lib/esm/appui-react/syncui/SyncUiEventDispatcher.js +2 -2
  167. package/lib/esm/appui-react/syncui/SyncUiEventDispatcher.js.map +1 -1
  168. package/lib/esm/appui-react/syncui/UiSyncEvent.d.ts +16 -0
  169. package/lib/esm/appui-react/syncui/UiSyncEvent.d.ts.map +1 -0
  170. package/lib/esm/appui-react/syncui/UiSyncEvent.js +14 -0
  171. package/lib/esm/appui-react/syncui/UiSyncEvent.js.map +1 -0
  172. package/lib/esm/appui-react/uistate/AppUiSettings.d.ts.map +1 -1
  173. package/lib/esm/appui-react/uistate/AppUiSettings.js.map +1 -1
  174. package/lib/esm/appui-react/uistate/useUiStateStorage.d.ts.map +1 -1
  175. package/lib/esm/appui-react/uistate/useUiStateStorage.js.map +1 -1
  176. package/lib/esm/appui-react/widget-panels/Frontstage.d.ts +7 -29
  177. package/lib/esm/appui-react/widget-panels/Frontstage.d.ts.map +1 -1
  178. package/lib/esm/appui-react/widget-panels/Frontstage.js +104 -433
  179. package/lib/esm/appui-react/widget-panels/Frontstage.js.map +1 -1
  180. package/lib/esm/appui-react/widget-panels/ToolSettings.d.ts.map +1 -1
  181. package/lib/esm/appui-react/widget-panels/ToolSettings.js +16 -3
  182. package/lib/esm/appui-react/widget-panels/ToolSettings.js.map +1 -1
  183. package/lib/esm/appui-react/widgets/Widget.d.ts +10 -4
  184. package/lib/esm/appui-react/widgets/Widget.d.ts.map +1 -1
  185. package/lib/esm/appui-react/widgets/Widget.js.map +1 -1
  186. package/lib/esm/appui-react/widgets/WidgetDef.d.ts +9 -29
  187. package/lib/esm/appui-react/widgets/WidgetDef.d.ts.map +1 -1
  188. package/lib/esm/appui-react/widgets/WidgetDef.js +89 -46
  189. package/lib/esm/appui-react/widgets/WidgetDef.js.map +1 -1
  190. package/lib/esm/appui-react.d.ts +1 -0
  191. package/lib/esm/appui-react.d.ts.map +1 -1
  192. package/lib/esm/appui-react.js +1 -0
  193. package/lib/esm/appui-react.js.map +1 -1
  194. package/package.json +10 -10
@@ -20,7 +20,6 @@ const UiFramework_1 = require("../UiFramework");
20
20
  const WidgetDef_1 = require("../widgets/WidgetDef");
21
21
  const TimeTracker_1 = require("../configurableui/TimeTracker");
22
22
  const PopoutWidget_1 = require("../childwindow/PopoutWidget");
23
- const Frontstage_1 = require("../widget-panels/Frontstage");
24
23
  const core_bentley_1 = require("@itwin/core-bentley");
25
24
  const StageUsage_1 = require("./StageUsage");
26
25
  const StagePanelLocation_1 = require("../stagepanels/StagePanelLocation");
@@ -104,101 +103,90 @@ class FrontstageDef {
104
103
  const panel = nineZone.panels[panelSide];
105
104
  const location = this.toStagePanelLocation(panelSide);
106
105
  const panelDef = this.getStagePanelDef(location);
107
- if (panelDef) {
108
- const panelState = panel.collapsed
109
- ? StagePanelDef_1.StagePanelState.Minimized
110
- : StagePanelDef_1.StagePanelState.Open;
111
- panelMap.set(panelDef, panelState);
112
- }
113
- for (const widgetId of panel.widgets) {
114
- const widget = nineZone.widgets[widgetId];
115
- // istanbul ignore else
116
- if (widget) {
117
- for (const tabId of widget.tabs) {
118
- const widgetDef = this.findWidgetDef(tabId);
119
- if (widgetDef) {
120
- let widgetState = WidgetState_1.WidgetState.Open;
121
- if (widget.minimized || tabId !== widget.activeTabId)
122
- widgetState = WidgetState_1.WidgetState.Closed;
123
- widgetMap.set(widgetDef, widgetState);
124
- }
125
- }
126
- }
127
- }
106
+ if (!panelDef)
107
+ continue;
108
+ const panelState = panel.collapsed
109
+ ? StagePanelDef_1.StagePanelState.Minimized
110
+ : StagePanelDef_1.StagePanelState.Open;
111
+ panelMap.set(panelDef, panelState);
128
112
  }
129
- // istanbul ignore next
130
- for (const widgetId of nineZone.floatingWidgets.allIds) {
131
- const widget = nineZone.widgets[widgetId];
132
- if (widget) {
133
- for (const tabId of widget.tabs) {
134
- const widgetDef = this.findWidgetDef(tabId);
135
- if (widgetDef) {
136
- let widgetState = WidgetState_1.WidgetState.Open;
137
- if (widget.minimized || tabId !== widget.activeTabId)
138
- widgetState = WidgetState_1.WidgetState.Closed;
139
- widgetMap.set(widgetDef, widgetState);
140
- }
113
+ for (const widgetDef of this.widgetDefs) {
114
+ const widgetId = widgetDef.id;
115
+ if (widgetDef === this.toolSettings) {
116
+ if (!nineZone.toolSettings) {
117
+ widgetMap.set(widgetDef, WidgetState_1.WidgetState.Hidden);
118
+ continue;
119
+ }
120
+ else if (nineZone.toolSettings.type === "docked") {
121
+ widgetMap.set(widgetDef, WidgetState_1.WidgetState.Open);
122
+ continue;
141
123
  }
142
124
  }
143
- }
144
- const toolSettingsDef = this.toolSettings;
145
- if (toolSettingsDef) {
146
- if (!nineZone.toolSettings) {
147
- widgetMap.set(toolSettingsDef, WidgetState_1.WidgetState.Hidden);
148
- }
149
- else if (nineZone.toolSettings.type === "docked") {
150
- widgetMap.set(toolSettingsDef, WidgetState_1.WidgetState.Open);
125
+ const tabLocation = (0, appui_layout_react_1.getTabLocation)(nineZone, widgetId);
126
+ if (!tabLocation) {
127
+ widgetMap.set(widgetDef, WidgetState_1.WidgetState.Hidden);
128
+ continue;
151
129
  }
130
+ const widget = nineZone.widgets[tabLocation.widgetId];
131
+ let widgetState = WidgetState_1.WidgetState.Open;
132
+ if (widget.minimized || widgetId !== widget.activeTabId)
133
+ widgetState = WidgetState_1.WidgetState.Closed;
134
+ widgetMap.set(widgetDef, widgetState);
152
135
  }
153
136
  }
154
- triggerStateChangeEventForWidgetsAndPanels(state) {
155
- // istanbul ignore else
156
- if (!(this._isStageClosing || this._isApplicationClosing)) {
157
- if (state) {
158
- const originalPanelStateMap = new Map();
159
- const originalWidgetStateMap = new Map();
160
- const newPanelStateMap = new Map();
161
- const newWidgetStateMap = new Map();
162
- this._nineZoneState &&
163
- this.populateStateMaps(this._nineZoneState, originalPanelStateMap, originalWidgetStateMap);
164
- this.populateStateMaps(state, newPanelStateMap, newWidgetStateMap);
165
- // set internal state value before triggering events
166
- this._nineZoneState = state;
167
- // now walk and trigger set state events
168
- newWidgetStateMap.forEach((stateValue, widgetDef) => {
169
- const originalState = originalWidgetStateMap.get(widgetDef);
170
- if (originalState !== stateValue) {
171
- UiFramework_1.UiFramework.frontstages.onWidgetStateChangedEvent.emit({
172
- widgetDef,
173
- widgetState: stateValue,
174
- });
175
- widgetDef.onWidgetStateChanged();
176
- }
177
- });
178
- newPanelStateMap.forEach((stateValue, panelDef) => {
179
- const originalState = originalPanelStateMap.get(panelDef);
180
- if (originalState !== stateValue) {
181
- UiFramework_1.UiFramework.frontstages.onPanelStateChangedEvent.emit({
182
- panelDef,
183
- panelState: stateValue,
184
- });
185
- }
186
- });
187
- for (const panelSide of appui_layout_react_1.panelSides) {
188
- const panel = state.panels[panelSide];
189
- const location = this.toStagePanelLocation(panelSide);
190
- const panelDef = this.getStagePanelDef(location);
191
- if (panelDef) {
192
- panelDef.size = panel.size;
193
- panelDef.pinned = panel.pinned;
194
- }
195
- }
137
+ triggerStateChangeEvents(oldState) {
138
+ const newState = this.nineZoneState;
139
+ if (!newState)
140
+ return;
141
+ if (this._isStageClosing || this._isApplicationClosing)
142
+ return;
143
+ const originalPanelStateMap = new Map();
144
+ const originalWidgetStateMap = new Map();
145
+ const newPanelStateMap = new Map();
146
+ const newWidgetStateMap = new Map();
147
+ this.populateStateMaps(oldState, originalPanelStateMap, originalWidgetStateMap);
148
+ this.populateStateMaps(newState, newPanelStateMap, newWidgetStateMap);
149
+ // Now walk and trigger set state events
150
+ newWidgetStateMap.forEach((newWidgetState, widgetDef) => {
151
+ const originalState = originalWidgetStateMap.get(widgetDef);
152
+ if (originalState === newWidgetState)
153
+ return;
154
+ widgetDef.handleWidgetStateChanged(newWidgetState);
155
+ });
156
+ newPanelStateMap.forEach((newPanelState, panelDef) => {
157
+ const originalState = originalPanelStateMap.get(panelDef);
158
+ if (originalState === newPanelState)
159
+ return;
160
+ panelDef.handlePanelStateChanged(newPanelState);
161
+ });
162
+ for (const panelSide of appui_layout_react_1.panelSides) {
163
+ const panel = newState.panels[panelSide];
164
+ const oldPanel = oldState.panels[panelSide];
165
+ const location = this.toStagePanelLocation(panelSide);
166
+ const panelDef = this.getStagePanelDef(location);
167
+ if (!panelDef)
168
+ continue;
169
+ if (panel.size !== oldPanel.size) {
170
+ panelDef.handleSizeChanged(panel.size);
196
171
  }
197
- else {
198
- this._nineZoneState = state;
172
+ if (panel.pinned !== oldPanel.pinned) {
173
+ panelDef.handlePinnedChanged(panel.pinned);
199
174
  }
200
175
  }
201
176
  }
177
+ handlePopouts(oldState) {
178
+ const newState = this.nineZoneState;
179
+ const oldPopouts = oldState?.popoutWidgets.allIds || [];
180
+ const newPopouts = newState?.popoutWidgets.allIds || [];
181
+ const popoutsToClose = oldPopouts.filter((p) => !newPopouts.includes(p));
182
+ const popoutsToOpen = newPopouts.filter((p) => !oldPopouts.includes(p));
183
+ for (const popoutId of popoutsToClose) {
184
+ UiFramework_1.UiFramework.childWindows.close(popoutId, true);
185
+ }
186
+ for (const popoutId of popoutsToOpen) {
187
+ this.openPopoutWidgetContainer(popoutId);
188
+ }
189
+ }
202
190
  /** @internal */
203
191
  get nineZoneState() {
204
192
  return this._nineZoneState;
@@ -206,26 +194,31 @@ class FrontstageDef {
206
194
  set nineZoneState(state) {
207
195
  if (this._nineZoneState === state)
208
196
  return;
209
- if (!this._nineZoneState) {
210
- this._nineZoneState = state;
211
- }
212
- else {
213
- this.triggerStateChangeEventForWidgetsAndPanels(state);
214
- }
215
- // istanbul ignore next - don't trigger any side effects until stage "isReady"
216
- if (!(this._isStageClosing || this._isApplicationClosing) || this.isReady) {
217
- InternalFrontstageManager_1.InternalFrontstageManager.onFrontstageNineZoneStateChangedEvent.emit({
218
- frontstageDef: this,
219
- state,
220
- });
221
- }
197
+ const oldState = this._nineZoneState;
198
+ this._nineZoneState = state;
199
+ this.handlePopouts(oldState);
200
+ if (oldState) {
201
+ this.triggerStateChangeEvents(oldState);
202
+ }
203
+ const isClosing = this._isStageClosing || this._isApplicationClosing;
204
+ if (isClosing && !this.isReady)
205
+ return;
206
+ InternalFrontstageManager_1.InternalFrontstageManager.onFrontstageNineZoneStateChangedEvent.emit({
207
+ frontstageDef: this,
208
+ state,
209
+ });
222
210
  }
223
211
  /** @internal */
224
- get savedWidgetDefs() {
225
- return this._savedWidgetDefs;
226
- }
227
- set savedWidgetDefs(widgets) {
228
- this._savedWidgetDefs = widgets;
212
+ get dispatch() {
213
+ return (this._dispatch ??= (action) => {
214
+ if (action.type === "RESIZE") {
215
+ InternalFrontstageManager_1.InternalFrontstageManager.nineZoneSize = core_react_1.Size.create(action.size);
216
+ }
217
+ const state = this.nineZoneState;
218
+ if (!state)
219
+ return;
220
+ this.nineZoneState = (0, appui_layout_react_1.NineZoneStateReducer)(state, action);
221
+ });
229
222
  }
230
223
  /** @internal */
231
224
  get timeTracker() {
@@ -515,7 +508,9 @@ class FrontstageDef {
515
508
  frontstageDef: this,
516
509
  });
517
510
  }
518
- /** @beta */
511
+ /** Restores frontstage layout to initial configuration.
512
+ * @beta
513
+ */
519
514
  restoreLayout() {
520
515
  for (const panelDef of this.panelDefs) {
521
516
  panelDef.size = panelDef.defaultSize;
@@ -545,11 +540,7 @@ class FrontstageDef {
545
540
  if (!location)
546
541
  return WidgetState_1.WidgetState.Hidden;
547
542
  if ((0, appui_layout_react_1.isFloatingTabLocation)(location)) {
548
- const floatingWidget = state.floatingWidgets.byId[location.floatingWidgetId];
549
- if (floatingWidget && floatingWidget.hidden)
550
- return WidgetState_1.WidgetState.Hidden;
551
- else
552
- return WidgetState_1.WidgetState.Floating;
543
+ return WidgetState_1.WidgetState.Floating;
553
544
  }
554
545
  let collapsedPanel = false;
555
546
  // istanbul ignore else
@@ -566,24 +557,6 @@ class FrontstageDef {
566
557
  }
567
558
  return widgetDef.defaultState;
568
559
  }
569
- /** Used only in UI 2.0 to determine StagePanelState and size from NinezoneState
570
- * @internal
571
- */
572
- getPanelCurrentState(panelDef) {
573
- // istanbul ignore next
574
- if (this.nineZoneState) {
575
- const side = (0, StagePanelDef_1.toPanelSide)(panelDef.location);
576
- const panel = this.nineZoneState.panels[side];
577
- if (panel)
578
- return [
579
- panel.collapsed ? StagePanelDef_1.StagePanelState.Minimized : StagePanelDef_1.StagePanelState.Open,
580
- panel.size ?? 0,
581
- panel.pinned,
582
- ];
583
- return [StagePanelDef_1.StagePanelState.Off, 0, false];
584
- }
585
- return [panelDef.defaultState, panelDef.defaultSize ?? 0, true];
586
- }
587
560
  isPopoutWidget(widgetId) {
588
561
  // istanbul ignore else
589
562
  if (this.nineZoneState) {
@@ -607,89 +580,65 @@ class FrontstageDef {
607
580
  /** Create a new floating panel that contains the widget specified by its Id. Supported only when in
608
581
  * UI 2.0 or higher.
609
582
  * @param widgetId case sensitive Widget Id
610
- * @param point Position of top left corner of floating panel in pixels. If undefined {x:50, y:100} is used.
583
+ * @param position Position of top left corner of floating panel in pixels. If undefined {x:50, y:100} is used.
611
584
  * @param size defines the width and height of the floating panel. If undefined and widget has been floated before
612
585
  * the previous size is used, else {height:400, width:400} is used.
613
586
  * @beta
614
587
  */
615
- floatWidget(widgetId, point, size) {
616
- // istanbul ignore else
617
- if (this.nineZoneState) {
618
- const location = (0, appui_layout_react_1.getTabLocation)(this.nineZoneState, widgetId);
619
- if (location) {
620
- let popoutWidgetContainerId;
621
- if ((0, appui_layout_react_1.isPopoutTabLocation)(location)) {
622
- popoutWidgetContainerId = location.popoutWidgetId;
623
- }
624
- const state = (0, appui_layout_react_1.floatWidget)(this.nineZoneState, widgetId, point, size);
625
- // istanbul ignore else
626
- if (state) {
627
- this.nineZoneState = state;
628
- setTimeout(() => {
629
- popoutWidgetContainerId &&
630
- UiFramework_1.UiFramework.childWindows.close(popoutWidgetContainerId, true);
631
- }, 600);
632
- }
633
- }
634
- }
588
+ floatWidget(widgetId, position, size) {
589
+ const state = this.nineZoneState;
590
+ if (!state)
591
+ return;
592
+ const widgetDef = this.findWidgetDef(widgetId);
593
+ if (!widgetDef)
594
+ return;
595
+ this.dispatch({
596
+ type: "WIDGET_TAB_FLOAT",
597
+ id: widgetId,
598
+ position,
599
+ size,
600
+ });
635
601
  }
636
602
  /** Check widget and panel state to determine whether the widget is currently displayed
637
603
  * @param widgetId case-sensitive Widget Id
638
604
  * @public
639
605
  */
640
606
  isWidgetDisplayed(widgetId) {
641
- let widgetIsVisible = false;
642
- // istanbul ignore else
643
- if (this.nineZoneState) {
644
- const tabLocation = (0, appui_layout_react_1.getTabLocation)(this.nineZoneState, widgetId);
645
- // istanbul ignore else
646
- if (tabLocation) {
647
- if ((0, appui_layout_react_1.isFloatingTabLocation)(tabLocation)) {
648
- const floatingWidget = this.nineZoneState.floatingWidgets.byId[tabLocation.floatingWidgetId];
649
- // istanbul ignore else
650
- if (!!!floatingWidget.hidden)
651
- widgetIsVisible = true;
652
- }
653
- else if ((0, appui_layout_react_1.isPopoutTabLocation)(tabLocation)) {
654
- widgetIsVisible = true;
655
- }
656
- else {
657
- // istanbul ignore else
658
- if ((0, appui_layout_react_1.isPanelTabLocation)(tabLocation)) {
659
- const panel = this.nineZoneState.panels[tabLocation.side];
660
- const widgetDef = this.findWidgetDef(widgetId);
661
- if (widgetDef &&
662
- widgetDef.state === WidgetState_1.WidgetState.Open &&
663
- !panel.collapsed)
664
- widgetIsVisible = true;
665
- }
666
- }
667
- }
607
+ if (!this.nineZoneState)
608
+ return false;
609
+ const tabLocation = (0, appui_layout_react_1.getTabLocation)(this.nineZoneState, widgetId);
610
+ if (!tabLocation)
611
+ return false;
612
+ if ((0, appui_layout_react_1.isPanelTabLocation)(tabLocation)) {
613
+ const panel = this.nineZoneState.panels[tabLocation.side];
614
+ const widgetDef = this.findWidgetDef(widgetId);
615
+ const isVisible = !!widgetDef && widgetDef.state === WidgetState_1.WidgetState.Open && !panel.collapsed;
616
+ return isVisible;
668
617
  }
669
- return widgetIsVisible;
618
+ return true;
670
619
  }
671
620
  /** Opens window for specified PopoutWidget container. Used to reopen popout when running in Electron.
672
- * @internal */
673
- openPopoutWidgetContainer(state, widgetContainerId) {
621
+ * @internal
622
+ */
623
+ openPopoutWidgetContainer(widgetContainerId) {
624
+ const state = this.nineZoneState;
625
+ if (!state)
626
+ return;
674
627
  const location = (0, appui_layout_react_1.getWidgetLocation)(state, widgetContainerId);
675
- // istanbul ignore next
676
628
  if (!location)
677
629
  return;
678
- // istanbul ignore next
679
630
  if (!(0, appui_layout_react_1.isPopoutWidgetLocation)(location))
680
631
  return;
681
632
  const widget = state.widgets[widgetContainerId];
682
- const popoutWidget = state.popoutWidgets.byId[location.popoutWidgetId];
683
633
  // Popout widget should only contain a single tab.
684
- // istanbul ignore next
685
634
  if (widget.tabs.length !== 1)
686
635
  return;
687
636
  const tabId = widget.tabs[0];
688
637
  const widgetDef = this.findWidgetDef(tabId);
689
- // istanbul ignore next
690
638
  if (!widgetDef)
691
639
  return;
692
640
  const popoutContent = (React.createElement(PopoutWidget_1.PopoutWidget, { widgetContainerId: widgetContainerId, widgetDef: widgetDef }));
641
+ const popoutWidget = state.popoutWidgets.byId[location.popoutWidgetId];
693
642
  const bounds = core_react_1.Rectangle.create(popoutWidget.bounds);
694
643
  const position = {
695
644
  width: bounds.getWidth(),
@@ -702,48 +651,23 @@ class FrontstageDef {
702
651
  /** Create a new popout/child window that contains the widget specified by its Id. Supported only when in
703
652
  * UI 2.0 or higher.
704
653
  * @param widgetId case sensitive Widget Id
705
- * @param point Position of top left corner of floating panel in pixels. If undefined {x:0, y:0} is used.
654
+ * @param position Position of top left corner of floating panel in pixels. If undefined {x:0, y:0} is used.
706
655
  * @param size defines the width and height of the floating panel. If undefined and widget has been floated before
707
656
  * the previous size is used, else {height:800, width:600} is used.
708
657
  * @beta
709
658
  */
710
- popoutWidget(widgetId, point, size) {
711
- // istanbul ignore next
712
- if (!this.nineZoneState)
713
- return;
714
- let location = (0, appui_layout_react_1.getTabLocation)(this.nineZoneState, widgetId);
715
- if (!location || (0, appui_layout_react_1.isPopoutTabLocation)(location))
659
+ popoutWidget(widgetId, position, size) {
660
+ const state = this.nineZoneState;
661
+ if (!state)
716
662
  return;
717
663
  const widgetDef = this.findWidgetDef(widgetId);
718
- // istanbul ignore next
719
664
  if (!widgetDef)
720
665
  return;
721
- // get the state to apply that will pop-out the specified WidgetTab to child window.
722
- let preferredBounds = core_react_1.Rectangle.createFromSize({ height: 800, width: 600 });
723
- // istanbul ignore next
724
- if (widgetDef.popoutBounds)
725
- preferredBounds = widgetDef.popoutBounds;
726
- if (size)
727
- preferredBounds = preferredBounds.setSize(size);
728
- if (point)
729
- preferredBounds = preferredBounds.setPosition(point);
730
- const state = (0, appui_layout_react_1.popoutWidgetToChildWindow)(this.nineZoneState, widgetId, preferredBounds);
731
- this.nineZoneState = state;
732
- // now that the state is updated get the id of the container that houses the widgetTab/widgetId
733
- location = (0, appui_layout_react_1.getTabLocation)(state, widgetId);
734
- (0, core_bentley_1.assert)(!!location && (0, appui_layout_react_1.isPopoutTabLocation)(location));
735
- const widgetContainerId = location.widgetId;
736
- const popoutWidget = state.popoutWidgets.byId[widgetContainerId];
737
- const bounds = core_react_1.Rectangle.create(popoutWidget.bounds);
738
- setTimeout(() => {
739
- const popoutContent = (React.createElement(PopoutWidget_1.PopoutWidget, { widgetContainerId: widgetContainerId, widgetDef: widgetDef }));
740
- const position = {
741
- width: bounds.getWidth(),
742
- height: bounds.getHeight(),
743
- left: bounds.left,
744
- top: bounds.top,
745
- };
746
- UiFramework_1.UiFramework.childWindows.open(widgetContainerId, widgetDef.label, popoutContent, position, UiFramework_1.UiFramework.useDefaultPopoutUrl);
666
+ this.dispatch({
667
+ type: "WIDGET_TAB_POPOUT",
668
+ id: widgetId,
669
+ position,
670
+ size,
747
671
  });
748
672
  }
749
673
  get isStageClosing() {
@@ -757,12 +681,13 @@ class FrontstageDef {
757
681
  }
758
682
  /** @internal */
759
683
  saveChildWindowSizeAndPosition(childWindowId, childWindow) {
760
- if (!this.nineZoneState)
684
+ const state = this.nineZoneState;
685
+ if (!state)
761
686
  return;
762
- const location = (0, appui_layout_react_1.getWidgetLocation)(this.nineZoneState, childWindowId);
687
+ const location = (0, appui_layout_react_1.getWidgetLocation)(state, childWindowId);
763
688
  if (!location || !(0, appui_layout_react_1.isPopoutWidgetLocation)(location))
764
689
  return;
765
- const widget = this.nineZoneState.widgets[location.popoutWidgetId];
690
+ const widget = state.widgets[location.popoutWidgetId];
766
691
  const tabId = widget.tabs[0];
767
692
  const widgetDef = this.findWidgetDef(tabId);
768
693
  if (!widgetDef)
@@ -775,23 +700,34 @@ class FrontstageDef {
775
700
  x: childWindow.screenX,
776
701
  y: childWindow.screenY,
777
702
  });
778
- widgetDef.popoutBounds = bounds;
703
+ this.dispatch({
704
+ type: "WIDGET_TAB_SET_POPOUT_BOUNDS",
705
+ id: tabId,
706
+ bounds,
707
+ });
779
708
  }
780
- /** Method used to possibly change a Popout Widget back to a docked widget if the user was the one closing the popout's child
781
- * window.
782
- * @internal
783
- */
784
- dockPopoutWidgetContainer(widgetContainerId) {
785
- if (!this.nineZoneState)
709
+ /** @internal */
710
+ dockWidgetContainerByContainerId(widgetContainerId) {
711
+ const state = this.nineZoneState;
712
+ if (!state)
786
713
  return;
787
- // 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
788
- // an API call has moved the widget from a popout state to a floating state.
789
- // istanbul ignore else
790
- const location = (0, appui_layout_react_1.getWidgetLocation)(this.nineZoneState, widgetContainerId);
791
- if (!location || !(0, appui_layout_react_1.isPopoutWidgetLocation)(location))
714
+ const location = (0, appui_layout_react_1.getWidgetLocation)(state, widgetContainerId);
715
+ if (!location)
716
+ return;
717
+ if ((0, appui_layout_react_1.isFloatingWidgetLocation)(location)) {
718
+ this.dispatch({
719
+ type: "FLOATING_WIDGET_SEND_BACK",
720
+ id: location.floatingWidgetId,
721
+ });
722
+ return;
723
+ }
724
+ if ((0, appui_layout_react_1.isPopoutWidgetLocation)(location)) {
725
+ this.dispatch({
726
+ type: "POPOUT_WIDGET_SEND_BACK",
727
+ id: location.popoutWidgetId,
728
+ });
792
729
  return;
793
- const state = (0, appui_layout_react_1.dockWidgetContainer)(this.nineZoneState, widgetContainerId, true);
794
- this.nineZoneState = state;
730
+ }
795
731
  }
796
732
  /** Finds the container with the specified widget and re-docks all widgets
797
733
  * back to the panel zone location that was used when the floating container
@@ -800,34 +736,28 @@ class FrontstageDef {
800
736
  * @beta
801
737
  */
802
738
  dockWidgetContainer(widgetId) {
803
- // istanbul ignore else
804
- if (this.nineZoneState) {
805
- const location = (0, appui_layout_react_1.getTabLocation)(this.nineZoneState, widgetId);
806
- if (location) {
807
- const widgetContainerId = location.widgetId;
808
- const state = (0, appui_layout_react_1.dockWidgetContainer)(this.nineZoneState, widgetContainerId, true);
809
- state && (this.nineZoneState = state);
810
- if ((0, appui_layout_react_1.isPopoutTabLocation)(location)) {
811
- UiFramework_1.UiFramework.childWindows.close(location.widgetId, true);
812
- }
813
- }
814
- }
739
+ const state = this.nineZoneState;
740
+ if (!state)
741
+ return;
742
+ const location = (0, appui_layout_react_1.getTabLocation)(state, widgetId);
743
+ if (!location)
744
+ return;
745
+ this.dockWidgetContainerByContainerId(location.widgetId);
815
746
  }
816
747
  setFloatingWidgetContainerBounds(floatingWidgetId, bounds) {
817
748
  if (!this.nineZoneState ||
818
749
  !(floatingWidgetId in this.nineZoneState.floatingWidgets.byId))
819
750
  return false;
820
- let state = (0, Frontstage_1.FrameworkStateReducer)(this.nineZoneState, {
751
+ this.dispatch({
821
752
  type: "FLOATING_WIDGET_SET_BOUNDS",
822
753
  id: floatingWidgetId,
823
754
  bounds,
824
- }, this);
825
- state = (0, Frontstage_1.FrameworkStateReducer)(state, {
755
+ });
756
+ this.dispatch({
826
757
  type: "FLOATING_WIDGET_SET_USER_SIZED",
827
758
  id: floatingWidgetId,
828
759
  userSized: true,
829
- }, this);
830
- this.nineZoneState = state;
760
+ });
831
761
  return true;
832
762
  }
833
763
  getFloatingWidgetContainerIds() {
@@ -925,8 +855,9 @@ const useActiveFrontstageId = () => {
925
855
  return id;
926
856
  };
927
857
  exports.useActiveFrontstageId = useActiveFrontstageId;
928
- /** Hook to return the active Frontstage def */
929
- /** @public */
858
+ /** Hook to return the active Frontstage def.
859
+ * @public
860
+ */
930
861
  function useActiveFrontstageDef() {
931
862
  const [def, setDef] = React.useState(UiFramework_1.UiFramework.frontstages.activeFrontstageDef);
932
863
  React.useEffect(() => {