@itwin/appui-react 3.3.0-dev.42 → 3.3.0-dev.43

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 (63) hide show
  1. package/lib/cjs/appui-react/configurableui/ConfigurableUiContent.js +1 -1
  2. package/lib/cjs/appui-react/configurableui/ConfigurableUiContent.js.map +1 -1
  3. package/lib/cjs/appui-react/frontstage/FrontstageDef.d.ts.map +1 -1
  4. package/lib/cjs/appui-react/frontstage/FrontstageDef.js +13 -3
  5. package/lib/cjs/appui-react/frontstage/FrontstageDef.js.map +1 -1
  6. package/lib/cjs/appui-react/stagepanels/StagePanelDef.d.ts +1 -0
  7. package/lib/cjs/appui-react/stagepanels/StagePanelDef.d.ts.map +1 -1
  8. package/lib/cjs/appui-react/widget-panels/Content.d.ts.map +1 -1
  9. package/lib/cjs/appui-react/widget-panels/Content.js +10 -0
  10. package/lib/cjs/appui-react/widget-panels/Content.js.map +1 -1
  11. package/lib/cjs/appui-react/widget-panels/Frontstage.d.ts +4 -0
  12. package/lib/cjs/appui-react/widget-panels/Frontstage.d.ts.map +1 -1
  13. package/lib/cjs/appui-react/widget-panels/Frontstage.js +72 -12
  14. package/lib/cjs/appui-react/widget-panels/Frontstage.js.map +1 -1
  15. package/lib/cjs/appui-react/widget-panels/useTransientState.d.ts +8 -0
  16. package/lib/cjs/appui-react/widget-panels/useTransientState.d.ts.map +1 -0
  17. package/lib/cjs/appui-react/widget-panels/useTransientState.js +19 -0
  18. package/lib/cjs/appui-react/widget-panels/useTransientState.js.map +1 -0
  19. package/lib/cjs/appui-react/widget-panels/useWidgetDirection.d.ts.map +1 -1
  20. package/lib/cjs/appui-react/widget-panels/useWidgetDirection.js +1 -0
  21. package/lib/cjs/appui-react/widget-panels/useWidgetDirection.js.map +1 -1
  22. package/lib/cjs/appui-react/widgets/WidgetDef.d.ts +1 -0
  23. package/lib/cjs/appui-react/widgets/WidgetDef.d.ts.map +1 -1
  24. package/lib/cjs/appui-react/widgets/WidgetDef.js.map +1 -1
  25. package/lib/cjs/appui-react/widgets/WidgetHost.d.ts.map +1 -1
  26. package/lib/cjs/appui-react/widgets/WidgetHost.js +3 -1
  27. package/lib/cjs/appui-react/widgets/WidgetHost.js.map +1 -1
  28. package/lib/cjs/appui-react.d.ts +1 -0
  29. package/lib/cjs/appui-react.d.ts.map +1 -1
  30. package/lib/cjs/appui-react.js +1 -0
  31. package/lib/cjs/appui-react.js.map +1 -1
  32. package/lib/esm/appui-react/configurableui/ConfigurableUiContent.js +1 -1
  33. package/lib/esm/appui-react/configurableui/ConfigurableUiContent.js.map +1 -1
  34. package/lib/esm/appui-react/frontstage/FrontstageDef.d.ts.map +1 -1
  35. package/lib/esm/appui-react/frontstage/FrontstageDef.js +13 -3
  36. package/lib/esm/appui-react/frontstage/FrontstageDef.js.map +1 -1
  37. package/lib/esm/appui-react/stagepanels/StagePanelDef.d.ts +1 -0
  38. package/lib/esm/appui-react/stagepanels/StagePanelDef.d.ts.map +1 -1
  39. package/lib/esm/appui-react/widget-panels/Content.d.ts.map +1 -1
  40. package/lib/esm/appui-react/widget-panels/Content.js +10 -0
  41. package/lib/esm/appui-react/widget-panels/Content.js.map +1 -1
  42. package/lib/esm/appui-react/widget-panels/Frontstage.d.ts +4 -0
  43. package/lib/esm/appui-react/widget-panels/Frontstage.d.ts.map +1 -1
  44. package/lib/esm/appui-react/widget-panels/Frontstage.js +73 -13
  45. package/lib/esm/appui-react/widget-panels/Frontstage.js.map +1 -1
  46. package/lib/esm/appui-react/widget-panels/useTransientState.d.ts +8 -0
  47. package/lib/esm/appui-react/widget-panels/useTransientState.d.ts.map +1 -0
  48. package/lib/esm/appui-react/widget-panels/useTransientState.js +15 -0
  49. package/lib/esm/appui-react/widget-panels/useTransientState.js.map +1 -0
  50. package/lib/esm/appui-react/widget-panels/useWidgetDirection.d.ts.map +1 -1
  51. package/lib/esm/appui-react/widget-panels/useWidgetDirection.js +1 -0
  52. package/lib/esm/appui-react/widget-panels/useWidgetDirection.js.map +1 -1
  53. package/lib/esm/appui-react/widgets/WidgetDef.d.ts +1 -0
  54. package/lib/esm/appui-react/widgets/WidgetDef.d.ts.map +1 -1
  55. package/lib/esm/appui-react/widgets/WidgetDef.js.map +1 -1
  56. package/lib/esm/appui-react/widgets/WidgetHost.d.ts.map +1 -1
  57. package/lib/esm/appui-react/widgets/WidgetHost.js +3 -1
  58. package/lib/esm/appui-react/widgets/WidgetHost.js.map +1 -1
  59. package/lib/esm/appui-react.d.ts +1 -0
  60. package/lib/esm/appui-react.d.ts.map +1 -1
  61. package/lib/esm/appui-react.js +1 -0
  62. package/lib/esm/appui-react.js.map +1 -1
  63. package/package.json +32 -32
