@itwin/tree-widget-react 0.3.0 → 0.4.2

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 (79) hide show
  1. package/lib/cjs/components/TreeWidgetUiItemsProvider.d.ts +9 -17
  2. package/lib/cjs/components/TreeWidgetUiItemsProvider.js +50 -47
  3. package/lib/cjs/components/TreeWidgetUiItemsProvider.js.map +1 -1
  4. package/lib/cjs/components/search-bar/SearchBar.scss +1 -0
  5. package/lib/cjs/components/trees/CategoriesTree.d.ts +2 -7
  6. package/lib/cjs/components/trees/CategoriesTree.js +21 -23
  7. package/lib/cjs/components/trees/CategoriesTree.js.map +1 -1
  8. package/lib/cjs/components/trees/IModelContentTree.d.ts +2 -5
  9. package/lib/cjs/components/trees/IModelContentTree.js +5 -11
  10. package/lib/cjs/components/trees/IModelContentTree.js.map +1 -1
  11. package/lib/cjs/components/trees/ModelsTree.d.ts +2 -8
  12. package/lib/cjs/components/trees/ModelsTree.js +8 -16
  13. package/lib/cjs/components/trees/ModelsTree.js.map +1 -1
  14. package/lib/cjs/components/trees/SpatialTree.d.ts +2 -2
  15. package/lib/cjs/components/trees/SpatialTree.js +11 -28
  16. package/lib/cjs/components/trees/SpatialTree.js.map +1 -1
  17. package/lib/cjs/components/trees/index.d.ts +0 -2
  18. package/lib/cjs/components/trees/index.js +3 -5
  19. package/lib/cjs/components/trees/index.js.map +1 -1
  20. package/lib/cjs/components/utils/AutoSizer.d.ts +10 -0
  21. package/lib/cjs/components/utils/AutoSizer.js +36 -0
  22. package/lib/cjs/components/utils/AutoSizer.js.map +1 -0
  23. package/lib/cjs/tree-widget-react.d.ts +1 -1
  24. package/lib/cjs/tree-widget-react.js +4 -4
  25. package/lib/cjs/tree-widget-react.js.map +1 -1
  26. package/lib/cjs/types.d.ts +26 -0
  27. package/lib/cjs/types.js +3 -0
  28. package/lib/cjs/types.js.map +1 -0
  29. package/lib/esm/components/TreeWidgetUiItemsProvider.d.ts +9 -17
  30. package/lib/esm/components/TreeWidgetUiItemsProvider.js +50 -47
  31. package/lib/esm/components/TreeWidgetUiItemsProvider.js.map +1 -1
  32. package/lib/esm/components/search-bar/SearchBar.scss +1 -0
  33. package/lib/esm/components/trees/CategoriesTree.d.ts +2 -7
  34. package/lib/esm/components/trees/CategoriesTree.js +23 -25
  35. package/lib/esm/components/trees/CategoriesTree.js.map +1 -1
  36. package/lib/esm/components/trees/IModelContentTree.d.ts +2 -5
  37. package/lib/esm/components/trees/IModelContentTree.js +6 -12
  38. package/lib/esm/components/trees/IModelContentTree.js.map +1 -1
  39. package/lib/esm/components/trees/ModelsTree.d.ts +2 -8
  40. package/lib/esm/components/trees/ModelsTree.js +9 -17
  41. package/lib/esm/components/trees/ModelsTree.js.map +1 -1
  42. package/lib/esm/components/trees/SpatialTree.d.ts +2 -2
  43. package/lib/esm/components/trees/SpatialTree.js +10 -11
  44. package/lib/esm/components/trees/SpatialTree.js.map +1 -1
  45. package/lib/esm/components/trees/index.d.ts +0 -2
  46. package/lib/esm/components/trees/index.js +3 -5
  47. package/lib/esm/components/trees/index.js.map +1 -1
  48. package/lib/esm/components/utils/AutoSizer.d.ts +10 -0
  49. package/lib/esm/components/utils/AutoSizer.js +13 -0
  50. package/lib/esm/components/utils/AutoSizer.js.map +1 -0
  51. package/lib/esm/tree-widget-react.d.ts +1 -1
  52. package/lib/esm/tree-widget-react.js +4 -4
  53. package/lib/esm/tree-widget-react.js.map +1 -1
  54. package/lib/esm/types.d.ts +26 -0
  55. package/lib/esm/types.js +2 -0
  56. package/lib/esm/types.js.map +1 -0
  57. package/package.json +6 -3
  58. package/lib/cjs/components/TreeWidgetControl.d.ts +0 -26
  59. package/lib/cjs/components/TreeWidgetControl.js +0 -66
  60. package/lib/cjs/components/TreeWidgetControl.js.map +0 -1
  61. package/lib/cjs/components/rulesets/ClassificationSystems.json +0 -122
  62. package/lib/cjs/components/trees/ClassificationsTree.d.ts +0 -7
  63. package/lib/cjs/components/trees/ClassificationsTree.js +0 -43
  64. package/lib/cjs/components/trees/ClassificationsTree.js.map +0 -1
  65. package/lib/cjs/components/trees/TreeWithRuleset.d.ts +0 -35
  66. package/lib/cjs/components/trees/TreeWithRuleset.js +0 -110
  67. package/lib/cjs/components/trees/TreeWithRuleset.js.map +0 -1
  68. package/lib/cjs/components/trees/TreeWithRulesetTree.scss +0 -17
  69. package/lib/esm/components/TreeWidgetControl.d.ts +0 -26
  70. package/lib/esm/components/TreeWidgetControl.js +0 -59
  71. package/lib/esm/components/TreeWidgetControl.js.map +0 -1
  72. package/lib/esm/components/rulesets/ClassificationSystems.json +0 -122
  73. package/lib/esm/components/trees/ClassificationsTree.d.ts +0 -7
  74. package/lib/esm/components/trees/ClassificationsTree.js +0 -17
  75. package/lib/esm/components/trees/ClassificationsTree.js.map +0 -1
  76. package/lib/esm/components/trees/TreeWithRuleset.d.ts +0 -35
  77. package/lib/esm/components/trees/TreeWithRuleset.js +0 -85
  78. package/lib/esm/components/trees/TreeWithRuleset.js.map +0 -1
  79. package/lib/esm/components/trees/TreeWithRulesetTree.scss +0 -17
