@itwin/appui-react 4.16.3 → 4.16.5

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 (64) hide show
  1. package/CHANGELOG.md +19 -1
  2. package/lib/cjs/appui-react/childwindow/CopyStyles.d.ts +1 -1
  3. package/lib/cjs/appui-react/childwindow/CopyStyles.d.ts.map +1 -1
  4. package/lib/cjs/appui-react/childwindow/CopyStyles.js +28 -7
  5. package/lib/cjs/appui-react/childwindow/CopyStyles.js.map +1 -1
  6. package/lib/cjs/appui-react/childwindow/InternalChildWindowManager.d.ts +1 -1
  7. package/lib/cjs/appui-react/childwindow/InternalChildWindowManager.d.ts.map +1 -1
  8. package/lib/cjs/appui-react/childwindow/InternalChildWindowManager.js +3 -3
  9. package/lib/cjs/appui-react/childwindow/InternalChildWindowManager.js.map +1 -1
  10. package/lib/cjs/appui-react/content/ContentGroup.js +1 -1
  11. package/lib/cjs/appui-react/content/ContentGroup.js.map +1 -1
  12. package/lib/cjs/appui-react/preview/new-toolbars/ToolGroup.scss +4 -0
  13. package/lib/cjs/appui-react/selection/SelectionContextItemDef.d.ts.map +1 -1
  14. package/lib/cjs/appui-react/selection/SelectionContextItemDef.js +27 -25
  15. package/lib/cjs/appui-react/selection/SelectionContextItemDef.js.map +1 -1
  16. package/lib/cjs/appui-react/statusbar/StatusBarComposer.d.ts.map +1 -1
  17. package/lib/cjs/appui-react/statusbar/StatusBarComposer.js +7 -6
  18. package/lib/cjs/appui-react/statusbar/StatusBarComposer.js.map +1 -1
  19. package/lib/cjs/appui-react/statusbar/StatusBarCornerComponentContext.js +2 -0
  20. package/lib/cjs/appui-react/statusbar/StatusBarCornerComponentContext.js.map +1 -1
  21. package/lib/cjs/appui-react/toolbar/ToolbarItem.d.ts +1 -1
  22. package/lib/cjs/appui-react/toolbar/ToolbarItem.js.map +1 -1
  23. package/lib/cjs/appui-react/tools/CoreToolDefinitions.d.ts.map +1 -1
  24. package/lib/cjs/appui-react/tools/CoreToolDefinitions.js +23 -25
  25. package/lib/cjs/appui-react/tools/CoreToolDefinitions.js.map +1 -1
  26. package/lib/cjs/appui-react/uiprovider/ComponentGenerator.d.ts.map +1 -1
  27. package/lib/cjs/appui-react/uiprovider/ComponentGenerator.js +16 -12
  28. package/lib/cjs/appui-react/uiprovider/ComponentGenerator.js.map +1 -1
  29. package/lib/cjs/appui-react/utils/getActiveViewport.d.ts +10 -0
  30. package/lib/cjs/appui-react/utils/getActiveViewport.d.ts.map +1 -0
  31. package/lib/cjs/appui-react/utils/getActiveViewport.js +26 -0
  32. package/lib/cjs/appui-react/utils/getActiveViewport.js.map +1 -0
  33. package/lib/esm/appui-react/childwindow/CopyStyles.d.ts +1 -1
  34. package/lib/esm/appui-react/childwindow/CopyStyles.d.ts.map +1 -1
  35. package/lib/esm/appui-react/childwindow/CopyStyles.js +26 -5
  36. package/lib/esm/appui-react/childwindow/CopyStyles.js.map +1 -1
  37. package/lib/esm/appui-react/childwindow/InternalChildWindowManager.d.ts +1 -1
  38. package/lib/esm/appui-react/childwindow/InternalChildWindowManager.d.ts.map +1 -1
  39. package/lib/esm/appui-react/childwindow/InternalChildWindowManager.js +3 -3
  40. package/lib/esm/appui-react/childwindow/InternalChildWindowManager.js.map +1 -1
  41. package/lib/esm/appui-react/content/ContentGroup.js +1 -1
  42. package/lib/esm/appui-react/content/ContentGroup.js.map +1 -1
  43. package/lib/esm/appui-react/preview/new-toolbars/ToolGroup.scss +4 -0
  44. package/lib/esm/appui-react/selection/SelectionContextItemDef.d.ts.map +1 -1
  45. package/lib/esm/appui-react/selection/SelectionContextItemDef.js +27 -25
  46. package/lib/esm/appui-react/selection/SelectionContextItemDef.js.map +1 -1
  47. package/lib/esm/appui-react/statusbar/StatusBarComposer.d.ts.map +1 -1
  48. package/lib/esm/appui-react/statusbar/StatusBarComposer.js +7 -6
  49. package/lib/esm/appui-react/statusbar/StatusBarComposer.js.map +1 -1
  50. package/lib/esm/appui-react/statusbar/StatusBarCornerComponentContext.js +2 -0
  51. package/lib/esm/appui-react/statusbar/StatusBarCornerComponentContext.js.map +1 -1
  52. package/lib/esm/appui-react/toolbar/ToolbarItem.d.ts +1 -1
  53. package/lib/esm/appui-react/toolbar/ToolbarItem.js.map +1 -1
  54. package/lib/esm/appui-react/tools/CoreToolDefinitions.d.ts.map +1 -1
  55. package/lib/esm/appui-react/tools/CoreToolDefinitions.js +23 -25
  56. package/lib/esm/appui-react/tools/CoreToolDefinitions.js.map +1 -1
  57. package/lib/esm/appui-react/uiprovider/ComponentGenerator.d.ts.map +1 -1
  58. package/lib/esm/appui-react/uiprovider/ComponentGenerator.js +16 -12
  59. package/lib/esm/appui-react/uiprovider/ComponentGenerator.js.map +1 -1
  60. package/lib/esm/appui-react/utils/getActiveViewport.d.ts +10 -0
  61. package/lib/esm/appui-react/utils/getActiveViewport.d.ts.map +1 -0
  62. package/lib/esm/appui-react/utils/getActiveViewport.js +22 -0
  63. package/lib/esm/appui-react/utils/getActiveViewport.js.map +1 -0
  64. package/package.json +7 -7
package/CHANGELOG.md CHANGED
@@ -1,6 +1,24 @@
1
1
  # Change Log - @itwin/appui-react
2
2
 
3
- This log was last generated on Tue, 03 Sep 2024 14:32:22 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 10 Sep 2024 16:40:45 GMT and should not be manually modified.
4
+
5
+ ## 4.16.5
6
+ Tue, 10 Sep 2024 16:40:45 GMT
7
+
8
+ ### Updates
9
+
10
+ - Fix copyStyles to ignore errors on external resource links.
11
+ - Fix tool conditionals that depend on active viewport when content control APIs are not used.
12
+ - Fix `Toolbar` to avoid rendering of borders artifact
13
+ - Fix synchronization of lock properties by properly invoking applyToolSettingPropertyChange.
14
+ - Fix `undefined` property access within `StatusBarComposer` component.
15
+
16
+ ## 4.16.4
17
+ Wed, 04 Sep 2024 08:10:19 GMT
18
+
19
+ ### Updates
20
+
21
+ - Fix link style load timing issue in window popups.
4
22
 
5
23
  ## 4.16.3
6
24
  Tue, 03 Sep 2024 14:32:22 GMT
@@ -1,5 +1,5 @@
1
1
  /** Copies the CSS style sheets from source document into the target document.
2
2
  * @internal
3
3
  */
4
- export declare function copyStyles(targetDoc: Document, sourceDoc?: Document): void;
4
+ export declare function copyStyles(targetDoc: Document, sourceDoc?: Document): Promise<void[]>;
5
5
  //# sourceMappingURL=CopyStyles.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CopyStyles.d.ts","sourceRoot":"","sources":["../../../../src/appui-react/childwindow/CopyStyles.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,wBAAgB,UAAU,CACxB,SAAS,EAAE,QAAQ,EACnB,SAAS,GAAE,QAAmB,QA2B/B"}
