@itwin/tree-widget-react 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/lib/cjs/components/TreeWidgetUiItemsProvider.d.ts +7 -16
  2. package/lib/cjs/components/TreeWidgetUiItemsProvider.js +45 -47
  3. package/lib/cjs/components/TreeWidgetUiItemsProvider.js.map +1 -1
  4. package/lib/cjs/components/trees/CategoriesTree.d.ts +2 -7
  5. package/lib/cjs/components/trees/CategoriesTree.js +21 -23
  6. package/lib/cjs/components/trees/CategoriesTree.js.map +1 -1
  7. package/lib/cjs/components/trees/IModelContentTree.d.ts +2 -5
  8. package/lib/cjs/components/trees/IModelContentTree.js +5 -11
  9. package/lib/cjs/components/trees/IModelContentTree.js.map +1 -1
  10. package/lib/cjs/components/trees/ModelsTree.d.ts +2 -8
  11. package/lib/cjs/components/trees/ModelsTree.js +8 -16
  12. package/lib/cjs/components/trees/ModelsTree.js.map +1 -1
  13. package/lib/cjs/components/trees/SpatialTree.d.ts +2 -2
  14. package/lib/cjs/components/trees/SpatialTree.js +11 -28
  15. package/lib/cjs/components/trees/SpatialTree.js.map +1 -1
  16. package/lib/cjs/components/trees/index.d.ts +0 -2
  17. package/lib/cjs/components/trees/index.js +3 -5
  18. package/lib/cjs/components/trees/index.js.map +1 -1
  19. package/lib/cjs/components/utils/AutoSizer.d.ts +10 -0
  20. package/lib/cjs/components/utils/AutoSizer.js +36 -0
  21. package/lib/cjs/components/utils/AutoSizer.js.map +1 -0
  22. package/lib/cjs/tree-widget-react.d.ts +1 -1
  23. package/lib/cjs/tree-widget-react.js +4 -4
  24. package/lib/cjs/tree-widget-react.js.map +1 -1
  25. package/lib/cjs/types.d.ts +23 -0
  26. package/lib/cjs/types.js +3 -0
  27. package/lib/cjs/types.js.map +1 -0
  28. package/lib/esm/components/TreeWidgetUiItemsProvider.d.ts +7 -16
  29. package/lib/esm/components/TreeWidgetUiItemsProvider.js +45 -47
  30. package/lib/esm/components/TreeWidgetUiItemsProvider.js.map +1 -1
  31. package/lib/esm/components/trees/CategoriesTree.d.ts +2 -7
  32. package/lib/esm/components/trees/CategoriesTree.js +23 -25
  33. package/lib/esm/components/trees/CategoriesTree.js.map +1 -1
  34. package/lib/esm/components/trees/IModelContentTree.d.ts +2 -5
  35. package/lib/esm/components/trees/IModelContentTree.js +6 -12
  36. package/lib/esm/components/trees/IModelContentTree.js.map +1 -1
  37. package/lib/esm/components/trees/ModelsTree.d.ts +2 -8
  38. package/lib/esm/components/trees/ModelsTree.js +9 -17
  39. package/lib/esm/components/trees/ModelsTree.js.map +1 -1
  40. package/lib/esm/components/trees/SpatialTree.d.ts +2 -2
  41. package/lib/esm/components/trees/SpatialTree.js +10 -11
  42. package/lib/esm/components/trees/SpatialTree.js.map +1 -1
  43. package/lib/esm/components/trees/index.d.ts +0 -2
  44. package/lib/esm/components/trees/index.js +3 -5
  45. package/lib/esm/components/trees/index.js.map +1 -1
  46. package/lib/esm/components/utils/AutoSizer.d.ts +10 -0
  47. package/lib/esm/components/utils/AutoSizer.js +13 -0
  48. package/lib/esm/components/utils/AutoSizer.js.map +1 -0
  49. package/lib/esm/tree-widget-react.d.ts +1 -1
  50. package/lib/esm/tree-widget-react.js +4 -4
  51. package/lib/esm/tree-widget-react.js.map +1 -1
  52. package/lib/esm/types.d.ts +23 -0
  53. package/lib/esm/types.js +2 -0
  54. package/lib/esm/types.js.map +1 -0
  55. package/package.json +1 -2
  56. package/lib/cjs/components/TreeWidgetControl.d.ts +0 -26
  57. package/lib/cjs/components/TreeWidgetControl.js +0 -66
  58. package/lib/cjs/components/TreeWidgetControl.js.map +0 -1
  59. package/lib/cjs/components/rulesets/ClassificationSystems.json +0 -122
  60. package/lib/cjs/components/trees/ClassificationsTree.d.ts +0 -7
  61. package/lib/cjs/components/trees/ClassificationsTree.js +0 -43
  62. package/lib/cjs/components/trees/ClassificationsTree.js.map +0 -1
  63. package/lib/cjs/components/trees/TreeWithRuleset.d.ts +0 -35
  64. package/lib/cjs/components/trees/TreeWithRuleset.js +0 -110
  65. package/lib/cjs/components/trees/TreeWithRuleset.js.map +0 -1
  66. package/lib/cjs/components/trees/TreeWithRulesetTree.scss +0 -17
  67. package/lib/esm/components/TreeWidgetControl.d.ts +0 -26
  68. package/lib/esm/components/TreeWidgetControl.js +0 -59
  69. package/lib/esm/components/TreeWidgetControl.js.map +0 -1
  70. package/lib/esm/components/rulesets/ClassificationSystems.json +0 -122
  71. package/lib/esm/components/trees/ClassificationsTree.d.ts +0 -7
  72. package/lib/esm/components/trees/ClassificationsTree.js +0 -17
  73. package/lib/esm/components/trees/ClassificationsTree.js.map +0 -1
  74. package/lib/esm/components/trees/TreeWithRuleset.d.ts +0 -35
  75. package/lib/esm/components/trees/TreeWithRuleset.js +0 -85
  76. package/lib/esm/components/trees/TreeWithRuleset.js.map +0 -1
  77. package/lib/esm/components/trees/TreeWithRulesetTree.scss +0 -17