@@ -1 +1 @@
1
- {"version":3,"file":"SpatialTree.js","sourceRoot":"","sources":["../../../../src/components/trees/SpatialTree.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAKA,oDAA4D;AAC5D,kDAAsD;AACtD,+CAAqD;AAE9C,MAAM,oBAAoB,GAAG,CAClC,KAA4D,EAC5D,EAAE;IACF,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,gBAAQ,CAAC,CAAC,CAAC,CAAC;IACxC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,gBAAQ,CAAC,CAAC,CAAC,CAAC;IACtC,MAAM,YAAY,GAAG,mBAAW,CAAC,CAAC,CAAS,EAAE,CAAS,EAAE,EAAE;QACxD,SAAS,CAAC,CAAC,CAAC,CAAC;QACb,QAAQ,CAAC,CAAC,CAAC,CAAC;IACd,CAAC,EAAE,EAAE,CAAC,CAAC;IACP,MAAM,GAAG,GAAG,8BAAiB,CAAiB,YAAY,CAAC,CAAC;IAE5D,OAAO,CACL,uCAAK,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IACpD,KAAK,IAAI,MAAM,IAAI,CAClB,8BAAC,oCAAsB,OAAK,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,GAAI,CACpE,CACG,CACP,CAAC;AACJ,CAAC,CAAC;AAlBW,QAAA,oBAAoB,wBAkB/B","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 type { SpatialContainmentTreeProps } from \"@itwin/appui-react\";\nimport { SpatialContainmentTree } from \"@itwin/appui-react\";\nimport { useResizeObserver } from \"@itwin/core-react\";\nimport React, { useCallback, useState } from \"react\";\n\nexport const SpatialTreeComponent = (\n props: Omit<SpatialContainmentTreeProps, \"width\" | \"height\">\n) => {\n const [height, setHeight] = useState(0);\n const [width, setWidth] = useState(0);\n const handleResize = useCallback((w: number, h: number) => {\n setHeight(h);\n setWidth(w);\n }, []);\n const ref = useResizeObserver<HTMLDivElement>(handleResize);\n\n return (\n <div ref={ref} style={{ width: \"100%\", height: \"100%\" }}>\n {width && height && (\n <SpatialContainmentTree {...props} width={width} height={height} />\n )}\n </div>\n );\n};\n"]}
1
+ {"version":3,"file":"SpatialTree.js","sourceRoot":"","sources":["../../../../src/components/trees/SpatialTree.tsx"],"names":[],"mappings":";;;;;;AAAA;;;+FAG+F;AAC/F,oDAAuF;AACvF,kDAA0B;AAE1B,kDAA+C;AAExC,MAAM,oBAAoB,GAAG,CAClC,KAAuB,EAAE,EAAE;IAC3B,MAAM,MAAM,GAAG,uCAAyB,EAAE,CAAC;IAE3C,OAAO,CACL,8DACG,MAAM;QACL,8BAAC,qBAAS,QACP,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,8BAAC,oCAAsB,OAAK,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAI,CACjG,CAEb,CACJ,CAAC;AACJ,CAAC,CAAC;AAbW,QAAA,oBAAoB,wBAa/B","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 { SpatialContainmentTree, useActiveIModelConnection } from \"@itwin/appui-react\";\nimport React from \"react\";\nimport type { SpatialTreeProps } from \"../../types\";\nimport { AutoSizer } from \"../utils/AutoSizer\";\n\nexport const SpatialTreeComponent = (\n props: SpatialTreeProps) => {\n const iModel = useActiveIModelConnection();\n\n return (\n <>\n {iModel &&\n <AutoSizer>\n {({ width, height }) => <SpatialContainmentTree {...props} width={width} height={height} iModel={iModel} />}\n </AutoSizer>\n }\n </>\n );\n};\n"]}
@@ -1,7 +1,5 @@
1
1
  export * from "./ModelsTree";
2
2
  export * from "./CategoriesTree";
3
3
  export * from "./SpatialTree";
4
- export * from "./ClassificationsTree";
5
- export * from "./TreeWithRuleset";
6
4
  export * from "./IModelContentTree";
7
5
  //# sourceMappingURL=index.d.ts.map
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
- * See LICENSE.md in the project root for license terms and full copyright notice.
5
- *--------------------------------------------------------------------------------------------*/
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
6
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
7
  if (k2 === undefined) k2 = k;
8
8
  Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
@@ -17,7 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./ModelsTree"), exports);
18
18
  __exportStar(require("./CategoriesTree"), exports);
19
19
  __exportStar(require("./SpatialTree"), exports);
20
- __exportStar(require("./ClassificationsTree"), exports);
21
- __exportStar(require("./TreeWithRuleset"), exports);
22
20
  __exportStar(require("./IModelContentTree"), exports);
23
21
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/trees/index.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;;;;;;;;;;AAE/F,+CAA6B;AAC7B,mDAAiC;AACjC,gDAA8B;AAC9B,wDAAsC;AACtC,oDAAkC;AAClC,sDAAoC","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\nexport * from \"./ModelsTree\";\nexport * from \"./CategoriesTree\";\nexport * from \"./SpatialTree\";\nexport * from \"./ClassificationsTree\";\nexport * from \"./TreeWithRuleset\";\nexport * from \"./IModelContentTree\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/trees/index.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;;;;;;;;;;AAEhG,+CAA6B;AAC7B,mDAAiC;AACjC,gDAA8B;AAC9B,sDAAoC","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\nexport * from \"./ModelsTree\";\nexport * from \"./CategoriesTree\";\nexport * from \"./SpatialTree\";\nexport * from \"./IModelContentTree\";\n"]}
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ export interface Size {
3
+ width: number;
4
+ height: number;
5
+ }
6
+ export interface AutoSizerProps {
7
+ children: (size: Size) => React.ReactElement | null;
8
+ }
9
+ export declare const AutoSizer: (props: AutoSizerProps) => JSX.Element;
10
+ //# sourceMappingURL=AutoSizer.d.ts.map
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.AutoSizer = void 0;
23
+ const react_1 = __importStar(require("react"));
24
+ const core_react_1 = require("@itwin/core-react");
25
+ const AutoSizer = (props) => {
26
+ const [height, setHeight] = react_1.useState(0);
27
+ const [width, setWidth] = react_1.useState(0);
28
+ const handleResize = react_1.useCallback((w, h) => {
29
+ setHeight(h);
30
+ setWidth(w);
31
+ }, []);
32
+ const ref = core_react_1.useResizeObserver(handleResize);
33
+ return (react_1.default.createElement("div", { ref: ref, style: { width: "100%", height: "100%" } }, width && height && (props.children({ width, height }))));
34
+ };
35
+ exports.AutoSizer = AutoSizer;
36
+ //# sourceMappingURL=AutoSizer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AutoSizer.js","sourceRoot":"","sources":["../../../../src/components/utils/AutoSizer.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAqD;AACrD,kDAAsD;AAW/C,MAAM,SAAS,GAAG,CAAC,KAAqB,EAAE,EAAE;IACjD,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,gBAAQ,CAAC,CAAC,CAAC,CAAC;IACxC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,gBAAQ,CAAC,CAAC,CAAC,CAAC;IACtC,MAAM,YAAY,GAAG,mBAAW,CAAC,CAAC,CAAS,EAAE,CAAS,EAAE,EAAE;QACxD,SAAS,CAAC,CAAC,CAAC,CAAC;QACb,QAAQ,CAAC,CAAC,CAAC,CAAC;IACd,CAAC,EAAE,EAAE,CAAC,CAAC;IACP,MAAM,GAAG,GAAG,8BAAiB,CAAiB,YAAY,CAAC,CAAC;IAE5D,OAAO,CACL,uCAAK,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IACpD,KAAK,IAAI,MAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,CACnD,CACP,CAAC;AACJ,CAAC,CAAC;AAdW,QAAA,SAAS,aAcpB","sourcesContent":["import React, { useCallback, useState } from \"react\";\nimport { useResizeObserver } from \"@itwin/core-react\";\n\nexport interface Size {\n width: number;\n height: number;\n}\n\nexport interface AutoSizerProps {\n children: (size: Size) => React.ReactElement | null;\n}\n\nexport const AutoSizer = (props: AutoSizerProps) => {\n const [height, setHeight] = useState(0);\n const [width, setWidth] = useState(0);\n const handleResize = useCallback((w: number, h: number) => {\n setHeight(h);\n setWidth(w);\n }, []);\n const ref = useResizeObserver<HTMLDivElement>(handleResize);\n\n return (\n <div ref={ref} style={{ width: \"100%\", height: \"100%\" }}>\n {width && height && (props.children({ width, height }))}\n </div>\n );\n};\n"]}
@@ -1,5 +1,5 @@
1
+ export * from "./types";
1
2
  export * from "./TreeWidget";
2
- export * from "./components/TreeWidgetControl";
3
3
  export * from "./components/TreeWidgetComponent";