1
+ {"version":3,"file":"CopyStyles.d.ts","sourceRoot":"","sources":["../../../../src/appui-react/childwindow/CopyStyles.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,wBAAsB,UAAU,CAC9B,SAAS,EAAE,QAAQ,EACnB,SAAS,GAAE,QAAmB,mBAoD/B"}
@@ -1,20 +1,38 @@
1
1
  "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.copyStyles = void 0;
2
4
  /*---------------------------------------------------------------------------------------------
3
5
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
6
  * See LICENSE.md in the project root for license terms and full copyright notice.
5
7
  *--------------------------------------------------------------------------------------------*/
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.copyStyles = void 0;
8
+ const core_bentley_1 = require("@itwin/core-bentley");
9
+ const UiFramework_1 = require("../UiFramework");
8
10
  /** Copies the CSS style sheets from source document into the target document.
9
11
  * @internal
10
12
  */
11
- function copyStyles(targetDoc, sourceDoc = document) {
13
+ async function copyStyles(targetDoc, sourceDoc = document) {
14
+ const promises = [];
12
15
  const styleSheets = Array.from(sourceDoc.styleSheets);
13
16
  styleSheets.forEach(({ ownerNode }) => {
14
17
  // Copy `link` and `style` elements.
15
18
  if (!ownerNode)
16
19
  return;
17
20
  const clonedNode = targetDoc.importNode(ownerNode, true);
21
+ if (clonedNode instanceof
22
+ (targetDoc.defaultView?.HTMLLinkElement ?? HTMLLinkElement) &&
23
+ clonedNode.href) {
24
+ promises.push(new Promise((resolve) => {
25
+ clonedNode.onload = () => {
26
+ resolve();
27
+ };
28
+ clonedNode.onerror = () => {
29
+ core_bentley_1.Logger.logError(UiFramework_1.UiFramework.loggerCategory(copyStyles), `Failed to load external resource`, {
30
+ href: clonedNode.href,
31
+ });
32
+ resolve();
33
+ };
34
+ }));
35
+ }
18
36
  targetDoc.head.appendChild(clonedNode);
19
37
  });
20
38
  const adoptedStyleSheets = Array.from(sourceDoc.adoptedStyleSheets ?? []);
@@ -23,10 +41,7 @@ function copyStyles(targetDoc, sourceDoc = document) {
23
41
  if (!targetDoc.defaultView)
24
42
  return;
25
43
  const newStyleSheet = new targetDoc.defaultView.CSSStyleSheet();
26
- Array.from(styleSheet.cssRules).forEach((rule, index) => {
27
- // `cssText` might not serialize complex shorthand properties correctly: https://github.com/iTwin/appui/issues/893
28
- newStyleSheet.insertRule(rule.cssText, index);
29
- });
44
+ promises.push(newStyleSheet.replace(stringifyStyleSheet(styleSheet)).then(() => { }));
30
45
  targetDoc.adoptedStyleSheets.push(newStyleSheet);
31
46
  });
32
47
  // Copy sprites.
@@ -34,6 +49,12 @@ function copyStyles(targetDoc, sourceDoc = document) {
34
49
  if (svgSymbolParent) {
35
50
  targetDoc.body.appendChild(svgSymbolParent.cloneNode(true));
36
51
  }
52
+ return Promise.all(promises);
37
53
  }
38
54
  exports.copyStyles = copyStyles;
55
+ function stringifyStyleSheet(stylesheet) {
56
+ return Array.from(stylesheet.cssRules)
57
+ .map((rule) => rule.cssText)
58
+ .join("\n");
59
+ }
39
60
  //# sourceMappingURL=CopyStyles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CopyStyles.js","sourceRoot":"","sources":["../../../../src/appui-react/childwindow/CopyStyles.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG;;GAEG;AACH,SAAgB,UAA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ourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\n/** Copies the CSS style sheets from source document into the target document.\n * @internal\n */\nexport function copyStyles(\n targetDoc: Document,\n sourceDoc: Document = document\n) {\n const styleSheets = Array.from(sourceDoc.styleSheets);\n styleSheets.forEach(({ ownerNode }) => {\n // Copy `link` and `style` elements.\n if (!ownerNode) return;\n const clonedNode = targetDoc.importNode(ownerNode, true);\n targetDoc.head.appendChild(clonedNode);\n });\n\n const adoptedStyleSheets = Array.from(sourceDoc.adoptedStyleSheets ?? []);\n adoptedStyleSheets.forEach((styleSheet) => {\n // Adopted stylesheet have no ownerNode and can't be shared between multiple documents.\n if (!targetDoc.defaultView) return;\n const newStyleSheet = new targetDoc.defaultView.CSSStyleSheet();\n Array.from(styleSheet.cssRules).forEach((rule, index) => {\n // `cssText` might not serialize complex shorthand properties correctly: https://github.com/iTwin/appui/issues/893\n newStyleSheet.insertRule(rule.cssText, index);\n });\n targetDoc.adoptedStyleSheets.push(newStyleSheet);\n });\n\n // Copy sprites.\n const svgSymbolParent = sourceDoc.getElementById(\"__SVG_SPRITE_NODE__\");\n if (svgSymbolParent) {\n targetDoc.body.appendChild(svgSymbolParent.cloneNode(true));\n }\n}\n"]}
1
+ {"version":3,"file":"CopyStyles.js","sourceRoot":"","sources":["../../../../src/appui-react/childwindow/CopyStyles.ts"],"names":[],"mappings":";;;AAAA;;;gGAGgG;AAChG,sDAA6C;AAC7C,gDAA6C;AAE7C;;GAEG;AACI,KAAK,UAAU,UAAU,CAC9B,SAAmB,EACnB,YAAsB,QAAQ;IAE9B,MAAM,QAAQ,GAAyB,EAAE,CAAC;IAC1C,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACtD,WAAW,CAAC,OAAO,CAAC,CAAC,EAAE,SAAS,EAAE,EAA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,CAAC,aAAa,CAAC,CAAC;IACnD,CAAC,CAAC,CAAC;IAEH,gBAAgB;IAChB,MAAM,eAAe,GAAG,SAAS,CAAC,cAAc,CAAC,qBAAqB,CAAC,CAAC;IACxE,IAAI,eAAe,EAAE,CAAC;QACpB,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;IAC9D,CAAC;IAED,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC/B,CAAC;AAtDD,gCAsDC;AAED,SAAS,mBAAmB,CAAC,UAAyB;IACpD,OAAO,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;SACnC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC;SAC3B,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\nimport { Logger } from \"@itwin/core-bentley\";\nimport { UiFramework } from \"../UiFramework\";\n\n/** Copies the CSS style sheets from source document into the target document.\n * @internal\n */\nexport async function copyStyles(\n targetDoc: Document,\n sourceDoc: Document = document\n) {\n const promises: Array<Promise<void>> = [];\n const styleSheets = Array.from(sourceDoc.styleSheets);\n styleSheets.forEach(({ ownerNode }) => {\n // Copy `link` and `style` elements.\n if (!ownerNode) return;\n const clonedNode = targetDoc.importNode(ownerNode, true);\n if (\n clonedNode instanceof\n (targetDoc.defaultView?.HTMLLinkElement ?? HTMLLinkElement) &&\n clonedNode.href\n ) {\n promises.push(\n new Promise((resolve) => {\n clonedNode.onload = () => {\n resolve();\n };\n clonedNode.onerror = () => {\n Logger.logError(\n UiFramework.loggerCategory(copyStyles),\n `Failed to load external resource`,\n {\n href: clonedNode.href,\n }\n );\n resolve();\n };\n })\n );\n }\n targetDoc.head.appendChild(clonedNode);\n });\n\n const adoptedStyleSheets = Array.from(sourceDoc.adoptedStyleSheets ?? []);\n adoptedStyleSheets.forEach((styleSheet) => {\n // Adopted stylesheet have no ownerNode and can't be shared between multiple documents.\n if (!targetDoc.defaultView) return;\n const newStyleSheet = new targetDoc.defaultView.CSSStyleSheet();\n promises.push(\n newStyleSheet.replace(stringifyStyleSheet(styleSheet)).then(() => {})\n );\n targetDoc.adoptedStyleSheets.push(newStyleSheet);\n });\n\n // Copy sprites.\n const svgSymbolParent = sourceDoc.getElementById(\"__SVG_SPRITE_NODE__\");\n if (svgSymbolParent) {\n targetDoc.body.appendChild(svgSymbolParent.cloneNode(true));\n }\n\n return Promise.all(promises);\n}\n\nfunction stringifyStyleSheet(stylesheet: CSSStyleSheet) {\n return Array.from(stylesheet.cssRules)\n .map((rule) => rule.cssText)\n .join(\"\\n\");\n}\n"]}
@@ -1,9 +1,9 @@
1
1
  /** @packageDocumentation
2
2
  * @module ChildWindowManager
3
3
  */
4
+ import "./InternalChildWindowManager.scss";
4
5
  import * as React from "react";
5
6
  import type { ChildWindowLocationProps, FrameworkChildWindows, OpenChildWindowInfo } from "../framework/FrameworkChildWindows";
6
- import "./InternalChildWindowManager.scss";
7
7
  /**
8
8
  * Simplification of non exported CreateRoot parameter, only to be used
9
9
  * in InternalChildWindowManager and ChildWindowManager
@@ -1 +1 @@
1
- {"version":3,"file":"InternalChildWindowManager.d.ts","sourceRoot":"","sources":["../../../../src/appui-react/childwindow/InternalChildWindowManager.tsx"],"names":[],"mappings":"AAKA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAO/B,OAAO,KAAK,EACV,wBAAwB,EACxB,qBAAqB,EACrB,mBAAmB,EACpB,MAAM,oCAAoC,CAAC;AAO5C,OAAO,mCAAmC,CAAC;AA2B3C;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,UAAU,CAAC,qBAAqB,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAE/E;;;;KAIK;AACL,qBAAa,0BAA2B,YAAW,qBAAqB;IACtE,OAAO,CAAC,iBAAiB,CAA6B;IACtD,OAAO,CAAC,WAAW,CAAC,CAAa;IACjC,OAAO,CAAC,MAAM,CAAwC;IAEtD,IAAW,gBAAgB,0BAE1B;IAED;;;;;;;;OAQG;IACI,aAAa,CAAC,YAAY,EAAE,UAAU,GAAG,IAAI;IAIpD;;;;OAIG;IACH,OAAO,CAAC,MAAM;IAqBd;;;;OAIG;IACI,IAAI,CACT,aAAa,EAAE,MAAM,GAAG,SAAS,GAChC,mBAAmB,GAAG,SAAS;IAQlC;;;;OAIG;IACI,MAAM,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,MAAM,GAAG,SAAS;IAS3E,OAAO,CAAC,yBAAyB;IAmFjC,gGAAgG;IACzF,QAAQ;IAOf;;;;;OAKG;IACI,KAAK,kBAAmB,MAAM,2CAkBnC;IAEF,OAAO,CAAC,oBAAoB;IAU5B;;;;;;;;OAQG;IACI,IAAI,CACT,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,KAAK,CAAC,SAAS,EACxB,QAAQ,EAAE,wBAAwB,EAClC,mBAAmB,CAAC,EAAE,OAAO;CA2DhC"}
1
+ {"version":3,"file":"InternalChildWindowManager.d.ts","sourceRoot":"","sources":["../../../../src/appui-react/childwindow/InternalChildWindowManager.tsx"],"names":[],"mappings":"AAKA;;GAEG;AAEH,OAAO,mCAAmC,CAAC;AAC3C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAO/B,OAAO,KAAK,EACV,wBAAwB,EACxB,qBAAqB,EACrB,mBAAmB,EACpB,MAAM,oCAAoC,CAAC;AAiC5C;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,UAAU,CAAC,qBAAqB,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAE/E;;;;KAIK;AACL,qBAAa,0BAA2B,YAAW,qBAAqB;IACtE,OAAO,CAAC,iBAAiB,CAA6B;IACtD,OAAO,CAAC,WAAW,CAAC,CAAa;IACjC,OAAO,CAAC,MAAM,CAAwC;IAEtD,IAAW,gBAAgB,0BAE1B;IAED;;;;;;;;OAQG;IACI,aAAa,CAAC,YAAY,EAAE,UAAU,GAAG,IAAI;IAIpD;;;;OAIG;IACH,OAAO,CAAC,MAAM;IAqBd;;;;OAIG;IACI,IAAI,CACT,aAAa,EAAE,MAAM,GAAG,SAAS,GAChC,mBAAmB,GAAG,SAAS;IAQlC;;;;OAIG;IACI,MAAM,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,MAAM,GAAG,SAAS;IAS3E,OAAO,CAAC,yBAAyB;IAmFjC,gGAAgG;IACzF,QAAQ;IAOf;;;;;OAKG;IACI,KAAK,kBAAmB,MAAM,2CAkBnC;IAEF,OAAO,CAAC,oBAAoB;IAU5B;;;;;;;;OAQG;IACI,IAAI,CACT,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,KAAK,CAAC,SAAS,EACxB,QAAQ,EAAE,wBAAwB,EAClC,mBAAmB,CAAC,EAAE,OAAO;CA2DhC"}
@@ -8,6 +8,7 @@ exports.InternalChildWindowManager = void 0;
8
8
  /** @packageDocumentation
9
9
  * @module ChildWindowManager
10
10
  */
11
+ require("./InternalChildWindowManager.scss");
11
12
  const React = require("react");
12
13
  const ReactDOM = require("react-dom");
13
14
  const react_redux_1 = require("react-redux");
@@ -20,7 +21,6 @@ const PopupManager_1 = require("../popup/PopupManager");
20
21
  const ThemeManager_1 = require("../theme/ThemeManager");
21
22
  const useUiStateStorage_1 = require("../uistate/useUiStateStorage");
22
23
  const CopyStyles_1 = require("./CopyStyles");
23
- require("./InternalChildWindowManager.scss");
24
24
  const usePopoutsStore_1 = require("../preview/reparent-popout-widgets/usePopoutsStore");
25
25
  const childHtml = `<!DOCTYPE html>
26
26
  <html>
@@ -160,8 +160,8 @@ class InternalChildWindowManager {
160
160
  React.createElement(CursorMenu_1.CursorPopupMenu, null),
161
161
  React.createElement("div", { className: "uifw-child-window-container nz-widget-widget" }, content)),
162
162
  React.createElement("div", { className: "uifw-childwindow-internalChildWindowManager_portalContainer" }))))));
163
- setTimeout(() => {
164
- (0, CopyStyles_1.copyStyles)(childWindow.document);
163
+ setTimeout(async () => {
164
+ await (0, CopyStyles_1.copyStyles)(childWindow.document);
165
165
  setTimeout(() => {
166
166
  this.render(element, reactConnectionDiv);
167
167
  if (childWindow.expectedHeight && childWindow.expectedWidth) {
@@ -1 +1 @@
1
- {"version":3,"file":"InternalChildWindowManager.js","sourceRoot":"","sources":["../../../../src/appui-react/childwindow/InternalChildWindowManager.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG;;GAEG;AAEH,+BAA+B;AAC/B,sCAAsC;AACtC,6CAAuC;AACvC,gDAA6C;AAC7C,gEAAkE;AAClE,qEAAmE;AACnE,2EAAyE;AAMzE,sEAAgE;AAChE,wDAAsD;AACtD,wDAAqD;AACrD,oEAAqE;AAErE,6CAA0C;AAC1C,6CAA2C;AAC3C,wFAAqF;AAGrF,MAAM,SAAS,GAAG;;;;;;;;;;;;;;;;;;;;;QAqBV,CAAC;AAST;;;;KAIK;AACL,MAAa,0BAA0B;IAAvC;QACU,sBAAiB,GAA0B,EAAE,CAAC;QAE9C,WAAM,GAAqC,EAAE,CAAC;QAqKtD;;;;;WAKG;QACI,UAAK,GAAG,CAAC,aAAqB,EAAE,kBAAkB,GAAG,IAAI,EAAE,EAAE;YAClE,MAAM,WAAW,GAAG,IAAI,CAAC,gBAAgB,CAAC,SAAS,CACjD,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,aAAa,KAAK,aAAa,CAC3D,CAAC;YACF,IAAI,WAAW,KAAK,CAAC,CAAC;gBAAE,OAAO,KAAK,CAAC;YACrC,MAAM,EAAE,mBAAmB,EAAE,GAAG,iCAAe,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C;YAClE,IAAI,aAAa,EAAE,CAAC;gBAClB,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;YAClC,CAAC;QACH,CAAC,EACD,KAAK,CACN,CAAC;QAEF,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AArRD,gEAqRC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\n/** @packageDocumentation\n * @module ChildWindowManager\n */\n\nimport * as React from \"react\";\nimport * as ReactDOM from \"react-dom\";\nimport { Provider } from \"react-redux\";\nimport { UiFramework } from \"../UiFramework\";\nimport { CursorPopupMenu } from \"../cursor/cursormenu/CursorMenu\";\nimport { ModalDialogRenderer } from \"../dialog/ModalDialogManager\";\nimport { ModelessDialogRenderer } from \"../dialog/ModelessDialogManager\";\nimport type {\n ChildWindowLocationProps,\n FrameworkChildWindows,\n OpenChildWindowInfo,\n} from \"../framework/FrameworkChildWindows\";\nimport { TabIdContext } from \"../layout/widget/ContentRenderer\";\nimport { PopupRenderer } from \"../popup/PopupManager\";\nimport { ThemeManager } from \"../theme/ThemeManager\";\nimport { UiStateStorageHandler } from \"../uistate/useUiStateStorage\";\nimport type { ChildWindow } from \"./ChildWindowConfig\";\nimport { copyStyles } from \"./CopyStyles\";\nimport \"./InternalChildWindowManager.scss\";\nimport { usePopoutsStore } from \"../preview/reparent-popout-widgets/usePopoutsStore\";\nimport type { WidgetDef } from \"../widgets/WidgetDef\";\n\nconst childHtml = `<!DOCTYPE html>\n<html>\n<head>\n <meta charset=\"utf-8\" />\n <style>\n html,\n body {\n height: 100%;\n width: 100%;\n margin: 0;\n overflow: hidden;\n }\n #root {\n height: 100%;\n }\n </style>\n</head>\n<body>\n <noscript>You need to enable JavaScript to run this app.</noscript>\n <div id=\"root\"></div>\n</body>\n</html>`;\n\n/**\n * Simplification of non exported CreateRoot parameter, only to be used\n * in InternalChildWindowManager and ChildWindowManager\n * @internal\n */\nexport type CreateRoot = Parameters<FrameworkChildWindows[\"useCreateRoot\"]>[0];\n\n/** Supports opening a child browser window from the main application window. The child window is managed by the main application\n * and is running in the same security context. The application must deliver the html file iTwinPopup.html along side its index.html.\n * See also: [Child Window Manager]($docs/learning/ui/appui-react/ChildWindows.md)\n * @internal\n * */\nexport class InternalChildWindowManager implements FrameworkChildWindows {\n private _openChildWindows: OpenChildWindowInfo[] = [];\n private _createRoot?: CreateRoot;\n private _roots: { [childwindowId: string]: any } = {};\n\n public get openChildWindows() {\n return this._openChildWindows;\n }\n\n /**\n * When using React 18, the `createRoot` function must be provided in order to render Popout content with React 18.\n * Do not call if using React 17 or before.\n *\n * Note: The type of the function is intentionally simplified here.\n *\n * @param createRootFn Function imported from `import { createRoot } from \"react-dom/client\";`\n * @beta Will be removed once the transition to React 18 is complete.\n */\n public useCreateRoot(createRootFn: CreateRoot): void {\n this._createRoot = createRootFn;\n }\n\n /**\n * Abstracts ReactDOM.render to use either the _createRoot method or the default ReactDOM.render.\n * @param element Element to render.\n * @param container Container to render to.\n */\n private render(\n element: React.FunctionComponentElement<any>,\n container: Element | DocumentFragment\n ) {\n // If createRoot is passed in for React 18 we have to render differently\n // than without it. React 17 vs React 18. We need to save the root to\n // unmount it.\n if (this._createRoot) {\n const childWindowId = UiFramework.childWindows.findId(\n container.ownerDocument.defaultView\n );\n if (childWindowId) {\n this._roots[childWindowId] = this._createRoot(container);\n this._roots[childWindowId].render(element);\n }\n } else {\n // eslint-disable-next-line react/no-deprecated, deprecation/deprecation\n ReactDOM.render(element, container);\n }\n }\n\n /**\n * Returns the OpenChildWindowInfo for the related id.\n * @param childWindowId Id of the window to retrieve.\n * @returns undefined if not found.\n */\n public find(\n childWindowId: string | undefined\n ): OpenChildWindowInfo | undefined {\n if (undefined === childWindowId) return undefined;\n\n return this.openChildWindows.find(\n (openWindow) => openWindow.childWindowId === childWindowId\n );\n }\n\n /**\n * Return the childWindowId of the provided window.\n * @param contentWindow Window element to identify\n * @returns undefined if not found\n */\n public findId(contentWindow: Window | undefined | null): string | undefined {\n if (!contentWindow) return undefined;\n\n const childWindow = this.openChildWindows.find(\n (openWindow) => openWindow.window === contentWindow\n );\n return childWindow?.childWindowId;\n }\n\n private renderChildWindowContents(\n childWindow: ChildWindow,\n childWindowId: string,\n content: React.ReactNode,\n title: string\n ) {\n childWindow.document.title = title;\n\n const reactConnectionDiv = childWindow.document.getElementById(\"root\");\n if (reactConnectionDiv && content && React.isValidElement(content)) {\n // set openChildWindows now so components can use it when they mount\n this._openChildWindows.push({\n childWindowId,\n window: childWindow,\n parentWindow: window,\n });\n const widgetDef = content.props.widgetDef as WidgetDef | undefined;\n const tabId = widgetDef?.id;\n const element = (\n // eslint-disable-next-line deprecation/deprecation\n <Provider store={UiFramework.store}>\n <TabIdContext.Provider value={tabId}>\n <UiStateStorageHandler>\n <ThemeManager>\n <div className=\"uifw-child-window-container-host\">\n <PopupRenderer />\n <ModalDialogRenderer />\n <ModelessDialogRenderer />\n <CursorPopupMenu />\n <div className=\"uifw-child-window-container nz-widget-widget\">\n {content}\n </div>\n </div>\n <div className=\"uifw-childwindow-internalChildWindowManager_portalContainer\" />\n </ThemeManager>\n </UiStateStorageHandler>\n </TabIdContext.Provider>\n </Provider>\n );\n\n setTimeout(() => {\n copyStyles(childWindow.document);\n setTimeout(() => {\n this.render(element, reactConnectionDiv);\n\n if (childWindow.expectedHeight && childWindow.expectedWidth) {\n childWindow.deltaWidth =\n childWindow.expectedWidth - childWindow.innerWidth;\n childWindow.deltaHeight =\n childWindow.expectedHeight - childWindow.innerHeight;\n }\n\n if (childWindow.expectedLeft && childWindow.expectedTop) {\n childWindow.deltaLeft =\n childWindow.expectedLeft - childWindow.screenLeft;\n childWindow.deltaTop =\n childWindow.expectedTop - childWindow.screenTop;\n }\n });\n });\n\n childWindow.addEventListener(\"pagehide\", () => {\n const frontStageDef = UiFramework.frontstages.activeFrontstageDef;\n if (!frontStageDef) return;\n frontStageDef.saveChildWindowSizeAndPosition(\n childWindowId,\n childWindow\n );\n\n // Trigger first so popout can be converted back to main window widget\n this.close(childWindowId, false);\n\n // UnmountComponentAtNode is deprecated in React 18, so if they are\n // using React 18 and passing in a createRoot function, unmount()\n // will be used\n if (this._roots[childWindowId]) {\n this._roots[childWindowId].unmount();\n // eslint-disable-next-line react/no-deprecated, deprecation/deprecation\n } else ReactDOM.unmountComponentAtNode(reactConnectionDiv);\n });\n }\n }\n\n /** Close all child/pop-out windows. This typically is called when the frontstage is changed. */\n public closeAll() {\n this.openChildWindows.forEach((openChildWindow) =>\n openChildWindow.window.close()\n );\n this._openChildWindows = [];\n }\n\n /**\n * Close a specific child window.\n * @param childWindowId Id of the window to close.\n * @param processWindowClose should the `close` method be called on the closing window. (defaults to true).\n * @returns false if the window could not be found.\n */\n public close = (childWindowId: string, processWindowClose = true) => {\n const windowIndex = this.openChildWindows.findIndex(\n (openWindow) => openWindow.childWindowId === childWindowId\n );\n if (windowIndex === -1) return false;\n const { onClosePopoutWidget } = usePopoutsStore.getState();\n onClosePopoutWidget.raiseEvent({ windowId: childWindowId });\n\n const childWindow = this.openChildWindows[windowIndex];\n this.openChildWindows.splice(windowIndex, 1);\n if (processWindowClose) {\n childWindow.window.close();\n } else {\n // call the following to convert popout to docked widget\n const frontStageDef = UiFramework.frontstages.activeFrontstageDef;\n frontStageDef?.dockWidgetContainerByContainerId(childWindowId);\n }\n return true;\n };\n\n private adjustWindowLocation(location: ChildWindowLocationProps) {\n // If no location is provided, child window will open in the center of the current window.\n if (location.top === 0 && location.left === 0) {\n location.left =\n window.outerWidth / 2 + window.screenX - location.width / 2;\n location.top =\n window.outerHeight / 2 + window.screenY - location.height / 2;\n }\n }\n\n /**\n * Open a new child window.\n * @param childWindowId Id to assign to the newly created window.\n * @param title Title to display on the window.\n * @param content ReactNode to be rendered in the window.\n * @param location Position and size information\n * @param useDefaultPopoutUrl use \"/iTwinPopup.html\" as the window Url, \"\" otherwise.\n * @returns true if the window is opened successfully.\n */\n public open(\n childWindowId: string,\n title: string,\n content: React.ReactNode,\n location: ChildWindowLocationProps,\n useDefaultPopoutUrl?: boolean\n ) {\n if (\n this.openChildWindows.some(\n (openWindow) => openWindow.childWindowId === childWindowId\n )\n ) {\n return false;\n }\n\n this.adjustWindowLocation(location);\n const url = useDefaultPopoutUrl ? \"/iTwinPopup.html\" : \"\";\n const childWindow: ChildWindow | null = window.open(\n url,\n \"\",\n `width=${location.width},height=${location.height},left=${location.left},top=${location.top},menubar=no,resizable=yes,scrollbars=no,status=no,location=no`\n );\n if (!childWindow) return false;\n childWindow.expectedHeight = location.height;\n childWindow.expectedWidth = location.width;\n childWindow.expectedLeft = location.left;\n childWindow.expectedTop = location.top;\n\n if (url.length === 0) {\n childWindow.document.write(childHtml);\n this.renderChildWindowContents(\n childWindow,\n childWindowId,\n content,\n title\n );\n } else {\n childWindow.addEventListener(\n \"DOMContentLoaded\",\n () => {\n this.renderChildWindowContents(\n childWindow,\n childWindowId,\n content,\n title\n );\n },\n false\n );\n }\n\n window.addEventListener(\n \"unload\",\n () => {\n const frontStageDef = UiFramework.frontstages.activeFrontstageDef;\n if (frontStageDef) {\n this.close(childWindowId, true);\n }\n },\n false\n );\n\n return true;\n }\n}\n"]}
1
+ {"version":3,"file":"InternalChildWindowManager.js","sourceRoot":"","sources":["../../../../src/appui-react/childwindow/InternalChildWindowManager.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG;;GAEG;AAEH,6CAA2C;AAC3C,+BAA+B;AAC/B,sCAAsC;AACtC,6CAAuC;AACvC,gDAA6C;AAC7C,gEAAkE;AAClE,qEAAmE;AACnE,2EAAyE;AAMzE,sEAAgE;AAChE,wDAAsD;AACtD,wDAAqD;AACrD,oEAAqE;AAErE,6CAA0C;AAC1C,wFAAqF;AAGrF,MAAM,SAAS,GAAG;;;;;;;;;;;;;;;;;;;;;QAqBV,CAAC;AAST;;;;KAIK;AACL,MAAa,0BAA0B;IAA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;YACtC,IAAI,CAAC,yBAAyB,CAC5B,WAAW,EACX,aAAa,EACb,OAAO,EACP,KAAK,CACN,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,WAAW,CAAC,gBAAgB,CAC1B,kBAAkB,EAClB,GAAG,EAAE;gBACH,IAAI,CAAC,yBAAyB,CAC5B,WAAW,EACX,aAAa,EACb,OAAO,EACP,KAAK,CACN,CAAC;YACJ,CAAC,EACD,KAAK,CACN,CAAC;QACJ,CAAC;QAED,MAAM,CAAC,gBAAgB,CACrB,QAAQ,EACR,GAAG,EAAE;YACH,MAAM,aAAa,GAAG,yBAAW,CAAC,WAAW,CAAC,mBAAmB,CAAC;YAClE,IAAI,aAAa,EAAE,CAAC;gBAClB,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;YAClC,CAAC;QACH,CAAC,EACD,KAAK,CACN,CAAC;QAEF,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AArRD,gEAqRC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\n/** @packageDocumentation\n * @module ChildWindowManager\n */\n\nimport \"./InternalChildWindowManager.scss\";\nimport * as React from \"react\";\nimport * as ReactDOM from \"react-dom\";\nimport { Provider } from \"react-redux\";\nimport { UiFramework } from \"../UiFramework\";\nimport { CursorPopupMenu } from \"../cursor/cursormenu/CursorMenu\";\nimport { ModalDialogRenderer } from \"../dialog/ModalDialogManager\";\nimport { ModelessDialogRenderer } from \"../dialog/ModelessDialogManager\";\nimport type {\n ChildWindowLocationProps,\n FrameworkChildWindows,\n OpenChildWindowInfo,\n} from \"../framework/FrameworkChildWindows\";\nimport { TabIdContext } from \"../layout/widget/ContentRenderer\";\nimport { PopupRenderer } from \"../popup/PopupManager\";\nimport { ThemeManager } from \"../theme/ThemeManager\";\nimport { UiStateStorageHandler } from \"../uistate/useUiStateStorage\";\nimport type { ChildWindow } from \"./ChildWindowConfig\";\nimport { copyStyles } from \"./CopyStyles\";\nimport { usePopoutsStore } from \"../preview/reparent-popout-widgets/usePopoutsStore\";\nimport type { WidgetDef } from \"../widgets/WidgetDef\";\n\nconst childHtml = `<!DOCTYPE html>\n<html>\n<head>\n <meta charset=\"utf-8\" />\n <style>\n html,\n body {\n height: 100%;\n width: 100%;\n margin: 0;\n overflow: hidden;\n }\n #root {\n height: 100%;\n }\n </style>\n</head>\n<body>\n <noscript>You need to enable JavaScript to run this app.</noscript>\n <div id=\"root\"></div>\n</body>\n</html>`;\n\n/**\n * Simplification of non exported CreateRoot parameter, only to be used\n * in InternalChildWindowManager and ChildWindowManager\n * @internal\n */\nexport type CreateRoot = Parameters<FrameworkChildWindows[\"useCreateRoot\"]>[0];\n\n/** Supports opening a child browser window from the main application window. The child window is managed by the main application\n * and is running in the same security context. The application must deliver the html file iTwinPopup.html along side its index.html.\n * See also: [Child Window Manager]($docs/learning/ui/appui-react/ChildWindows.md)\n * @internal\n * */\nexport class InternalChildWindowManager implements FrameworkChildWindows {\n private _openChildWindows: OpenChildWindowInfo[] = [];\n private _createRoot?: CreateRoot;\n private _roots: { [childwindowId: string]: any } = {};\n\n public get openChildWindows() {\n return this._openChildWindows;\n }\n\n /**\n * When using React 18, the `createRoot` function must be provided in order to render Popout content with React 18.\n * Do not call if using React 17 or before.\n *\n * Note: The type of the function is intentionally simplified here.\n *\n * @param createRootFn Function imported from `import { createRoot } from \"react-dom/client\";`\n * @beta Will be removed once the transition to React 18 is complete.\n */\n public useCreateRoot(createRootFn: CreateRoot): void {\n this._createRoot = createRootFn;\n }\n\n /**\n * Abstracts ReactDOM.render to use either the _createRoot method or the default ReactDOM.render.\n * @param element Element to render.\n * @param container Container to render to.\n */\n private render(\n element: React.FunctionComponentElement<any>,\n container: Element | DocumentFragment\n ) {\n // If createRoot is passed in for React 18 we have to render differently\n // than without it. React 17 vs React 18. We need to save the root to\n // unmount it.\n if (this._createRoot) {\n const childWindowId = UiFramework.childWindows.findId(\n container.ownerDocument.defaultView\n );\n if (childWindowId) {\n this._roots[childWindowId] = this._createRoot(container);\n this._roots[childWindowId].render(element);\n }\n } else {\n // eslint-disable-next-line react/no-deprecated, deprecation/deprecation\n ReactDOM.render(element, container);\n }\n }\n\n /**\n * Returns the OpenChildWindowInfo for the related id.\n * @param childWindowId Id of the window to retrieve.\n * @returns undefined if not found.\n */\n public find(\n childWindowId: string | undefined\n ): OpenChildWindowInfo | undefined {\n if (undefined === childWindowId) return undefined;\n\n return this.openChildWindows.find(\n (openWindow) => openWindow.childWindowId === childWindowId\n );\n }\n\n /**\n * Return the childWindowId of the provided window.\n * @param contentWindow Window element to identify\n * @returns undefined if not found\n */\n public findId(contentWindow: Window | undefined | null): string | undefined {\n if (!contentWindow) return undefined;\n\n const childWindow = this.openChildWindows.find(\n (openWindow) => openWindow.window === contentWindow\n );\n return childWindow?.childWindowId;\n }\n\n private renderChildWindowContents(\n childWindow: ChildWindow,\n childWindowId: string,\n content: React.ReactNode,\n title: string\n ) {\n childWindow.document.title = title;\n\n const reactConnectionDiv = childWindow.document.getElementById(\"root\");\n if (reactConnectionDiv && content && React.isValidElement(content)) {\n // set openChildWindows now so components can use it when they mount\n this._openChildWindows.push({\n childWindowId,\n window: childWindow,\n parentWindow: window,\n });\n const widgetDef = content.props.widgetDef as WidgetDef | undefined;\n const tabId = widgetDef?.id;\n const element = (\n // eslint-disable-next-line deprecation/deprecation\n <Provider store={UiFramework.store}>\n <TabIdContext.Provider value={tabId}>\n <UiStateStorageHandler>\n <ThemeManager>\n <div className=\"uifw-child-window-container-host\">\n <PopupRenderer />\n <ModalDialogRenderer />\n <ModelessDialogRenderer />\n <CursorPopupMenu />\n <div className=\"uifw-child-window-container nz-widget-widget\">\n {content}\n </div>\n </div>\n <div className=\"uifw-childwindow-internalChildWindowManager_portalContainer\" />\n </ThemeManager>\n </UiStateStorageHandler>\n </TabIdContext.Provider>\n </Provider>\n );\n\n setTimeout(async () => {\n await copyStyles(childWindow.document);\n setTimeout(() => {\n this.render(element, reactConnectionDiv);\n\n if (childWindow.expectedHeight && childWindow.expectedWidth) {\n childWindow.deltaWidth =\n childWindow.expectedWidth - childWindow.innerWidth;\n childWindow.deltaHeight =\n childWindow.expectedHeight - childWindow.innerHeight;\n }\n\n if (childWindow.expectedLeft && childWindow.expectedTop) {\n childWindow.deltaLeft =\n childWindow.expectedLeft - childWindow.screenLeft;\n childWindow.deltaTop =\n childWindow.expectedTop - childWindow.screenTop;\n }\n });\n });\n\n childWindow.addEventListener(\"pagehide\", () => {\n const frontStageDef = UiFramework.frontstages.activeFrontstageDef;\n if (!frontStageDef) return;\n frontStageDef.saveChildWindowSizeAndPosition(\n childWindowId,\n childWindow\n );\n\n // Trigger first so popout can be converted back to main window widget\n this.close(childWindowId, false);\n\n // UnmountComponentAtNode is deprecated in React 18, so if they are\n // using React 18 and passing in a createRoot function, unmount()\n // will be used\n if (this._roots[childWindowId]) {\n this._roots[childWindowId].unmount();\n // eslint-disable-next-line react/no-deprecated, deprecation/deprecation\n } else ReactDOM.unmountComponentAtNode(reactConnectionDiv);\n });\n }\n }\n\n /** Close all child/pop-out windows. This typically is called when the frontstage is changed. */\n public closeAll() {\n this.openChildWindows.forEach((openChildWindow) =>\n openChildWindow.window.close()\n );\n this._openChildWindows = [];\n }\n\n /**\n * Close a specific child window.\n * @param childWindowId Id of the window to close.\n * @param processWindowClose should the `close` method be called on the closing window. (defaults to true).\n * @returns false if the window could not be found.\n */\n public close = (childWindowId: string, processWindowClose = true) => {\n const windowIndex = this.openChildWindows.findIndex(\n (openWindow) => openWindow.childWindowId === childWindowId\n );\n if (windowIndex === -1) return false;\n const { onClosePopoutWidget } = usePopoutsStore.getState();\n onClosePopoutWidget.raiseEvent({ windowId: childWindowId });\n\n const childWindow = this.openChildWindows[windowIndex];\n this.openChildWindows.splice(windowIndex, 1);\n if (processWindowClose) {\n childWindow.window.close();\n } else {\n // call the following to convert popout to docked widget\n const frontStageDef = UiFramework.frontstages.activeFrontstageDef;\n frontStageDef?.dockWidgetContainerByContainerId(childWindowId);\n }\n return true;\n };\n\n private adjustWindowLocation(location: ChildWindowLocationProps) {\n // If no location is provided, child window will open in the center of the current window.\n if (location.top === 0 && location.left === 0) {\n location.left =\n window.outerWidth / 2 + window.screenX - location.width / 2;\n location.top =\n window.outerHeight / 2 + window.screenY - location.height / 2;\n }\n }\n\n /**\n * Open a new child window.\n * @param childWindowId Id to assign to the newly created window.\n * @param title Title to display on the window.\n * @param content ReactNode to be rendered in the window.\n * @param location Position and size information\n * @param useDefaultPopoutUrl use \"/iTwinPopup.html\" as the window Url, \"\" otherwise.\n * @returns true if the window is opened successfully.\n */\n public open(\n childWindowId: string,\n title: string,\n content: React.ReactNode,\n location: ChildWindowLocationProps,\n useDefaultPopoutUrl?: boolean\n ) {\n if (\n this.openChildWindows.some(\n (openWindow) => openWindow.childWindowId === childWindowId\n )\n ) {\n return false;\n }\n\n this.adjustWindowLocation(location);\n const url = useDefaultPopoutUrl ? \"/iTwinPopup.html\" : \"\";\n const childWindow: ChildWindow | null = window.open(\n url,\n \"\",\n `width=${location.width},height=${location.height},left=${location.left},top=${location.top},menubar=no,resizable=yes,scrollbars=no,status=no,location=no`\n );\n if (!childWindow) return false;\n childWindow.expectedHeight = location.height;\n childWindow.expectedWidth = location.width;\n childWindow.expectedLeft = location.left;\n childWindow.expectedTop = location.top;\n\n if (url.length === 0) {\n childWindow.document.write(childHtml);\n this.renderChildWindowContents(\n childWindow,\n childWindowId,\n content,\n title\n );\n } else {\n childWindow.addEventListener(\n \"DOMContentLoaded\",\n () => {\n this.renderChildWindowContents(\n childWindow,\n childWindowId,\n content,\n title\n );\n },\n false\n );\n }\n\n window.addEventListener(\n \"unload\",\n () => {\n const frontStageDef = UiFramework.frontstages.activeFrontstageDef;\n if (frontStageDef) {\n this.close(childWindowId, true);\n }\n },\n false\n );\n\n return true;\n }\n}\n"]}
@@ -105,7 +105,7 @@ class ContentGroup {
105
105
  else
106
106
  throw new appui_abstract_1.UiError(// eslint-disable-line deprecation/deprecation
107
107
  UiFramework_1.UiFramework.loggerCategory(this), `toJSON: ContentControl at index ${index} is NOT registered with a string id`);
108
- if (contentCallback)
108
+ if (typeof contentCallback === "function")
109
109
  contentCallback(content);
110
110
  }