@@ -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,23 @@
1
+ /// <reference types="react" />
2
+ import type { CategoryTreeProps, ModelsTreeProps, SpatialContainmentTreeProps } from "@itwin/appui-react";
3
+ import type { SelectableContentDefinition } from "@itwin/components-react";
4
+ import type { IModelConnection } from "@itwin/core-frontend";
5
+ export interface IModelContentTreeProps extends Omit<React.AllHTMLAttributes<HTMLDivElement>, "children"> {
6
+ iModel: IModelConnection;
7
+ }
8
+ export declare type ModelTreeProps = Omit<ModelsTreeProps, "iModel" | "activeView" | "width" | "height" | "filterInfo" | "onFilterApplied">;
9
+ export declare type CategoriesTreeProps = Omit<CategoryTreeProps, "iModel" | "activeView" | "width" | "height" | "filterInfo" | "onFilterApplied">;
10
+ export declare type SpatialTreeProps = Omit<SpatialContainmentTreeProps, "iModel" | "width" | "height">;
11
+ export interface TreeWidgetOptions {
12
+ enableElementsClassGrouping?: boolean;
13
+ additionalTrees?: SelectableContentDefinition[];
14
+ modelsTreeProps?: ModelTreeProps;
15
+ categoriesTreeProps?: CategoriesTreeProps;
16
+ spatialTreeProps?: SpatialTreeProps;
17
+ hideTrees?: {
18
+ modelsTree?: boolean;
19
+ categoriesTree?: boolean;
20
+ spatialTree?: boolean;
21
+ };
22
+ }
23
+ //# 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 {\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 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,11 @@
1
1
  import type { AbstractWidgetProps, StagePanelSection, UiItemsProvider } from "@itwin/appui-abstract";
2
- import { StagePanelLocation } from "@itwin/appui-abstract";
3
- import type { TreeWidgetControlOptions } from "./TreeWidgetControl";
2
+ import { AbstractZoneLocation, StagePanelLocation } from "@itwin/appui-abstract";
3
+ import type { TreeWidgetOptions } from "../types";
4
+ export declare const TreeWidgetId = "tree-widget-react:trees";
4
5
  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>;
6
+ private _treeWidgetOptions?;
7
+ readonly id = "TreeWidgetUiItemsProvider";
8
+ constructor(_treeWidgetOptions?: TreeWidgetOptions | undefined);
9
+ provideWidgets(_stageId: string, stageUsage: string, location: StagePanelLocation, section?: StagePanelSection, zoneLocation?: AbstractZoneLocation): ReadonlyArray<AbstractWidgetProps>;
19
10
  }
20
11
  //# sourceMappingURL=TreeWidgetUiItemsProvider.d.ts.map
@@ -1,4 +1,4 @@
1
- import { StagePanelLocation, StageUsage, } from "@itwin/appui-abstract";
1
+ import { AbstractZoneLocation, StagePanelLocation, StageUsage, } from "@itwin/appui-abstract";
2
2
  import { ClassGroupingOption, UiFramework } from "@itwin/appui-react";
3
3
  import React from "react";
