@itwin/appui-react 4.2.1 → 4.3.0

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 (105) hide show
  1. package/CHANGELOG.md +12 -4
  2. package/lib/cjs/appui-react/UiFramework.d.ts +0 -7
  3. package/lib/cjs/appui-react/UiFramework.d.ts.map +1 -1
  4. package/lib/cjs/appui-react/UiFramework.js +0 -22
  5. package/lib/cjs/appui-react/UiFramework.js.map +1 -1
  6. package/lib/cjs/appui-react/_variables.scss +3 -3
  7. package/lib/cjs/appui-react/accudraw/AccuDrawFieldContainer.scss +3 -3
  8. package/lib/cjs/appui-react/accudraw/AccuDrawInputField.scss +3 -3
  9. package/lib/cjs/appui-react/childwindow/InternalChildWindowManager.d.ts.map +1 -1
  10. package/lib/cjs/appui-react/childwindow/InternalChildWindowManager.js +1 -2
  11. package/lib/cjs/appui-react/childwindow/InternalChildWindowManager.js.map +1 -1
  12. package/lib/cjs/appui-react/childwindow/InternalChildWindowManager.scss +3 -3
  13. package/lib/cjs/appui-react/configurableui/configurableui.scss +3 -3
  14. package/lib/cjs/appui-react/content/DefaultViewOverlay.scss +3 -3
  15. package/lib/cjs/appui-react/feedback/ValidationTextbox.scss +3 -3
  16. package/lib/cjs/appui-react/frontstage/FrontstageDef.d.ts.map +1 -1
  17. package/lib/cjs/appui-react/frontstage/FrontstageDef.js +25 -5
  18. package/lib/cjs/appui-react/frontstage/FrontstageDef.js.map +1 -1
  19. package/lib/cjs/appui-react/navigationaids/SheetNavigationAid.scss +3 -3
  20. package/lib/cjs/appui-react/navigationaids/StandardRotationNavigationAid.scss +3 -3
  21. package/lib/cjs/appui-react/pickers/ViewSelector.d.ts.map +1 -1
  22. package/lib/cjs/appui-react/pickers/ViewSelector.js +3 -1
  23. package/lib/cjs/appui-react/pickers/ViewSelector.js.map +1 -1
  24. package/lib/cjs/appui-react/popup/CardPopup.scss +3 -3
  25. package/lib/cjs/appui-react/selection/HideIsolateEmphasizeManager.d.ts.map +1 -1
  26. package/lib/cjs/appui-react/selection/HideIsolateEmphasizeManager.js +0 -53
  27. package/lib/cjs/appui-react/selection/HideIsolateEmphasizeManager.js.map +1 -1
  28. package/lib/cjs/appui-react/settings/quantityformatting/QuantityFormat.scss +3 -3
  29. package/lib/cjs/appui-react/settings/ui/UiSettingsPage.scss +3 -3
  30. package/lib/cjs/appui-react/statusbar/Separator.scss +3 -3
  31. package/lib/cjs/appui-react/statusfields/SectionsField.scss +3 -3
  32. package/lib/cjs/appui-react/statusfields/SelectionCount.scss +3 -3
  33. package/lib/cjs/appui-react/statusfields/SelectionScope.scss +3 -3
  34. package/lib/cjs/appui-react/statusfields/ViewAttributes.scss +3 -3
  35. package/lib/cjs/appui-react/statusfields/tileloading/TileLoadingIndicator.scss +3 -3
  36. package/lib/cjs/appui-react/statusfields/toolassistance/ToolAssistanceField.scss +3 -3
  37. package/lib/cjs/appui-react/widget-panels/Frontstage.d.ts +3 -1
  38. package/lib/cjs/appui-react/widget-panels/Frontstage.d.ts.map +1 -1
  39. package/lib/cjs/appui-react/widget-panels/Frontstage.js +93 -77
  40. package/lib/cjs/appui-react/widget-panels/Frontstage.js.map +1 -1
  41. package/lib/cjs/appui-react/widget-panels/Frontstage.scss +3 -3
  42. package/lib/cjs/appui-react/widget-panels/Tab.scss +3 -3
  43. package/lib/cjs/appui-react/widget-panels/ToolSettings.d.ts +1 -1
  44. package/lib/cjs/appui-react/widget-panels/ToolSettings.d.ts.map +1 -1
  45. package/lib/cjs/appui-react/widget-panels/ToolSettings.js +23 -29
  46. package/lib/cjs/appui-react/widget-panels/ToolSettings.js.map +1 -1
  47. package/lib/cjs/appui-react/widget-panels/ToolSettings.scss +3 -3
  48. package/lib/cjs/appui-react/widget-panels/Toolbars.scss +3 -3
  49. package/lib/cjs/appui-react/widgets/WidgetDef.d.ts +1 -1
  50. package/lib/cjs/appui-react/widgets/WidgetDef.d.ts.map +1 -1
  51. package/lib/cjs/appui-react/widgets/WidgetDef.js +12 -11
  52. package/lib/cjs/appui-react/widgets/WidgetDef.js.map +1 -1
  53. package/lib/esm/appui-react/UiFramework.d.ts +0 -7
  54. package/lib/esm/appui-react/UiFramework.d.ts.map +1 -1
  55. package/lib/esm/appui-react/UiFramework.js +0 -22
  56. package/lib/esm/appui-react/UiFramework.js.map +1 -1
  57. package/lib/esm/appui-react/_variables.scss +3 -3
  58. package/lib/esm/appui-react/accudraw/AccuDrawFieldContainer.scss +3 -3
  59. package/lib/esm/appui-react/accudraw/AccuDrawInputField.scss +3 -3
  60. package/lib/esm/appui-react/childwindow/InternalChildWindowManager.d.ts.map +1 -1
  61. package/lib/esm/appui-react/childwindow/InternalChildWindowManager.js +1 -2
  62. package/lib/esm/appui-react/childwindow/InternalChildWindowManager.js.map +1 -1
  63. package/lib/esm/appui-react/childwindow/InternalChildWindowManager.scss +3 -3
  64. package/lib/esm/appui-react/configurableui/configurableui.scss +3 -3
  65. package/lib/esm/appui-react/content/DefaultViewOverlay.scss +3 -3
  66. package/lib/esm/appui-react/feedback/ValidationTextbox.scss +3 -3
  67. package/lib/esm/appui-react/frontstage/FrontstageDef.d.ts.map +1 -1
  68. package/lib/esm/appui-react/frontstage/FrontstageDef.js +25 -5
  69. package/lib/esm/appui-react/frontstage/FrontstageDef.js.map +1 -1
  70. package/lib/esm/appui-react/navigationaids/SheetNavigationAid.scss +3 -3
  71. package/lib/esm/appui-react/navigationaids/StandardRotationNavigationAid.scss +3 -3
  72. package/lib/esm/appui-react/pickers/ViewSelector.d.ts.map +1 -1
  73. package/lib/esm/appui-react/pickers/ViewSelector.js +3 -1
  74. package/lib/esm/appui-react/pickers/ViewSelector.js.map +1 -1
  75. package/lib/esm/appui-react/popup/CardPopup.scss +3 -3
  76. package/lib/esm/appui-react/selection/HideIsolateEmphasizeManager.d.ts.map +1 -1
  77. package/lib/esm/appui-react/selection/HideIsolateEmphasizeManager.js +0 -53
  78. package/lib/esm/appui-react/selection/HideIsolateEmphasizeManager.js.map +1 -1
  79. package/lib/esm/appui-react/settings/quantityformatting/QuantityFormat.scss +3 -3
  80. package/lib/esm/appui-react/settings/ui/UiSettingsPage.scss +3 -3
  81. package/lib/esm/appui-react/statusbar/Separator.scss +3 -3
  82. package/lib/esm/appui-react/statusfields/SectionsField.scss +3 -3
  83. package/lib/esm/appui-react/statusfields/SelectionCount.scss +3 -3
  84. package/lib/esm/appui-react/statusfields/SelectionScope.scss +3 -3
  85. package/lib/esm/appui-react/statusfields/ViewAttributes.scss +3 -3
  86. package/lib/esm/appui-react/statusfields/tileloading/TileLoadingIndicator.scss +3 -3
  87. package/lib/esm/appui-react/statusfields/toolassistance/ToolAssistanceField.scss +3 -3
  88. package/lib/esm/appui-react/widget-panels/Frontstage.d.ts +3 -1
  89. package/lib/esm/appui-react/widget-panels/Frontstage.d.ts.map +1 -1
  90. package/lib/esm/appui-react/widget-panels/Frontstage.js +90 -74
  91. package/lib/esm/appui-react/widget-panels/Frontstage.js.map +1 -1
  92. package/lib/esm/appui-react/widget-panels/Frontstage.scss +3 -3
  93. package/lib/esm/appui-react/widget-panels/Tab.scss +3 -3
  94. package/lib/esm/appui-react/widget-panels/ToolSettings.d.ts +1 -1
  95. package/lib/esm/appui-react/widget-panels/ToolSettings.d.ts.map +1 -1
  96. package/lib/esm/appui-react/widget-panels/ToolSettings.js +23 -29
  97. package/lib/esm/appui-react/widget-panels/ToolSettings.js.map +1 -1
  98. package/lib/esm/appui-react/widget-panels/ToolSettings.scss +3 -3
  99. package/lib/esm/appui-react/widget-panels/Toolbars.scss +3 -3
  100. package/lib/esm/appui-react/widgets/WidgetDef.d.ts +1 -1
  101. package/lib/esm/appui-react/widgets/WidgetDef.d.ts.map +1 -1
  102. package/lib/esm/appui-react/widgets/WidgetDef.js +12 -11
  103. package/lib/esm/appui-react/widgets/WidgetDef.js.map +1 -1
  104. package/lib/public/locales/en/UiFramework.json +3 -1
  105. package/package.json +12 -12