@@ -14,7 +14,7 @@ import { assert, Logger, ProcessDetector } from "@itwin/core-bentley";
14
14
  import { StagePanelLocation, UiItemsManager, WidgetState } from "@itwin/appui-abstract";
15
15
  import { Size, UiStateStorageStatus } from "@itwin/core-react";
16
16
  import { ToolbarPopupAutoHideContext } from "@itwin/components-react";
17
- import { addPanelWidget, addTab, addWidgetTabToFloatingPanel, addWidgetTabToPanelSection, convertAllPopupWidgetContainersToFloating, createNineZoneState, createTabsState, createTabState, createWidgetState, findTab, findWidget, floatingWidgetBringToFront, FloatingWidgets, getUniqueId, getWidgetPanelSectionId, isFloatingLocation, isHorizontalPanelSide, NineZone, NineZoneStateReducer, panelSides, removeTab, toolSettingsTabId, WidgetPanels, } from "@itwin/appui-layout-react";
17
+ import { addPanelWidget, addTab, addWidgetTabToDraftFloatingPanel, addWidgetTabToFloatingPanel, addWidgetTabToPanelSection, convertAllPopupWidgetContainersToFloating, createNineZoneState, createTabsState, createTabState, createWidgetState, findTab, findWidget, floatingWidgetBringToFront, FloatingWidgets, getUniqueId, getWidgetPanelSectionId, isFloatingLocation, isHorizontalPanelSide, isPopoutLocation, NineZone, NineZoneStateReducer, panelSides, removeTab, toolSettingsTabId, WidgetPanels, } from "@itwin/appui-layout-react";
18
18
  import { useActiveFrontstageDef } from "../frontstage/Frontstage";
19
19
  import { FrontstageManager } from "../frontstage/FrontstageManager";
20
20
  import { StagePanelState } from "../stagepanels/StagePanelDef";
@@ -653,6 +653,20 @@ export function restoreNineZoneState(frontstageDef, saved) {
653
653
  }
654
654
  return restored;
655
655
  }
656
+ /**
657
+ * Checks to see whether a widget id is one of our generated uuids
658
+ * @param uuid the string value to test
659
+ * @returns boolean
660
+ */
661
+ function isUUID(uuid) {
662
+ const s = `${uuid}`;
663
+ 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}$");
664
+ // istanbul ignore else
665
+ if (result === null) {
666
+ return false;
667
+ }
668
+ return true;
669
+ }
656
670
  /** Prepares NineZoneState to be saved.
657
671
  * @note Removes toolSettings tab.
658
672
  * @note Removes tab labels and iconSpec.
@@ -667,6 +681,9 @@ export function packNineZoneState(state) {
667
681
  for (const [, tab] of Object.entries(state.tabs)) {
668
682
  if (tab.id === toolSettingsTabId)
669
683
  continue;
684
+ // istanbul ignore else
685
+ if (isUUID(tab.id))
686
+ continue;
670
687
  draft.tabs[tab.id] = {
671
688
  id: tab.id,
672
689
  preferredFloatingWidgetSize: tab.preferredFloatingWidgetSize,
@@ -676,6 +693,18 @@ export function packNineZoneState(state) {
676
693
  };
677
694
  }
678
695
  });
696
+ packed = produce(packed, (draft) => {
697
+ for (const [, floatingWidget] of Object.entries(state.floatingWidgets.byId)) {
698
+ const widgetId = floatingWidget.id;
699
+ // istanbul ignore else
700
+ if (isUUID(widgetId)) {
701
+ const idIndex = draft.floatingWidgets.allIds.indexOf(widgetId);
702
+ draft.floatingWidgets.allIds.splice(idIndex, 1);
703
+ delete draft.floatingWidgets.byId[widgetId];
704
+ delete draft.widgets[widgetId];
705
+ }
706
+ }
707
+ });
679
708
  return packed;
680
709
  }
681
710
  /** @internal */
@@ -685,6 +714,7 @@ export function isPanelCollapsed(zoneStates, panelStates) {
685
714
  return !openZone && !openPanel;
686
715
  }