4
4
  export * from "./components/header/TreeHeader";
5
5
  export * from "./components/trees";
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
- * See LICENSE.md in the project root for license terms and full copyright notice.
5
- *--------------------------------------------------------------------------------------------*/
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
6
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
7
  if (k2 === undefined) k2 = k;
8
8
  Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
@@ -14,8 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./types"), exports);
17
18
  __exportStar(require("./TreeWidget"), exports);
18
- __exportStar(require("./components/TreeWidgetControl"), exports);
19
19
  __exportStar(require("./components/TreeWidgetComponent"), exports);
20
20
  __exportStar(require("./components/header/TreeHeader"), exports);
21
21
  __exportStar(require("./components/trees"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"tree-widget-react.js","sourceRoot":"","sources":["../../src/tree-widget-react.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;;;;;;;;;;AAE/F,+CAA6B;AAC7B,iEAA+C;AAC/C,mEAAiD;AACjD,iEAA+C;AAC/C,qDAAmC;AACnC,yEAAuD","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\nexport * from \"./TreeWidget\";\nexport * from \"./components/TreeWidgetControl\";\nexport * from \"./components/TreeWidgetComponent\";\nexport * from \"./components/header/TreeHeader\";\nexport * from \"./components/trees\";\nexport * from \"./components/TreeWidgetUiItemsProvider\";\n"]}
1
+ {"version":3,"file":"tree-widget-react.js","sourceRoot":"","sources":["../../src/tree-widget-react.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;;;;;;;;;;AAEhG,0CAAwB;AACxB,+CAA6B;AAC7B,mEAAiD;AACjD,iEAA+C;AAC/C,qDAAmC;AACnC,yEAAuD","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\nexport * from \"./types\";\nexport * from \"./TreeWidget\";\nexport * from \"./components/TreeWidgetComponent\";\nexport * from \"./components/header/TreeHeader\";\nexport * from \"./components/trees\";\nexport * from \"./components/TreeWidgetUiItemsProvider\";\n"]}
@@ -0,0 +1,26 @@
1
+ /// <reference types="react" />
2
+ import type { StagePanelLocation, StagePanelSection } from "@itwin/appui-abstract";
3
+ import type { CategoryTreeProps, ModelsTreeProps, SpatialContainmentTreeProps } from "@itwin/appui-react";
4
+ import type { SelectableContentDefinition } from "@itwin/components-react";
5
+ import type { IModelConnection } from "@itwin/core-frontend";
6
+ export interface IModelContentTreeProps extends Omit<React.AllHTMLAttributes<HTMLDivElement>, "children"> {
7
+ iModel: IModelConnection;
8
+ }
9
+ export declare type ModelTreeProps = Omit<ModelsTreeProps, "iModel" | "activeView" | "width" | "height" | "filterInfo" | "onFilterApplied">;
10
+ export declare type CategoriesTreeProps = Omit<CategoryTreeProps, "iModel" | "activeView" | "width" | "height" | "filterInfo" | "onFilterApplied">;
11
+ export declare type SpatialTreeProps = Omit<SpatialContainmentTreeProps, "iModel" | "width" | "height">;
12
+ export interface TreeWidgetOptions {
13
+ defaultPanelLocation?: StagePanelLocation;
14
+ defaultPanelSection?: StagePanelSection;
15
+ enableElementsClassGrouping?: boolean;
16
+ additionalTrees?: SelectableContentDefinition[];
17
+ modelsTreeProps?: ModelTreeProps;
18
+ categoriesTreeProps?: CategoriesTreeProps;
19
+ spatialTreeProps?: SpatialTreeProps;
20
+ hideTrees?: {
21
+ modelsTree?: boolean;
22
+ categoriesTree?: boolean;
23
+ spatialTree?: boolean;
24
+ };
25
+ }
26
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"","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 type { StagePanelLocation, StagePanelSection } from \"@itwin/appui-abstract\";\nimport type {\n CategoryTreeProps,\n ModelsTreeProps,\n SpatialContainmentTreeProps,\n} from \"@itwin/appui-react\";\nimport type { SelectableContentDefinition } from \"@itwin/components-react\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\n\nexport interface IModelContentTreeProps\n extends Omit<React.AllHTMLAttributes<HTMLDivElement>, \"children\"> {\n iModel: IModelConnection;\n}\n\nexport type ModelTreeProps = Omit<\nModelsTreeProps,\n| \"iModel\"\n| \"activeView\"\n| \"width\"\n| \"height\"\n| \"filterInfo\"\n| \"onFilterApplied\"\n>;\n\nexport type CategoriesTreeProps = Omit<\nCategoryTreeProps,\n| \"iModel\"\n| \"activeView\"\n| \"width\"\n| \"height\"\n| \"filterInfo\"\n| \"onFilterApplied\"\n>;\n\nexport type SpatialTreeProps = Omit<\nSpatialContainmentTreeProps,\n\"iModel\" | \"width\" | \"height\"\n>;\n\nexport interface TreeWidgetOptions {\n defaultPanelLocation?: StagePanelLocation;\n defaultPanelSection?: StagePanelSection;\n enableElementsClassGrouping?: boolean;\n additionalTrees?: SelectableContentDefinition[];\n modelsTreeProps?: ModelTreeProps;\n categoriesTreeProps?: CategoriesTreeProps;\n spatialTreeProps?: SpatialTreeProps;\n hideTrees?: {\n modelsTree?: boolean;\n categoriesTree?: boolean;\n spatialTree?: boolean;\n };\n}\n"]}
@@ -1,20 +1,12 @@
1
- import type { AbstractWidgetProps, StagePanelSection, UiItemsProvider } from "@itwin/appui-abstract";
2
- import { StagePanelLocation } from "@itwin/appui-abstract";
3
- import type { TreeWidgetControlOptions } from "./TreeWidgetControl";
1
+ import type { AbstractWidgetProps, UiItemsProvider } from "@itwin/appui-abstract";
2
+ import { StagePanelSection } from "@itwin/appui-abstract";
3
+ import { AbstractZoneLocation, StagePanelLocation } from "@itwin/appui-abstract";
4
+ import type { TreeWidgetOptions } from "../types";
5
+ export declare const TreeWidgetId = "tree-widget-react:trees";
4
6
  export declare class TreeWidgetUiItemsProvider implements UiItemsProvider {
5
- readonly id = "TreeWidgetUiitemsProvider";
6
- private _imodel?;
7
- private _activeView?;
8
- private _enableElementsClassGrouping?;
9
- private _allViewports?;
10
- private _additionalTrees?;
11
- private _modelsTreeProps?;
12
- private _categoriesTreeProps?;
13
- private _spatialTreeProps?;
14
- private _modelsTreeReplacement?;
15
- private _categoriesTreeReplacement?;
16
- private _spatialTreeReplacement?;
17
- constructor(props?: Partial<TreeWidgetControlOptions>);
18
- provideWidgets(_stageId: string, stageUsage: string, location: StagePanelLocation, _section: StagePanelSection | undefined): ReadonlyArray<AbstractWidgetProps>;
7
+ private _treeWidgetOptions?;
8
+ readonly id = "TreeWidgetUiItemsProvider";
9
+ constructor(_treeWidgetOptions?: TreeWidgetOptions | undefined);
10
+ provideWidgets(_stageId: string, stageUsage: string, location: StagePanelLocation, section?: StagePanelSection, zoneLocation?: AbstractZoneLocation): ReadonlyArray<AbstractWidgetProps>;
19
11
  }
20
12
  //# sourceMappingURL=TreeWidgetUiItemsProvider.d.ts.map
