@itwin/tree-widget-react 0.2.1 → 0.4.1

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 (83) hide show
  1. package/README.md +30 -1
  2. package/lib/cjs/components/TreeWidgetComponent.d.ts +1 -0
  3. package/lib/cjs/components/TreeWidgetUiItemsProvider.d.ts +9 -17
  4. package/lib/cjs/components/TreeWidgetUiItemsProvider.js +50 -47
  5. package/lib/cjs/components/TreeWidgetUiItemsProvider.js.map +1 -1
  6. package/lib/cjs/components/header/TreeHeader.d.ts +1 -0
  7. package/lib/cjs/components/rulesets/IModelContent.json +435 -0
  8. package/lib/cjs/components/trees/CategoriesTree.d.ts +3 -7
  9. package/lib/cjs/components/trees/CategoriesTree.js +21 -23
  10. package/lib/cjs/components/trees/CategoriesTree.js.map +1 -1
  11. package/lib/cjs/components/trees/IModelContentTree.d.ts +4 -0
  12. package/lib/cjs/components/trees/{ClassificationsTree.js → IModelContentTree.js} +19 -12
  13. package/lib/cjs/components/trees/IModelContentTree.js.map +1 -0
  14. package/lib/cjs/components/trees/ModelsTree.d.ts +3 -8
  15. package/lib/cjs/components/trees/ModelsTree.js +8 -16
  16. package/lib/cjs/components/trees/ModelsTree.js.map +1 -1
  17. package/lib/cjs/components/trees/SpatialTree.d.ts +3 -2
  18. package/lib/cjs/components/trees/SpatialTree.js +11 -28
  19. package/lib/cjs/components/trees/SpatialTree.js.map +1 -1
  20. package/lib/cjs/components/trees/index.d.ts +1 -2
  21. package/lib/cjs/components/trees/index.js +5 -6
  22. package/lib/cjs/components/trees/index.js.map +1 -1
  23. package/lib/cjs/components/utils/AutoSizer.d.ts +10 -0
  24. package/lib/cjs/components/utils/AutoSizer.js +36 -0
  25. package/lib/cjs/components/utils/AutoSizer.js.map +1 -0
  26. package/lib/cjs/tree-widget-react.d.ts +1 -1
  27. package/lib/cjs/tree-widget-react.js +4 -4
  28. package/lib/cjs/tree-widget-react.js.map +1 -1
  29. package/lib/cjs/types.d.ts +26 -0
  30. package/lib/cjs/types.js +3 -0
  31. package/lib/cjs/types.js.map +1 -0
  32. package/lib/esm/components/TreeWidgetComponent.d.ts +1 -0
  33. package/lib/esm/components/TreeWidgetUiItemsProvider.d.ts +9 -17
  34. package/lib/esm/components/TreeWidgetUiItemsProvider.js +50 -47
  35. package/lib/esm/components/TreeWidgetUiItemsProvider.js.map +1 -1
  36. package/lib/esm/components/header/TreeHeader.d.ts +1 -0
  37. package/lib/esm/components/rulesets/IModelContent.json +435 -0
  38. package/lib/esm/components/trees/CategoriesTree.d.ts +3 -7
  39. package/lib/esm/components/trees/CategoriesTree.js +23 -25
  40. package/lib/esm/components/trees/CategoriesTree.js.map +1 -1
  41. package/lib/esm/components/trees/IModelContentTree.d.ts +4 -0
  42. package/lib/esm/components/trees/IModelContentTree.js +24 -0
  43. package/lib/esm/components/trees/IModelContentTree.js.map +1 -0
  44. package/lib/esm/components/trees/ModelsTree.d.ts +3 -8
  45. package/lib/esm/components/trees/ModelsTree.js +9 -17
  46. package/lib/esm/components/trees/ModelsTree.js.map +1 -1
  47. package/lib/esm/components/trees/SpatialTree.d.ts +3 -2
  48. package/lib/esm/components/trees/SpatialTree.js +10 -11
  49. package/lib/esm/components/trees/SpatialTree.js.map +1 -1
  50. package/lib/esm/components/trees/index.d.ts +1 -2
  51. package/lib/esm/components/trees/index.js +4 -5
  52. package/lib/esm/components/trees/index.js.map +1 -1
  53. package/lib/esm/components/utils/AutoSizer.d.ts +10 -0
  54. package/lib/esm/components/utils/AutoSizer.js +13 -0
  55. package/lib/esm/components/utils/AutoSizer.js.map +1 -0
  56. package/lib/esm/tree-widget-react.d.ts +1 -1
  57. package/lib/esm/tree-widget-react.js +4 -4
  58. package/lib/esm/tree-widget-react.js.map +1 -1
  59. package/lib/esm/types.d.ts +26 -0
  60. package/lib/esm/types.js +2 -0
  61. package/lib/esm/types.js.map +1 -0
  62. package/package.json +6 -3
  63. package/lib/cjs/components/TreeWidgetControl.d.ts +0 -26
  64. package/lib/cjs/components/TreeWidgetControl.js +0 -66
  65. package/lib/cjs/components/TreeWidgetControl.js.map +0 -1
  66. package/lib/cjs/components/rulesets/ClassificationSystems.json +0 -122
  67. package/lib/cjs/components/trees/ClassificationsTree.d.ts +0 -6
  68. package/lib/cjs/components/trees/ClassificationsTree.js.map +0 -1
  69. package/lib/cjs/components/trees/TreeWithRuleset.d.ts +0 -35
  70. package/lib/cjs/components/trees/TreeWithRuleset.js +0 -110
  71. package/lib/cjs/components/trees/TreeWithRuleset.js.map +0 -1
  72. package/lib/cjs/components/trees/TreeWithRulesetTree.scss +0 -17
  73. package/lib/esm/components/TreeWidgetControl.d.ts +0 -26
  74. package/lib/esm/components/TreeWidgetControl.js +0 -59
  75. package/lib/esm/components/TreeWidgetControl.js.map +0 -1
  76. package/lib/esm/components/rulesets/ClassificationSystems.json +0 -122
  77. package/lib/esm/components/trees/ClassificationsTree.d.ts +0 -6
  78. package/lib/esm/components/trees/ClassificationsTree.js +0 -17
  79. package/lib/esm/components/trees/ClassificationsTree.js.map +0 -1
  80. package/lib/esm/components/trees/TreeWithRuleset.d.ts +0 -35
  81. package/lib/esm/components/trees/TreeWithRuleset.js +0 -85
  82. package/lib/esm/components/trees/TreeWithRuleset.js.map +0 -1
  83. package/lib/esm/components/trees/TreeWithRulesetTree.scss +0 -17