@@ -13,7 +13,7 @@ import { unstable_batchedUpdates } from "react-dom";
13
13
  import { assert, Logger, ProcessDetector } from "@itwin/core-bentley";
14
14
  import { Rectangle, Size, UiStateStorageStatus } from "@itwin/core-react";
15
15
  import { ToolbarPopupAutoHideContext } from "@itwin/components-react";
16
- import { addFloatingWidget, addPanelWidget, addTab, addTabToWidget, convertAllPopupWidgetContainersToFloating, createLayoutStore, createNineZoneState, floatingWidgetBringToFront, FloatingWidgets, getTabLocation, getUniqueId, getWidgetPanelSectionId, insertPanelWidget, insertTabToWidget, isFloatingTabLocation, isHorizontalPanelSide, isPanelTabLocation, isPopoutTabLocation, NineZone, NineZoneStateReducer, panelSides, removeTab, removeTabFromWidget, toolSettingsTabId, WidgetPanels, } from "@itwin/appui-layout-react";
16
+ import { addDockedToolSettings, addFloatingWidget, addPanelWidget, addTab, addTabToWidget, addWidgetToolSettings, convertAllPopupWidgetContainersToFloating, createLayoutStore, createNineZoneState, floatingWidgetBringToFront, FloatingWidgets, getTabLocation, getUniqueId, getWidgetPanelSectionId, insertPanelWidget, insertTabToWidget, isFloatingTabLocation, isHorizontalPanelSide, isPanelTabLocation, isPopoutTabLocation, NineZone, NineZoneStateReducer, panelSides, removeTab, removeTabFromWidget, removeToolSettings, WidgetPanels, } from "@itwin/appui-layout-react";
17
17
  import { StagePanelState, toPanelSide } from "../stagepanels/StagePanelDef";