4
4
  import { TreeWidgetComponent } from "./TreeWidgetComponent";
@@ -6,64 +6,62 @@ import { CategoriesTreeComponent } from "./trees/CategoriesTree";
6
6
  import { ModelsTreeComponent } from "./trees/ModelsTree";
7
7
  import { SpatialTreeComponent } from "./trees/SpatialTree";
8
8
  import { TreeWidget } from "../TreeWidget";
9
+ export const TreeWidgetId = "tree-widget-react:trees";
9
10
  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;
11
+ constructor(_treeWidgetOptions) {
12
+ this._treeWidgetOptions = _treeWidgetOptions;
13
+ this.id = "TreeWidgetUiItemsProvider";
24
14
  }
25
- provideWidgets(_stageId, stageUsage, location, _section) {
26
- var _a, _b, _c;
15
+ provideWidgets(_stageId, stageUsage, location, section,
16
+ // eslint-disable-next-line deprecation/deprecation
17
+ zoneLocation) {
18
+ var _a, _b, _c, _d, _e, _f, _g;
27
19
  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
- {
20
+ if (
21
+ // eslint-disable-next-line deprecation/deprecation
22
+ (!section && stageUsage === StageUsage.General && zoneLocation === AbstractZoneLocation.CenterRight) ||
23
+ (stageUsage === StageUsage.General && location === StagePanelLocation.Right && UiFramework.uiVersion !== "1")) {
24
+ const trees = [];
25
+ if (!((_b = (_a = this._treeWidgetOptions) === null || _a === void 0 ? void 0 : _a.hideTrees) === null || _b === void 0 ? void 0 : _b.modelsTree)) {
26
+ trees.push({
39
27
  label: TreeWidget.translate("modeltree"),
40
28
  id: "model-tree",
41
- render: this._modelsTreeReplacement
42
- ? this._modelsTreeReplacement
43
- : () => modelsTreeComponent,
44
- },
45
- {
29
+ render: () => {
30
+ var _a, _b;
31
+ return (React.createElement(ModelsTreeComponent, { enableElementsClassGrouping: ((_a = this._treeWidgetOptions) === null || _a === void 0 ? void 0 : _a.enableElementsClassGrouping)
32
+ ? ClassGroupingOption.YesWithCounts
33
+ : ClassGroupingOption.No, ...(_b = this._treeWidgetOptions) === null || _b === void 0 ? void 0 : _b.modelsTreeProps }));
34
+ },
35
+ });
36
+ }
37
+ if (!((_d = (_c = this._treeWidgetOptions) === null || _c === void 0 ? void 0 : _c.hideTrees) === null || _d === void 0 ? void 0 : _d.categoriesTree)) {
38
+ trees.push({
46
39
  label: TreeWidget.translate("categories"),
47
40
  id: "categories-tree",
48
- render: this._categoriesTreeReplacement
49
- ? this._categoriesTreeReplacement
50
- : () => categoriesTreeComponent,
51
- },
52
- {
41
+ render: () => {
42
+ var _a;
43
+ return (React.createElement(CategoriesTreeComponent, { ...(_a = this._treeWidgetOptions) === null || _a === void 0 ? void 0 : _a.categoriesTreeProps }));
44
+ },
45
+ });
46
+ }
47
+ if (!((_f = (_e = this._treeWidgetOptions) === null || _e === void 0 ? void 0 : _e.hideTrees) === null || _f === void 0 ? void 0 : _f.spatialTree)) {
48
+ trees.push({
53
49
  label: TreeWidget.translate("containment"),
54
50
  id: "spatial-containment-tree",
55
- render: this._spatialTreeReplacement
56
- ? this._spatialTreeReplacement
57
- : () => spatialContainmentComponent,
58
- },
59
- ];
60
- if (this._additionalTrees) {
61
- trees.push(...this._additionalTrees);
51
+ render: () => {
52
+ var _a, _b;
53
+ return (React.createElement(SpatialTreeComponent, { enableElementsClassGrouping: ((_a = this._treeWidgetOptions) === null || _a === void 0 ? void 0 : _a.enableElementsClassGrouping)
54
+ ? ClassGroupingOption.YesWithCounts
55
+ : ClassGroupingOption.No, ...(_b = this._treeWidgetOptions) === null || _b === void 0 ? void 0 : _b.spatialTreeProps }));
56
+ },
57
+ });
58
+ }
59
+ if ((_g = this._treeWidgetOptions) === null || _g === void 0 ? void 0 : _g.additionalTrees) {
60
+ trees.push(...this._treeWidgetOptions.additionalTrees);
62
61
  }
63
62
  widgets.push({
64
- id: "tree",
63
+ id: TreeWidgetId,
65
64
  label: TreeWidget.translate("treeview"),
66
- // eslint-disable-next-line react/display-name
67
65
  getWidgetContent: () => React.createElement(TreeWidgetComponent, { trees: trees }),
68
66
  });
69
67
  }
@@ -1 +1 @@
1
- {"version":3,"file":"TreeWidgetUiItemsProvider.js","sourceRoot":"","sources":["../../../src/components/TreeWidgetUiItemsProvider.tsx"],"names":[],"mappings":"AASA,OAAO,EACL,kBAAkB,EACl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G;oBACzB,CAAC,CAAC,mBAAmB,CAAC,EAAE,KAExB,IAAI,CAAC,iBAAiB,GAC1B,CACH,CAAC;YAEF,MAAM,KAAK,GAAkC;gBAC3C;oBACE,KAAK,EAAE,UAAU,CAAC,SAAS,CAAC,WAAW,CAAC;oBACxC,EAAE,EAAE,YAAY;oBAChB,MAAM,EAAE,IAAI,CAAC,sBAAsB;wBACjC,CAAC,CAAC,IAAI,CAAC,sBAAsB;wBAC7B,CAAC,CAAC,GAAG,EAAE,CAAC,mBAAmB;iBAC9B;gBACD;oBACE,KAAK,EAAE,UAAU,CAAC,SAAS,CAAC,YAAY,CAAC;oBACzC,EAAE,EAAE,iBAAiB;oBACrB,MAAM,EAAE,IAAI,CAAC,0BAA0B;wBACrC,CAAC,CAAC,IAAI,CAAC,0BAA0B;wBACjC,CAAC,CAAC,GAAG,EAAE,CAAC,uBAAuB;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,"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MAAA,IAAI,CAAC,kBAAkB,0CAAE,gBAAgB,GAC7C,CACH,CAAA;qBAAA;iBACF,CAAC,CAAC;aACJ;YAED,IAAI,MAAA,IAAI,CAAC,kBAAkB,0CAAE,eAAe,EAAE;gBAC5C,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAAC;aACxD;YAED,OAAO,CAAC,IAAI,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;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*--------------------------------------------------------------------------------------------*/\n/* eslint-disable react/display-name */\nimport type {\n AbstractWidgetProps,\n StagePanelSection,\n UiItemsProvider,\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 if (\n // eslint-disable-next-line deprecation/deprecation\n (!section && stageUsage === StageUsage.General && zoneLocation === AbstractZoneLocation.CenterRight) ||\n (stageUsage === StageUsage.General && location === StagePanelLocation.Right && 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 });\n }\n\n return widgets;\n }\n}\n"]}
@@ -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,CAAC,CAAC;IACtC,MAAM,YAAY,GAAG,WAAW,CAAC,CAAC,CAAS,E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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,IAAI,EAAE;QACrC,IAAI,CAAC,MAAM;YAAE,OAAO;QACpB,OAAO,mBA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AC,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
@@ -1 +1 @@
1
- {"version":3,"file":"IModelContentTree.js","sourceRoot":"","sources":["../../../../src/components/trees/IModelContentTree.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAG9D,OAAO,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,oBA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CAAC;QAC5H,oBAAC,cAAc,IACb,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,aAAa,CAAC,IAAI,EACjC,aAAa,EAAE,YAAY,EAC3B,KAAK,EAAE,YAAY,CAAC,UAAU,CAAC,WAAW,CAAC,EAC3C,YAAY,EAAE,IAAI,GAClB,CACE,CACP,CAAC;AACJ,CAAC,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 classNames from \"classnames\";\nimport React, { useCallback, useMemo, useState } from \"react\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport type { Ruleset } from \"@itwin/presentation-common\";\nimport { usePresentationTreeNodeLoader } from \"@itwin/presentation-components\";\nimport { ControlledTree, SelectionMode, useTreeEventsHandler, useTreeModel } from \"@itwin/components-react\";\nimport IMODEL_CONTENT_RULESET from \"../rulesets/IModelContent.json\";\nimport { useResizeObserver } from \"@itwin/core-react\";\n\nexport interface IModelContentTreeProps extends Omit<React.AllHTMLAttributes<HTMLDivElement>, \"children\"> {\n iModel: IModelConnection;\n}\n\nexport const IModelContentTree = (props: IModelContentTreeProps) => {\n const { iModel, className, ...divProps } = props;\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 { nodeLoader } = usePresentationTreeNodeLoader({\n imodel: iModel,\n ruleset: IMODEL_CONTENT_RULESET as Ruleset,\n pagingSize: 20,\n appendChildrenCountForGroupingNodes: true,\n });\n const eventHandler = useTreeEventsHandler(useMemo(() => ({ nodeLoader, modelSource: nodeLoader.modelSource, collapsedChildrenDisposalEnabled: true }), [nodeLoader]));\n\n return (\n <div ref={ref} style={{ width: \"100%\", height: \"100%\" }} {...divProps} className={classNames(\"imodel-content-tree\", className)}>\n <ControlledTree\n width={width}\n height={height}\n nodeLoader={nodeLoader}\n selectionMode={SelectionMode.None}\n eventsHandler={eventHandler}\n model={useTreeModel(nodeLoader.modelSource)}\n iconsEnabled={true}\n />\n </div>\n );\n};\n"]}
1
+ {"version":3,"file":"IModelContentTree.js","sourceRoot":"","sources":["../../../../src/components/trees/IModelContentTree.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5G,OAAO,sBAAsB,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,UAAU,MAAM,YAAY,CAAC;AAGpC,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,KAA6B,EAAE,EAAE;IACjE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,QAAQ,EAAE,GAAG,KAAK,CAAC;IAEjD,MAAM,EAAE,UAAU,EAAE,GAAG,6BAA6B,CAAC;QACnD,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,sBAAiC;QAC1C,UAAU,EAAE,EAAE;QACd,mCAAmC,EAAE,IAAI;KAC1C,CAAC,CAAC;IACH,MAAM,YAAY,GAAG,oBAAoB,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,CAAC,WAAW,EAAE,gCAAgC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAEtK,MAAM,SAAS,GAAG,YAAY,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IAEvD,OAAO,CACL,oBAAC,SAAS,QACP,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CACtB,gCAAS,QAAQ,EAAE,SAAS,EAAE,UAAU,CAAC,qBAAqB,EAAE,SAAS,CAAC;QACxE,oBAAC,cAAc,IACb,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,aAAa,CAAC,IAAI,EACjC,aAAa,EAAE,YAAY,EAC3B,KAAK,EAAE,SAAS,EAChB,YAAY,EAAE,IAAI,GAClB,CACE,CACP,CACS,CACb,CAAC;AACJ,CAAC,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, { useMemo } from \"react\";\nimport type { Ruleset } from \"@itwin/presentation-common\";\nimport { usePresentationTreeNodeLoader } from \"@itwin/presentation-components\";\nimport { ControlledTree, SelectionMode, useTreeEventsHandler, useTreeModel } from \"@itwin/components-react\";\nimport IMODEL_CONTENT_RULESET from \"../rulesets/IModelContent.json\";\nimport { AutoSizer } from \"../utils/AutoSizer\";\nimport classNames from \"classnames\";\nimport type { IModelContentTreeProps } from \"../../types\";\n\nexport const IModelContentTree = (props: IModelContentTreeProps) => {\n const { iModel, className, ...divProps } = props;\n\n const { nodeLoader } = usePresentationTreeNodeLoader({\n imodel: iModel,\n ruleset: IMODEL_CONTENT_RULESET as Ruleset,\n pagingSize: 20,\n appendChildrenCountForGroupingNodes: true,\n });\n const eventHandler = useTreeEventsHandler(useMemo(() => ({ nodeLoader, modelSource: nodeLoader.modelSource, collapsedChildrenDisposalEnabled: true }), [nodeLoader]));\n\n const treeModel = useTreeModel(nodeLoader.modelSource);\n\n return (\n <AutoSizer>\n {({ width, height }) => (\n <div {...divProps} className={classNames(\"imodel-content-tree\", className)}>\n <ControlledTree\n width={width}\n height={height}\n nodeLoader={nodeLoader}\n selectionMode={SelectionMode.None}\n eventsHandler={eventHandler}\n model={treeModel}\n iconsEnabled={true}\n />\n </div>\n )}\n </AutoSizer>\n );\n};\n"]}
@@ -1,11 +1,5 @@
1
1
  /// <reference types="react" />
2
- import type { IModelConnection, Viewport } from "@itwin/core-frontend";
3
2
  import "./ModelsTree.scss";
4
- export interface ModelTreeProps {
5
- iModel: IModelConnection;
6
- allViewports?: boolean;
7
- activeView?: Viewport;
8
- enableElementsClassGrouping?: boolean;
9
- }
10
- export declare const ModelsTreeComponent: (props: ModelTreeProps) => JSX.Element | null;
3
+ import type { ModelTreeProps } from "../../types";
4
+ export declare const ModelsTreeComponent: (props: ModelTreeProps) => JSX.Element;
11
5
  //# sourceMappingURL=ModelsTree.d.ts.map