111
111
  });
@@ -1 +1 @@
1
- {"version":3,"file":"ContentGroup.js","sourceRoot":"","sources":["../../../../src/appui-react/content/ContentGroup.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAKH,0DAAgD;AAEhD,mFAGiD;AACjD,gDAA6C;AAE7C,mGAAgG;AAoChG;;;GAGG;AACH,MAAsB,oBAAoB;IAIxC;;OAEG;IACI,kBAAkB,CAAC,iBAAoC;QAC5D,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAED;;OAEG;IACI,wBAAwB,CAAC,iBAAoC;QAClE,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAED,kFAAkF;IAC3E,KAAK,CAAC,uBAAuB,KAAI,CAAC;CAC1C;AApBD,oDAoBC;AAOD;;GAEG;AACH,MAAa,YAAY;IAOvB,IAAW,EAAE;QACX,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,YAAY,iBAAoC;QAsGhD,4CAA4C;QAEpC,qBAAgB,GAAG,IAAI,GAAG,EAA0B,CAAC;QACrD,mBAAc,GAAG,IAAI,GAAG,EAA0B,CAAC;QAxGzD,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,iBAAiB,CAAC,MAAM,EAAE,CAAC;QAC9C,IAAI,CAAC,OAAO,GAAG,iBAAiB,CAAC,EAAE,CAAC;QACpC,mIAAmI;QACnI,IAAI,CAAC,OAAO,GAAG,IAAI,iBAAiB,CAAC,EAAE,IAAI,YAAY,CAAC,IAAI,EAAE,GAAG,CAAC;QAClE,IAAI,CAAC,gBAAgB,GAAG,iBAAiB,CAAC,QAAQ,CAAC;IACrD,CAAC;IAED;;OAEG;IACI,eAAe;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CAAC;QAED,OAAO,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;IACpD,CAAC;IAED;;OAEG;IACI,qBAAqB,CAAC,EAAU;QACrC,OAAO,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACvC,CAAC;IAED;;OAEG;IACI,qBAAqB,CAC1B,IAAqB;QAErB,IAAI,IAAI,CAAC,cAAc,CAAC,IAAI,KAAK,CAAC;YAAE,IAAI,CAAC,eAAe,EAAE,CAAC;QAE3D,IAAI,IAAI,IAAK,IAAgC,CAAC,GAAG,EAAE,CAAC;YAClD,MAAM,GAAG,GAAI,IAAgC,CAAC,GAAa,CAAC;YAC5D,oFAAoF;YACpF,MAAM,SAAS,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACxC,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAC5C,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;OAEG;IACI,kBAAkB;QACvB,MAAM,eAAe,GAAqB,IAAI,KAAK,EAAkB,CAAC;QAEtE,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,YAAY,EAAE,KAAK,EAAE,EAAE;YACpD,MAAM,OAAO,GAAG,IAAI,CAAC,iBAAiB,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;YAC5D,IAAI,CAAC,OAAO;gBAAE,OAAO;YAErB,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAChC,CAAC,CAAC,CAAC;QAEH,OAAO,eAAe,CAAC;IACzB,CAAC;;AAvNH,oCA0NC;AAzNgB,iBAAI,GAAG,CAAC,AAAJ,CAAK","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module ContentView\n */\n\nimport type * as React from \"react\";\nimport type { ScreenViewport } from \"@itwin/core-frontend\";\nimport type { ContentLayoutProps } from \"@itwin/appui-abstract\";\nimport { UiError } from \"@itwin/appui-abstract\";\nimport type { ConfigurableUiControlConstructor } from \"../configurableui/ConfigurableUiControl\";\nimport {\n ConfigurableCreateInfo,\n ConfigurableUiControlType,\n} from \"../configurableui/ConfigurableUiControl\";\nimport { UiFramework } from \"../UiFramework\";\nimport type { ContentControl } from \"./ContentControl\";\nimport { InternalConfigurableUiManager } from \"../configurableui/InternalConfigurableUiManager\";\nimport type { Frontstage } from \"../frontstage/Frontstage\";\n\n/** Properties for content displayed in a content view\n * @public\n */\nexport interface ContentProps {\n /** A unique id for the Content View within the group. */\n id: string;\n /** The class name or [[ConfigurableUiControlConstructor]] of the content control.\n * @deprecated in 4.16.0. Use {@link ContentProps.content} instead and specify an empty string for this property. This will be made optional in 5.0.0.\n */\n // eslint-disable-next-line deprecation/deprecation\n classId: string | ConfigurableUiControlConstructor;\n /** Optional application data passed down to the content view.\n * @deprecated in 4.16.0. Use {@link ContentProps.content} instead.\n */\n applicationData?: any;\n /** Content to be displayed in the content view.\n * @beta\n */\n content?: React.ReactNode;\n}\n\n/** Properties for a [[ContentGroup]]\n * @public\n */\nexport interface ContentGroupProps {\n /** An id for the [[ContentGroup]]. This id is used to locate a ContentGroup and it also can be used by an ContentGroupProvider to save/restore content settings */\n id: string;\n /** Content Layout Id or complete set of [[ContentLayoutProps]] */\n layout: ContentLayoutProps;\n /** A collection of [[ContentProps]], one for each content view */\n contents: ContentProps[];\n}\n\n/** Abstract class that can be implemented and specified by frontstage to dynamically construct\n * content group just prior to activating the frontstage.\n * @public\n */\nexport abstract class ContentGroupProvider {\n /** Return the contentGroup based on the `Frontstage`. */\n public abstract contentGroup(frontstage: Frontstage): Promise<ContentGroup>;\n\n /** Allow provider to update any data stored in ContentGroupProps. Typically this may\n * be to remove applicationData entries.\n */\n public prepareToSaveProps(contentGroupProps: ContentGroupProps) {\n return contentGroupProps;\n }\n\n /** Allow provider to update any stored ContentGroupProps be it is to be used to create ContentGroup and layouts.\n * Typically this may be to add applicationData to content entries.\n */\n public applyUpdatesToSavedProps(contentGroupProps: ContentGroupProps) {\n return contentGroupProps;\n }\n\n /** Allow provider to save any content group data before the stage deactivated. */\n public async onFrontstageDeactivated() {}\n}\n\n/** Callback to process content properties during toJSON method\n * @public\n */\nexport type ContentCallback = (content: ContentProps) => void;\n\n/** ContentGroup class. Content Groups define content displayed in content views that are laid out using a [[ContentLayout]].\n * @public\n */\nexport class ContentGroup {\n private static _sId = 0;\n public groupId: string;\n public propsId: string;\n public layout: ContentLayoutProps;\n public contentPropsList: ContentProps[];\n\n public get id() {\n return this.groupId;\n }\n\n constructor(contentGroupProps: ContentGroupProps) {\n this.layout = { ...contentGroupProps.layout };\n this.propsId = contentGroupProps.id;\n // ensure we have a unique groupId for each instance of a content group - this will be used to generate a key in the React controls\n this.groupId = `[${contentGroupProps.id}-${ContentGroup._sId++}]`;\n this.contentPropsList = contentGroupProps.contents;\n }\n\n /** Gets the React nodes representing the content views in this content group.\n * @deprecated in 4.16.0. Use {@link ContentGroup.contentPropsList} instead.\n */\n public getContentNodes(): React.ReactNode[] {\n const contentNodes: React.ReactNode[] = new Array<React.ReactNode>();\n\n this._contentSetMap.clear();\n\n this.contentPropsList.forEach((contentProps, index) => {\n if (contentProps.content) {\n contentNodes.push(contentProps.content);\n return;\n }\n\n // eslint-disable-next-line deprecation/deprecation\n const control = this.getContentControl(contentProps, index);\n if (!control) return;\n\n contentNodes.push(control.reactNode);\n this._contentSetMap.set(control.controlId, control);\n });\n\n return contentNodes;\n }\n\n /** Refreshes the React nodes representing the Content Views in this Content Group. */\n public refreshContentNodes() {\n this._contentSetMap.clear();\n }\n\n /** Called when Frontstage is deactivated. */\n public onFrontstageDeactivated(): void {\n this.clearContentControls();\n }\n\n /** Called when Frontstage is ready. */\n public onFrontstageReady(): void {}\n\n /** Clears the map of content controls. */\n public clearContentControls(): void {\n this._contentControls.clear();\n }\n\n /** Creates [[ContentGroupProps]] for JSON purposes.\n * @public\n */\n public toJSON(contentCallback?: ContentCallback): ContentGroupProps {\n const contentGroupProps: ContentGroupProps = {\n id: this.propsId,\n layout: this.layout,\n contents: this.contentPropsList,\n };\n\n contentGroupProps.contents.forEach((content, index) => {\n // eslint-disable-next-line deprecation/deprecation\n if (typeof content.classId !== \"string\") {\n const classId = InternalConfigurableUiManager.getConstructorClassId(\n // eslint-disable-next-line deprecation/deprecation\n content.classId\n );\n // eslint-disable-next-line deprecation/deprecation\n if (classId !== undefined) content.classId = classId;\n else\n throw new UiError( // eslint-disable-line deprecation/deprecation\n UiFramework.loggerCategory(this),\n `toJSON: ContentControl at index ${index} is NOT registered with a string id`\n );\n\n if (contentCallback) contentCallback(content);\n }\n });\n\n return contentGroupProps;\n }\n\n /** Gets Viewports from Viewport Content Controls.\n * @internal\n */\n public getViewports(): Array<ScreenViewport | undefined> {\n // eslint-disable-next-line deprecation/deprecation\n const contentControls = this.getContentControls();\n const viewports = new Array<ScreenViewport | undefined>();\n\n contentControls.forEach((control) => {\n if (control.isViewport && control.viewport) {\n viewports.push(control.viewport);\n } else {\n viewports.push(undefined);\n }\n });\n\n return viewports;\n }\n\n /* eslint-disable deprecation/deprecation */\n\n private _contentControls = new Map<string, ContentControl>();\n private _contentSetMap = new Map<string, ContentControl>();\n\n /** Gets a [[ContentControl]] from the Content Group based on its [[ContentProps]].\n * @deprecated in 4.16.0. Uses a deprecated class {@link ContentControl}.\n */\n public getContentControl(\n contentProps: ContentProps,\n _index: number\n ): ContentControl | undefined {\n // ensure we have a unique control Id for each instance of a content control - this will be used as a key for the React control - see `ContentControl.getKeyedReactNode`\n const id = `${contentProps.id}::${this.groupId}`;\n let contentControl: ContentControl | undefined;\n\n if (!this._contentControls.get(contentProps.id)) {\n let usedClassId: string = \"\";\n\n if (typeof contentProps.classId === \"string\") {\n if (\n !this._contentControls.get(contentProps.id) &&\n UiFramework.controls.isRegistered(contentProps.classId)\n ) {\n contentControl = UiFramework.controls.create(\n contentProps.classId,\n id,\n contentProps.applicationData,\n contentProps.id\n ) as ContentControl;\n usedClassId = contentProps.classId;\n }\n } else {\n const info = new ConfigurableCreateInfo(\n contentProps.classId.name,\n id,\n contentProps.id\n );\n contentControl = new contentProps.classId(\n info,\n contentProps.applicationData\n ) as ContentControl;\n usedClassId = contentProps.classId.name;\n }\n\n if (contentControl) {\n if (\n contentControl.getType() !== ConfigurableUiControlType.Content &&\n contentControl.getType() !== ConfigurableUiControlType.Viewport\n ) {\n throw new UiError(\n UiFramework.loggerCategory(this),\n `getContentControl error: '${usedClassId}' is NOT a ContentControl or ViewportContentControl`\n );\n }\n contentControl.initialize();\n this._contentControls.set(contentProps.id, contentControl);\n }\n }\n\n return this._contentControls.get(contentProps.id);\n }\n\n /** Gets a [[ContentControl]] from the Content Group with a given ID.\n * @deprecated in 4.16.0. Uses a deprecated class {@link ContentControl}.\n */\n public getContentControlById(id: string): ContentControl | undefined {\n return this._contentControls.get(id);\n }\n\n /** Gets the [[ContentControl]] associated with a given React node representing a Content View.\n * @deprecated in 4.16.0. Uses a deprecated class {@link ContentControl}.\n */\n public getControlFromElement(\n node: React.ReactNode\n ): ContentControl | undefined {\n if (this._contentSetMap.size === 0) this.getContentNodes();\n\n if (node && (node as React.ReactElement<any>).key) {\n const key = (node as React.ReactElement<any>).key as string;\n // key has format `${contentProps.id}::${this.groupId}` which is stored as unique id\n const controlId = key.split(\"::\", 1)[0];\n return this._contentSetMap.get(controlId);\n }\n\n return undefined;\n }\n\n /** Gets an array of the content controls representing the Content Views.\n * @deprecated in 4.16.0. Uses a deprecated class {@link ContentControl}.\n */\n public getContentControls(): ContentControl[] {\n const contentControls: ContentControl[] = new Array<ContentControl>();\n\n this.contentPropsList.forEach((contentProps, index) => {\n const control = this.getContentControl(contentProps, index);\n if (!control) return;\n\n contentControls.push(control);\n });\n\n return contentControls;\n }\n\n /* eslint-enable deprecation/deprecation */\n}\n"]}
1
+ {"version":3,"file":"ContentGroup.js","sourceRoot":"","sources":["../../../../src/appui-react/content/ContentGroup.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAKH,0DAAgD;AAEhD,mFAGiD;AACjD,gDAA6C;AAE7C,mGAAgG;AAoChG;;;GAGG;AACH,MAAsB,oBAAoB;IAIxC;;OAEG;IACI,kBAAkB,CAAC,iBAAoC;QAC5D,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAED;;OAEG;IACI,wBAAwB,CAAC,iBAAoC;QAClE,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAED,kFAAkF;IAC3E,KAAK,CAAC,uBAAuB,KAAI,CAAC;CAC1C;AApBD,oDAoBC;AAOD;;GAEG;AACH,MAAa,YAAY;IAOvB,IAAW,EAAE;QACX,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,YAAY,iBAAoC;QAsGhD,4CAA4C;QAEpC,qBAAgB,GAAG,IAAI,GAAG,EAA0B,CAAC;QACrD,mBAAc,GAAG,IAAI,GAAG,EAA0B,CAAC;QAxGzD,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,iBAAiB,CAAC,MAAM,EAAE,CAAC;QAC9C,IAAI,CAAC,OAAO,GAAG,iBAAiB,CAAC,EAAE,CAAC;QACpC,mIAAmI;QACnI,IAAI,CAAC,OAAO,GAAG,IAAI,iBAAiB,CAAC,EAAE,IAAI,YAAY,CAAC,IAAI,EAAE,GAAG,CAAC;QAClE,IAAI,CAAC,gBAAgB,GAAG,iBAAiB,CAAC,QAAQ,CAAC;IACrD,CAAC;IAED;;OAEG;IACI,eAAe;QACpB,MAAM,YAAY,GAAsB,IAAI,KAAK,EAAmB,CAAC;QAErE,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;QAE5B,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,YAAY,EAAE,KAAK,EAAE,EAA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BAAgB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACvC,CAAC;IAED;;OAEG;IACI,qBAAqB,CAC1B,IAAqB;QAErB,IAAI,IAAI,CAAC,cAAc,CAAC,IAAI,KAAK,CAAC;YAAE,IAAI,CAAC,eAAe,EAAE,CAAC;QAE3D,IAAI,IAAI,IAAK,IAAgC,CAAC,GAAG,EAAE,CAAC;YAClD,MAAM,GAAG,GAAI,IAAgC,CAAC,GAAa,CAAC;YAC5D,oFAAoF;YACpF,MAAM,SAAS,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACxC,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAC5C,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;OAEG;IACI,kBAAkB;QACvB,MAAM,eAAe,GAAqB,IAAI,KAAK,EAAkB,CAAC;QAEtE,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,YAAY,EAAE,KAAK,EAAE,EAAE;YACpD,MAAM,OAAO,GAAG,IAAI,CAAC,iBAAiB,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;YAC5D,IAAI,CAAC,OAAO;gBAAE,OAAO;YAErB,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAChC,CAAC,CAAC,CAAC;QAEH,OAAO,eAAe,CAAC;IACzB,CAAC;;AAvNH,oCA0NC;AAzNgB,iBAAI,GAAG,CAAC,AAAJ,CAAK","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module ContentView\n */\n\nimport type * as React from \"react\";\nimport type { ScreenViewport } from \"@itwin/core-frontend\";\nimport type { ContentLayoutProps } from \"@itwin/appui-abstract\";\nimport { UiError } from \"@itwin/appui-abstract\";\nimport type { ConfigurableUiControlConstructor } from \"../configurableui/ConfigurableUiControl\";\nimport {\n ConfigurableCreateInfo,\n ConfigurableUiControlType,\n} from \"../configurableui/ConfigurableUiControl\";\nimport { UiFramework } from \"../UiFramework\";\nimport type { ContentControl } from \"./ContentControl\";\nimport { InternalConfigurableUiManager } from \"../configurableui/InternalConfigurableUiManager\";\nimport type { Frontstage } from \"../frontstage/Frontstage\";\n\n/** Properties for content displayed in a content view\n * @public\n */\nexport interface ContentProps {\n /** A unique id for the Content View within the group. */\n id: string;\n /** The class name or [[ConfigurableUiControlConstructor]] of the content control.\n * @deprecated in 4.16.0. Use {@link ContentProps.content} instead and specify an empty string for this property. This will be made optional in 5.0.0.\n */\n // eslint-disable-next-line deprecation/deprecation\n classId: string | ConfigurableUiControlConstructor;\n /** Optional application data passed down to the content view.\n * @deprecated in 4.16.0. Use {@link ContentProps.content} instead.\n */\n applicationData?: any;\n /** Content to be displayed in the content view.\n * @beta\n */\n content?: React.ReactNode;\n}\n\n/** Properties for a [[ContentGroup]]\n * @public\n */\nexport interface ContentGroupProps {\n /** An id for the [[ContentGroup]]. This id is used to locate a ContentGroup and it also can be used by an ContentGroupProvider to save/restore content settings */\n id: string;\n /** Content Layout Id or complete set of [[ContentLayoutProps]] */\n layout: ContentLayoutProps;\n /** A collection of [[ContentProps]], one for each content view */\n contents: ContentProps[];\n}\n\n/** Abstract class that can be implemented and specified by frontstage to dynamically construct\n * content group just prior to activating the frontstage.\n * @public\n */\nexport abstract class ContentGroupProvider {\n /** Return the contentGroup based on the `Frontstage`. */\n public abstract contentGroup(frontstage: Frontstage): Promise<ContentGroup>;\n\n /** Allow provider to update any data stored in ContentGroupProps. Typically this may\n * be to remove applicationData entries.\n */\n public prepareToSaveProps(contentGroupProps: ContentGroupProps) {\n return contentGroupProps;\n }\n\n /** Allow provider to update any stored ContentGroupProps be it is to be used to create ContentGroup and layouts.\n * Typically this may be to add applicationData to content entries.\n */\n public applyUpdatesToSavedProps(contentGroupProps: ContentGroupProps) {\n return contentGroupProps;\n }\n\n /** Allow provider to save any content group data before the stage deactivated. */\n public async onFrontstageDeactivated() {}\n}\n\n/** Callback to process content properties during toJSON method\n * @public\n */\nexport type ContentCallback = (content: ContentProps) => void;\n\n/** ContentGroup class. Content Groups define content displayed in content views that are laid out using a [[ContentLayout]].\n * @public\n */\nexport class ContentGroup {\n private static _sId = 0;\n public groupId: string;\n public propsId: string;\n public layout: ContentLayoutProps;\n public contentPropsList: ContentProps[];\n\n public get id() {\n return this.groupId;\n }\n\n constructor(contentGroupProps: ContentGroupProps) {\n this.layout = { ...contentGroupProps.layout };\n this.propsId = contentGroupProps.id;\n // ensure we have a unique groupId for each instance of a content group - this will be used to generate a key in the React controls\n this.groupId = `[${contentGroupProps.id}-${ContentGroup._sId++}]`;\n this.contentPropsList = contentGroupProps.contents;\n }\n\n /** Gets the React nodes representing the content views in this content group.\n * @deprecated in 4.16.0. Use {@link ContentGroup.contentPropsList} instead.\n */\n public getContentNodes(): React.ReactNode[] {\n const contentNodes: React.ReactNode[] = new Array<React.ReactNode>();\n\n this._contentSetMap.clear();\n\n this.contentPropsList.forEach((contentProps, index) => {\n if (contentProps.content) {\n contentNodes.push(contentProps.content);\n return;\n }\n\n // eslint-disable-next-line deprecation/deprecation\n const control = this.getContentControl(contentProps, index);\n if (!control) return;\n\n contentNodes.push(control.reactNode);\n this._contentSetMap.set(control.controlId, control);\n });\n\n return contentNodes;\n }\n\n /** Refreshes the React nodes representing the Content Views in this Content Group. */\n public refreshContentNodes() {\n this._contentSetMap.clear();\n }\n\n /** Called when Frontstage is deactivated. */\n public onFrontstageDeactivated(): void {\n this.clearContentControls();\n }\n\n /** Called when Frontstage is ready. */\n public onFrontstageReady(): void {}\n\n /** Clears the map of content controls. */\n public clearContentControls(): void {\n this._contentControls.clear();\n }\n\n /** Creates [[ContentGroupProps]] for JSON purposes.\n * @public\n */\n public toJSON(contentCallback?: ContentCallback): ContentGroupProps {\n const contentGroupProps: ContentGroupProps = {\n id: this.propsId,\n layout: this.layout,\n contents: this.contentPropsList,\n };\n\n contentGroupProps.contents.forEach((content, index) => {\n // eslint-disable-next-line deprecation/deprecation\n if (typeof content.classId !== \"string\") {\n const classId = InternalConfigurableUiManager.getConstructorClassId(\n // eslint-disable-next-line deprecation/deprecation\n content.classId\n );\n // eslint-disable-next-line deprecation/deprecation\n if (classId !== undefined) content.classId = classId;\n else\n throw new UiError( // eslint-disable-line deprecation/deprecation\n UiFramework.loggerCategory(this),\n `toJSON: ContentControl at index ${index} is NOT registered with a string id`\n );\n\n if (typeof contentCallback === \"function\") contentCallback(content);\n }\n });\n\n return contentGroupProps;\n }\n\n /** Gets Viewports from Viewport Content Controls.\n * @internal\n */\n public getViewports(): Array<ScreenViewport | undefined> {\n // eslint-disable-next-line deprecation/deprecation\n const contentControls = this.getContentControls();\n const viewports = new Array<ScreenViewport | undefined>();\n\n contentControls.forEach((control) => {\n if (control.isViewport && control.viewport) {\n viewports.push(control.viewport);\n } else {\n viewports.push(undefined);\n }\n });\n\n return viewports;\n }\n\n /* eslint-disable deprecation/deprecation */\n\n private _contentControls = new Map<string, ContentControl>();\n private _contentSetMap = new Map<string, ContentControl>();\n\n /** Gets a [[ContentControl]] from the Content Group based on its [[ContentProps]].\n * @deprecated in 4.16.0. Uses a deprecated class {@link ContentControl}.\n */\n public getContentControl(\n contentProps: ContentProps,\n _index: number\n ): ContentControl | undefined {\n // ensure we have a unique control Id for each instance of a content control - this will be used as a key for the React control - see `ContentControl.getKeyedReactNode`\n const id = `${contentProps.id}::${this.groupId}`;\n let contentControl: ContentControl | undefined;\n\n if (!this._contentControls.get(contentProps.id)) {\n let usedClassId: string = \"\";\n\n if (typeof contentProps.classId === \"string\") {\n if (\n !this._contentControls.get(contentProps.id) &&\n UiFramework.controls.isRegistered(contentProps.classId)\n ) {\n contentControl = UiFramework.controls.create(\n contentProps.classId,\n id,\n contentProps.applicationData,\n contentProps.id\n ) as ContentControl;\n usedClassId = contentProps.classId;\n }\n } else {\n const info = new ConfigurableCreateInfo(\n contentProps.classId.name,\n id,\n contentProps.id\n );\n contentControl = new contentProps.classId(\n info,\n contentProps.applicationData\n ) as ContentControl;\n usedClassId = contentProps.classId.name;\n }\n\n if (contentControl) {\n if (\n contentControl.getType() !== ConfigurableUiControlType.Content &&\n contentControl.getType() !== ConfigurableUiControlType.Viewport\n ) {\n throw new UiError(\n UiFramework.loggerCategory(this),\n `getContentControl error: '${usedClassId}' is NOT a ContentControl or ViewportContentControl`\n );\n }\n contentControl.initialize();\n this._contentControls.set(contentProps.id, contentControl);\n }\n }\n\n return this._contentControls.get(contentProps.id);\n }\n\n /** Gets a [[ContentControl]] from the Content Group with a given ID.\n * @deprecated in 4.16.0. Uses a deprecated class {@link ContentControl}.\n */\n public getContentControlById(id: string): ContentControl | undefined {\n return this._contentControls.get(id);\n }\n\n /** Gets the [[ContentControl]] associated with a given React node representing a Content View.\n * @deprecated in 4.16.0. Uses a deprecated class {@link ContentControl}.\n */\n public getControlFromElement(\n node: React.ReactNode\n ): ContentControl | undefined {\n if (this._contentSetMap.size === 0) this.getContentNodes();\n\n if (node && (node as React.ReactElement<any>).key) {\n const key = (node as React.ReactElement<any>).key as string;\n // key has format `${contentProps.id}::${this.groupId}` which is stored as unique id\n const controlId = key.split(\"::\", 1)[0];\n return this._contentSetMap.get(controlId);\n }\n\n return undefined;\n }\n\n /** Gets an array of the content controls representing the Content Views.\n * @deprecated in 4.16.0. Uses a deprecated class {@link ContentControl}.\n */\n public getContentControls(): ContentControl[] {\n const contentControls: ContentControl[] = new Array<ContentControl>();\n\n this.contentPropsList.forEach((contentProps, index) => {\n const control = this.getContentControl(contentProps, index);\n if (!control) return;\n\n contentControls.push(control);\n });\n\n return contentControls;\n }\n\n /* eslint-enable deprecation/deprecation */\n}\n"]}
@@ -40,4 +40,8 @@
40
40
  &:focus-within {
41
41
  border-color: var(--iui-color-border-foreground-hover);
42
42
  }