18
18
  import { UiFramework } from "../UiFramework";
19
19
  import { useUiStateStorageHandler } from "../uistate/useUiStateStorage";
@@ -120,14 +120,6 @@ export function useNineZoneDispatch(frontstageDef) {
120
120
  if (action.type === "RESIZE") {
121
121
  InternalFrontstageManager.nineZoneSize = Size.create(action.size);
122
122
  }
123
- // istanbul ignore if
124
- if (action.type === "TOOL_SETTINGS_DRAG_START") {
125
- void UiFramework.postTelemetry("Tool Settings Undocking", "28B04E07-AE73-4533-A0BA-8E2A8DC99ADF");
126
- }
127
- // istanbul ignore if
128
- if (action.type === "TOOL_SETTINGS_DOCK") {
129
- void UiFramework.postTelemetry("Tool Settings Docking to Settings Bar", "BEDE684B-B3DB-4637-B3AF-DC3CBA223F94");
130
- }
131
123
  if (action.type === "WIDGET_TAB_POPOUT") {
132
124
  const tabId = action.id;
133
125
  frontstageDef.popoutWidget(tabId);
@@ -204,25 +196,28 @@ export function useLabels() {
204
196
  popoutActiveTab: UiFramework.translate("widget.tooltips.popoutActiveTab"),
205
197
  }), []);