@@ -1,4 +1,5 @@
1
- import { StagePanelLocation, StageUsage, } from "@itwin/appui-abstract";
1
+ import { StagePanelSection, } from "@itwin/appui-abstract";
2
+ import { AbstractZoneLocation, StagePanelLocation, StageUsage, } from "@itwin/appui-abstract";
2
3
  import { ClassGroupingOption, UiFramework } from "@itwin/appui-react";
3
4
  import React from "react";
4
5
  import { TreeWidgetComponent } from "./TreeWidgetComponent";
@@ -6,65 +7,67 @@ import { CategoriesTreeComponent } from "./trees/CategoriesTree";
6
7
  import { ModelsTreeComponent } from "./trees/ModelsTree";
7
8
  import { SpatialTreeComponent } from "./trees/SpatialTree";
8
9
  import { TreeWidget } from "../TreeWidget";
10
+ export const TreeWidgetId = "tree-widget-react:trees";
9
11
  export class TreeWidgetUiItemsProvider {
10
- constructor(props) {
11
- var _a, _b, _c, _d, _e, _f;
12
- this.id = "TreeWidgetUiitemsProvider";
13
- this._imodel = props === null || props === void 0 ? void 0 : props.iModelConnection;
14
- this._activeView = props === null || props === void 0 ? void 0 : props.activeView;
15
- this._enableElementsClassGrouping = props === null || props === void 0 ? void 0 : props.enableElementsClassGrouping;
16
- this._allViewports = props === null || props === void 0 ? void 0 : props.allViewports;
17
- this._additionalTrees = props === null || props === void 0 ? void 0 : props.additionalTrees;
18
- this._modelsTreeProps = (_a = props === null || props === void 0 ? void 0 : props.additionalProps) === null || _a === void 0 ? void 0 : _a.modelsTree;
19
- this._categoriesTreeProps = (_b = props === null || props === void 0 ? void 0 : props.additionalProps) === null || _b === void 0 ? void 0 : _b.categoriesTree;
20
- this._spatialTreeProps = (_c = props === null || props === void 0 ? void 0 : props.additionalProps) === null || _c === void 0 ? void 0 : _c.spatialTree;
21
- this._modelsTreeReplacement = (_d = props === null || props === void 0 ? void 0 : props.treeReplacements) === null || _d === void 0 ? void 0 : _d.modelsTree;
22
- this._categoriesTreeReplacement = (_e = props === null || props === void 0 ? void 0 : props.treeReplacements) === null || _e === void 0 ? void 0 : _e.categoriesTree;
23
- this._spatialTreeReplacement = (_f = props === null || props === void 0 ? void 0 : props.treeReplacements) === null || _f === void 0 ? void 0 : _f.spatialTree;
12
+ constructor(_treeWidgetOptions) {
13
+ this._treeWidgetOptions = _treeWidgetOptions;
14
+ this.id = "TreeWidgetUiItemsProvider";
24
15
  }
25
- provideWidgets(_stageId, stageUsage, location, _section) {
26
- var _a, _b, _c;
16
+ provideWidgets(_stageId, stageUsage, location, section,
17
+ // eslint-disable-next-line deprecation/deprecation
18
+ zoneLocation) {
19
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
27
20
  const widgets = [];
28
- const imodel = UiFramework.getIModelConnection();
29
- if (stageUsage === StageUsage.General &&
30
- location === StagePanelLocation.Right &&
31
- imodel !== undefined) {
32
- const modelsTreeComponent = (React.createElement(ModelsTreeComponent, { iModel: (_a = this._imodel) !== null && _a !== void 0 ? _a : imodel, allViewports: this._allViewports, activeView: this._activeView, enableElementsClassGrouping: this._enableElementsClassGrouping, ...this._modelsTreeProps }));
33
- const categoriesTreeComponent = (React.createElement(CategoriesTreeComponent, { iModel: (_b = this._imodel) !== null && _b !== void 0 ? _b : imodel, allViewports: this._allViewports, activeView: this._activeView, ...this._categoriesTreeProps }));
34
- const spatialContainmentComponent = (React.createElement(SpatialTreeComponent, { iModel: (_c = this._imodel) !== null && _c !== void 0 ? _c : imodel, enableElementsClassGrouping: this._enableElementsClassGrouping
35
- ? ClassGroupingOption.Yes
36
- : ClassGroupingOption.No, ...this._spatialTreeProps }));
37
- const trees = [
38
- {
21
+ const preferredLocation = (_b = (_a = this._treeWidgetOptions) === null || _a === void 0 ? void 0 : _a.defaultPanelLocation) !== null && _b !== void 0 ? _b : StagePanelLocation.Right;
22
+ const preferredPanelSection = (_d = (_c = this._treeWidgetOptions) === null || _c === void 0 ? void 0 : _c.defaultPanelSection) !== null && _d !== void 0 ? _d : StagePanelSection.Start;
23
+ if (
24
+ // eslint-disable-next-line deprecation/deprecation
25
+ (!section && stageUsage === StageUsage.General && zoneLocation === AbstractZoneLocation.CenterRight) ||
26
+ (stageUsage === StageUsage.General && location === preferredLocation && section === preferredPanelSection
27
+ && UiFramework.uiVersion !== "1")) {
28
+ const trees = [];
29
+ if (!((_f = (_e = this._treeWidgetOptions) === null || _e === void 0 ? void 0 : _e.hideTrees) === null || _f === void 0 ? void 0 : _f.modelsTree)) {
30
+ trees.push({
39
31
  label: TreeWidget.translate("modeltree"),
40
32
  id: "model-tree",
41
- render: this._modelsTreeReplacement
42
- ? this._modelsTreeReplacement
43
- : () => modelsTreeComponent,
44
- },
45
- {
33
+ render: () => {
34
+ var _a, _b;
35
+ return (React.createElement(ModelsTreeComponent, { enableElementsClassGrouping: ((_a = this._treeWidgetOptions) === null || _a === void 0 ? void 0 : _a.enableElementsClassGrouping)
36
+ ? ClassGroupingOption.YesWithCounts
37
+ : ClassGroupingOption.No, ...(_b = this._treeWidgetOptions) === null || _b === void 0 ? void 0 : _b.modelsTreeProps }));
38
+ },
39
+ });
40
+ }
41
+ if (!((_h = (_g = this._treeWidgetOptions) === null || _g === void 0 ? void 0 : _g.hideTrees) === null || _h === void 0 ? void 0 : _h.categoriesTree)) {
42
+ trees.push({
46
43
  label: TreeWidget.translate("categories"),
47
44
  id: "categories-tree",
48
- render: this._categoriesTreeReplacement
49
- ? this._categoriesTreeReplacement
50
- : () => categoriesTreeComponent,
51
- },
52
- {
45
+ render: () => {
46
+ var _a;
47
+ return (React.createElement(CategoriesTreeComponent, { ...(_a = this._treeWidgetOptions) === null || _a === void 0 ? void 0 : _a.categoriesTreeProps }));
48
+ },
49
+ });
50
+ }
51
+ if (!((_k = (_j = this._treeWidgetOptions) === null || _j === void 0 ? void 0 : _j.hideTrees) === null || _k === void 0 ? void 0 : _k.spatialTree)) {
52
+ trees.push({
53
53
  label: TreeWidget.translate("containment"),
54
54
  id: "spatial-containment-tree",
55
- render: this._spatialTreeReplacement
56
- ? this._spatialTreeReplacement
57
- : () => spatialContainmentComponent,
58
- },
59
- ];
60
- if (this._additionalTrees) {
61
- trees.push(...this._additionalTrees);
55
+ render: () => {
56
+ var _a, _b;
57
+ return (React.createElement(SpatialTreeComponent, { enableElementsClassGrouping: ((_a = this._treeWidgetOptions) === null || _a === void 0 ? void 0 : _a.enableElementsClassGrouping)
58
+ ? ClassGroupingOption.YesWithCounts
59
+ : ClassGroupingOption.No, ...(_b = this._treeWidgetOptions) === null || _b === void 0 ? void 0 : _b.spatialTreeProps }));
60
+ },
61
+ });
62
+ }
63
+ if ((_l = this._treeWidgetOptions) === null || _l === void 0 ? void 0 : _l.additionalTrees) {
64
+ trees.push(...this._treeWidgetOptions.additionalTrees);
62
65
  }
63
66
  widgets.push({
64
- id: "tree",
67
+ id: TreeWidgetId,
65
68
  label: TreeWidget.translate("treeview"),
66
- // eslint-disable-next-line react/display-name
67
69
  getWidgetContent: () => React.createElement(TreeWidgetComponent, { trees: trees }),
70
+ icon: "icon-hierarchy-tree",
68
71
  });
69
72
  }
70
73
  return widgets;
@@ -1 +1 @@
1
- {"version":3,"file":"TreeWidgetUiItemsProvider.js","sourceRoot":"","sources":["../../../src/components/TreeWidgetUiItemsProvider.tsx"],"names":[],"mappings":"AASA,OAAO,EACL,kBAAkB,EAClB,UAAU,GACX,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAG3D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,MAAM,OAAO,yBAAyB;IAepC,YAAY,KAAyC;;QAdrC,OAAE,GAAG,2BAA2B,CAAC;QAe/C,IAAI,CAAC,OAAO,GAAG,KAAK,aAAL,KAAK,uBAAL,KA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BAAuB;iBAClC;gBACD;oBACE,KAAK,EAAE,UAAU,CAAC,SAAS,CAAC,aAAa,CAAC;oBAC1C,EAAE,EAAE,0BAA0B;oBAC9B,MAAM,EAAE,IAAI,CAAC,uBAAuB;wBAClC,CAAC,CAAC,IAAI,CAAC,uBAAuB;wBAC9B,CAAC,CAAC,GAAG,EAAE,CAAC,2BAA2B;iBACtC;aACF,CAAC;YAEF,IAAI,IAAI,CAAC,gBAAgB,EAAE;gBACzB,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,gBAAgB,CAAC,CAAC;aACtC;YAED,OAAO,CAAC,IAAI,CAAC;gBACX,EAAE,EAAE,MAAM;gBACV,KAAK,EAAE,UAAU,CAAC,SAAS,CAAC,UAAU,CAAC;gBACvC,8CAA8C;gBAC9C,gBAAgB,EAAE,GAAG,EAAE,CAAC,oBAAC,mBAAmB,IAAC,KAAK,EAAE,KAAK,GAAI;aAC9D,CAAC,CAAC;SACJ;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF","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 type {\n AbstractWidgetProps,\n StagePanelSection,\n UiItemsProvider,\n} from \"@itwin/appui-abstract\";\nimport {\n StagePanelLocation,\n StageUsage,\n} from \"@itwin/appui-abstract\";\nimport { ClassGroupingOption, UiFramework } from \"@itwin/appui-react\";\nimport React from \"react\";\nimport { TreeWidgetComponent } from \"./TreeWidgetComponent\";\nimport { CategoriesTreeComponent } from \"./trees/CategoriesTree\";\nimport { ModelsTreeComponent } from \"./trees/ModelsTree\";\nimport { SpatialTreeComponent } from \"./trees/SpatialTree\";\nimport type { IModelConnection, Viewport } from \"@itwin/core-frontend\";\nimport type { SelectableContentDefinition } from \"@itwin/components-react\";\nimport { TreeWidget } from \"../TreeWidget\";\nimport type { TreeWidgetControlOptions } from \"./TreeWidgetControl\";\n\nexport class TreeWidgetUiItemsProvider implements UiItemsProvider {\n public readonly id = \"TreeWidgetUiitemsProvider\";\n\n private _imodel?: IModelConnection;\n private _activeView?: Viewport;\n private _enableElementsClassGrouping?: boolean;\n private _allViewports?: boolean;\n private _additionalTrees?: SelectableContentDefinition[];\n private _modelsTreeProps?: {};\n private _categoriesTreeProps?: {};\n private _spatialTreeProps?: {};\n private _modelsTreeReplacement?: () => React.ReactNode;\n private _categoriesTreeReplacement?: () => React.ReactNode;\n private _spatialTreeReplacement?: () => React.ReactNode;\n\n constructor(props?: Partial<TreeWidgetControlOptions>) {\n this._imodel = props?.iModelConnection;\n this._activeView = props?.activeView;\n this._enableElementsClassGrouping = props?.enableElementsClassGrouping;\n this._allViewports = props?.allViewports;\n this._additionalTrees = props?.additionalTrees;\n this._modelsTreeProps = props?.additionalProps?.modelsTree;\n this._categoriesTreeProps = props?.additionalProps?.categoriesTree;\n this._spatialTreeProps = props?.additionalProps?.spatialTree;\n this._modelsTreeReplacement = props?.treeReplacements?.modelsTree;\n this._categoriesTreeReplacement = props?.treeReplacements?.categoriesTree;\n this._spatialTreeReplacement = props?.treeReplacements?.spatialTree;\n }\n\n public provideWidgets(\n _stageId: string,\n stageUsage: string,\n location: StagePanelLocation,\n _section: StagePanelSection | undefined\n ): ReadonlyArray<AbstractWidgetProps> {\n const widgets: AbstractWidgetProps[] = [];\n const imodel = UiFramework.getIModelConnection();\n if (\n stageUsage === StageUsage.General &&\n location === StagePanelLocation.Right &&\n imodel !== undefined\n ) {\n const modelsTreeComponent = (\n <ModelsTreeComponent\n iModel={this._imodel ?? imodel}\n allViewports={this._allViewports}\n activeView={this._activeView}\n enableElementsClassGrouping={this._enableElementsClassGrouping}\n {...this._modelsTreeProps}\n />\n );\n\n const categoriesTreeComponent = (\n <CategoriesTreeComponent\n iModel={this._imodel ?? imodel}\n allViewports={this._allViewports}\n activeView={this._activeView}\n {...this._categoriesTreeProps}\n />\n );\n\n const spatialContainmentComponent = (\n <SpatialTreeComponent\n iModel={this._imodel ?? imodel}\n enableElementsClassGrouping={\n this._enableElementsClassGrouping\n ? ClassGroupingOption.Yes\n : ClassGroupingOption.No\n }\n {...this._spatialTreeProps}\n />\n );\n\n const trees: SelectableContentDefinition[] = [\n {\n label: TreeWidget.translate(\"modeltree\"),\n id: \"model-tree\",\n render: this._modelsTreeReplacement\n ? this._modelsTreeReplacement\n : () => modelsTreeComponent,\n },\n {\n label: TreeWidget.translate(\"categories\"),\n id: \"categories-tree\",\n render: this._categoriesTreeReplacement\n ? this._categoriesTreeReplacement\n : () => categoriesTreeComponent,\n },\n {\n label: TreeWidget.translate(\"containment\"),\n id: \"spatial-containment-tree\",\n render: this._spatialTreeReplacement\n ? this._spatialTreeReplacement\n : () => spatialContainmentComponent,\n },\n ];\n\n if (this._additionalTrees) {\n trees.push(...this._additionalTrees);\n }\n\n widgets.push({\n id: \"tree\",\n label: TreeWidget.translate(\"treeview\"),\n // eslint-disable-next-line react/display-name\n getWidgetContent: () => <TreeWidgetComponent trees={trees} />,\n });\n }\n\n return widgets;\n }\n}\n"]}
1
+ {"version":3,"file":"TreeWidgetUiItemsProvider.js","sourceRoot":"","sources":["../../../src/components/TreeWidgetUiItemsProvider.tsx"],"names":[],"mappings":"AASA,OAAO,EACL,iBAAiB,GAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,UAAU,GACX,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D,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I,CAAC;gBACX,EAAE,EAAE,YAAY;gBAChB,KAAK,EAAE,UAAU,CAAC,SAAS,CAAC,UAAU,CAAC;gBACvC,gBAAgB,EAAE,GAAG,EAAE,CAAC,oBAAC,mBAAmB,IAAC,KAAK,EAAE,KAAK,GAAI;gBAC7D,IAAI,EAAE,qBAAqB;aAC5B,CAAC,CAAC;SACJ;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF","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/* eslint-disable react/display-name */\nimport type {\n AbstractWidgetProps,\n UiItemsProvider,\n} from \"@itwin/appui-abstract\";\nimport {\n StagePanelSection,\n} from \"@itwin/appui-abstract\";\nimport {\n AbstractZoneLocation,\n StagePanelLocation,\n StageUsage,\n} from \"@itwin/appui-abstract\";\nimport { ClassGroupingOption, UiFramework } from \"@itwin/appui-react\";\nimport React from \"react\";\nimport { TreeWidgetComponent } from \"./TreeWidgetComponent\";\nimport { CategoriesTreeComponent } from \"./trees/CategoriesTree\";\nimport { ModelsTreeComponent } from \"./trees/ModelsTree\";\nimport { SpatialTreeComponent } from \"./trees/SpatialTree\";\nimport type { SelectableContentDefinition } from \"@itwin/components-react\";\nimport { TreeWidget } from \"../TreeWidget\";\nimport type { TreeWidgetOptions } from \"../types\";\n\nexport const TreeWidgetId = \"tree-widget-react:trees\";\nexport class TreeWidgetUiItemsProvider implements UiItemsProvider {\n public readonly id = \"TreeWidgetUiItemsProvider\";\n\n constructor(private _treeWidgetOptions?: TreeWidgetOptions) { }\n\n public provideWidgets(\n _stageId: string,\n stageUsage: string,\n location: StagePanelLocation,\n section?: StagePanelSection,\n // eslint-disable-next-line deprecation/deprecation\n zoneLocation?: AbstractZoneLocation,\n ): ReadonlyArray<AbstractWidgetProps> {\n const widgets: AbstractWidgetProps[] = [];\n const preferredLocation = this._treeWidgetOptions?.defaultPanelLocation ?? StagePanelLocation.Right;\n const preferredPanelSection = this._treeWidgetOptions?.defaultPanelSection ?? StagePanelSection.Start;\n if (\n // eslint-disable-next-line deprecation/deprecation\n (!section && stageUsage === StageUsage.General && zoneLocation === AbstractZoneLocation.CenterRight) ||\n (stageUsage === StageUsage.General && location === preferredLocation && section === preferredPanelSection\n && UiFramework.uiVersion !== \"1\")\n ) {\n const trees: SelectableContentDefinition[] = [];\n\n if (!this._treeWidgetOptions?.hideTrees?.modelsTree) {\n trees.push({\n label: TreeWidget.translate(\"modeltree\"),\n id: \"model-tree\",\n render: () => (\n <ModelsTreeComponent\n enableElementsClassGrouping={\n this._treeWidgetOptions?.enableElementsClassGrouping\n ? ClassGroupingOption.YesWithCounts\n : ClassGroupingOption.No\n }\n {...this._treeWidgetOptions?.modelsTreeProps}\n />\n ),\n });\n }\n\n if (!this._treeWidgetOptions?.hideTrees?.categoriesTree) {\n trees.push({\n label: TreeWidget.translate(\"categories\"),\n id: \"categories-tree\",\n render: () => (\n <CategoriesTreeComponent {...this._treeWidgetOptions?.categoriesTreeProps} />\n ),\n });\n }\n\n if (!this._treeWidgetOptions?.hideTrees?.spatialTree) {\n trees.push({\n label: TreeWidget.translate(\"containment\"),\n id: \"spatial-containment-tree\",\n render: () => (\n <SpatialTreeComponent\n enableElementsClassGrouping={\n this._treeWidgetOptions?.enableElementsClassGrouping\n ? ClassGroupingOption.YesWithCounts\n : ClassGroupingOption.No\n }\n {...this._treeWidgetOptions?.spatialTreeProps}\n />\n ),\n });\n }\n\n if (this._treeWidgetOptions?.additionalTrees) {\n trees.push(...this._treeWidgetOptions.additionalTrees);\n }\n\n widgets.push({\n id: TreeWidgetId,\n label: TreeWidget.translate(\"treeview\"),\n getWidgetContent: () => <TreeWidgetComponent trees={trees} />,\n icon: \"icon-hierarchy-tree\",\n });\n }\n\n return widgets;\n }\n}\n"]}
@@ -63,6 +63,7 @@
63
63
  height: 100%;
64
64
  position: absolute;
65
65
  left: 0;
66
+ right: 0;
66
67
 
67
68
  .search-bar-search-box {
68
69
  height: 32px;
@@ -1,10 +1,5 @@
1
1
  /// <reference types="react" />
2
- import type { IModelConnection, Viewport } from "@itwin/core-frontend";
3
2
  import "./CategoriesTree.scss";
4
- export interface CategoriesTreeComponentProps {
5
- iModel: IModelConnection;
6
- allViewports?: boolean;
7
- activeView?: Viewport;
8
- }
9
- export declare function CategoriesTreeComponent(props: CategoriesTreeComponentProps): JSX.Element;
3
+ import type { CategoriesTreeProps } from "../../types";
4
+ export declare function CategoriesTreeComponent(props: CategoriesTreeProps): JSX.Element;
10
5
  //# sourceMappingURL=CategoriesTree.d.ts.map
@@ -2,39 +2,36 @@
2
2
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
- import React, { useCallback, useState } from "react";
5
+ import React, { useCallback } from "react";
6
6
  import { IModelApp } from "@itwin/core-frontend";
7
- import { CategoryTree, getCategories, toggleAllCategories } from "@itwin/appui-react";
7
+ import { CategoryTree, getCategories, toggleAllCategories, useActiveIModelConnection, useActiveViewport } from "@itwin/appui-react";
8
8
  import { useTreeFilteringState } from "../TreeFilteringState";
9
9
  import "./CategoriesTree.scss";
10
10
  import { TreeHeaderComponent } from "../header/TreeHeader";
11
11
  import { CategoryVisibilityHandler } from "@itwin/appui-react";
12
- import { useResizeObserver } from "@itwin/core-react";
12
+ import { AutoSizer } from "../utils/AutoSizer";
13
13
  export function CategoriesTreeComponent(props) {
14
+ const iModel = useActiveIModelConnection();
15
+ const viewport = useActiveViewport();
14
16
  const { searchOptions, filterString, activeMatchIndex, onFilterApplied, filteredProvider, } = useTreeFilteringState();
15
- const [height, setHeight] = useState(0);
16
- const [width, setWidth] = useState(0);
17
- const handleResize = useCallback((w, h) => {
18
- setHeight(h);
19
- setWidth(w);
20
- }, []);
21
- const ref = useResizeObserver(handleResize);
22
17
  const showAll = useCallback(async () => {
23
- return toggleAllCategories(IModelApp.viewManager, props.iModel, true, undefined, true, filteredProvider);
24
- }, [props.iModel, filteredProvider]);
18
+ if (!iModel)
19
+ return;
20
+ return toggleAllCategories(IModelApp.viewManager, iModel, true, undefined, true, filteredProvider);
21
+ }, [iModel, filteredProvider]);
25
22
  const hideAll = useCallback(async () => {
26
- return toggleAllCategories(IModelApp.viewManager, props.iModel, false, undefined, true, filteredProvider);
27
- }, [props.iModel, filteredProvider]);
23
+ if (!iModel)
24
+ return;
25
+ return toggleAllCategories(IModelApp.viewManager, iModel, false, undefined, true, filteredProvider);
26
+ }, [iModel, filteredProvider]);
28
27
  const invert = useCallback(async () => {
29
- const activeView = IModelApp.viewManager.getFirstOpenView();
30
- if (!activeView) {
28
+ if (!iModel || !viewport)
31
29
  return;
32
- }
33
- const ids = await getCategories(props.iModel, activeView, filteredProvider);
30
+ const ids = await getCategories(iModel, viewport, filteredProvider);
34
31
  const enabled = [];
35
32
  const disabled = [];
36
33
  for (const id of ids) {
37
- if (activeView.view.viewsCategory(id)) {
34
+ if (viewport.view.viewsCategory(id)) {
38
35
  enabled.push(id);
39
36
  }
40
37
  else {
@@ -42,12 +39,13 @@ export function CategoriesTreeComponent(props) {
42
39
  }
43
40
  }
44
41
  // Disable enabled
45
- CategoryVisibilityHandler.enableCategory(IModelApp.viewManager, props.iModel, enabled, false, true);
42
+ CategoryVisibilityHandler.enableCategory(IModelApp.viewManager, iModel, enabled, false, true);
46
43
  // Enable disabled
47
- CategoryVisibilityHandler.enableCategory(IModelApp.viewManager, props.iModel, disabled, true, true);
48
- }, [props.iModel, filteredProvider]);
49
- return (React.createElement(React.Fragment, null,
50
- React.createElement(TreeHeaderComponent, { searchOptions: searchOptions, showAll: showAll, hideAll: hideAll, invert: invert }),
51
- React.createElement("div", { ref: ref, style: { width: "100%", height: "100%" } }, width && height && (React.createElement(CategoryTree, { ...props, filterInfo: { filter: filterString, activeMatchIndex }, onFilterApplied: onFilterApplied, width: width, height: height })))));
44
+ CategoryVisibilityHandler.enableCategory(IModelApp.viewManager, iModel, disabled, true, true);
45
+ }, [iModel, viewport, filteredProvider]);
46
+ return (React.createElement(React.Fragment, null, iModel && viewport &&
47
+ React.createElement(React.Fragment, null,
48
+ React.createElement(TreeHeaderComponent, { searchOptions: searchOptions, showAll: showAll, hideAll: hideAll, invert: invert }),
49
+ React.createElement(AutoSizer, null, ({ width, height }) => (React.createElement(CategoryTree, { ...props, iModel: iModel, width: width, height: height, filterInfo: { filter: filterString, activeMatchIndex }, onFilterApplied: onFilterApplied }))))));
52
50
  }
53
51
  //# sourceMappingURL=CategoriesTree.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CategoriesTree.js","sourceRoot":"","sources":["../../../../src/components/trees/CategoriesTree.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAErD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACtF,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,uBAAuB,CAAC;AAC/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAQtD,MAAM,UAAU,uBAAuB,CAAC,KAAmC;IACzE,MAAM,EACJ,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,gBAAgB,GACjB,GAAG,qBAAqB,EAAE,CAAC;IAE5B,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IACxC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,CAAC,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AAC,IAAI,CAAC,EAAE,CAAC,CAAC;aAClB;iBAAM;gBACL,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;aACnB;SACF;QACD,kBAAkB;QAClB,yBAAyB,CAAC,cAAc,CACtC,SAAS,CAAC,WAAW,EACrB,KAAK,CAAC,MAAM,EACZ,OAAO,EACP,KAAK,EACL,IAAI,CACL,CAAC;QACF,kBAAkB;QAClB,yBAAyB,CAAC,cAAc,CACtC,SAAS,CAAC,WAAW,EACrB,KAAK,CAAC,MAAM,EACZ,QAAQ,EACR,IAAI,EACJ,IAAI,CACL,CAAC;IACJ,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAErC,OAAO,CACL;QACE,oBAAC,mBAAmB,IAClB,aAAa,EAAE,aAAa,EAC5B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,GACd;QACF,6BAAK,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IACpD,KAAK,IAAI,MAAM,IAAI,CAClB,oBAAC,YAAY,OACP,KAAK,EACT,UAAU,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,gBAAgB,EAAE,EACtD,eAAe,EAAE,eAAe,EAChC,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,GACd,CACH,CACG,CACL,CACJ,CAAC;AACJ,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 React, { useCallback, useState } from \"react\";\nimport type { IModelConnection, Viewport } from \"@itwin/core-frontend\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { CategoryTree, getCategories, toggleAllCategories } from \"@itwin/appui-react\";\nimport { useTreeFilteringState } from \"../TreeFilteringState\";\nimport \"./CategoriesTree.scss\";\nimport { TreeHeaderComponent } from \"../header/TreeHeader\";\nimport { CategoryVisibilityHandler } from \"@itwin/appui-react\";\nimport { useResizeObserver } from \"@itwin/core-react\";\n\nexport interface CategoriesTreeComponentProps {\n iModel: IModelConnection;\n allViewports?: boolean;\n activeView?: Viewport;\n}\n\nexport function CategoriesTreeComponent(props: CategoriesTreeComponentProps) {\n const {\n searchOptions,\n filterString,\n activeMatchIndex,\n onFilterApplied,\n filteredProvider,\n } = useTreeFilteringState();\n\n const [height, setHeight] = useState(0);\n const [width, setWidth] = useState(0);\n const handleResize = useCallback((w: number, h: number) => {\n setHeight(h);\n setWidth(w);\n }, []);\n const ref = useResizeObserver<HTMLDivElement>(handleResize);\n\n const showAll = useCallback(async () => {\n return toggleAllCategories(\n IModelApp.viewManager,\n props.iModel,\n true,\n undefined,\n true,\n filteredProvider\n );\n }, [props.iModel, filteredProvider]);\n\n const hideAll = useCallback(async () => {\n return toggleAllCategories(\n IModelApp.viewManager,\n props.iModel,\n false,\n undefined,\n true,\n filteredProvider\n );\n }, [props.iModel, filteredProvider]);\n\n const invert = useCallback(async () => {\n const activeView = IModelApp.viewManager.getFirstOpenView();\n if (!activeView) {\n return;\n }\n\n const ids = await getCategories(props.iModel, activeView, filteredProvider);\n const enabled: string[] = [];\n const disabled: string[] = [];\n for (const id of ids) {\n if (activeView.view.viewsCategory(id)) {\n enabled.push(id);\n } else {\n disabled.push(id);\n }\n }\n // Disable enabled\n CategoryVisibilityHandler.enableCategory(\n IModelApp.viewManager,\n props.iModel,\n enabled,\n false,\n true\n );\n // Enable disabled\n CategoryVisibilityHandler.enableCategory(\n IModelApp.viewManager,\n props.iModel,\n disabled,\n true,\n true\n );\n }, [props.iModel, filteredProvider]);\n\n return (\n <>\n <TreeHeaderComponent\n searchOptions={searchOptions}\n showAll={showAll}\n hideAll={hideAll}\n invert={invert}\n />\n <div ref={ref} style={{ width: \"100%\", height: \"100%\" }}>\n {width && height && (\n <CategoryTree\n {...props}\n filterInfo={{ filter: filterString, activeMatchIndex }}\n onFilterApplied={onFilterApplied}\n width={width}\n height={height}\n />\n )}\n </div>\n </>\n );\n}\n"]}
1
+ {"version":3,"file":"CategoriesTree.js","sourceRoot":"","sources":["../../../../src/components/trees/CategoriesTree.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACpI,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,uBAAuB,CAAC;AAC/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAE/D,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,MAAM,UAAU,uBAAuB,CAAC,KAA0B;IAChE,MAAM,MAAM,GAAG,yBAAyB,EAAE,CAAC;IAC3C,MAAM,QAAQ,GAAG,iBAAiB,EAAE,CAAC;IAErC,MAAM,EACJ,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,gBAAgB,GACjB,GAAG,qBAAqB,EAAE,CAAC;IAE5B,MAAM,OAAO,GAAG,WAAW,CAAC,KAAK,IAAI,EAAE;QACrC,IAAI,CAAC,MAAM;YAAE,OAAO;QAEpB,OAAO,mBAAmB,CACxB,SAAS,CAAC,WAAW,EACrB,MAAM,EACN,IAAI,EACJ,SAAS,EACT,IAAI,EACJ,gBAAgB,CACjB,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAE/B,MAAM,OAAO,GAAG,WAAW,CAAC,KAAK,IA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SAAS,QACP,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CACtB,oBAAC,YAAY,OACP,KAAK,EACT,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,gBAAgB,EAAE,EACtD,eAAe,EAAE,eAAe,GAChC,CACH,CACS,CACX,CAEJ,CACJ,CAAC;AACJ,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 React, { useCallback } from \"react\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { CategoryTree, getCategories, toggleAllCategories, useActiveIModelConnection, useActiveViewport } from \"@itwin/appui-react\";\nimport { useTreeFilteringState } from \"../TreeFilteringState\";\nimport \"./CategoriesTree.scss\";\nimport { TreeHeaderComponent } from \"../header/TreeHeader\";\nimport { CategoryVisibilityHandler } from \"@itwin/appui-react\";\nimport type { CategoriesTreeProps } from \"../../types\";\nimport { AutoSizer } from \"../utils/AutoSizer\";\n\nexport function CategoriesTreeComponent(props: CategoriesTreeProps) {\n const iModel = useActiveIModelConnection();\n const viewport = useActiveViewport();\n\n const {\n searchOptions,\n filterString,\n activeMatchIndex,\n onFilterApplied,\n filteredProvider,\n } = useTreeFilteringState();\n\n const showAll = useCallback(async () => {\n if (!iModel) return;\n\n return toggleAllCategories(\n IModelApp.viewManager,\n iModel,\n true,\n undefined,\n true,\n filteredProvider\n );\n }, [iModel, filteredProvider]);\n\n const hideAll = useCallback(async () => {\n if (!iModel) return;\n return toggleAllCategories(\n IModelApp.viewManager,\n iModel,\n false,\n undefined,\n true,\n filteredProvider\n );\n }, [iModel, filteredProvider]);\n\n const invert = useCallback(async () => {\n if (!iModel || !viewport) return;\n\n const ids = await getCategories(iModel, viewport, filteredProvider);\n const enabled: string[] = [];\n const disabled: string[] = [];\n for (const id of ids) {\n if (viewport.view.viewsCategory(id)) {\n enabled.push(id);\n } else {\n disabled.push(id);\n }\n }\n // Disable enabled\n CategoryVisibilityHandler.enableCategory(\n IModelApp.viewManager,\n iModel,\n enabled,\n false,\n true\n );\n // Enable disabled\n CategoryVisibilityHandler.enableCategory(\n IModelApp.viewManager,\n iModel,\n disabled,\n true,\n true\n );\n }, [iModel, viewport, filteredProvider]);\n\n return (\n <>\n {iModel && viewport &&\n <>\n <TreeHeaderComponent\n searchOptions={searchOptions}\n showAll={showAll}\n hideAll={hideAll}\n invert={invert}\n />\n <AutoSizer>\n {({ width, height }) => (\n <CategoryTree\n {...props}\n iModel={iModel}\n width={width}\n height={height}\n filterInfo={{ filter: filterString, activeMatchIndex }}\n onFilterApplied={onFilterApplied}\n />\n )}\n </AutoSizer>\n </>\n }\n </>\n );\n}\n"]}
@@ -1,7 +1,4 @@
1
- import React from "react";
2
- import type { IModelConnection } from "@itwin/core-frontend";
3
- export interface IModelContentTreeProps extends Omit<React.AllHTMLAttributes<HTMLDivElement>, "children"> {
4
- iModel: IModelConnection;
5
- }
1
+ /// <reference types="react" />
2
+ import type { IModelContentTreeProps } from "../../types";
6
3
  export declare const IModelContentTree: (props: IModelContentTreeProps) => JSX.Element;
7
4
  //# sourceMappingURL=IModelContentTree.d.ts.map
@@ -2,21 +2,14 @@
2
2
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
- import classNames from "classnames";
6
- import React, { useCallback, useMemo, useState } from "react";
5
+ import React, { useMemo } from "react";
7
6
  import { usePresentationTreeNodeLoader } from "@itwin/presentation-components";
8
7
  import { ControlledTree, SelectionMode, useTreeEventsHandler, useTreeModel } from "@itwin/components-react";
9
8
  import IMODEL_CONTENT_RULESET from "../rulesets/IModelContent.json";
10
- import { useResizeObserver } from "@itwin/core-react";
9
+ import { AutoSizer } from "../utils/AutoSizer";
10
+ import classNames from "classnames";
11
11
  export const IModelContentTree = (props) => {
12
12
  const { iModel, className, ...divProps } = props;
13
- const [height, setHeight] = useState(0);
14
- const [width, setWidth] = useState(0);
15
- const handleResize = useCallback((w, h) => {
16
- setHeight(h);
17
- setWidth(w);
18
- }, []);
19
- const ref = useResizeObserver(handleResize);
20
13
  const { nodeLoader } = usePresentationTreeNodeLoader({
21
14
  imodel: iModel,
22
15
  ruleset: IMODEL_CONTENT_RULESET,
@@ -24,7 +17,8 @@ export const IModelContentTree = (props) => {
24
17
  appendChildrenCountForGroupingNodes: true,
25
18
  });
26
19
  const eventHandler = useTreeEventsHandler(useMemo(() => ({ nodeLoader, modelSource: nodeLoader.modelSource, collapsedChildrenDisposalEnabled: true }), [nodeLoader]));
27
- return (React.createElement("div", { ref: ref, style: { width: "100%", height: "100%" }, ...divProps, className: classNames("imodel-content-tree", className) },
28
- React.createElement(ControlledTree, { width: width, height: height, nodeLoader: nodeLoader, selectionMode: SelectionMode.None, eventsHandler: eventHandler, model: useTreeModel(nodeLoader.modelSource), iconsEnabled: true })));
20
+ const treeModel = useTreeModel(nodeLoader.modelSource);
21
+ return (React.createElement(AutoSizer, null, ({ width, height }) => (React.createElement("div", { ...divProps, className: classNames("imodel-content-tree", className) },
22
+ React.createElement(ControlledTree, { width: width, height: height, nodeLoader: nodeLoader, selectionMode: SelectionMode.None, eventsHandler: eventHandler, model: treeModel, iconsEnabled: true })))));
29
23
  };
30
24
  //# sourceMappingURL=IModelContentTree.js.map