@@ -1,35 +0,0 @@
1
- import React from "react";
2
- import type { Ruleset } from "@itwin/presentation-common";
3
- import type { IPresentationTreeDataProvider } from "@itwin/presentation-components";
4
- import "./TreeWithRulesetTree.scss";
5
- import type { IModelConnection } from "@itwin/core-frontend";
6
- export interface ControlledTreeProps {
7
- iModel: IModelConnection;
8
- dataProvider: IPresentationTreeDataProvider;
9
- rulesetId: string;
10
- pageSize?: number;
11
- }
12
- export interface TreeProps {
13
- imodel: IModelConnection;
14
- ruleSet: Ruleset;
15
- dataProvider: IPresentationTreeDataProvider;
16
- }
17
- export interface TreeState {
18
- initialized: false;
19
- dataProvider?: IPresentationTreeDataProvider;
20
- }
21
- export declare abstract class TreeWithRuleset<T extends TreeProps, S extends TreeState> extends React.Component<T, S> {
22
- private _ruleset?;
23
- /** @internal */
24
- componentDidMount(): Promise<void>;
25
- componentDidUpdate(prevProps: any): Promise<void>;
26
- componentWillUnmount(): void;
27
- private removeRuleset;
28
- private _setRuleSet;
29
- }
30
- export declare class SimpleTreeWithRuleset extends TreeWithRuleset<TreeProps, TreeState> {
31
- constructor(props: TreeProps);
32
- render(): JSX.Element;
33
- }
34
- export declare const ControlledTreeWrapper: React.FC<ControlledTreeProps>;
35
- //# sourceMappingURL=TreeWithRuleset.d.ts.map
@@ -1,110 +0,0 @@
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.ControlledTreeWrapper = exports.SimpleTreeWithRuleset = exports.TreeWithRuleset = void 0;
23
- /*---------------------------------------------------------------------------------------------
24
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
25
- * See LICENSE.md in the project root for license terms and full copyright notice.
26
- *--------------------------------------------------------------------------------------------*/
27
- const react_1 = __importStar(require("react"));
28
- const presentation_components_1 = require("@itwin/presentation-components");
29
- const components_react_1 = require("@itwin/components-react");
30
- const presentation_frontend_1 = require("@itwin/presentation-frontend");
31
- require("./TreeWithRulesetTree.scss");
32
- const core_react_1 = require("@itwin/core-react");
33
- class TreeWithRuleset extends react_1.default.Component {
34
- constructor() {
35
- super(...arguments);
36
- this._setRuleSet = async () => {
37
- return presentation_frontend_1.Presentation.presentation
38
- .rulesets()
39
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
40
- .add(this.props.ruleSet)
41
- .then((ruleset) => {
42
- this._ruleset = ruleset;
43
- const dataProvider = this.props.dataProvider;
44
- this.setState({ dataProvider });
45
- });
46
- };
47
- }
48
- /** @internal */
49
- async componentDidMount() {
50
- await this._setRuleSet();
51
- }
52
- async componentDidUpdate(prevProps) {
53
- if (this.props.ruleSet !== prevProps.ruleSet) {
54
- this.removeRuleset();
55
- await this._setRuleSet();
56
- }
57
- }
58
- componentWillUnmount() {
59
- this.removeRuleset();
60
- }
61
- removeRuleset() {
62
- if (this._ruleset) {
63
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
64
- presentation_frontend_1.Presentation.presentation.rulesets().remove(this._ruleset);
65
- }
66
- }
67
- }
68
- exports.TreeWithRuleset = TreeWithRuleset;
69
- class SimpleTreeWithRuleset extends TreeWithRuleset {
70
- constructor(props) {
71
- super(props);
72
- this.state = {
73
- initialized: false,
74
- };
75
- }
76
- render() {
77
- const dataProvider = this.state
78
- .dataProvider;
79
- if (!dataProvider)
80
- return react_1.default.createElement("div", null);
81
- else {
82
- return (react_1.default.createElement("div", { className: "spatial-tree" },
83
- react_1.default.createElement(exports.ControlledTreeWrapper, { rulesetId: this.props.ruleSet.id, iModel: this.props.imodel, dataProvider: dataProvider, pageSize: dataProvider.pagingSize })));
84
- }
85
- }
86
- }
87
- exports.SimpleTreeWithRuleset = SimpleTreeWithRuleset;
88
- const ControlledTreeWrapper = (props) => {
89
- const { nodeLoader } = presentation_components_1.usePresentationTreeNodeLoader({
90
- imodel: props.iModel,
91
- ruleset: props.rulesetId,
92
- pagingSize: props.pageSize || 20,
93
- });
94
- const modelSource = nodeLoader.modelSource;
95
- const unifiedSelectionEventHandler = presentation_components_1.useUnifiedSelectionTreeEventHandler({
96
- nodeLoader,
97
- collapsedChildrenDisposalEnabled: true,
98
- });
99
- const [height, setHeight] = react_1.useState(0);
100
- const [width, setWidth] = react_1.useState(0);
101
- const handleResize = react_1.useCallback((w, h) => {
102
- setHeight(h);
103
- setWidth(w);
104
- }, []);
105
- const ref = core_react_1.useResizeObserver(handleResize);
106
- const treeModel = components_react_1.useTreeModel(modelSource);
107
- return (react_1.default.createElement("div", { ref: ref, style: { width: "100%", height: "100%" } }, width && height && (react_1.default.createElement(components_react_1.ControlledTree, { model: treeModel, nodeLoader: nodeLoader, eventsHandler: unifiedSelectionEventHandler, selectionMode: components_react_1.SelectionMode.Extended, width: width, height: height }))));
108
- };
109
- exports.ControlledTreeWrapper = ControlledTreeWrapper;
110
- //# sourceMappingURL=TreeWithRuleset.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TreeWithRuleset.js","sourceRoot":"","sources":["../../../../src/components/trees/TreeWithRuleset.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,+CAAqD;AAMrD,4EAGwC;AACxC,8DAIiC;AACjC,wEAA4D;AAC5D,sCAAoC;AAEpC,kDAAsD;AAoBtD,MAAsB,eAGpB,SAAQ,eAAK,CAAC,SAAe;IAH/B;;QA4BU,gBAAW,GAAG,KAAK,IAAI,EAAE;YAC/B,OAAO,oCAAY,CAAC,YAAY;iBAC7B,QAAQ,EAAE;gBACX,mEAAmE;iBAClE,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;iBACvB,IAAI,CAAC,CAAC,OAA0B,EAAE,EAAE;gBACnC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;gBACxB,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC;gBAC7C,IAAI,CAAC,QAAQ,CAAC,EAAE,YAAY,EAA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ChC","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 { RegisteredRuleset, Ruleset } from \"@itwin/presentation-common\";\nimport type {\n IPresentationTreeDataProvider,\n PresentationTreeDataProvider,\n} from \"@itwin/presentation-components\";\nimport {\n usePresentationTreeNodeLoader,\n useUnifiedSelectionTreeEventHandler,\n} from \"@itwin/presentation-components\";\nimport {\n ControlledTree,\n SelectionMode,\n useTreeModel,\n} from \"@itwin/components-react\";\nimport { Presentation } from \"@itwin/presentation-frontend\";\nimport \"./TreeWithRulesetTree.scss\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport { useResizeObserver } from \"@itwin/core-react\";\n\nexport interface ControlledTreeProps {\n iModel: IModelConnection;\n dataProvider: IPresentationTreeDataProvider;\n rulesetId: string;\n pageSize?: number;\n}\n\nexport interface TreeProps {\n imodel: IModelConnection;\n ruleSet: Ruleset;\n dataProvider: IPresentationTreeDataProvider;\n}\n\nexport interface TreeState {\n initialized: false;\n dataProvider?: IPresentationTreeDataProvider;\n}\n\nexport abstract class TreeWithRuleset<\n T extends TreeProps,\n S extends TreeState\n> extends React.Component<T, S> {\n private _ruleset?: RegisteredRuleset;\n /** @internal */\n public async componentDidMount() {\n await this._setRuleSet();\n }\n\n public async componentDidUpdate(prevProps: any) {\n if (this.props.ruleSet !== prevProps.ruleSet) {\n this.removeRuleset();\n await this._setRuleSet();\n }\n }\n\n public componentWillUnmount() {\n this.removeRuleset();\n }\n\n private removeRuleset() {\n if (this._ruleset) {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n Presentation.presentation.rulesets().remove(this._ruleset);\n }\n }\n\n private _setRuleSet = async () => {\n return Presentation.presentation\n .rulesets()\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n .add(this.props.ruleSet)\n .then((ruleset: RegisteredRuleset) => {\n this._ruleset = ruleset;\n const dataProvider = this.props.dataProvider;\n this.setState({ dataProvider });\n });\n };\n}\n\nexport class SimpleTreeWithRuleset extends TreeWithRuleset<\nTreeProps,\nTreeState\n> {\n constructor(props: TreeProps) {\n super(props);\n this.state = {\n initialized: false,\n };\n }\n\n public render() {\n const dataProvider = this.state\n .dataProvider as PresentationTreeDataProvider;\n if (!dataProvider) return <div />;\n else {\n return (\n <div className=\"spatial-tree\">\n <ControlledTreeWrapper\n rulesetId={this.props.ruleSet.id}\n iModel={this.props.imodel}\n dataProvider={dataProvider}\n pageSize={dataProvider.pagingSize}\n />\n </div>\n );\n }\n }\n}\n\nexport const ControlledTreeWrapper: React.FC<ControlledTreeProps> = (\n props: ControlledTreeProps\n) => {\n const { nodeLoader } = usePresentationTreeNodeLoader({\n imodel: props.iModel,\n ruleset: props.rulesetId,\n pagingSize: props.pageSize || 20,\n });\n\n const modelSource = nodeLoader.modelSource;\n const unifiedSelectionEventHandler = useUnifiedSelectionTreeEventHandler({\n nodeLoader,\n collapsedChildrenDisposalEnabled: true,\n });\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 treeModel = useTreeModel(modelSource);\n\n return (\n <div ref={ref} style={{ width: \"100%\", height: \"100%\" }}>\n {width && height && (\n <ControlledTree\n model={treeModel}\n nodeLoader={nodeLoader}\n eventsHandler={unifiedSelectionEventHandler}\n selectionMode={SelectionMode.Extended}\n width={width}\n height={height}\n />\n )}\n </div>\n );\n};\n\n"]}
@@ -1,17 +0,0 @@
1
- /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
- * See LICENSE.md in the project root for license terms and full copyright notice.
4
- *--------------------------------------------------------------------------------------------*/
5
- @import "~@itwin/core-react/lib/cjs/core-react/index";
6
- .spatial-tree {
7
- display: flex;
8
- flex-direction: column;
9
- height: 100%;
10
- }
11
- .components-tree-node-content {
12
- height: $uicore-l;
13
- line-height: $uicore-font-size-small;
14
- display: flex;
15
- flex-direction: column;
16
- justify-content: center;
17
- }
@@ -1,26 +0,0 @@
1
- import type { ConfigurableCreateInfo } from "@itwin/appui-react";
2
- import { WidgetControl } from "@itwin/appui-react";
3
- import React from "react";
4
- import type { IModelConnection, Viewport } from "@itwin/core-frontend";
5
- import type { SelectableContentDefinition } from "@itwin/components-react";
6
- export interface TreeWidgetControlOptions {
7
- iModelConnection: IModelConnection;
8
- activeView?: Viewport;
9
- enableElementsClassGrouping?: boolean;
10
- allViewports?: boolean;
11
- additionalTrees?: SelectableContentDefinition[];
12
- additionalProps?: {
13
- modelsTree?: {};
14
- categoriesTree?: {};
15
- spatialTree?: {};
16
- };
17
- treeReplacements?: {
18
- modelsTree?: () => React.ReactNode;
19
- categoriesTree?: () => React.ReactNode;
20
- spatialTree?: () => React.ReactNode;
21
- };
22
- }
23
- export declare class TreeWidgetControl extends WidgetControl {
24
- constructor(info: ConfigurableCreateInfo, options: TreeWidgetControlOptions);
25
- }
26
- //# sourceMappingURL=TreeWidgetControl.d.ts.map
@@ -1,59 +0,0 @@
1
- /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
- * See LICENSE.md in the project root for license terms and full copyright notice.
4
- *--------------------------------------------------------------------------------------------*/
5
- import { ClassGroupingOption, WidgetControl, } from "@itwin/appui-react";
6
- import React from "react";
7
- import { CategoriesTreeComponent } from "./trees/CategoriesTree";
8
- import { ModelsTreeComponent } from "./trees/ModelsTree";
9
- import { SpatialTreeComponent } from "./trees/SpatialTree";
10
- import { TreeWidgetComponent } from "./TreeWidgetComponent";
11
- import { TreeWidget } from "../TreeWidget";
12
- export class TreeWidgetControl extends WidgetControl {
13
- constructor(info, options) {
14
- var _a, _b, _c, _d, _e, _f;
15
- super(info, options);
16
- const { iModelConnection: imodel, activeView } = options;
17
- const modelsTreeProps = (_a = options.additionalProps) === null || _a === void 0 ? void 0 : _a.modelsTree;
18
- const categoriesTreeProps = (_b = options.additionalProps) === null || _b === void 0 ? void 0 : _b.categoriesTree;
19
- const spatialTreeProps = (_c = options.additionalProps) === null || _c === void 0 ? void 0 : _c.spatialTree;
20
- const enableElementsClassGrouping = options.enableElementsClassGrouping;
21
- const allViewPorts = options.allViewports;
22
- const additionalTrees = options.additionalTrees;
23
- const modelsTreeReplacement = (_d = options.treeReplacements) === null || _d === void 0 ? void 0 : _d.modelsTree;
24
- const categoriesTreeReplacement = (_e = options.treeReplacements) === null || _e === void 0 ? void 0 : _e.categoriesTree;
25
- const spatialTreeReplacement = (_f = options.treeReplacements) === null || _f === void 0 ? void 0 : _f.spatialTree;
26
- const modelsTreeComponent = (React.createElement(ModelsTreeComponent, { iModel: imodel, allViewports: allViewPorts, activeView: activeView, enableElementsClassGrouping: enableElementsClassGrouping, ...modelsTreeProps }));
27
- const categoriesTreeComponent = (React.createElement(CategoriesTreeComponent, { iModel: imodel, allViewports: allViewPorts, activeView: activeView, ...categoriesTreeProps }));
28
- const spatialContainmentComponent = (React.createElement(SpatialTreeComponent, { iModel: imodel, enableElementsClassGrouping: enableElementsClassGrouping
29
- ? ClassGroupingOption.Yes
30
- : ClassGroupingOption.No, ...spatialTreeProps }));
31
- const trees = [
32
- {
33
- label: TreeWidget.translate("modeltree"),
34
- id: "model-tree",
35
- render: modelsTreeReplacement
36
- ? modelsTreeReplacement
37
- : () => modelsTreeComponent,
38
- },
39
- {
40
- label: TreeWidget.translate("categories"),
41
- id: "categories-tree",
42
- render: categoriesTreeReplacement
43
- ? categoriesTreeReplacement
44
- : () => categoriesTreeComponent,
45
- },
46
- {
47
- label: TreeWidget.translate("containment"),
48
- id: "spatial-containment-tree",
49
- render: spatialTreeReplacement
50
- ? spatialTreeReplacement
51
- : () => spatialContainmentComponent,
52
- },
53
- ];
54
- if (additionalTrees)
55
- trees.push(...additionalTrees);
56
- this.reactNode = React.createElement(TreeWidgetComponent, { trees: trees });
57
- }
58
- }
59
- //# sourceMappingURL=TreeWidgetControl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TreeWidgetControl.js","sourceRoot":"","sources":["../../../src/components/TreeWidgetControl.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAG/F,OAAO,EACL,mBAAmB,EACnB,aAAa,GACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAoB3C,MAAM,OAAO,iBAAkB,SAAQ,aAAa;IAClD,YAAY,IAA4B,EAAE,OAAiC;;QACzE,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAErB,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;QACzD,MAAM,eAAe,GAAG,MAAA,OAAO,CAAC,eAAe,0CAAE,UAAU,CAAC;QAC5D,MAAM,mBAAmB,GAAG,MAAA,OAAO,CAAC,eAAe,0CAAE,cAAc,CAAC;QACpE,MAAM,gBAAgB,GAAG,MAAA,OAAO,CAAC,eAAe,0CAAE,WAAW,CAAC;QAC9D,MAAM,2BAA2B,GAAG,OAAO,CAAC,2BAA2B,CAAC;QACxE,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;QAC1C,MAAM,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;QAChD,MAAM,qBAAqB,GAAG,MAAA,OAAO,CAAC,gBAAgB,0CAAE,UAAU,CAAC;QACnE,MAAM,yBAAyB,GAAG,MAAA,OAAO,CAAC,gB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AE,CAAC,2BAA2B;aACtC;SACF,CAAC;QAEF,IAAI,eAAe;YAAE,KAAK,CAAC,IAAI,CAAC,GAAG,eAAe,CAAC,CAAC;QAEpD,IAAI,CAAC,SAAS,GAAG,oBAAC,mBAAmB,IAAC,KAAK,EAAE,KAAK,GAAI,CAAC;IACzD,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\nimport type { ConfigurableCreateInfo } from \"@itwin/appui-react\";\nimport {\n ClassGroupingOption,\n WidgetControl,\n} from \"@itwin/appui-react\";\nimport React from \"react\";\nimport { CategoriesTreeComponent } from \"./trees/CategoriesTree\";\nimport { ModelsTreeComponent } from \"./trees/ModelsTree\";\nimport { SpatialTreeComponent } from \"./trees/SpatialTree\";\nimport type { IModelConnection, Viewport } from \"@itwin/core-frontend\";\nimport { TreeWidgetComponent } from \"./TreeWidgetComponent\";\nimport type { SelectableContentDefinition } from \"@itwin/components-react\";\nimport { TreeWidget } from \"../TreeWidget\";\n\nexport interface TreeWidgetControlOptions {\n iModelConnection: IModelConnection;\n activeView?: Viewport;\n enableElementsClassGrouping?: boolean;\n allViewports?: boolean;\n additionalTrees?: SelectableContentDefinition[];\n additionalProps?: {\n modelsTree?: {};\n categoriesTree?: {};\n spatialTree?: {};\n };\n treeReplacements?: {\n modelsTree?: () => React.ReactNode;\n categoriesTree?: () => React.ReactNode;\n spatialTree?: () => React.ReactNode;\n };\n}\n\nexport class TreeWidgetControl extends WidgetControl {\n constructor(info: ConfigurableCreateInfo, options: TreeWidgetControlOptions) {\n super(info, options);\n\n const { iModelConnection: imodel, activeView } = options;\n const modelsTreeProps = options.additionalProps?.modelsTree;\n const categoriesTreeProps = options.additionalProps?.categoriesTree;\n const spatialTreeProps = options.additionalProps?.spatialTree;\n const enableElementsClassGrouping = options.enableElementsClassGrouping;\n const allViewPorts = options.allViewports;\n const additionalTrees = options.additionalTrees;\n const modelsTreeReplacement = options.treeReplacements?.modelsTree;\n const categoriesTreeReplacement = options.treeReplacements?.categoriesTree;\n const spatialTreeReplacement = options.treeReplacements?.spatialTree;\n\n const modelsTreeComponent = (\n <ModelsTreeComponent\n iModel={imodel}\n allViewports={allViewPorts}\n activeView={activeView}\n enableElementsClassGrouping={enableElementsClassGrouping}\n {...modelsTreeProps}\n />\n );\n\n const categoriesTreeComponent = (\n <CategoriesTreeComponent\n iModel={imodel}\n allViewports={allViewPorts}\n activeView={activeView}\n {...categoriesTreeProps}\n />\n );\n\n const spatialContainmentComponent = (\n <SpatialTreeComponent\n iModel={imodel}\n enableElementsClassGrouping={\n enableElementsClassGrouping\n ? ClassGroupingOption.Yes\n : ClassGroupingOption.No\n }\n {...spatialTreeProps}\n />\n );\n\n const trees: SelectableContentDefinition[] = [\n {\n label: TreeWidget.translate(\"modeltree\"),\n id: \"model-tree\",\n render: modelsTreeReplacement\n ? modelsTreeReplacement\n : () => modelsTreeComponent,\n },\n {\n label: TreeWidget.translate(\"categories\"),\n id: \"categories-tree\",\n render: categoriesTreeReplacement\n ? categoriesTreeReplacement\n : () => categoriesTreeComponent,\n },\n {\n label: TreeWidget.translate(\"containment\"),\n id: \"spatial-containment-tree\",\n render: spatialTreeReplacement\n ? spatialTreeReplacement\n : () => spatialContainmentComponent,\n },\n ];\n\n if (additionalTrees) trees.push(...additionalTrees);\n\n this.reactNode = <TreeWidgetComponent trees={trees} />;\n }\n}\n"]}
@@ -1,122 +0,0 @@
1
- {
2
- "id": "tree-widget-react/ClassificationSystems",
3
- "rules": [
4
- {
5
- "ruleType": "RootNodes",
6
- "specifications": [
7
- {
8
- "specType": "InstanceNodesOfSpecificClasses",
9
- "classes": [
10
- {
11
- "schemaName": "ClassificationSystems",
12
- "classNames": [
13
- "ClassificationSystem"
14
- ]
15
- }
16
- ],
17
- "arePolymorphic": false,
18
- "groupByClass": false,
19
- "groupByLabel": false
20
- }
21
- ]
22
- },
23
- {
24
- "ruleType": "ChildNodes",
25
- "condition": "ParentNode.IsOfClass(\"ClassificationSystem\", \"ClassificationSystems\")",
26
- "specifications": [
27
- {
28
- "specType": "RelatedInstanceNodes",
29
- "relationships": {
30
- "schemaName": "ClassificationSystems",
31
- "classNames": [
32
- "ClassificationSystemOwnsClassificationTable"
33
- ]
34
- },
35
- "relatedClasses": {
36
- "schemaName": "ClassificationSystems",
37
- "classNames": [
38
- "ClassificationTable"
39
- ]
40
- },
41
- "requiredDirection": "Forward",
42
- "groupByClass": false,
43
- "groupByLabel": false,
44
- "doNotSort": true
45
- }
46
- ]
47
- },
48
- {
49
- "ruleType": "ChildNodes",
50
- "condition": "ParentNode.IsOfClass(\"ClassificationTable\", \"ClassificationSystems\")",
51
- "specifications": [
52
- {
53
- "specType": "RelatedInstanceNodes",
54
- "relationships": {
55
- "schemaName": "BisCore",
56
- "classNames": [
57
- "ModelModelsElement"
58
- ]
59
- },
60
- "relatedClasses": {
61
- "schemaName": "BisCore",
62
- "classNames": [
63
- "Model"
64
- ]
65
- },
66
- "requiredDirection": "Backward",
67
- "groupByClass": false,
68
- "groupByLabel": false,
69
- "hideNodesInHierarchy": true
70
- }
71
- ]
72
- },
73
- {
74
- "ruleType": "ChildNodes",
75
- "condition": "ParentNode.IsOfClass(\"Model\", \"BisCore\")",
76
- "specifications": [
77
- {
78
- "specType": "RelatedInstanceNodes",
79
- "relationships": {
80
- "schemaName": "BisCore",
81
- "classNames": [
82
- "ModelContainsElements"
83
- ]
84
- },
85
- "relatedClasses": {
86
- "schemaName": "ClassificationSystems",
87
- "classNames": [
88
- "Classification"
89
- ]
90
- },
91
- "requiredDirection": "Forward",
92
- "groupByClass": false,
93
- "groupByLabel": false
94
- }
95
- ]
96
- },
97
- {
98
- "ruleType": "ChildNodes",
99
- "condition": "ParentNode.IsOfClass(\"Classification\", \"ClassificationSystems\")",
100
- "specifications": [
101
- {
102
- "specType": "RelatedInstanceNodes",
103
- "relationships": {
104
- "schemaName": "ClassificationSystems",
105
- "classNames": [
106
- "ElementHasClassifications"
107
- ]
108
- },
109
- "relatedClasses": {
110
- "schemaName": "BisCore",
111
- "classNames": [
112
- "Element"
113
- ]
114
- },
115
- "requiredDirection": "Backward",
116
- "groupByClass": false,
117
- "groupByLabel": false
118
- }
119
- ]
120
- }
121
- ]
122
- }
@@ -1,6 +0,0 @@
1
- import type { IModelConnection } from "@itwin/core-frontend";
2
- export interface ClassificationsTreeComponentProps {
3
- iModel: IModelConnection;
4
- }
5
- export declare function ClassificationsTreeComponent(props: ClassificationsTreeComponentProps): JSX.Element;
6
- //# sourceMappingURL=ClassificationsTree.d.ts.map
@@ -1,17 +0,0 @@
1
- /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
- * See LICENSE.md in the project root for license terms and full copyright notice.
4
- *--------------------------------------------------------------------------------------------*/
5
- import * as React from "react";
6
- import { SimpleTreeWithRuleset } from "./TreeWithRuleset";
7
- import { PresentationTreeDataProvider } from "@itwin/presentation-components";
8
- import classificationRules from "../rulesets/ClassificationSystems.json";
9
- export function ClassificationsTreeComponent(props) {
10
- const dataProvider = new PresentationTreeDataProvider({
11
- imodel: props.iModel,
12
- ruleset: classificationRules.id,
13
- pagingSize: 20,
14
- });
15
- return (React.createElement(SimpleTreeWithRuleset, { imodel: props.iModel, ruleSet: classificationRules, dataProvider: dataProvider }));
16
- }
17
- //# sourceMappingURL=ClassificationsTree.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ClassificationsTree.js","sourceRoot":"","sources":["../../../../src/components/trees/ClassificationsTree.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,mBAAmB,MAAM,wCAAwC,CAAC;AAMzE,MAAM,UAAU,4BAA4B,CAC1C,KAAwC;IAExC,MAAM,YAAY,GAAG,IAAI,4BAA4B,CAAC;QACpD,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,OAAO,EAAE,mBAAmB,CAAC,EAAE;QAC/B,UAAU,EAAE,EAAE;KACf,CAAC,CAAC;IAEH,OAAO,CACL,oBAAC,qBAAqB,IACpB,MAAM,EAAE,KAAK,CAAC,MAAM,EACpB,OAAO,EAAE,mBAA8B,EACvC,YAAY,EAAE,YAAY,GAC1B,CACH,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 * as React from \"react\";\nimport type { Ruleset } from \"@itwin/presentation-common\";\nimport { SimpleTreeWithRuleset } from \"./TreeWithRuleset\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport { PresentationTreeDataProvider } from \"@itwin/presentation-components\";\nimport classificationRules from \"../rulesets/ClassificationSystems.json\";\n\nexport interface ClassificationsTreeComponentProps {\n iModel: IModelConnection;\n}\n\nexport function ClassificationsTreeComponent(\n props: ClassificationsTreeComponentProps\n) {\n const dataProvider = new PresentationTreeDataProvider({\n imodel: props.iModel,\n ruleset: classificationRules.id,\n pagingSize: 20,\n });\n\n return (\n <SimpleTreeWithRuleset\n imodel={props.iModel}\n ruleSet={classificationRules as Ruleset}\n dataProvider={dataProvider}\n />\n );\n}\n"]}
@@ -1,35 +0,0 @@
1
- import React from "react";
2
- import type { Ruleset } from "@itwin/presentation-common";
3
- import type { IPresentationTreeDataProvider } from "@itwin/presentation-components";
4
- import "./TreeWithRulesetTree.scss";
5
- import type { IModelConnection } from "@itwin/core-frontend";
6
- export interface ControlledTreeProps {
7
- iModel: IModelConnection;
8
- dataProvider: IPresentationTreeDataProvider;
9
- rulesetId: string;
10
- pageSize?: number;
11
- }
12
- export interface TreeProps {
13
- imodel: IModelConnection;
14
- ruleSet: Ruleset;
15
- dataProvider: IPresentationTreeDataProvider;
16
- }
17
- export interface TreeState {
18
- initialized: false;
19
- dataProvider?: IPresentationTreeDataProvider;
20
- }
21
- export declare abstract class TreeWithRuleset<T extends TreeProps, S extends TreeState> extends React.Component<T, S> {
22
- private _ruleset?;
23
- /** @internal */
24
- componentDidMount(): Promise<void>;
25
- componentDidUpdate(prevProps: any): Promise<void>;
26
- componentWillUnmount(): void;
27
- private removeRuleset;
28
- private _setRuleSet;
29
- }
30
- export declare class SimpleTreeWithRuleset extends TreeWithRuleset<TreeProps, TreeState> {
31
- constructor(props: TreeProps);
32
- render(): JSX.Element;
33
- }
34
- export declare const ControlledTreeWrapper: React.FC<ControlledTreeProps>;
35
- //# sourceMappingURL=TreeWithRuleset.d.ts.map
@@ -1,85 +0,0 @@
1
- /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
- * See LICENSE.md in the project root for license terms and full copyright notice.
4
- *--------------------------------------------------------------------------------------------*/
5
- import React, { useCallback, useState } from "react";
6
- import { usePresentationTreeNodeLoader, useUnifiedSelectionTreeEventHandler, } from "@itwin/presentation-components";
7
- import { ControlledTree, SelectionMode, useTreeModel, } from "@itwin/components-react";
8
- import { Presentation } from "@itwin/presentation-frontend";
9
- import "./TreeWithRulesetTree.scss";
10
- import { useResizeObserver } from "@itwin/core-react";
11
- export class TreeWithRuleset extends React.Component {
12
- constructor() {
13
- super(...arguments);
14
- this._setRuleSet = async () => {
15
- return Presentation.presentation
16
- .rulesets()
17
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
18
- .add(this.props.ruleSet)
19
- .then((ruleset) => {
20
- this._ruleset = ruleset;
21
- const dataProvider = this.props.dataProvider;
22
- this.setState({ dataProvider });
23
- });
24
- };
25
- }
26
- /** @internal */
27
- async componentDidMount() {
28
- await this._setRuleSet();
29
- }
30
- async componentDidUpdate(prevProps) {
31
- if (this.props.ruleSet !== prevProps.ruleSet) {
32
- this.removeRuleset();
33
- await this._setRuleSet();
34
- }
35
- }
36
- componentWillUnmount() {
37
- this.removeRuleset();
38
- }
39
- removeRuleset() {
40
- if (this._ruleset) {
41
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
42
- Presentation.presentation.rulesets().remove(this._ruleset);
43
- }
44
- }
45
- }
46
- export class SimpleTreeWithRuleset extends TreeWithRuleset {
47
- constructor(props) {
48
- super(props);
49
- this.state = {
50
- initialized: false,
51
- };
52
- }
53
- render() {
54
- const dataProvider = this.state
55
- .dataProvider;
56
- if (!dataProvider)
57
- return React.createElement("div", null);
58
- else {
59
- return (React.createElement("div", { className: "spatial-tree" },
60
- React.createElement(ControlledTreeWrapper, { rulesetId: this.props.ruleSet.id, iModel: this.props.imodel, dataProvider: dataProvider, pageSize: dataProvider.pagingSize })));
61
- }
62
- }
63
- }
64
- export const ControlledTreeWrapper = (props) => {
65
- const { nodeLoader } = usePresentationTreeNodeLoader({
66
- imodel: props.iModel,
67
- ruleset: props.rulesetId,
68
- pagingSize: props.pageSize || 20,
69
- });
70
- const modelSource = nodeLoader.modelSource;
71
- const unifiedSelectionEventHandler = useUnifiedSelectionTreeEventHandler({
72
- nodeLoader,
73
- collapsedChildrenDisposalEnabled: true,
74
- });
75
- const [height, setHeight] = useState(0);
76
- const [width, setWidth] = useState(0);
77
- const handleResize = useCallback((w, h) => {
78
- setHeight(h);
79
- setWidth(w);
80
- }, []);
81
- const ref = useResizeObserver(handleResize);
82
- const treeModel = useTreeModel(modelSource);
83
- return (React.createElement("div", { ref: ref, style: { width: "100%", height: "100%" } }, width && height && (React.createElement(ControlledTree, { model: treeModel, nodeLoader: nodeLoader, eventsHandler: unifiedSelectionEventHandler, selectionMode: SelectionMode.Extended, width: width, height: height }))));
84
- };
85
- //# sourceMappingURL=TreeWithRuleset.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TreeWithRuleset.js","sourceRoot":"","sources":["../../../../src/components/trees/TreeWithRuleset.tsx"],"names":[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AAC;IACxC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IACtC,MAAM,YAAY,GAAG,WAAW,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,iBAAiB,CAAiB,YAAY,CAAC,CAAC;IAE5D,MAAM,SAAS,GAAG,YAAY,CAAC,WAAW,CAAC,CAAC;IAE5C,OAAO,CACL,6BAAK,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IACpD,KAAK,IAAI,MAAM,IAAI,CAClB,oBAAC,cAAc,IACb,KAAK,EAAE,SAAS,EAChB,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,4BAA4B,EAC3C,aAAa,EAAE,aAAa,CAAC,QAAQ,EACrC,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,GACd,CACH,CACG,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 React, { useCallback, useState } from \"react\";\nimport type { RegisteredRuleset, Ruleset } from \"@itwin/presentation-common\";\nimport type {\n IPresentationTreeDataProvider,\n PresentationTreeDataProvider,\n} from \"@itwin/presentation-components\";\nimport {\n usePresentationTreeNodeLoader,\n useUnifiedSelectionTreeEventHandler,\n} from \"@itwin/presentation-components\";\nimport {\n ControlledTree,\n SelectionMode,\n useTreeModel,\n} from \"@itwin/components-react\";\nimport { Presentation } from \"@itwin/presentation-frontend\";\nimport \"./TreeWithRulesetTree.scss\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport { useResizeObserver } from \"@itwin/core-react\";\n\nexport interface ControlledTreeProps {\n iModel: IModelConnection;\n dataProvider: IPresentationTreeDataProvider;\n rulesetId: string;\n pageSize?: number;\n}\n\nexport interface TreeProps {\n imodel: IModelConnection;\n ruleSet: Ruleset;\n dataProvider: IPresentationTreeDataProvider;\n}\n\nexport interface TreeState {\n initialized: false;\n dataProvider?: IPresentationTreeDataProvider;\n}\n\nexport abstract class TreeWithRuleset<\n T extends TreeProps,\n S extends TreeState\n> extends React.Component<T, S> {\n private _ruleset?: RegisteredRuleset;\n /** @internal */\n public async componentDidMount() {\n await this._setRuleSet();\n }\n\n public async componentDidUpdate(prevProps: any) {\n if (this.props.ruleSet !== prevProps.ruleSet) {\n this.removeRuleset();\n await this._setRuleSet();\n }\n }\n\n public componentWillUnmount() {\n this.removeRuleset();\n }\n\n private removeRuleset() {\n if (this._ruleset) {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n Presentation.presentation.rulesets().remove(this._ruleset);\n }\n }\n\n private _setRuleSet = async () => {\n return Presentation.presentation\n .rulesets()\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n .add(this.props.ruleSet)\n .then((ruleset: RegisteredRuleset) => {\n this._ruleset = ruleset;\n const dataProvider = this.props.dataProvider;\n this.setState({ dataProvider });\n });\n };\n}\n\nexport class SimpleTreeWithRuleset extends TreeWithRuleset<\nTreeProps,\nTreeState\n> {\n constructor(props: TreeProps) {\n super(props);\n this.state = {\n initialized: false,\n };\n }\n\n public render() {\n const dataProvider = this.state\n .dataProvider as PresentationTreeDataProvider;\n if (!dataProvider) return <div />;\n else {\n return (\n <div className=\"spatial-tree\">\n <ControlledTreeWrapper\n rulesetId={this.props.ruleSet.id}\n iModel={this.props.imodel}\n dataProvider={dataProvider}\n pageSize={dataProvider.pagingSize}\n />\n </div>\n );\n }\n }\n}\n\nexport const ControlledTreeWrapper: React.FC<ControlledTreeProps> = (\n props: ControlledTreeProps\n) => {\n const { nodeLoader } = usePresentationTreeNodeLoader({\n imodel: props.iModel,\n ruleset: props.rulesetId,\n pagingSize: props.pageSize || 20,\n });\n\n const modelSource = nodeLoader.modelSource;\n const unifiedSelectionEventHandler = useUnifiedSelectionTreeEventHandler({\n nodeLoader,\n collapsedChildrenDisposalEnabled: true,\n });\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 treeModel = useTreeModel(modelSource);\n\n return (\n <div ref={ref} style={{ width: \"100%\", height: \"100%\" }}>\n {width && height && (\n <ControlledTree\n model={treeModel}\n nodeLoader={nodeLoader}\n eventsHandler={unifiedSelectionEventHandler}\n selectionMode={SelectionMode.Extended}\n width={width}\n height={height}\n />\n )}\n </div>\n );\n};\n\n"]}
@@ -1,17 +0,0 @@
1
- /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
- * See LICENSE.md in the project root for license terms and full copyright notice.
4
- *--------------------------------------------------------------------------------------------*/
5
- @import "~@itwin/core-react/lib/cjs/core-react/index";
6
- .spatial-tree {
7
- display: flex;
8
- flex-direction: column;
9
- height: 100%;
10
- }
11
- .components-tree-node-content {
12
- height: $uicore-l;
13
- line-height: $uicore-font-size-small;
14
- display: flex;
15
- flex-direction: column;
16
- justify-content: center;
17
- }