206
198
  }
199
+ function toTabArgs(widget) {
200
+ var _a;
201
+ const label = getWidgetLabel(widget.label);
202
+ return {
203
+ allowedPanelTargets: (_a = widget.allowedPanelTargets) === null || _a === void 0 ? void 0 : _a.map((location) => toPanelSide(location)),
204
+ hideWithUiWhenFloating: !!widget.hideWithUiWhenFloating,
205
+ canPopout: widget.canPopout,
206
+ iconSpec: widget.iconSpec,
207
+ isFloatingStateWindowResizable: widget.isFloatingStateWindowResizable,
208
+ label,
209
+ preferredFloatingWidgetSize: widget.defaultFloatingSize,
210
+ preferredPanelWidgetSize: widget.preferredPanelSize,
211
+ };
212
+ }
207
213
  /** @internal */
208
214
  export function addWidgets(state, widgets, side, widgetId) {
209
- var _a;
210
215
  const visibleWidgets = widgets.filter((w) => w.isVisible && w.defaultState !== WidgetState.Floating);
211
216
  if (visibleWidgets.length === 0)
212
217
  return state;
213
218
  const tabs = new Array();
214
219
  for (const widget of visibleWidgets) {
215
- const label = getWidgetLabel(widget.label);
216
- state = addTab(state, widget.id, {
217
- label,
218
- iconSpec: widget.iconSpec,
219
- preferredPanelWidgetSize: widget.preferredPanelSize,
220
- preferredFloatingWidgetSize: widget.defaultFloatingSize,
221
- canPopout: widget.canPopout,
222
- isFloatingStateWindowResizable: widget.isFloatingStateWindowResizable,
223
- hideWithUiWhenFloating: !!widget.hideWithUiWhenFloating,
224
- allowedPanelTargets: (_a = widget.allowedPanelTargets) === null || _a === void 0 ? void 0 : _a.map((location) => toPanelSide(location)),
225
- });
220
+ state = addTab(state, widget.id, toTabArgs(widget));
226
221
  tabs.push(widget.id);
227
222
  }
228
223
  const activeWidget = visibleWidgets.find((widget) => widget.isActive);
@@ -239,13 +234,10 @@ export function addWidgets(state, widgets, side, widgetId) {
239
234
  /** @internal */
240
235
  // istanbul ignore next
241
236
  export function appendWidgets(state, widgetDefs, location, section) {
242
- var _a, _b;
243
- if (widgetDefs.length === 0)
244
- return state;
237
+ var _a;
245
238
  const side = toPanelSide(location);
246
239
  // Add missing widget tabs.
247
240
  for (const widgetDef of widgetDefs) {
248
- const label = getWidgetLabel(widgetDef.label);
249
241
  const saveTab = state.tabs[widgetDef.id];
250
242
  const preferredPanelWidgetSize = saveTab
251
243
  ? saveTab.preferredPanelWidgetSize
@@ -260,19 +252,14 @@ export function appendWidgets(state, widgetDefs, location, section) {
260
252
  !!saveTab.preferredFloatingWidgetSize)
261
253
  : !!widgetDef.defaultFloatingSize;
262
254
  state = addTab(state, widgetDef.id, {
263
- label,
264
- iconSpec: widgetDef.iconSpec,
265
- canPopout: widgetDef.canPopout,
266
- preferredPanelWidgetSize,
255
+ ...toTabArgs(widgetDef),
267
256
  preferredFloatingWidgetSize,
257
+ preferredPanelWidgetSize,
268
258
  userSized,
269
- isFloatingStateWindowResizable: widgetDef.isFloatingStateWindowResizable,
270
- hideWithUiWhenFloating: !!widgetDef.hideWithUiWhenFloating,
271
- allowedPanelTargets: (_a = widgetDef.allowedPanelTargets) === null || _a === void 0 ? void 0 : _a.map((l) => toPanelSide(l)),
272
259
  });
273
260
  if (widgetDef.isFloatingStateSupported &&
274
261
  widgetDef.defaultState === WidgetState.Floating) {
275
- const floatingContainerId = (_b = widgetDef.floatingContainerId) !== null && _b !== void 0 ? _b : getUniqueId();
262
+ const floatingContainerId = (_a = widgetDef.floatingContainerId) !== null && _a !== void 0 ? _a : getUniqueId();
276
263
  const widgetContainerId = getWidgetId(location, section);
277
264
  const home = {
278
265
  side,
@@ -359,6 +346,12 @@ export function addMissingWidgets(frontstageDef, initialState) {
359
346
  state = appendWidgets(state, determineNewWidgets((_f = frontstageDef.topPanel) === null || _f === void 0 ? void 0 : _f.getPanelSectionDef(StagePanelSection.End).widgetDefs, state), StagePanelLocation.Top, StagePanelSection.End);
360
347
  state = appendWidgets(state, determineNewWidgets((_g = frontstageDef.bottomPanel) === null || _g === void 0 ? void 0 : _g.getPanelSectionDef(StagePanelSection.Start).widgetDefs, state), StagePanelLocation.Bottom, StagePanelSection.Start);
361
348
  state = appendWidgets(state, determineNewWidgets((_h = frontstageDef.bottomPanel) === null || _h === void 0 ? void 0 : _h.getPanelSectionDef(StagePanelSection.End).widgetDefs, state), StagePanelLocation.Bottom, StagePanelSection.End);
349
+ if (frontstageDef.toolSettings) {
350
+ const newToolSettingsWidgets = determineNewWidgets([frontstageDef.toolSettings], state);
351
+ for (const newToolSettingsWidget of newToolSettingsWidgets) {
352
+ state = addTab(state, newToolSettingsWidget.id, toTabArgs(newToolSettingsWidget));
353
+ }
354
+ }
362
355
  return state;
363
356
  }
364
357
  /** Hide widgets with Hidden defaultState. */
@@ -377,8 +370,9 @@ function hideWidgets(state, frontstageDef) {
377
370
  /** Removes NineZoneState widgets that are missing in frontstageDef.
378
371
  * @internal
379
372
  */
380
- export function removeMissingWidgets(frontstageDef, initialState) {
381
- let state = initialState;
373
+ export function removeMissingWidgets(frontstageDef, state) {
374
+ var _a;
375
+ const toolSettingsTabId = (_a = state.toolSettings) === null || _a === void 0 ? void 0 : _a.tabId;
382
376
  for (const [, tab] of Object.entries(state.tabs)) {
383
377
  if (tab.id === toolSettingsTabId)
384
378
  continue;
@@ -483,7 +477,8 @@ function getPanelMaxSize(maxSizeSpec, panel, nineZoneSize) {
483
477
  : nineZoneSize.width;
484
478
  return (maxSizeSpec.percentage / 100) * size;
485
479
  }
486
- const stateVersion = 13; // this needs to be bumped when NineZoneState is changed (to recreate the layout).
480
+ /** @internal */
481
+ export const stateVersion = 14; // this needs to be bumped when NineZoneState is changed (to recreate the layout).
487
482
  /** @internal */
488
483
  export function initializeNineZoneState(frontstageDef) {
489
484
  let nineZone = defaultNineZone;
@@ -500,30 +495,27 @@ export function initializeNineZoneState(frontstageDef) {
500
495
  nineZone = initializePanel(nineZone, frontstageDef, StagePanelLocation.Right);
501
496
  nineZone = initializePanel(nineZone, frontstageDef, StagePanelLocation.Top);
502
497
  nineZone = initializePanel(nineZone, frontstageDef, StagePanelLocation.Bottom);
503
- nineZone = produce(nineZone, (stateDraft) => {
498
+ nineZone = produce(nineZone, (draft) => {
504
499
  var _a, _b, _c, _d;
505
- for (const [, panel] of Object.entries(stateDraft.panels)) {
506
- const expanded = panel.widgets.find((widgetId) => stateDraft.widgets[widgetId].minimized === false);
507
- const firstWidget = panel.widgets.length > 0
508
- ? stateDraft.widgets[panel.widgets[0]]
509
- : undefined;
500
+ for (const [, panel] of Object.entries(draft.panels)) {
501
+ const expanded = panel.widgets.find((widgetId) => draft.widgets[widgetId].minimized === false);
502
+ const firstWidget = panel.widgets.length > 0 ? draft.widgets[panel.widgets[0]] : undefined;
510
503
  // istanbul ignore next
511
504
  if (!expanded && firstWidget) {
512
505
  firstWidget.minimized = false;
513
506
  }
514
507
  }
515
- stateDraft.panels.left.collapsed = isPanelCollapsed((_a = frontstageDef.leftPanel) === null || _a === void 0 ? void 0 : _a.panelState);
516
- stateDraft.panels.right.collapsed = isPanelCollapsed((_b = frontstageDef.rightPanel) === null || _b === void 0 ? void 0 : _b.panelState);
517
- stateDraft.panels.top.collapsed = isPanelCollapsed((_c = frontstageDef.topPanel) === null || _c === void 0 ? void 0 : _c.panelState);
518
- stateDraft.panels.bottom.collapsed = isPanelCollapsed((_d = frontstageDef.bottomPanel) === null || _d === void 0 ? void 0 : _d.panelState);
519
- const toolSettingsWidgetDef = frontstageDef.toolSettings;
520
- if (toolSettingsWidgetDef) {
521
- const toolSettingsTab = stateDraft.tabs[toolSettingsTabId];
522
- toolSettingsTab.preferredPanelWidgetSize =
523
- toolSettingsWidgetDef.preferredPanelSize;
524
- }
508
+ draft.panels.left.collapsed = isPanelCollapsed((_a = frontstageDef.leftPanel) === null || _a === void 0 ? void 0 : _a.panelState);
509
+ draft.panels.right.collapsed = isPanelCollapsed((_b = frontstageDef.rightPanel) === null || _b === void 0 ? void 0 : _b.panelState);
510
+ draft.panels.top.collapsed = isPanelCollapsed((_c = frontstageDef.topPanel) === null || _c === void 0 ? void 0 : _c.panelState);
511
+ draft.panels.bottom.collapsed = isPanelCollapsed((_d = frontstageDef.bottomPanel) === null || _d === void 0 ? void 0 : _d.panelState);
525
512
  });
526
513
  nineZone = addMissingWidgets(frontstageDef, nineZone);
514
+ const toolSettingsWidgetDef = frontstageDef.toolSettings;
515
+ if (toolSettingsWidgetDef) {
516
+ const toolSettingsTabId = toolSettingsWidgetDef.id;
517
+ nineZone = addDockedToolSettings(nineZone, toolSettingsTabId);
518
+ }
527
519
  nineZone = hideWidgets(nineZone, frontstageDef);
528
520
  nineZone = processPopoutWidgets(nineZone, frontstageDef);
529
521
  return nineZone;
@@ -536,7 +528,7 @@ export function initializeNineZoneState(frontstageDef) {
536
528
  export function restoreNineZoneState(frontstageDef, saved) {
537
529
  let restored = {
538
530
  ...saved,
539
- tabs: defaultNineZone.tabs,
531
+ tabs: {},
540
532
  };
541
533
  for (const [, tab] of Object.entries(saved.tabs)) {
542
534
  // Re-add the placeholder tab in order to correctly remove it from the state if WidgetDef is not found.
@@ -551,15 +543,11 @@ export function restoreNineZoneState(frontstageDef, saved) {
551
543
  continue;
552
544
  }
553
545
  restored = produce(restored, (draft) => {
554
- var _a;
555
546
  draft.tabs[tab.id] = {
556
547
  ...tab,
557
- label: getWidgetLabel(widgetDef.label),
558
- hideWithUiWhenFloating: widgetDef.hideWithUiWhenFloating,
559
- iconSpec: widgetDef.iconSpec,
560
- canPopout: widgetDef.canPopout,
561
- isFloatingStateWindowResizable: widgetDef.isFloatingStateWindowResizable,
562
- allowedPanelTargets: (_a = widgetDef.allowedPanelTargets) === null || _a === void 0 ? void 0 : _a.map((location) => toPanelSide(location)),
548
+ ...toTabArgs(widgetDef),
549
+ preferredFloatingWidgetSize: tab.preferredFloatingWidgetSize,
550
+ preferredPanelWidgetSize: tab.preferredPanelWidgetSize,
563
551
  };
564
552
  });
565
553
  }
@@ -616,12 +604,9 @@ export function packNineZoneState(state) {
616
604
  };
617
605
  packed = produce(packed, (draft) => {
618
606
  for (const [, tab] of Object.entries(state.tabs)) {
619
- if (tab.id === toolSettingsTabId)
620
- continue;
621
607
  draft.tabs[tab.id] = {
622
608
  id: tab.id,
623
609
  preferredFloatingWidgetSize: tab.preferredFloatingWidgetSize,
624
- allowedPanelTargets: tab.allowedPanelTargets,
625
610
  userSized: tab.userSized,
626
611
  };
627
612
  }
@@ -714,16 +699,26 @@ function addHiddenWidget(state, widgetDef) {
714
699
  }
715
700
  /** @internal */
716
701
  export function setWidgetState(state, widgetDef, widgetState) {
717
- var _a, _b;
702
+ var _a, _b, _c, _d, _e;
718
703
  if (widgetState === WidgetState.Hidden) {
719
704
  return hideWidget(state, widgetDef);
720
705
  }
721
706
  else if (widgetState === WidgetState.Open) {
722
707
  const id = widgetDef.id;
708
+ if (widgetDef.isToolSettings) {
709
+ if (!state.toolSettings && !widgetDef.tabLocation) {
710
+ state = addDockedToolSettings(state, id);
711
+ }
712
+ if (((_a = state.toolSettings) === null || _a === void 0 ? void 0 : _a.type) === "docked")
713
+ return state;
714
+ }
723
715
  let location = getTabLocation(state, id);
724
716
  if (!location) {
725
717
  state = addHiddenWidget(state, widgetDef);
726
718
  location = getTabLocation(state, id);
719
+ if (widgetDef.isToolSettings) {
720
+ state = addWidgetToolSettings(state, id);
721
+ }
727
722
  }
728
723
  return produce(state, (draft) => {
729
724
  var _a;
@@ -748,6 +743,9 @@ export function setWidgetState(state, widgetDef, widgetState) {
748
743
  }
749
744
  else if (widgetState === WidgetState.Closed) {
750
745
  const id = widgetDef.id;
746
+ if (widgetDef.isToolSettings && ((_b = state.toolSettings) === null || _b === void 0 ? void 0 : _b.type) !== "widget") {
747
+ return state;
748
+ }
751
749
  let location = getTabLocation(state, id);
752
750
  if (!location) {
753
751
  state = addHiddenWidget(state, widgetDef);
@@ -776,13 +774,31 @@ export function setWidgetState(state, widgetDef, widgetState) {
776
774
  return state;
777
775
  // Widget is not floating.
778
776
  state = removeTabFromWidget(state, id);
779
- const bounds = (_b = (_a = widgetDef.tabLocation) === null || _a === void 0 ? void 0 : _a.floatingWidget) === null || _b === void 0 ? void 0 : _b.bounds;
777
+ const bounds = (_d = (_c = widgetDef.tabLocation) === null || _c === void 0 ? void 0 : _c.floatingWidget) === null || _d === void 0 ? void 0 : _d.bounds;
780
778
  state = addFloatingWidget(state, getUniqueId(), [id], { bounds });
779
+ if (widgetDef.isToolSettings) {
780
+ if (((_e = state.toolSettings) === null || _e === void 0 ? void 0 : _e.type) === "docked") {
781
+ state = removeToolSettings(state);
782
+ }
783
+ if (!state.toolSettings) {
784
+ state = addWidgetToolSettings(state, id);
785
+ }
786
+ }
781
787
  }
782
788
  return state;
783
789
  }
784
790
  /** Stores widget location and hides it in the UI. */
785
791
  function hideWidget(state, widgetDef) {
792
+ var _a, _b;
793
+ const toolSettingsTabId = (_a = state.toolSettings) === null || _a === void 0 ? void 0 : _a.tabId;
794
+ if (widgetDef.id === toolSettingsTabId) {
795
+ widgetDef.tabLocation = undefined;
796
+ state = produce(state, (draft) => {
797
+ draft.toolSettings = undefined;
798
+ });
799
+ if (((_b = state.toolSettings) === null || _b === void 0 ? void 0 : _b.type) === "docked")
800
+ return state;
801
+ }
786
802
  const location = getTabLocation(state, widgetDef.id);
787
803
  if (!location)
788
804
  return state;
@@ -886,8 +902,8 @@ export function useSavedFrontstageState(frontstageDef) {
886
902
  return;
887
903
  if (isFrontstageStateSettingResult(settingResult)) {
888
904
  const setting = settingResult.setting;
889
- if (setting.version >= version &&
890
- setting.stateVersion >= stateVersion) {
905
+ if (setting.version === version &&
906
+ setting.stateVersion === stateVersion) {
891
907
  const restored = restoreNineZoneState(frontstageDef, setting.nineZone);
892
908
  frontstageDef.savedWidgetDefs = setting.widgets;
893
909
  restoreSavedWidgets(frontstageDef);
@@ -974,14 +990,11 @@ const createListener = (frontstageDef, listener) => {
974
990
  /** @internal */
975
991
  export function useFrontstageManager(frontstageDef, useToolAsToolSettingsLabel) {
976
992
  React.useEffect(() => {
977
- const listener = createListener(frontstageDef, ({ widgetDef, widgetState }) => {
978
- assert(!!frontstageDef.nineZoneState);
993
+ return UiFramework.frontstages.onWidgetStateChangedEvent.addListener(({ widgetDef, widgetState }) => {
994
+ if (!frontstageDef.nineZoneState)
995
+ return;
979
996
  frontstageDef.nineZoneState = setWidgetState(frontstageDef.nineZoneState, widgetDef, widgetState);
980
997
  });
981
- UiFramework.frontstages.onWidgetStateChangedEvent.addListener(listener);
982
- return () => {
983
- UiFramework.frontstages.onWidgetStateChangedEvent.removeListener(listener);
984
- };
985
998
  }, [frontstageDef]);
986
999
  React.useEffect(() => {
987
1000
  const listener = createListener(frontstageDef, ({ widgetDef }) => {
@@ -1039,12 +1052,15 @@ export function useFrontstageManager(frontstageDef, useToolAsToolSettingsLabel)
1039
1052
  const defaultLabel = React.useMemo(() => UiFramework.translate("widget.labels.toolSettings"), []);
1040
1053
  React.useEffect(() => {
1041
1054
  const updateLabel = createListener(frontstageDef, () => {
1042
- var _a;
1055
+ var _a, _b;
1043
1056
  const toolId = UiFramework.frontstages.activeToolId;
1044
1057
  assert(!!frontstageDef.nineZoneState);
1045
1058
  const label = useToolAsToolSettingsLabel
1046
1059
  ? ((_a = IModelApp.tools.find(toolId)) === null || _a === void 0 ? void 0 : _a.flyover) || defaultLabel
1047
1060
  : defaultLabel;
1061
+ const toolSettingsTabId = (_b = frontstageDef.nineZoneState.toolSettings) === null || _b === void 0 ? void 0 : _b.tabId;
1062
+ if (!toolSettingsTabId)
1063
+ return;
1048
1064
  frontstageDef.nineZoneState = setWidgetLabel(frontstageDef.nineZoneState, toolSettingsTabId, label);
1049
1065
  });
1050
1066
  // Whenever the frontstageDef or the useTool... changes, keep the label up to date.