687
716
  function addRemovedTab(nineZone, widgetDef) {
717
+ var _a, _b;
688
718
  const newTab = createTabState(widgetDef.id, {
689
719
  label: getWidgetLabel(widgetDef.label),
690
720
  canPopout: widgetDef.canPopout,
@@ -699,6 +729,18 @@ function addRemovedTab(nineZone, widgetDef) {
699
729
  const newTabWidget = nineZone.widgets[widgetId];
700
730
  newTabWidget.tabs.splice(widgetDef.tabLocation.tabIndex, 0, newTab.id);
701
731
  }
732
+ else if (widgetDef.tabLocation.floating) {
733
+ const id = widgetDef.tabLocation.widgetId;
734
+ if (id in nineZone.floatingWidgets.byId) {
735
+ nineZone.floatingWidgets.allIds.push(id);
736
+ nineZone.floatingWidgets.byId[id].hidden = false;
737
+ addWidgetTabToDraftFloatingPanel(nineZone, (_a = widgetDef.floatingContainerId) !== null && _a !== void 0 ? _a : widgetDef.id, widgetDef.id, nineZone.floatingWidgets.byId[id].home, newTab);
738
+ }
739
+ else {
740
+ const home = { side: widgetDef.tabLocation.side, widgetId: widgetDef.floatingContainerId, widgetIndex: 0 };
741
+ addWidgetTabToDraftFloatingPanel(nineZone, (_b = widgetDef.floatingContainerId) !== null && _b !== void 0 ? _b : widgetDef.id, widgetDef.id, home, newTab);
742
+ }
743
+ }
702
744
  else {
703
745
  const newTabPanel = nineZone.panels[widgetDef.tabLocation.side];
704
746
  if (newTabPanel.maxWidgetCount === newTabPanel.widgets.length) {
@@ -718,7 +760,7 @@ function addRemovedTab(nineZone, widgetDef) {
718
760
  }
719
761
  /** @internal */
720
762
  export const setWidgetState = produce((nineZone, widgetDef, state) => {
721
- var _a;
763
+ var _a, _b;
722
764
  if (state === WidgetState.Open) {
723
765
  const id = widgetDef.id;
724
766
  let location = findTab(nineZone, id);
@@ -727,6 +769,9 @@ export const setWidgetState = produce((nineZone, widgetDef, state) => {
727
769
  location = findTab(nineZone, id);
728
770
  assert(!!location);
729
771
  }
772
+ if (!!widgetDef.tabLocation.floating) {
773
+ nineZone.floatingWidgets.byId[(_a = widgetDef.floatingContainerId) !== null && _a !== void 0 ? _a : widgetDef.id].hidden = false;
774
+ }
730
775
  const widget = nineZone.widgets[location.widgetId];
731
776
  widget.minimized = false;
732
777
  widget.activeTabId = id;
@@ -737,7 +782,7 @@ export const setWidgetState = produce((nineZone, widgetDef, state) => {
737
782
  panel.collapsed && (panel.collapsed = false);
738
783
  // istanbul ignore next
739
784
  if (undefined === panel.size || 0 === panel.size) {
740
- panel.size = (_a = panel.minSize) !== null && _a !== void 0 ? _a : 200;
785
+ panel.size = (_b = panel.minSize) !== null && _b !== void 0 ? _b : 200;
741
786
  }
742
787
  }
743
788
  }
@@ -765,16 +810,31 @@ function hideWidget(state, widgetDef) {
765
810
  const location = findTab(state, widgetDef.id);
766
811
  if (!location)
767
812
  return;
768
- const widgetId = location.widgetId;
769
- const side = "side" in location ? location.side : "left";
770
- const widgetIndex = "side" in location ? state.panels[side].widgets.indexOf(widgetId) : 0;
771
- const tabIndex = state.widgets[location.widgetId].tabs.indexOf(widgetDef.id);
772
- widgetDef.tabLocation = {
773
- side,
774
- tabIndex,
775
- widgetId,
776
- widgetIndex,
777
- };
813
+ if (isFloatingLocation(location)) {
814
+ const widget = state.floatingWidgets.byId[location.widgetId];
815
+ widgetDef.setFloatingContainerId(location.floatingWidgetId);
816
+ widgetDef.tabLocation = {
817
+ side: widget.home.side,
818
+ tabIndex: widget.home.widgetIndex,
819
+ widgetId: widgetDef.id,
820
+ widgetIndex: widget.home.widgetIndex,
821
+ floating: true,
822
+ };
823
+ }
824
+ else
825
+ // istanbul ignore else
826
+ if (!isPopoutLocation(location)) {
827
+ const widgetId = location.widgetId;
828
+ const side = "side" in location ? location.side : "left";
829
+ const widgetIndex = "side" in location ? state.panels[side].widgets.indexOf(widgetId) : 0;
830
+ const tabIndex = state.widgets[location.widgetId].tabs.indexOf(widgetDef.id);
831
+ widgetDef.tabLocation = {
832
+ side,
833
+ tabIndex,
834
+ widgetId,
835
+ widgetIndex,
836
+ };
837
+ }
778
838
  removeTab(state, widgetDef.id);
779
839
  }
780
840
  /** @internal */