43
+
44
+ &:empty {
45
+ display: none;
46
+ }
43
47
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SelectionContextItemDef.d.ts","sourceRoot":"","sources":["../../../../src/appui-react/selection/SelectionContextItemDef.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAEhE,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAgBpD;;;GAGG;AACH,wBAAgB,8BAA8B,IAAI,MAAM,EAAE,CAOzD;AAED;;;GAGG;AACH,wBAAgB,+BAA+B,IAAI,MAAM,EAAE,CAU1D;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAgB7C;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,IAAI,OAAO,CAQrD;AAED;;;GAGG;AACH,wBAAgB,mCAAmC,IAAI,uBAAuB,CAK7E;AAED;;;GAGG;AACH,wBAAgB,+BAA+B,IAAI,uBAAuB,CAKzE;AAED;;;GAGG;AACH,wBAAgB,+BAA+B,CAC7C,KAAK,EAAE,QAAQ,CAAC,aAAa,CAAC,GAC7B,aAAa,CAWf;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,QAAQ,CAAC,aAAa,CAAC,GAC7B,aAAa,CAaf;AAED;;;GAGG;AACH,qBAAa,+BAA+B;IAC1C,WAAkB,+BAA+B,mBAQhD;IAED,WAAkB,mCAAmC,mBAQpD;IAED,WAAkB,sBAAsB,mBASvC;IAED,WAAkB,yBAAyB,iBAa1C;IAED,WAAkB,4BAA4B,mBAQ7C;IAED,WAAkB,gCAAgC,mBAQjD;IAED,WAAkB,mBAAmB,mBASpC;IAED,WAAkB,oBAAoB,iBAarC;IAED,WAAkB,wBAAwB,mBASzC;IAED,WAAkB,wCAAwC,mBAYzD;CACF"}
1
+ {"version":3,"file":"SelectionContextItemDef.d.ts","sourceRoot":"","sources":["../../../../src/appui-react/selection/SelectionContextItemDef.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAEhE,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAiBpD;;;GAGG;AACH,wBAAgB,8BAA8B,IAAI,MAAM,EAAE,CAOzD;AAED;;;GAGG;AACH,wBAAgB,+BAA+B,IAAI,MAAM,EAAE,CAU1D;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAgB7C;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,IAAI,OAAO,CASrD;AAED;;;GAGG;AACH,wBAAgB,mCAAmC,IAAI,uBAAuB,CAK7E;AAED;;;GAGG;AACH,wBAAgB,+BAA+B,IAAI,uBAAuB,CAKzE;AAED;;;GAGG;AACH,wBAAgB,+BAA+B,CAC7C,KAAK,EAAE,QAAQ,CAAC,aAAa,CAAC,GAC7B,aAAa,CAWf;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,QAAQ,CAAC,aAAa,CAAC,GAC7B,aAAa,CAUf;AAED;;;GAGG;AACH,qBAAa,+BAA+B;IAC1C,WAAkB,+BAA+B,mBAQhD;IAED,WAAkB,mCAAmC,mBAQpD;IAED,WAAkB,sBAAsB,mBASvC;IAED,WAAkB,yBAAyB,iBAa1C;IAED,WAAkB,4BAA4B,mBAQ7C;IAED,WAAkB,gCAAgC,mBAQjD;IAED,WAAkB,mBAAmB,mBASpC;IAED,WAAkB,oBAAoB,iBAarC;IAED,WAAkB,wBAAwB,mBASzC;IAED,WAAkB,wCAAwC,mBAYzD;CACF"}
@@ -24,6 +24,7 @@ const asset_classification_hide_svg_1 = require("@bentley/icons-generic/icons/as
24
24
  const visibility_semi_transparent_svg_1 = require("@bentley/icons-generic/icons/visibility-semi-transparent.svg");
25
25
  const visibility_hide_2_svg_1 = require("@bentley/icons-generic/icons/visibility-hide_2.svg");
26
26
  const visibility_svg_1 = require("@bentley/icons-generic/icons/visibility.svg");
27
+ const getActiveViewport_1 = require("../utils/getActiveViewport");
27
28
  /* eslint-disable deprecation/deprecation */
28
29
  /** Return SyncEventIds that trigger selection state function refresh.
29
30
  * @beta
@@ -59,16 +60,18 @@ exports.getSelectionContextSyncEventIds = getSelectionContextSyncEventIds;
59
60
  * @deprecated in 4.15.0. Use {@link ToolbarItems} or a custom conditional value instead.
60
61
  */
61
62
  function isNoSelectionActive() {
62
- const activeContentControl = UiFramework_1.UiFramework.content.getActiveContentControl();
63
- const selectionCount = UiFramework_1.UiFramework.getNumItemsSelected();
64
- if (activeContentControl?.viewport) {
65
- const hiddenElementsSet = activeContentControl.viewport.neverDrawn;
66
- const selectedElementsSet = activeContentControl.viewport.view.iModel.selectionSet.elements;
67
- // TODO: add check for categories, subcategories and models
68
- if (selectionCount > 0 ||
69
- ![...selectedElementsSet].every((value) => hiddenElementsSet?.has(value)))
70
- return false;
63
+ const viewport = (0, getActiveViewport_1.getActiveViewport)();
64
+ if (!viewport) {
65
+ return true;
71
66
  }
67
+ const selectionCount = UiFramework_1.UiFramework.getNumItemsSelected();
68
+ if (selectionCount > 0)
69
+ return false;
70
+ // TODO: add check for categories, subcategories and models
71
+ const hiddenElementsSet = viewport.neverDrawn;
72
+ const selectedElementsSet = viewport.view.iModel.selectionSet.elements;
73
+ if (![...selectedElementsSet].every((value) => hiddenElementsSet?.has(value)))
74
+ return false;
72
75
  return true;
73
76
  }
74
77
  exports.isNoSelectionActive = isNoSelectionActive;
@@ -77,10 +80,11 @@ exports.isNoSelectionActive = isNoSelectionActive;
77
80
  * @deprecated in 4.15.0. Use {@link ToolbarItems} or a custom conditional value instead.
78
81
  */
79
82
  function areNoFeatureOverridesActive() {
80
- const activeContentControl = UiFramework_1.UiFramework.content.getActiveContentControl();
81
- if (activeContentControl && activeContentControl.viewport)
82
- return !UiFramework_1.UiFramework.hideIsolateEmphasizeActionHandler.areFeatureOverridesActive(activeContentControl.viewport);
83
- return true;
83
+ const viewport = (0, getActiveViewport_1.getActiveViewport)();
84
+ if (!viewport) {
85
+ return true;
86
+ }
87
+ return !UiFramework_1.UiFramework.hideIsolateEmphasizeActionHandler.areFeatureOverridesActive(viewport);
84
88
  }
85
89
  exports.areNoFeatureOverridesActive = areNoFeatureOverridesActive;
86
90
  /** Return ConditionalBooleanValue object used to show item if feature overrides are active.
@@ -104,11 +108,11 @@ exports.getIsHiddenIfSelectionNotActive = getIsHiddenIfSelectionNotActive;
104
108
  * @deprecated in 4.15.0. Use {@link ToolbarItems} or a custom conditional value instead.
105
109
  */
106
110
  function featureOverridesActiveStateFunc(state) {
107
- const activeContentControl = UiFramework_1.UiFramework.content.getActiveContentControl();
108
- let isVisible = false;
109
- if (activeContentControl && activeContentControl.viewport)
110
- isVisible =
111
- UiFramework_1.UiFramework.hideIsolateEmphasizeActionHandler.areFeatureOverridesActive(activeContentControl.viewport);
111
+ const viewport = (0, getActiveViewport_1.getActiveViewport)();
112
+ if (!viewport) {
113
+ return { ...state, isVisible: false };
114
+ }
115
+ const isVisible = UiFramework_1.UiFramework.hideIsolateEmphasizeActionHandler.areFeatureOverridesActive(viewport);
112
116
  return { ...state, isVisible };
113
117
  }
114
118
  exports.featureOverridesActiveStateFunc = featureOverridesActiveStateFunc;
@@ -117,14 +121,12 @@ exports.featureOverridesActiveStateFunc = featureOverridesActiveStateFunc;
117
121
  * @deprecated in 4.15.0. Use {@link ToolbarItems} or a custom conditional value instead.
118
122
  */
119
123
  function selectionContextStateFunc(state) {
120
- const activeContentControl = UiFramework_1.UiFramework.content.getActiveContentControl();
121
- let isVisible = false;
124
+ const viewport = (0, getActiveViewport_1.getActiveViewport)();
125
+ if (!viewport) {
126
+ return { ...state, isVisible: false };
127
+ }
122
128
  const selectionCount = UiFramework_1.UiFramework.getNumItemsSelected();
123
- if (activeContentControl &&
124
- activeContentControl.viewport &&
125
- (activeContentControl.viewport.view.iModel.selectionSet.size > 0 ||
126
- selectionCount > 0))
127
- isVisible = true;
129
+ const isVisible = viewport.view.iModel.selectionSet.size > 0 || selectionCount > 0;
128
130
  return { ...state, isVisible };
129
131
  }
130
132
  exports.selectionContextStateFunc = selectionContextStateFunc;
@@ -1 +1 @@
1
- {"version":3,"file":"SelectionContextItemDef.js","sourceRoot":"","sources":["../../../../src/appui-react/selection/SelectionContextItemDef.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,0DAAgE;AAChE,wDAA6D;AAC7D,6DAA0D;AAE1D,2EAAgE;AAChE,oDAAoD;AACpD,gDAA6C;AAC7C,sFAA6E;AAC7E,wFAA+E;AAC/E,sFAA6E;AAC7E,0EAAkE;AAClE,gFAAuE;AACvE,kFAAyE;AACzE,8GAAoG;AACpG,kHAAwG;AACxG,8FAAmF;AACnF,gFAAwE;AAGxE,4CAA4C;AAE5C;;;GAGG;AACH,SAAgB,8BAA8B;IAC5C,OAAO;QACL,qCAAa,CAAC,oBAAoB;QAClC,qCAAa,CAAC,qBAAqB;QACnC,qCAAa,CAAC,uBAAuB;QACrC,qCAAa,CAAC,mBAAmB;KAClC,CAAC;AACJ,CAAC;AAPD,wEAOC;AAED;;;GAGG;AACH,SAAgB,+BAA+B;IAC7C,OAAO;QACL,qCAAa,CAAC,mBAAmB;QACjC,qCAAa,CAAC,oBAAoB;QAClC,qCAAa,CAAC,qBAAqB;QACnC,mDAAmD;QACnD,mCAAoB,CAAC,mBAAmB;QACxC,qCAAa,CAAC,uBAAuB;QACrC,qCAAa,CAAC,mBAAmB;KAClC,CAAC;AACJ,CAAC;AAVD,0EAUC;AAED;;;GAGG;AACH,SAAgB,mBAAmB;IACjC,MAAM,oBAAoB,GAAG,yBAAW,CAAC,OAAO,CAAC,uBAAuB,EAAE,CAAC;IAC3E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AAC,8BAA8B,EAAE,CAAC;YACvF,CAAC;SACF,CAAC,CAAC;IACL,CAAC;CACF;AArHD,0EAqHC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Tools\n */\n\nimport { ConditionalBooleanValue } from \"@itwin/appui-abstract\";\nimport { SessionStateActionId } from \"../redux/SessionState\";\nimport { CommandItemDef } from \"../shared/CommandItemDef\";\nimport type { BaseItemState } from \"../shared/ItemDefBase\";\nimport { SyncUiEventId } from \"../syncui/SyncUiEventDispatcher\";\nimport { GroupItemDef } from \"../toolbar/GroupItem\";\nimport { UiFramework } from \"../UiFramework\";\nimport svgModelIsolate from \"@bentley/icons-generic/icons/model-isolate.svg\";\nimport svgLayersIsolate from \"@bentley/icons-generic/icons/layers-isolate.svg\";\nimport svgAssetIsolate from \"@bentley/icons-generic/icons/asset-isolate.svg\";\nimport svgIsolate from \"@bentley/icons-generic/icons/isolate.svg\";\nimport svgModelHide from \"@bentley/icons-generic/icons/model-hide.svg\";\nimport svgLayersHide from \"@bentley/icons-generic/icons/layers-hide.svg\";\nimport svgAssetClassificationHide from \"@bentley/icons-generic/icons/asset-classification-hide.svg\";\nimport svgVisibilitySemiTransparent from \"@bentley/icons-generic/icons/visibility-semi-transparent.svg\";\nimport svgVisibilityHide from \"@bentley/icons-generic/icons/visibility-hide_2.svg\";\nimport svgVisibility from \"@bentley/icons-generic/icons/visibility.svg\";\nimport type { ToolbarItems } from \"../tools/ToolbarItems\";\n\n/* eslint-disable deprecation/deprecation */\n\n/** Return SyncEventIds that trigger selection state function refresh.\n * @beta\n * @deprecated in 4.15.0. Use {@link ToolbarItems} or a custom conditional value instead.\n */\nexport function getFeatureOverrideSyncEventIds(): string[] {\n return [\n SyncUiEventId.ActiveContentChanged,\n SyncUiEventId.ActiveViewportChanged,\n SyncUiEventId.FeatureOverridesChanged,\n SyncUiEventId.ViewedModelsChanged,\n ];\n}\n\n/** Return SyncEventIds that trigger selection state function refresh.\n * @beta\n * @deprecated in 4.15.0. Use {@link ToolbarItems} or a custom conditional value instead.\n */\nexport function getSelectionContextSyncEventIds(): string[] {\n return [\n SyncUiEventId.SelectionSetChanged,\n SyncUiEventId.ActiveContentChanged,\n SyncUiEventId.ActiveViewportChanged,\n // eslint-disable-next-line deprecation/deprecation\n SessionStateActionId.SetNumItemsSelected,\n SyncUiEventId.FeatureOverridesChanged,\n SyncUiEventId.ViewedModelsChanged,\n ];\n}\n\n/** Return SyncEventIds that trigger selection state function refresh.\n * @beta\n * @deprecated in 4.15.0. Use {@link ToolbarItems} or a custom conditional value instead.\n */\nexport function isNoSelectionActive(): boolean {\n const activeContentControl = UiFramework.content.getActiveContentControl();\n const selectionCount = UiFramework.getNumItemsSelected();\n\n if (activeContentControl?.viewport) {\n const hiddenElementsSet = activeContentControl.viewport.neverDrawn;\n const selectedElementsSet =\n activeContentControl.viewport.view.iModel.selectionSet.elements;\n // TODO: add check for categories, subcategories and models\n if (\n selectionCount > 0 ||\n ![...selectedElementsSet].every((value) => hiddenElementsSet?.has(value))\n )\n return false;\n }\n return true;\n}\n\n/** Return ConditionalBooleanValue object used to show items if selection set is active.\n * @beta\n * @deprecated in 4.15.0. Use {@link ToolbarItems} or a custom conditional value instead.\n */\nexport function areNoFeatureOverridesActive(): boolean {\n const activeContentControl = UiFramework.content.getActiveContentControl();\n if (activeContentControl && activeContentControl.viewport)\n return !UiFramework.hideIsolateEmphasizeActionHandler.areFeatureOverridesActive(\n activeContentControl.viewport\n );\n\n return true;\n}\n\n/** Return ConditionalBooleanValue object used to show item if feature overrides are active.\n * @beta\n * @deprecated in 4.15.0. Use {@link ToolbarItems} or a custom conditional value instead.\n */\nexport function getIsHiddenIfFeatureOverridesActive(): ConditionalBooleanValue {\n return new ConditionalBooleanValue(\n areNoFeatureOverridesActive,\n getFeatureOverrideSyncEventIds()\n );\n}\n\n/** Return ConditionalBooleanValue object used to show items if selection set is active.\n * @beta\n * @deprecated in 4.15.0. Use {@link ToolbarItems} or a custom conditional value instead.\n */\nexport function getIsHiddenIfSelectionNotActive(): ConditionalBooleanValue {\n return new ConditionalBooleanValue(\n isNoSelectionActive,\n getSelectionContextSyncEventIds()\n );\n}\n\n/** Return state with isVisible set to true is SectionSet is active.\n * @beta\n * @deprecated in 4.15.0. Use {@link ToolbarItems} or a custom conditional value instead.\n */\nexport function featureOverridesActiveStateFunc(\n state: Readonly<BaseItemState>\n): BaseItemState {\n const activeContentControl = UiFramework.content.getActiveContentControl();\n let isVisible = false;\n\n if (activeContentControl && activeContentControl.viewport)\n isVisible =\n UiFramework.hideIsolateEmphasizeActionHandler.areFeatureOverridesActive(\n activeContentControl.viewport\n );\n\n return { ...state, isVisible };\n}\n\n/** Return state with isVisible set to true is SectionSet is active.\n * @beta\n * @deprecated in 4.15.0. Use {@link ToolbarItems} or a custom conditional value instead.\n */\nexport function selectionContextStateFunc(\n state: Readonly<BaseItemState>\n): BaseItemState {\n const activeContentControl = UiFramework.content.getActiveContentControl();\n let isVisible = false;\n\n const selectionCount = UiFramework.getNumItemsSelected();\n if (\n activeContentControl &&\n activeContentControl.viewport &&\n (activeContentControl.viewport.view.iModel.selectionSet.size > 0 ||\n selectionCount > 0)\n )\n isVisible = true;\n return { ...state, isVisible };\n}\n\n/** Utility Class that provides definitions for tools dependent on current selection. These definitions can be used to populate toolbars.\n * @public\n * @deprecated in 4.15.0. Use {@link ToolbarItems} instead.\n */\nexport class SelectionContextToolDefinitions {\n public static get isolateModelsInSelectionItemDef() {\n return new CommandItemDef({\n commandId: \"UiFramework.IsolateModel\",\n iconSpec: svgModelIsolate,\n labelKey: \"UiFramework:tools.isolateModels\",\n execute: async () =>\n UiFramework.hideIsolateEmphasizeActionHandler.processIsolateSelectedElementsModel(),\n });\n }\n\n public static get isolateCategoriesInSelectionItemDef() {\n return new CommandItemDef({\n commandId: \"UiFramework.IsolateCategory\",\n iconSpec: svgLayersIsolate,\n labelKey: \"UiFramework:tools.isolateCategories\",\n execute: async () =>\n UiFramework.hideIsolateEmphasizeActionHandler.processIsolateSelectedElementsCategory(),\n });\n }\n\n public static get isolateElementsItemDef() {\n return new CommandItemDef({\n commandId: \"UiFramework.IsolateSelected\",\n iconSpec: svgAssetIsolate,\n labelKey: \"UiFramework:tools.isolateSelected\",\n isHidden: getIsHiddenIfSelectionNotActive(),\n execute: async () =>\n UiFramework.hideIsolateEmphasizeActionHandler.processIsolateSelected(),\n });\n }\n\n public static get isolateSelectionToolGroup() {\n return new GroupItemDef({\n groupId: \"UiFramework.IsolateSelectionGroup\",\n labelKey: \"UiFramework:tools.isolate\",\n iconSpec: svgIsolate,\n isHidden: getIsHiddenIfSelectionNotActive(),\n items: [\n this.isolateElementsItemDef,\n this.isolateCategoriesInSelectionItemDef,\n this.isolateModelsInSelectionItemDef,\n ],\n itemsInColumn: 3,\n });\n }\n\n public static get hideModelsInSelectionItemDef() {\n return new CommandItemDef({\n commandId: \"UiFramework.HideModel\",\n iconSpec: svgModelHide,\n labelKey: \"UiFramework:tools.hideModels\",\n execute: async () =>\n UiFramework.hideIsolateEmphasizeActionHandler.processHideSelectedElementsModel(),\n });\n }\n\n public static get hideCategoriesInSelectionItemDef() {\n return new CommandItemDef({\n commandId: \"UiFramework.HideCategory\",\n iconSpec: svgLayersHide,\n labelKey: \"UiFramework:tools.hideCategories\",\n execute: async () =>\n UiFramework.hideIsolateEmphasizeActionHandler.processHideSelectedElementsCategory(),\n });\n }\n\n public static get hideElementsItemDef() {\n return new CommandItemDef({\n commandId: \"UiFramework.HideSelected\",\n iconSpec: svgAssetClassificationHide,\n labelKey: \"UiFramework:tools.hideSelected\",\n isHidden: getIsHiddenIfSelectionNotActive(),\n execute: async () =>\n UiFramework.hideIsolateEmphasizeActionHandler.processHideSelected(),\n });\n }\n\n public static get hideSectionToolGroup() {\n return new GroupItemDef({\n groupId: \"UiFramework.HideSelectionGroup\",\n labelKey: \"UiFramework:tools.hide\",\n iconSpec: svgVisibilityHide,\n isHidden: getIsHiddenIfSelectionNotActive(),\n items: [\n this.hideElementsItemDef,\n this.hideCategoriesInSelectionItemDef,\n this.hideModelsInSelectionItemDef,\n ],\n itemsInColumn: 3,\n });\n }\n\n public static get emphasizeElementsItemDef() {\n return new CommandItemDef({\n commandId: \"UiFramework.EmphasizeSelected\",\n iconSpec: svgVisibilitySemiTransparent,\n labelKey: \"UiFramework:tools.emphasizeSelected\",\n isHidden: getIsHiddenIfSelectionNotActive(),\n execute: async () =>\n UiFramework.hideIsolateEmphasizeActionHandler.processEmphasizeSelected(),\n });\n }\n\n public static get clearHideIsolateEmphasizeElementsItemDef() {\n return new CommandItemDef({\n commandId: \"UiFramework.ClearHideIsolateEmphasize\",\n iconSpec: svgVisibility,\n labelKey: \"UiFramework:tools.clearVisibility\",\n isHidden: getIsHiddenIfFeatureOverridesActive(),\n execute: async () => {\n await UiFramework.hideIsolateEmphasizeActionHandler.processClearEmphasize();\n await UiFramework.hideIsolateEmphasizeActionHandler.processClearOverrideModels();\n await UiFramework.hideIsolateEmphasizeActionHandler.processClearOverrideCategories();\n },\n });\n }\n}\n"]}
1
+ {"version":3,"file":"SelectionContextItemDef.js","sourceRoot":"","sources":["../../../../src/appui-react/selection/SelectionContextItemDef.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,0DAAgE;AAChE,wDAA6D;AAC7D,6DAA0D;AAE1D,2EAAgE;AAChE,oDAAoD;AACpD,gDAA6C;AAC7C,sFAA6E;AAC7E,wFAA+E;AAC/E,sFAA6E;AAC7E,0EAAkE;AAClE,gFAAuE;AACvE,kFAAyE;AACzE,8GAAoG;AACpG,kHAAwG;AACxG,8FAAmF;AACnF,gFAAwE;AAExE,kEAA+D;AAE/D,4CAA4C;AAE5C;;;GAGG;AACH,SAAgB,8BAA8B;IAC5C,OAAO;QACL,qCAAa,CAAC,oBAAoB;QAClC,qCAAa,CAAC,qBAA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AC,CAAC;IACL,CAAC;IAEM,MAAM,KAAK,wCAAwC;QACxD,OAAO,IAAI,+BAAc,CAAC;YACxB,SAAS,EAAE,uCAAuC;YAClD,QAAQ,EAAE,wBAAa;YACvB,QAAQ,EAAE,mCAAmC;YAC7C,QAAQ,EAAE,mCAAmC,EAAE;YAC/C,OAAO,EAAE,KAAK,IAAI,EAAE;gBAClB,MAAM,yBAAW,CAAC,iCAAiC,CAAC,qBAAqB,EAAE,CAAC;gBAC5E,MAAM,yBAAW,CAAC,iCAAiC,CAAC,0BAA0B,EAAE,CAAC;gBACjF,MAAM,yBAAW,CAAC,iCAAiC,CAAC,8BAA8B,EAAE,CAAC;YACvF,CAAC;SACF,CAAC,CAAC;IACL,CAAC;CACF;AArHD,0EAqHC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Tools\n */\n\nimport { ConditionalBooleanValue } from \"@itwin/appui-abstract\";\nimport { SessionStateActionId } from \"../redux/SessionState\";\nimport { CommandItemDef } from \"../shared/CommandItemDef\";\nimport type { BaseItemState } from \"../shared/ItemDefBase\";\nimport { SyncUiEventId } from \"../syncui/SyncUiEventDispatcher\";\nimport { GroupItemDef } from \"../toolbar/GroupItem\";\nimport { UiFramework } from \"../UiFramework\";\nimport svgModelIsolate from \"@bentley/icons-generic/icons/model-isolate.svg\";\nimport svgLayersIsolate from \"@bentley/icons-generic/icons/layers-isolate.svg\";\nimport svgAssetIsolate from \"@bentley/icons-generic/icons/asset-isolate.svg\";\nimport svgIsolate from \"@bentley/icons-generic/icons/isolate.svg\";\nimport svgModelHide from \"@bentley/icons-generic/icons/model-hide.svg\";\nimport svgLayersHide from \"@bentley/icons-generic/icons/layers-hide.svg\";\nimport svgAssetClassificationHide from \"@bentley/icons-generic/icons/asset-classification-hide.svg\";\nimport svgVisibilitySemiTransparent from \"@bentley/icons-generic/icons/visibility-semi-transparent.svg\";\nimport svgVisibilityHide from \"@bentley/icons-generic/icons/visibility-hide_2.svg\";\nimport svgVisibility from \"@bentley/icons-generic/icons/visibility.svg\";\nimport type { ToolbarItems } from \"../tools/ToolbarItems\";\nimport { getActiveViewport } from \"../utils/getActiveViewport\";\n\n/* eslint-disable deprecation/deprecation */\n\n/** Return SyncEventIds that trigger selection state function refresh.\n * @beta\n * @deprecated in 4.15.0. Use {@link ToolbarItems} or a custom conditional value instead.\n */\nexport function getFeatureOverrideSyncEventIds(): string[] {\n return [\n SyncUiEventId.ActiveContentChanged,\n SyncUiEventId.ActiveViewportChanged,\n SyncUiEventId.FeatureOverridesChanged,\n SyncUiEventId.ViewedModelsChanged,\n ];\n}\n\n/** Return SyncEventIds that trigger selection state function refresh.\n * @beta\n * @deprecated in 4.15.0. Use {@link ToolbarItems} or a custom conditional value instead.\n */\nexport function getSelectionContextSyncEventIds(): string[] {\n return [\n SyncUiEventId.SelectionSetChanged,\n SyncUiEventId.ActiveContentChanged,\n SyncUiEventId.ActiveViewportChanged,\n // eslint-disable-next-line deprecation/deprecation\n SessionStateActionId.SetNumItemsSelected,\n SyncUiEventId.FeatureOverridesChanged,\n SyncUiEventId.ViewedModelsChanged,\n ];\n}\n\n/** Return SyncEventIds that trigger selection state function refresh.\n * @beta\n * @deprecated in 4.15.0. Use {@link ToolbarItems} or a custom conditional value instead.\n */\nexport function isNoSelectionActive(): boolean {\n const viewport = getActiveViewport();\n if (!viewport) {\n return true;\n }\n\n const selectionCount = UiFramework.getNumItemsSelected();\n if (selectionCount > 0) return false;\n\n // TODO: add check for categories, subcategories and models\n const hiddenElementsSet = viewport.neverDrawn;\n const selectedElementsSet = viewport.view.iModel.selectionSet.elements;\n if (![...selectedElementsSet].every((value) => hiddenElementsSet?.has(value)))\n return false;\n\n return true;\n}\n\n/** Return ConditionalBooleanValue object used to show items if selection set is active.\n * @beta\n * @deprecated in 4.15.0. Use {@link ToolbarItems} or a custom conditional value instead.\n */\nexport function areNoFeatureOverridesActive(): boolean {\n const viewport = getActiveViewport();\n if (!viewport) {\n return true;\n }\n\n return !UiFramework.hideIsolateEmphasizeActionHandler.areFeatureOverridesActive(\n viewport\n );\n}\n\n/** Return ConditionalBooleanValue object used to show item if feature overrides are active.\n * @beta\n * @deprecated in 4.15.0. Use {@link ToolbarItems} or a custom conditional value instead.\n */\nexport function getIsHiddenIfFeatureOverridesActive(): ConditionalBooleanValue {\n return new ConditionalBooleanValue(\n areNoFeatureOverridesActive,\n getFeatureOverrideSyncEventIds()\n );\n}\n\n/** Return ConditionalBooleanValue object used to show items if selection set is active.\n * @beta\n * @deprecated in 4.15.0. Use {@link ToolbarItems} or a custom conditional value instead.\n */\nexport function getIsHiddenIfSelectionNotActive(): ConditionalBooleanValue {\n return new ConditionalBooleanValue(\n isNoSelectionActive,\n getSelectionContextSyncEventIds()\n );\n}\n\n/** Return state with isVisible set to true is SectionSet is active.\n * @beta\n * @deprecated in 4.15.0. Use {@link ToolbarItems} or a custom conditional value instead.\n */\nexport function featureOverridesActiveStateFunc(\n state: Readonly<BaseItemState>\n): BaseItemState {\n const viewport = getActiveViewport();\n if (!viewport) {\n return { ...state, isVisible: false };\n }\n\n const isVisible =\n UiFramework.hideIsolateEmphasizeActionHandler.areFeatureOverridesActive(\n viewport\n );\n return { ...state, isVisible };\n}\n\n/** Return state with isVisible set to true is SectionSet is active.\n * @beta\n * @deprecated in 4.15.0. Use {@link ToolbarItems} or a custom conditional value instead.\n */\nexport function selectionContextStateFunc(\n state: Readonly<BaseItemState>\n): BaseItemState {\n const viewport = getActiveViewport();\n if (!viewport) {\n return { ...state, isVisible: false };\n }\n\n const selectionCount = UiFramework.getNumItemsSelected();\n const isVisible =\n viewport.view.iModel.selectionSet.size > 0 || selectionCount > 0;\n return { ...state, isVisible };\n}\n\n/** Utility Class that provides definitions for tools dependent on current selection. These definitions can be used to populate toolbars.\n * @public\n * @deprecated in 4.15.0. Use {@link ToolbarItems} instead.\n */\nexport class SelectionContextToolDefinitions {\n public static get isolateModelsInSelectionItemDef() {\n return new CommandItemDef({\n commandId: \"UiFramework.IsolateModel\",\n iconSpec: svgModelIsolate,\n labelKey: \"UiFramework:tools.isolateModels\",\n execute: async () =>\n UiFramework.hideIsolateEmphasizeActionHandler.processIsolateSelectedElementsModel(),\n });\n }\n\n public static get isolateCategoriesInSelectionItemDef() {\n return new CommandItemDef({\n commandId: \"UiFramework.IsolateCategory\",\n iconSpec: svgLayersIsolate,\n labelKey: \"UiFramework:tools.isolateCategories\",\n execute: async () =>\n UiFramework.hideIsolateEmphasizeActionHandler.processIsolateSelectedElementsCategory(),\n });\n }\n\n public static get isolateElementsItemDef() {\n return new CommandItemDef({\n commandId: \"UiFramework.IsolateSelected\",\n iconSpec: svgAssetIsolate,\n labelKey: \"UiFramework:tools.isolateSelected\",\n isHidden: getIsHiddenIfSelectionNotActive(),\n execute: async () =>\n UiFramework.hideIsolateEmphasizeActionHandler.processIsolateSelected(),\n });\n }\n\n public static get isolateSelectionToolGroup() {\n return new GroupItemDef({\n groupId: \"UiFramework.IsolateSelectionGroup\",\n labelKey: \"UiFramework:tools.isolate\",\n iconSpec: svgIsolate,\n isHidden: getIsHiddenIfSelectionNotActive(),\n items: [\n this.isolateElementsItemDef,\n this.isolateCategoriesInSelectionItemDef,\n this.isolateModelsInSelectionItemDef,\n ],\n itemsInColumn: 3,\n });\n }\n\n public static get hideModelsInSelectionItemDef() {\n return new CommandItemDef({\n commandId: \"UiFramework.HideModel\",\n iconSpec: svgModelHide,\n labelKey: \"UiFramework:tools.hideModels\",\n execute: async () =>\n UiFramework.hideIsolateEmphasizeActionHandler.processHideSelectedElementsModel(),\n });\n }\n\n public static get hideCategoriesInSelectionItemDef() {\n return new CommandItemDef({\n commandId: \"UiFramework.HideCategory\",\n iconSpec: svgLayersHide,\n labelKey: \"UiFramework:tools.hideCategories\",\n execute: async () =>\n UiFramework.hideIsolateEmphasizeActionHandler.processHideSelectedElementsCategory(),\n });\n }\n\n public static get hideElementsItemDef() {\n return new CommandItemDef({\n commandId: \"UiFramework.HideSelected\",\n iconSpec: svgAssetClassificationHide,\n labelKey: \"UiFramework:tools.hideSelected\",\n isHidden: getIsHiddenIfSelectionNotActive(),\n execute: async () =>\n UiFramework.hideIsolateEmphasizeActionHandler.processHideSelected(),\n });\n }\n\n public static get hideSectionToolGroup() {\n return new GroupItemDef({\n groupId: \"UiFramework.HideSelectionGroup\",\n labelKey: \"UiFramework:tools.hide\",\n iconSpec: svgVisibilityHide,\n isHidden: getIsHiddenIfSelectionNotActive(),\n items: [\n this.hideElementsItemDef,\n this.hideCategoriesInSelectionItemDef,\n this.hideModelsInSelectionItemDef,\n ],\n itemsInColumn: 3,\n });\n }\n\n public static get emphasizeElementsItemDef() {\n return new CommandItemDef({\n commandId: \"UiFramework.EmphasizeSelected\",\n iconSpec: svgVisibilitySemiTransparent,\n labelKey: \"UiFramework:tools.emphasizeSelected\",\n isHidden: getIsHiddenIfSelectionNotActive(),\n execute: async () =>\n UiFramework.hideIsolateEmphasizeActionHandler.processEmphasizeSelected(),\n });\n }\n\n public static get clearHideIsolateEmphasizeElementsItemDef() {\n return new CommandItemDef({\n commandId: \"UiFramework.ClearHideIsolateEmphasize\",\n iconSpec: svgVisibility,\n labelKey: \"UiFramework:tools.clearVisibility\",\n isHidden: getIsHiddenIfFeatureOverridesActive(),\n execute: async () => {\n await UiFramework.hideIsolateEmphasizeActionHandler.processClearEmphasize();\n await UiFramework.hideIsolateEmphasizeActionHandler.processClearOverrideModels();\n await UiFramework.hideIsolateEmphasizeActionHandler.processClearOverrideCategories();\n },\n });\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"StatusBarComposer.d.ts","sourceRoot":"","sources":["../../../../src/appui-react/statusbar/StatusBarComposer.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAMH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD,OAAO,KAAK,KAAK,MAAM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AAU,8BAA8B;IACtC,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC;AAMD,gBAAgB;AAChB,wBAAgB,iBAAiB,mCAEhC;AAED;;GAEG;AAEH,MAAM,WAAW,kBAAmB,SAAQ,WAAW;IACrD,4BAA4B;IAC5B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,kBAAkB,qBAqB5D;AAoLD;;GAEG;AAEH,MAAM,WAAW,sBAAuB,SAAQ,WAAW;IACzD,uBAAuB;IACvB,KAAK,EAAE,aAAa,EAAE,CAAC;IAEvB,yDAAyD;IACzD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,mDAAmD;IACnD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,qDAAqD;IACrD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,oDAAoD;IACpD,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,qBAoR9D"}
@@ -202,8 +202,10 @@ function StatusBarComposer(props) {
202
202
  const combinedItems = combineItems(defaultItems, addonItems);
203
203
  return sortItems(combinedItems);
204
204
  }, [defaultItems, addonItems]);
205
- const itemsNotInOverflow = React.useMemo(() => {
206
- return statusBarItems.filter((item) => !isItemInOverflow(item.id, overflown));
205
+ const notOverflown = React.useMemo(() => {
206
+ return statusBarItems
207
+ .filter((item) => !isItemInOverflow(item.id, overflown))
208
+ .map((item) => item.id);
207
209
  }, [overflown, statusBarItems]);
208
210
  const calculateOverflow = React.useCallback(() => {
209
211
  const widths = verifiedMapEntries(entryWidths.current);
@@ -256,10 +258,9 @@ function StatusBarComposer(props) {
256
258
  const providerId = (0, isProviderItem_1.isProviderItem)(item) ? item.providerId : undefined;
257
259
  return (React.createElement(DockedStatusBarEntry, { key: key, entryKey: key, getOnResize: handleEntryResize },
258
260
  React.createElement(DockedStatusBarItem, { key: key, itemId: item.id, itemPriority: itemPriority, providerId: providerId, section: getSectionName(section) },
259
- React.createElement(StatusBarCornerComponentContext_1.StatusBarCornerComponentContext.Provider, { value: key === itemsNotInOverflow[0].id
261
+ React.createElement(StatusBarCornerComponentContext_1.StatusBarCornerComponentContext.Provider, { value: key === notOverflown[0]
260
262
  ? "left-corner"
261
- : (key ===
262
- itemsNotInOverflow[itemsNotInOverflow.length - 1].id &&
263
+ : (key === notOverflown[notOverflown.length - 1] &&
263
264
  overflown?.length === 0) ||
264
265
  isItemInOverflow(key, overflown)
265
266
  ? "right-corner"
@@ -267,7 +268,7 @@ function StatusBarComposer(props) {
267
268
  (0, StatusBarItem_1.isStatusBarCustomItem)(item) && item.content,
268
269
  (0, StatusBarItem_1.isStatusBarActionItem)(item) && (React.createElement(StatusBarActionItemComponent, { ...item })),
269
270
  (0, StatusBarItem_1.isStatusBarLabelItem)(item) && (React.createElement(StatusBarLabelItemComponent, { ...item }))))));
270
- }, [handleEntryResize, itemsNotInOverflow, overflown]);
271
+ }, [handleEntryResize, notOverflown, overflown]);
271
272
  const getSectionItems = React.useCallback((section) => {
272
273
  const sectionItems = statusBarItems
273
274
  .filter((item) => item.section.valueOf() === section.valueOf() &&