@itwin/tree-widget-react 3.6.0 → 3.7.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.
- package/CHANGELOG.md +19 -2
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.d.ts +6 -0
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js +48 -3
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.d.ts +4 -2
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.js +91 -96
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/common/UseIModelAccess.d.ts +18 -0
- package/lib/cjs/tree-widget-react/components/trees/common/UseIModelAccess.js +34 -0
- package/lib/cjs/tree-widget-react/components/trees/common/UseIModelAccess.js.map +1 -0
- package/lib/cjs/tree-widget-react/components/trees/common/Utils.d.ts +0 -14
- package/lib/cjs/tree-widget-react/components/trees/common/Utils.js +1 -16
- package/lib/cjs/tree-widget-react/components/trees/common/Utils.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/common/components/Tree.d.ts +5 -0
- package/lib/cjs/tree-widget-react/components/trees/common/components/Tree.js +16 -9
- package/lib/cjs/tree-widget-react/components/trees/common/components/Tree.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/common/components/VisibilityTree.d.ts +2 -2
- package/lib/cjs/tree-widget-react/components/trees/common/components/VisibilityTree.js +8 -4
- package/lib/cjs/tree-widget-react/components/trees/common/components/VisibilityTree.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.d.ts +3 -0
- package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js +9 -5
- package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.d.ts +6 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js +48 -3
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.d.ts +4 -2
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.js +92 -97
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/UseIModelAccess.d.ts +18 -0
- package/lib/esm/tree-widget-react/components/trees/common/UseIModelAccess.js +30 -0
- package/lib/esm/tree-widget-react/components/trees/common/UseIModelAccess.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/Utils.d.ts +0 -14
- package/lib/esm/tree-widget-react/components/trees/common/Utils.js +0 -14
- package/lib/esm/tree-widget-react/components/trees/common/Utils.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/Tree.d.ts +5 -0
- package/lib/esm/tree-widget-react/components/trees/common/components/Tree.js +15 -9
- package/lib/esm/tree-widget-react/components/trees/common/components/Tree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTree.d.ts +2 -2
- package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTree.js +10 -6
- package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.d.ts +3 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js +9 -5
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js.map +1 -1
- package/package.json +2 -2
|
@@ -2,7 +2,8 @@
|
|
|
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 { BeEvent } from "@itwin/core-bentley";
|
|
5
|
+
import { assert, BeEvent } from "@itwin/core-bentley";
|
|
6
|
+
import { PerModelCategoryVisibility } from "@itwin/core-frontend";
|
|
6
7
|
import { HierarchyNode } from "@itwin/presentation-hierarchies";
|
|
7
8
|
import { enableCategoryDisplay, enableSubCategoryDisplay } from "../../common/CategoriesVisibilityUtils.js";
|
|
8
9
|
import { createVisibilityStatus } from "../../common/Tooltip.js";
|
|
@@ -11,18 +12,24 @@ import { CategoriesTreeNode } from "./CategoriesTreeNode.js";
|
|
|
11
12
|
export class CategoriesVisibilityHandler {
|
|
12
13
|
constructor(props) {
|
|
13
14
|
this.onVisibilityChange = new BeEvent();
|
|
14
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
15
15
|
this.onDisplayStyleChanged = () => {
|
|
16
16
|
this.onVisibilityChangeInternal();
|
|
17
17
|
};
|
|
18
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
19
18
|
this.onViewedCategoriesChanged = () => {
|
|
20
19
|
this.onVisibilityChangeInternal();
|
|
21
20
|
};
|
|
21
|
+
this.onViewedCategoriesPerModelChanged = () => {
|
|
22
|
+
this.onVisibilityChangeInternal();
|
|
23
|
+
};
|
|
24
|
+
this.onViewedModelsChanged = () => {
|
|
25
|
+
this.onVisibilityChangeInternal();
|
|
26
|
+
};
|
|
22
27
|
this._idsCache = props.idsCache;
|
|
23
28
|
this._viewport = props.viewport;
|
|
24
29
|
this._viewport.onDisplayStyleChanged.addListener(this.onDisplayStyleChanged);
|
|
25
30
|
this._viewport.onViewedCategoriesChanged.addListener(this.onViewedCategoriesChanged);
|
|
31
|
+
this._viewport.onViewedCategoriesPerModelChanged.addListener(this.onViewedCategoriesPerModelChanged);
|
|
32
|
+
this._viewport.onViewedModelsChanged.addListener(this.onViewedModelsChanged);
|
|
26
33
|
}
|
|
27
34
|
dispose() {
|
|
28
35
|
this[Symbol.dispose]();
|
|
@@ -30,6 +37,8 @@ export class CategoriesVisibilityHandler {
|
|
|
30
37
|
[Symbol.dispose]() {
|
|
31
38
|
this._viewport.onDisplayStyleChanged.removeListener(this.onDisplayStyleChanged);
|
|
32
39
|
this._viewport.onViewedCategoriesChanged.removeListener(this.onViewedCategoriesChanged);
|
|
40
|
+
this._viewport.onViewedCategoriesPerModelChanged.removeListener(this.onViewedCategoriesPerModelChanged);
|
|
41
|
+
this._viewport.onViewedModelsChanged.removeListener(this.onViewedModelsChanged);
|
|
33
42
|
clearTimeout(this._pendingVisibilityChange);
|
|
34
43
|
}
|
|
35
44
|
/** Returns visibility status of the tree node. */
|
|
@@ -38,7 +47,10 @@ export class CategoriesVisibilityHandler {
|
|
|
38
47
|
return { state: "hidden", isDisabled: true };
|
|
39
48
|
}
|
|
40
49
|
if (CategoriesTreeNode.isSubCategoryNode(node)) {
|
|
41
|
-
|
|
50
|
+
if (!node.extendedData?.categoryId) {
|
|
51
|
+
return { state: "hidden", isDisabled: true };
|
|
52
|
+
}
|
|
53
|
+
return createVisibilityStatus(await this.getSubCategoriesVisibility(CategoriesVisibilityHandler.getInstanceIdsFromHierarchyNode(node), node.extendedData.categoryId));
|
|
42
54
|
}
|
|
43
55
|
if (CategoriesTreeNode.isCategoryNode(node)) {
|
|
44
56
|
return createVisibilityStatus(await this.getCategoriesVisibility(CategoriesVisibilityHandler.getInstanceIdsFromHierarchyNode(node)));
|
|
@@ -53,7 +65,7 @@ export class CategoriesVisibilityHandler {
|
|
|
53
65
|
return;
|
|
54
66
|
}
|
|
55
67
|
if (CategoriesTreeNode.isCategoryNode(node)) {
|
|
56
|
-
return this.changeCategoryVisibility(node, on);
|
|
68
|
+
return this.changeCategoryVisibility(CategoriesVisibilityHandler.getInstanceIdsFromHierarchyNode(node), on);
|
|
57
69
|
}
|
|
58
70
|
if (CategoriesTreeNode.isSubCategoryNode(node)) {
|
|
59
71
|
return this.changeSubCategoryVisibility(node, on);
|
|
@@ -62,135 +74,118 @@ export class CategoriesVisibilityHandler {
|
|
|
62
74
|
return this.changeDefinitionContainerVisibility(node, on);
|
|
63
75
|
}
|
|
64
76
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
77
|
+
async getSubCategoriesVisibility(subCategoryIds, parentCategoryId) {
|
|
78
|
+
let visibility = "unknown";
|
|
79
|
+
const categoryModels = [...(await this._idsCache.getCategoriesElementModels([parentCategoryId])).values()].flat();
|
|
80
|
+
let nonDefaultModelDisplayStatesCount = 0;
|
|
81
|
+
for (const modelId of categoryModels) {
|
|
82
|
+
if (!this._viewport.view.viewsModel(modelId)) {
|
|
83
|
+
if (visibility === "visible") {
|
|
84
|
+
return "partial";
|
|
85
|
+
}
|
|
86
|
+
visibility = "hidden";
|
|
87
|
+
++nonDefaultModelDisplayStatesCount;
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
const override = this._viewport.perModelCategoryVisibility.getOverride(modelId, parentCategoryId);
|
|
91
|
+
if (override === PerModelCategoryVisibility.Override.Show) {
|
|
92
|
+
if (visibility === "hidden") {
|
|
93
|
+
return "partial";
|
|
94
|
+
}
|
|
95
|
+
visibility = "visible";
|
|
96
|
+
++nonDefaultModelDisplayStatesCount;
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
if (override === PerModelCategoryVisibility.Override.Hide) {
|
|
100
|
+
if (visibility === "visible") {
|
|
101
|
+
return "partial";
|
|
102
|
+
}
|
|
103
|
+
visibility = "hidden";
|
|
104
|
+
++nonDefaultModelDisplayStatesCount;
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
69
107
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
return
|
|
108
|
+
if (categoryModels.length > 0 && nonDefaultModelDisplayStatesCount === categoryModels.length) {
|
|
109
|
+
assert(visibility === "visible" || visibility === "hidden");
|
|
110
|
+
return visibility;
|
|
73
111
|
}
|
|
74
112
|
if (!this._viewport.view.viewsCategory(parentCategoryId)) {
|
|
75
|
-
return "hidden";
|
|
113
|
+
return visibility === "visible" ? "partial" : "hidden";
|
|
76
114
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
let hiddenCount = 0;
|
|
80
|
-
for (const subCategoryId of subCategoryIds) {
|
|
81
|
-
const isVisible = this._viewport.isSubCategoryVisible(subCategoryId);
|
|
82
|
-
if (isVisible) {
|
|
83
|
-
++visibleCount;
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
++hiddenCount;
|
|
87
|
-
}
|
|
88
|
-
if (visibleCount > 0 && hiddenCount > 0) {
|
|
115
|
+
if (subCategoryIds.length === 0) {
|
|
116
|
+
if (visibility === "hidden") {
|
|
89
117
|
return "partial";
|
|
90
118
|
}
|
|
119
|
+
return "visible";
|
|
91
120
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const childrenResult = await this._idsCache.getAllContainedCategories(CategoriesVisibilityHandler.getInstanceIdsFromHierarchyNode(node));
|
|
96
|
-
let hiddenCount = 0;
|
|
97
|
-
let visibleCount = 0;
|
|
98
|
-
for (const categoryId of childrenResult) {
|
|
99
|
-
const categoryVisibility = await this.getCategoriesVisibility([categoryId]);
|
|
100
|
-
if (categoryVisibility === "partial") {
|
|
121
|
+
for (const subCategoryId of subCategoryIds) {
|
|
122
|
+
const isSubCategoryVisible = this._viewport.isSubCategoryVisible(subCategoryId);
|
|
123
|
+
if (isSubCategoryVisible && visibility === "hidden") {
|
|
101
124
|
return "partial";
|
|
102
125
|
}
|
|
103
|
-
if (
|
|
104
|
-
++hiddenCount;
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
++visibleCount;
|
|
108
|
-
}
|
|
109
|
-
if (hiddenCount > 0 && visibleCount > 0) {
|
|
126
|
+
if (!isSubCategoryVisible && visibility === "visible") {
|
|
110
127
|
return "partial";
|
|
111
128
|
}
|
|
129
|
+
visibility = isSubCategoryVisible ? "visible" : "hidden";
|
|
112
130
|
}
|
|
113
|
-
|
|
131
|
+
assert(visibility === "visible" || visibility === "hidden");
|
|
132
|
+
return visibility;
|
|
133
|
+
}
|
|
134
|
+
async getDefinitionContainerVisibility(node) {
|
|
135
|
+
const categoryIds = await this._idsCache.getAllContainedCategories(CategoriesVisibilityHandler.getInstanceIdsFromHierarchyNode(node));
|
|
136
|
+
return this.getCategoriesVisibility(categoryIds);
|
|
114
137
|
}
|
|
115
138
|
async getCategoriesVisibility(categoryIds) {
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
return
|
|
119
|
-
}
|
|
120
|
-
let
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
const isVisible = this._viewport.view.viewsCategory(categoryId);
|
|
124
|
-
if (isVisible) {
|
|
125
|
-
++visibleCount;
|
|
126
|
-
}
|
|
127
|
-
else {
|
|
128
|
-
++hiddenCount;
|
|
129
|
-
}
|
|
130
|
-
if (visibleCount > 0 && hiddenCount > 0) {
|
|
139
|
+
const subCategoriesVisibilities = await Promise.all(categoryIds.map(async (categoryId) => {
|
|
140
|
+
const subCategories = await this._idsCache.getSubCategories(categoryId);
|
|
141
|
+
return this.getSubCategoriesVisibility(subCategories, categoryId);
|
|
142
|
+
}));
|
|
143
|
+
let visibility = "unknown";
|
|
144
|
+
for (const subCategoriesVisibility of subCategoriesVisibilities) {
|
|
145
|
+
if (subCategoriesVisibility === "partial") {
|
|
131
146
|
return "partial";
|
|
132
147
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
return "hidden";
|
|
136
|
-
}
|
|
137
|
-
const subCategories = (await Promise.all(categoryIds.map(async (id) => this._idsCache.getSubCategories(id)))).reduce((acc, val) => acc.concat(val), []);
|
|
138
|
-
let visibleSubCategoryCount = 0;
|
|
139
|
-
let hiddenSubCategoryCount = 0;
|
|
140
|
-
for (const subCategory of subCategories) {
|
|
141
|
-
const isVisible = this._viewport.isSubCategoryVisible(subCategory);
|
|
142
|
-
if (isVisible) {
|
|
143
|
-
++visibleSubCategoryCount;
|
|
144
|
-
}
|
|
145
|
-
else {
|
|
146
|
-
++hiddenSubCategoryCount;
|
|
148
|
+
if (subCategoriesVisibility === "hidden" && visibility === "visible") {
|
|
149
|
+
return "partial";
|
|
147
150
|
}
|
|
148
|
-
if (
|
|
151
|
+
if (subCategoriesVisibility === "visible" && visibility === "hidden") {
|
|
149
152
|
return "partial";
|
|
150
153
|
}
|
|
154
|
+
visibility = subCategoriesVisibility;
|
|
151
155
|
}
|
|
152
|
-
|
|
156
|
+
assert(visibility !== "unknown");
|
|
157
|
+
return visibility;
|
|
153
158
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
++showOverrides;
|
|
161
|
-
}
|
|
162
|
-
else {
|
|
163
|
-
++hideOverrides;
|
|
164
|
-
}
|
|
165
|
-
if (showOverrides > 0 && hideOverrides > 0) {
|
|
166
|
-
return "partial";
|
|
167
|
-
}
|
|
168
|
-
}
|
|
159
|
+
async enableCategoriesElementModelsVisibility(categoryIds) {
|
|
160
|
+
const categoriesModelsMap = await this._idsCache.getCategoriesElementModels(categoryIds);
|
|
161
|
+
const modelIds = [...categoriesModelsMap.values()].flat();
|
|
162
|
+
const hiddenModels = modelIds.filter((modelId) => !this._viewport.view.viewsModel(modelId));
|
|
163
|
+
if (hiddenModels.length > 0) {
|
|
164
|
+
this._viewport.changeModelDisplay(hiddenModels, true);
|
|
169
165
|
}
|
|
170
|
-
if (showOverrides === 0 && hideOverrides === 0) {
|
|
171
|
-
return "none";
|
|
172
|
-
}
|
|
173
|
-
return showOverrides > 0 ? "visible" : "hidden";
|
|
174
166
|
}
|
|
175
167
|
async changeSubCategoryVisibility(node, on) {
|
|
176
168
|
const parentCategoryId = node.extendedData?.categoryId;
|
|
177
|
-
// make sure parent category
|
|
169
|
+
// make sure parent category and models are enabled
|
|
178
170
|
if (on && parentCategoryId) {
|
|
179
|
-
await this.changeCategoryState([parentCategoryId], true, false);
|
|
171
|
+
await Promise.all([this.enableCategoriesElementModelsVisibility([parentCategoryId]), this.changeCategoryState([parentCategoryId], true, false)]);
|
|
180
172
|
}
|
|
181
173
|
const subCategoryIds = CategoriesVisibilityHandler.getInstanceIdsFromHierarchyNode(node);
|
|
182
174
|
subCategoryIds.forEach((id) => {
|
|
183
175
|
this.changeSubCategoryState(id, on);
|
|
184
176
|
});
|
|
185
177
|
}
|
|
186
|
-
async changeCategoryVisibility(
|
|
187
|
-
|
|
178
|
+
async changeCategoryVisibility(categoryIds, on) {
|
|
179
|
+
// make sure models are enabled
|
|
180
|
+
if (on) {
|
|
181
|
+
await this.enableCategoriesElementModelsVisibility(categoryIds);
|
|
182
|
+
}
|
|
188
183
|
return this.changeCategoryState(categoryIds, on, on);
|
|
189
184
|
}
|
|
190
185
|
async changeDefinitionContainerVisibility(node, on) {
|
|
191
186
|
const definitionContainerId = CategoriesVisibilityHandler.getInstanceIdsFromHierarchyNode(node);
|
|
192
187
|
const childCategories = await this._idsCache.getAllContainedCategories(definitionContainerId);
|
|
193
|
-
return this.
|
|
188
|
+
return this.changeCategoryVisibility(childCategories, on);
|
|
194
189
|
}
|
|
195
190
|
onVisibilityChangeInternal() {
|
|
196
191
|
if (this._pendingVisibilityChange) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CategoriesVisibilityHandler.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,MAAM,2CAA2C,CAAC;AAC5G,OAAO,EAAE,sBAAsB,EAAE,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C,EAAE,CAAC,CAAC,CAAC;IACR,CAAC;IAEO,MAAM,CAAC,+BAA+B,CAAC,IAAmB;QAChE,OAAO,aAAa,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,0BAA0B,CAAC,EAAE,CAAC;IAC1I,CAAC;IAEO,KAAK,CAAC,mBAAmB,CAAC,GAAa,EAAE,OAAgB,EAAE,sBAA+B;QAChG,MAAM,qBAAqB,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,sBAAsB,CAAC,CAAC;IACpF,CAAC;IAEO,sBAAsB,CAAC,GAAW,EAAE,OAAgB;QAC1D,wBAAwB,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE,OAAO,CAAC,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 { BeEvent } from \"@itwin/core-bentley\";\nimport { HierarchyNode } from \"@itwin/presentation-hierarchies\";\nimport { enableCategoryDisplay, enableSubCategoryDisplay } from \"../../common/CategoriesVisibilityUtils.js\";\nimport { createVisibilityStatus } from \"../../common/Tooltip.js\";\nimport { CategoriesTreeNode } from \"./CategoriesTreeNode.js\";\n\nimport type { Id64Array } from \"@itwin/core-bentley\";\nimport type { Viewport } from \"@itwin/core-frontend\";\nimport type { HierarchyVisibilityHandler, VisibilityStatus } from \"../../common/UseHierarchyVisibility.js\";\nimport type { CategoriesTreeIdsCache } from \"./CategoriesTreeIdsCache.js\";\n\n/** @internal */\nexport interface CategoriesVisibilityHandlerProps {\n viewport: Viewport;\n idsCache: CategoriesTreeIdsCache;\n}\n\n/** @internal */\nexport class CategoriesVisibilityHandler implements HierarchyVisibilityHandler {\n private _pendingVisibilityChange: any;\n private _viewport: Viewport;\n private _idsCache: CategoriesTreeIdsCache;\n\n constructor(props: CategoriesVisibilityHandlerProps) {\n this._idsCache = props.idsCache;\n this._viewport = props.viewport;\n this._viewport.onDisplayStyleChanged.addListener(this.onDisplayStyleChanged);\n this._viewport.onViewedCategoriesChanged.addListener(this.onViewedCategoriesChanged);\n }\n\n public dispose() {\n this[Symbol.dispose]();\n }\n\n public [Symbol.dispose]() {\n this._viewport.onDisplayStyleChanged.removeListener(this.onDisplayStyleChanged);\n this._viewport.onViewedCategoriesChanged.removeListener(this.onViewedCategoriesChanged);\n clearTimeout(this._pendingVisibilityChange);\n }\n\n public onVisibilityChange = new BeEvent();\n\n /** Returns visibility status of the tree node. */\n public async getVisibilityStatus(node: HierarchyNode): Promise<VisibilityStatus> {\n if (!HierarchyNode.isInstancesNode(node)) {\n return { state: \"hidden\", isDisabled: true };\n }\n\n if (CategoriesTreeNode.isSubCategoryNode(node)) {\n return createVisibilityStatus(this.getSubCategoryVisibility(node));\n }\n\n if (CategoriesTreeNode.isCategoryNode(node)) {\n return createVisibilityStatus(await this.getCategoriesVisibility(CategoriesVisibilityHandler.getInstanceIdsFromHierarchyNode(node)));\n }\n\n if (CategoriesTreeNode.isDefinitionContainerNode(node)) {\n return createVisibilityStatus(await this.getDefinitionContainerVisibility(node));\n }\n\n return { state: \"hidden\", isDisabled: true };\n }\n\n public async changeVisibility(node: HierarchyNode, on: boolean) {\n if (!HierarchyNode.isInstancesNode(node)) {\n return;\n }\n\n if (CategoriesTreeNode.isCategoryNode(node)) {\n return this.changeCategoryVisibility(node, on);\n }\n\n if (CategoriesTreeNode.isSubCategoryNode(node)) {\n return this.changeSubCategoryVisibility(node, on);\n }\n\n if (CategoriesTreeNode.isDefinitionContainerNode(node)) {\n return this.changeDefinitionContainerVisibility(node, on);\n }\n }\n\n private getSubCategoryVisibility(node: HierarchyNode): VisibilityStatus[\"state\"] {\n const parentCategoryId = node.extendedData?.categoryId;\n if (!parentCategoryId) {\n return \"hidden\";\n }\n\n const categoryOverrideResult = this.getCategoryVisibilityFromOverrides(parentCategoryId);\n if (categoryOverrideResult === \"hidden\" || categoryOverrideResult === \"visible\") {\n return categoryOverrideResult;\n }\n\n if (!this._viewport.view.viewsCategory(parentCategoryId)) {\n return \"hidden\";\n }\n const subCategoryIds = CategoriesVisibilityHandler.getInstanceIdsFromHierarchyNode(node);\n let visibleCount = 0;\n let hiddenCount = 0;\n for (const subCategoryId of subCategoryIds) {\n const isVisible = this._viewport.isSubCategoryVisible(subCategoryId);\n if (isVisible) {\n ++visibleCount;\n } else {\n ++hiddenCount;\n }\n if (visibleCount > 0 && hiddenCount > 0) {\n return \"partial\";\n }\n }\n return visibleCount > 0 ? \"visible\" : \"hidden\";\n }\n\n private async getDefinitionContainerVisibility(node: HierarchyNode): Promise<VisibilityStatus[\"state\"]> {\n const childrenResult = await this._idsCache.getAllContainedCategories(CategoriesVisibilityHandler.getInstanceIdsFromHierarchyNode(node));\n let hiddenCount = 0;\n let visibleCount = 0;\n for (const categoryId of childrenResult) {\n const categoryVisibility = await this.getCategoriesVisibility([categoryId]);\n if (categoryVisibility === \"partial\") {\n return \"partial\";\n }\n\n if (categoryVisibility === \"hidden\") {\n ++hiddenCount;\n } else {\n ++visibleCount;\n }\n\n if (hiddenCount > 0 && visibleCount > 0) {\n return \"partial\";\n }\n }\n\n return hiddenCount > 0 ? \"hidden\" : \"visible\";\n }\n\n private async getCategoriesVisibility(categoryIds: Id64Array): Promise<VisibilityStatus[\"state\"]> {\n const overrideResult = this.getCategoryVisibilityFromOverrides(categoryIds);\n if (overrideResult !== \"none\") {\n return overrideResult;\n }\n let visibleCount = 0;\n let hiddenCount = 0;\n for (const categoryId of categoryIds) {\n const isVisible = this._viewport.view.viewsCategory(categoryId);\n if (isVisible) {\n ++visibleCount;\n } else {\n ++hiddenCount;\n }\n if (visibleCount > 0 && hiddenCount > 0) {\n return \"partial\";\n }\n }\n\n if (hiddenCount > 0) {\n return \"hidden\";\n }\n\n const subCategories = (await Promise.all(categoryIds.map(async (id) => this._idsCache.getSubCategories(id)))).reduce((acc, val) => acc.concat(val), []);\n let visibleSubCategoryCount = 0;\n let hiddenSubCategoryCount = 0;\n\n for (const subCategory of subCategories) {\n const isVisible = this._viewport.isSubCategoryVisible(subCategory);\n if (isVisible) {\n ++visibleSubCategoryCount;\n } else {\n ++hiddenSubCategoryCount;\n }\n if (hiddenSubCategoryCount > 0 && visibleSubCategoryCount > 0) {\n return \"partial\";\n }\n }\n\n return hiddenSubCategoryCount > 0 ? \"hidden\" : \"visible\";\n }\n\n private getCategoryVisibilityFromOverrides(categoryIds: Id64Array): VisibilityStatus[\"state\"] | \"none\" {\n let showOverrides = 0;\n let hideOverrides = 0;\n\n for (const currentOverride of this._viewport.perModelCategoryVisibility) {\n if (categoryIds.includes(currentOverride.categoryId)) {\n if (currentOverride.visible) {\n ++showOverrides;\n } else {\n ++hideOverrides;\n }\n\n if (showOverrides > 0 && hideOverrides > 0) {\n return \"partial\";\n }\n }\n }\n\n if (showOverrides === 0 && hideOverrides === 0) {\n return \"none\";\n }\n\n return showOverrides > 0 ? \"visible\" : \"hidden\";\n }\n\n private async changeSubCategoryVisibility(node: HierarchyNode, on: boolean) {\n const parentCategoryId = node.extendedData?.categoryId;\n\n // make sure parent category is enabled\n if (on && parentCategoryId) {\n await this.changeCategoryState([parentCategoryId], true, false);\n }\n\n const subCategoryIds = CategoriesVisibilityHandler.getInstanceIdsFromHierarchyNode(node);\n subCategoryIds.forEach((id) => {\n this.changeSubCategoryState(id, on);\n });\n }\n\n private async changeCategoryVisibility(node: HierarchyNode, on: boolean) {\n const categoryIds = CategoriesVisibilityHandler.getInstanceIdsFromHierarchyNode(node);\n return this.changeCategoryState(categoryIds, on, on);\n }\n\n private async changeDefinitionContainerVisibility(node: HierarchyNode, on: boolean) {\n const definitionContainerId = CategoriesVisibilityHandler.getInstanceIdsFromHierarchyNode(node);\n const childCategories = await this._idsCache.getAllContainedCategories(definitionContainerId);\n return this.changeCategoryState(childCategories, on, on);\n }\n\n // eslint-disable-next-line @typescript-eslint/naming-convention\n private onDisplayStyleChanged = () => {\n this.onVisibilityChangeInternal();\n };\n\n // eslint-disable-next-line @typescript-eslint/naming-convention\n private onViewedCategoriesChanged = () => {\n this.onVisibilityChangeInternal();\n };\n\n private onVisibilityChangeInternal() {\n if (this._pendingVisibilityChange) {\n return;\n }\n\n this._pendingVisibilityChange = setTimeout(() => {\n this.onVisibilityChange.raiseEvent();\n this._pendingVisibilityChange = undefined;\n }, 0);\n }\n\n private static getInstanceIdsFromHierarchyNode(node: HierarchyNode) {\n return HierarchyNode.isInstancesNode(node) ? node.key.instanceKeys.map((instanceKey) => instanceKey.id) : /* istanbul ignore next */ [];\n }\n\n private async changeCategoryState(ids: string[], enabled: boolean, enableAllSubCategories: boolean) {\n await enableCategoryDisplay(this._viewport, ids, enabled, enableAllSubCategories);\n }\n\n private changeSubCategoryState(key: string, enabled: boolean) {\n enableSubCategoryDisplay(this._viewport, key, enabled);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CategoriesVisibilityHandler.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,MAAM,2CAA2C,CAAC;AAC5G,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAc7D,gBAAgB;AAChB,MAAM,OAAO,2BAA2B;IAKtC,YAAY,KAAuC;Q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------------------------------------------------------------------------------------\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 { assert, BeEvent } from \"@itwin/core-bentley\";\nimport { PerModelCategoryVisibility } from \"@itwin/core-frontend\";\nimport { HierarchyNode } from \"@itwin/presentation-hierarchies\";\nimport { enableCategoryDisplay, enableSubCategoryDisplay } from \"../../common/CategoriesVisibilityUtils.js\";\nimport { createVisibilityStatus } from \"../../common/Tooltip.js\";\nimport { CategoriesTreeNode } from \"./CategoriesTreeNode.js\";\n\nimport type { Viewport } from \"@itwin/core-frontend\";\nimport type { Visibility } from \"../../common/Tooltip.js\";\nimport type { Id64Array, Id64String } from \"@itwin/core-bentley\";\nimport type { HierarchyVisibilityHandler, VisibilityStatus } from \"../../common/UseHierarchyVisibility.js\";\nimport type { CategoriesTreeIdsCache } from \"./CategoriesTreeIdsCache.js\";\n\n/** @internal */\nexport interface CategoriesVisibilityHandlerProps {\n viewport: Viewport;\n idsCache: CategoriesTreeIdsCache;\n}\n\n/** @internal */\nexport class CategoriesVisibilityHandler implements HierarchyVisibilityHandler {\n private _pendingVisibilityChange: any;\n private _viewport: Viewport;\n private _idsCache: CategoriesTreeIdsCache;\n\n constructor(props: CategoriesVisibilityHandlerProps) {\n this._idsCache = props.idsCache;\n this._viewport = props.viewport;\n this._viewport.onDisplayStyleChanged.addListener(this.onDisplayStyleChanged);\n this._viewport.onViewedCategoriesChanged.addListener(this.onViewedCategoriesChanged);\n this._viewport.onViewedCategoriesPerModelChanged.addListener(this.onViewedCategoriesPerModelChanged);\n this._viewport.onViewedModelsChanged.addListener(this.onViewedModelsChanged);\n }\n\n public dispose() {\n this[Symbol.dispose]();\n }\n\n public [Symbol.dispose]() {\n this._viewport.onDisplayStyleChanged.removeListener(this.onDisplayStyleChanged);\n this._viewport.onViewedCategoriesChanged.removeListener(this.onViewedCategoriesChanged);\n this._viewport.onViewedCategoriesPerModelChanged.removeListener(this.onViewedCategoriesPerModelChanged);\n this._viewport.onViewedModelsChanged.removeListener(this.onViewedModelsChanged);\n clearTimeout(this._pendingVisibilityChange);\n }\n\n public onVisibilityChange = new BeEvent();\n\n /** Returns visibility status of the tree node. */\n public async getVisibilityStatus(node: HierarchyNode): Promise<VisibilityStatus> {\n if (!HierarchyNode.isInstancesNode(node)) {\n return { state: \"hidden\", isDisabled: true };\n }\n\n if (CategoriesTreeNode.isSubCategoryNode(node)) {\n if (!node.extendedData?.categoryId) {\n return { state: \"hidden\", isDisabled: true };\n }\n return createVisibilityStatus(\n await this.getSubCategoriesVisibility(CategoriesVisibilityHandler.getInstanceIdsFromHierarchyNode(node), node.extendedData.categoryId),\n );\n }\n\n if (CategoriesTreeNode.isCategoryNode(node)) {\n return createVisibilityStatus(await this.getCategoriesVisibility(CategoriesVisibilityHandler.getInstanceIdsFromHierarchyNode(node)));\n }\n\n if (CategoriesTreeNode.isDefinitionContainerNode(node)) {\n return createVisibilityStatus(await this.getDefinitionContainerVisibility(node));\n }\n\n return { state: \"hidden\", isDisabled: true };\n }\n\n public async changeVisibility(node: HierarchyNode, on: boolean) {\n if (!HierarchyNode.isInstancesNode(node)) {\n return;\n }\n\n if (CategoriesTreeNode.isCategoryNode(node)) {\n return this.changeCategoryVisibility(CategoriesVisibilityHandler.getInstanceIdsFromHierarchyNode(node), on);\n }\n\n if (CategoriesTreeNode.isSubCategoryNode(node)) {\n return this.changeSubCategoryVisibility(node, on);\n }\n\n if (CategoriesTreeNode.isDefinitionContainerNode(node)) {\n return this.changeDefinitionContainerVisibility(node, on);\n }\n }\n\n private async getSubCategoriesVisibility(subCategoryIds: Id64Array, parentCategoryId: Id64String): Promise<Visibility> {\n let visibility: \"visible\" | \"hidden\" | \"unknown\" = \"unknown\";\n const categoryModels = [...(await this._idsCache.getCategoriesElementModels([parentCategoryId])).values()].flat();\n let nonDefaultModelDisplayStatesCount = 0;\n for (const modelId of categoryModels) {\n if (!this._viewport.view.viewsModel(modelId)) {\n if (visibility === \"visible\") {\n return \"partial\";\n }\n visibility = \"hidden\";\n ++nonDefaultModelDisplayStatesCount;\n continue;\n }\n const override = this._viewport.perModelCategoryVisibility.getOverride(modelId, parentCategoryId);\n if (override === PerModelCategoryVisibility.Override.Show) {\n if (visibility === \"hidden\") {\n return \"partial\";\n }\n visibility = \"visible\";\n ++nonDefaultModelDisplayStatesCount;\n continue;\n }\n if (override === PerModelCategoryVisibility.Override.Hide) {\n if (visibility === \"visible\") {\n return \"partial\";\n }\n visibility = \"hidden\";\n ++nonDefaultModelDisplayStatesCount;\n continue;\n }\n }\n if (categoryModels.length > 0 && nonDefaultModelDisplayStatesCount === categoryModels.length) {\n assert(visibility === \"visible\" || visibility === \"hidden\");\n return visibility;\n }\n\n if (!this._viewport.view.viewsCategory(parentCategoryId)) {\n return visibility === \"visible\" ? \"partial\" : \"hidden\";\n }\n\n if (subCategoryIds.length === 0) {\n if (visibility === \"hidden\") {\n return \"partial\";\n }\n return \"visible\";\n }\n\n for (const subCategoryId of subCategoryIds) {\n const isSubCategoryVisible = this._viewport.isSubCategoryVisible(subCategoryId);\n if (isSubCategoryVisible && visibility === \"hidden\") {\n return \"partial\";\n }\n if (!isSubCategoryVisible && visibility === \"visible\") {\n return \"partial\";\n }\n visibility = isSubCategoryVisible ? \"visible\" : \"hidden\";\n }\n assert(visibility === \"visible\" || visibility === \"hidden\");\n return visibility;\n }\n\n private async getDefinitionContainerVisibility(node: HierarchyNode): Promise<Visibility> {\n const categoryIds = await this._idsCache.getAllContainedCategories(CategoriesVisibilityHandler.getInstanceIdsFromHierarchyNode(node));\n return this.getCategoriesVisibility(categoryIds);\n }\n\n private async getCategoriesVisibility(categoryIds: Id64Array): Promise<Visibility> {\n const subCategoriesVisibilities = await Promise.all(\n categoryIds.map(async (categoryId) => {\n const subCategories = await this._idsCache.getSubCategories(categoryId);\n return this.getSubCategoriesVisibility(subCategories, categoryId);\n }),\n );\n let visibility: \"visible\" | \"hidden\" | \"unknown\" = \"unknown\";\n\n for (const subCategoriesVisibility of subCategoriesVisibilities) {\n if (subCategoriesVisibility === \"partial\") {\n return \"partial\";\n }\n if (subCategoriesVisibility === \"hidden\" && visibility === \"visible\") {\n return \"partial\";\n }\n if (subCategoriesVisibility === \"visible\" && visibility === \"hidden\") {\n return \"partial\";\n }\n visibility = subCategoriesVisibility;\n }\n assert(visibility !== \"unknown\");\n return visibility;\n }\n\n private async enableCategoriesElementModelsVisibility(categoryIds: Id64Array) {\n const categoriesModelsMap = await this._idsCache.getCategoriesElementModels(categoryIds);\n const modelIds = [...categoriesModelsMap.values()].flat();\n const hiddenModels = modelIds.filter((modelId) => !this._viewport.view.viewsModel(modelId));\n if (hiddenModels.length > 0) {\n this._viewport.changeModelDisplay(hiddenModels, true);\n }\n }\n\n private async changeSubCategoryVisibility(node: HierarchyNode, on: boolean) {\n const parentCategoryId = node.extendedData?.categoryId;\n\n // make sure parent category and models are enabled\n if (on && parentCategoryId) {\n await Promise.all([this.enableCategoriesElementModelsVisibility([parentCategoryId]), this.changeCategoryState([parentCategoryId], true, false)]);\n }\n\n const subCategoryIds = CategoriesVisibilityHandler.getInstanceIdsFromHierarchyNode(node);\n subCategoryIds.forEach((id) => {\n this.changeSubCategoryState(id, on);\n });\n }\n private async changeCategoryVisibility(categoryIds: Id64Array, on: boolean) {\n // make sure models are enabled\n if (on) {\n await this.enableCategoriesElementModelsVisibility(categoryIds);\n }\n return this.changeCategoryState(categoryIds, on, on);\n }\n\n private async changeDefinitionContainerVisibility(node: HierarchyNode, on: boolean) {\n const definitionContainerId = CategoriesVisibilityHandler.getInstanceIdsFromHierarchyNode(node);\n const childCategories = await this._idsCache.getAllContainedCategories(definitionContainerId);\n return this.changeCategoryVisibility(childCategories, on);\n }\n\n private onDisplayStyleChanged = () => {\n this.onVisibilityChangeInternal();\n };\n\n private onViewedCategoriesChanged = () => {\n this.onVisibilityChangeInternal();\n };\n\n private onViewedCategoriesPerModelChanged = () => {\n this.onVisibilityChangeInternal();\n };\n\n private onViewedModelsChanged = () => {\n this.onVisibilityChangeInternal();\n };\n\n private onVisibilityChangeInternal() {\n if (this._pendingVisibilityChange) {\n return;\n }\n\n this._pendingVisibilityChange = setTimeout(() => {\n this.onVisibilityChange.raiseEvent();\n this._pendingVisibilityChange = undefined;\n }, 0);\n }\n\n private static getInstanceIdsFromHierarchyNode(node: HierarchyNode) {\n return HierarchyNode.isInstancesNode(node) ? node.key.instanceKeys.map((instanceKey) => instanceKey.id) : /* istanbul ignore next */ [];\n }\n\n private async changeCategoryState(ids: string[], enabled: boolean, enableAllSubCategories: boolean) {\n await enableCategoryDisplay(this._viewport, ids, enabled, enableAllSubCategories);\n }\n\n private changeSubCategoryState(key: string, enabled: boolean) {\n enableSubCategoryDisplay(this._viewport, key, enabled);\n }\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { IModelConnection } from "@itwin/core-frontend";
|
|
2
|
+
import type { SchemaContext } from "@itwin/ecschema-metadata";
|
|
3
|
+
import type { useIModelTree } from "@itwin/presentation-hierarchies-react";
|
|
4
|
+
import type { FunctionProps } from "./Utils.js";
|
|
5
|
+
type IModelAccess = FunctionProps<typeof useIModelTree>["imodelAccess"];
|
|
6
|
+
export interface UseIModelAccessProps {
|
|
7
|
+
imodel: IModelConnection;
|
|
8
|
+
getSchemaContext: (imodel: IModelConnection) => SchemaContext;
|
|
9
|
+
imodelAccess?: IModelAccess;
|
|
10
|
+
hierarchyLevelSizeLimit?: number;
|
|
11
|
+
}
|
|
12
|
+
/** @internal */
|
|
13
|
+
export declare function useIModelAccess({ imodel, getSchemaContext, imodelAccess: providedIModelAccess, hierarchyLevelSizeLimit }: UseIModelAccessProps): {
|
|
14
|
+
imodelAccess: IModelAccess;
|
|
15
|
+
currentHierarchyLevelSizeLimit: number;
|
|
16
|
+
};
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=UseIModelAccess.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
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 { useMemo } from "react";
|
|
6
|
+
import { createECSchemaProvider, createECSqlQueryExecutor } from "@itwin/presentation-core-interop";
|
|
7
|
+
import { createLimitingECSqlQueryExecutor } from "@itwin/presentation-hierarchies";
|
|
8
|
+
import { createCachingECClassHierarchyInspector } from "@itwin/presentation-shared";
|
|
9
|
+
/** @internal */
|
|
10
|
+
export function useIModelAccess({ imodel, getSchemaContext, imodelAccess: providedIModelAccess, hierarchyLevelSizeLimit }) {
|
|
11
|
+
const defaultHierarchyLevelSizeLimit = hierarchyLevelSizeLimit ?? 1000;
|
|
12
|
+
const imodelAccess = useMemo(() => {
|
|
13
|
+
return providedIModelAccess ?? createIModelAccess({ getSchemaContext, imodel, hierarchyLevelSizeLimit: defaultHierarchyLevelSizeLimit });
|
|
14
|
+
}, [providedIModelAccess, getSchemaContext, imodel, defaultHierarchyLevelSizeLimit]);
|
|
15
|
+
return {
|
|
16
|
+
imodelAccess,
|
|
17
|
+
currentHierarchyLevelSizeLimit: defaultHierarchyLevelSizeLimit,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function createIModelAccess({ imodel, getSchemaContext, hierarchyLevelSizeLimit, }) {
|
|
21
|
+
const schemas = getSchemaContext(imodel);
|
|
22
|
+
const schemaProvider = createECSchemaProvider(schemas);
|
|
23
|
+
return {
|
|
24
|
+
imodelKey: imodel.key,
|
|
25
|
+
...schemaProvider,
|
|
26
|
+
...createCachingECClassHierarchyInspector({ schemaProvider, cacheSize: 100 }),
|
|
27
|
+
...createLimitingECSqlQueryExecutor(createECSqlQueryExecutor(imodel), hierarchyLevelSizeLimit),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=UseIModelAccess.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UseIModelAccess.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/common/UseIModelAccess.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AACpG,OAAO,EAAE,gCAAgC,EAAE,MAAM,iCAAiC,CAAC;AACnF,OAAO,EAAE,sCAAsC,EAAE,MAAM,4BAA4B,CAAC;AAgBpF,gBAAgB;AAChB,MAAM,UAAU,eAAe,CAAC,EAAC,MAAM,EAAE,gBAAgB,EAAE,YAAY,EAAE,oBAAoB,EAAE,uBAAuB,EAAuB;IAIzI,MAAM,8BAA8B,GAAG,uBAAuB,IAAI,IAAI,CAAC;IACvE,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,EAAE;QAChC,OAAO,oBAAoB,IAAI,kBAAkB,CAAC,EAAE,gBAAgB,EAAE,MAAM,EAAE,uBAAuB,EAAE,8BAA8B,EAAE,CAAC,CAAC;IAC3I,CAAC,EAAE,CAAC,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,EAAE,8BAA8B,CAAC,CAAC,CAAC;IAErF,OAAO;QACL,YAAY;QACZ,8BAA8B,EAAE,8BAA8B;KAC/D,CAAA;AACL,CAAC;AAED,SAAS,kBAAkB,CAAC,EAC1B,MAAM,EACN,gBAAgB,EAChB,uBAAuB,GAKxB;IACC,MAAM,OAAO,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACzC,MAAM,cAAc,GAAG,sBAAsB,CAAC,OAAO,CAAC,CAAC;IACvD,OAAO;QACL,SAAS,EAAE,MAAM,CAAC,GAAG;QACrB,GAAG,cAAc;QACjB,GAAG,sCAAsC,CAAC,EAAE,cAAc,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC;QAC7E,GAAG,gCAAgC,CAAC,wBAAwB,CAAC,MAAM,CAAC,EAAE,uBAAuB,CAAC;KAC/F,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 *--------------------------------------------------------------------------------------------*/\n\nimport { useMemo } from \"react\";\nimport { createECSchemaProvider, createECSqlQueryExecutor } from \"@itwin/presentation-core-interop\";\nimport { createLimitingECSqlQueryExecutor } from \"@itwin/presentation-hierarchies\";\nimport { createCachingECClassHierarchyInspector } from \"@itwin/presentation-shared\";\n\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport type { SchemaContext } from \"@itwin/ecschema-metadata\";\nimport type { useIModelTree } from \"@itwin/presentation-hierarchies-react\";\nimport type { FunctionProps } from \"./Utils.js\";\n\ntype IModelAccess = FunctionProps<typeof useIModelTree>[\"imodelAccess\"];\n\nexport interface UseIModelAccessProps {\n imodel: IModelConnection;\n getSchemaContext: (imodel: IModelConnection) => SchemaContext;\n imodelAccess?: IModelAccess;\n hierarchyLevelSizeLimit?: number;\n}\n\n/** @internal */\nexport function useIModelAccess({imodel, getSchemaContext, imodelAccess: providedIModelAccess, hierarchyLevelSizeLimit}: UseIModelAccessProps): {\n imodelAccess: IModelAccess;\n currentHierarchyLevelSizeLimit: number;\n} {\n const defaultHierarchyLevelSizeLimit = hierarchyLevelSizeLimit ?? 1000;\n const imodelAccess = useMemo(() => {\n return providedIModelAccess ?? createIModelAccess({ getSchemaContext, imodel, hierarchyLevelSizeLimit: defaultHierarchyLevelSizeLimit });\n }, [providedIModelAccess, getSchemaContext, imodel, defaultHierarchyLevelSizeLimit]);\n\n return {\n imodelAccess,\n currentHierarchyLevelSizeLimit: defaultHierarchyLevelSizeLimit,\n }\n}\n\nfunction createIModelAccess({\n imodel,\n getSchemaContext,\n hierarchyLevelSizeLimit,\n}: {\n imodel: IModelConnection;\n getSchemaContext: (imodel: IModelConnection) => SchemaContext;\n hierarchyLevelSizeLimit: number;\n}) {\n const schemas = getSchemaContext(imodel);\n const schemaProvider = createECSchemaProvider(schemas);\n return {\n imodelKey: imodel.key,\n ...schemaProvider,\n ...createCachingECClassHierarchyInspector({ schemaProvider, cacheSize: 100 }),\n ...createLimitingECSqlQueryExecutor(createECSqlQueryExecutor(imodel), hierarchyLevelSizeLimit),\n };\n}\n"]}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { Id64Array } from "@itwin/core-bentley";
|
|
3
|
-
import type { IModelConnection } from "@itwin/core-frontend";
|
|
4
|
-
import type { SchemaContext } from "@itwin/ecschema-metadata";
|
|
5
3
|
/** @beta */
|
|
6
4
|
export type FunctionProps<THook extends (props: any) => any> = Parameters<THook>[0];
|
|
7
5
|
/** @internal */
|
|
@@ -11,17 +9,5 @@ export declare function parseIdsSelectorResult(selectorResult: any): Id64Array;
|
|
|
11
9
|
/** @internal */
|
|
12
10
|
export declare function pushToMap<TKey, TValue>(targetMap: Map<TKey, Set<TValue>>, key: TKey, value: TValue): void;
|
|
13
11
|
/** @internal */
|
|
14
|
-
export declare function createIModelAccess({ imodel, getSchemaContext }: {
|
|
15
|
-
imodel: IModelConnection;
|
|
16
|
-
getSchemaContext: (imodel: IModelConnection) => SchemaContext;
|
|
17
|
-
}): {
|
|
18
|
-
createQueryReader(query: import("@itwin/presentation-shared").ECSqlQueryDef, config?: (import("@itwin/presentation-shared").ECSqlQueryReaderOptions & {
|
|
19
|
-
limit?: number | "unbounded" | undefined;
|
|
20
|
-
}) | undefined): AsyncIterableIterator<import("@itwin/presentation-shared").ECSqlQueryRow>;
|
|
21
|
-
classDerivesFrom(derivedClassFullName: string, candidateBaseClassFullName: string): boolean | Promise<boolean>;
|
|
22
|
-
getSchema(schemaName: string): Promise<import("@itwin/presentation-shared").EC.Schema | undefined>;
|
|
23
|
-
imodelKey: string;
|
|
24
|
-
};
|
|
25
|
-
/** @internal */
|
|
26
12
|
export declare function useLatest<T>(value: T): import("react").MutableRefObject<T>;
|
|
27
13
|
//# sourceMappingURL=Utils.d.ts.map
|
|
@@ -3,9 +3,6 @@
|
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import { useEffect, useRef } from "react";
|
|
6
|
-
import { createECSchemaProvider, createECSqlQueryExecutor } from "@itwin/presentation-core-interop";
|
|
7
|
-
import { createLimitingECSqlQueryExecutor } from "@itwin/presentation-hierarchies";
|
|
8
|
-
import { createCachingECClassHierarchyInspector } from "@itwin/presentation-shared";
|
|
9
6
|
/** @internal */
|
|
10
7
|
export function createIdsSelector(ids) {
|
|
11
8
|
// Note: `json_array` function only accepts up to 127 arguments and we may have more `ids` than that. As a workaround,
|
|
@@ -37,17 +34,6 @@ export function pushToMap(targetMap, key, value) {
|
|
|
37
34
|
set.add(value);
|
|
38
35
|
}
|
|
39
36
|
/** @internal */
|
|
40
|
-
export function createIModelAccess({ imodel, getSchemaContext }) {
|
|
41
|
-
const schemas = getSchemaContext(imodel);
|
|
42
|
-
const schemaProvider = createECSchemaProvider(schemas);
|
|
43
|
-
return {
|
|
44
|
-
imodelKey: imodel.key,
|
|
45
|
-
...schemaProvider,
|
|
46
|
-
...createCachingECClassHierarchyInspector({ schemaProvider, cacheSize: 100 }),
|
|
47
|
-
...createLimitingECSqlQueryExecutor(createECSqlQueryExecutor(imodel), 1000),
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
/** @internal */
|
|
51
37
|
export function useLatest(value) {
|
|
52
38
|
const ref = useRef(value);
|
|
53
39
|
useEffect(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/common/Utils.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Utils.js","sourceR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IAAI,KAAK,EAAc,CAAC,CAAC;AAClJ,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,SAAS,CAAe,SAAiC,EAAE,GAAS,EAAE,KAAa;IACjG,IAAI,GAAG,GAAG,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC7B,IAAI,CAAC,GAAG,EAAE;QACR,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC;QAChB,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;KACzB;IACD,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACjB,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,SAAS,CAAI,KAAQ;IACnC,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC1B,SAAS,CAAC,GAAG,EAAE;QACb,GAAG,CAAC,OAAO,GAAG,KAAK,CAAC;IACtB,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IACZ,OAAO,GAAG,CAAC;AACb,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 *--------------------------------------------------------------------------------------------*/\n\nimport { useEffect, useRef } from \"react\";\n\nimport type { Id64Array, Id64String } from \"@itwin/core-bentley\";\n\n/** @beta */\nexport type FunctionProps<THook extends (props: any) => any> = Parameters<THook>[0];\n\n/** @internal */\nexport function createIdsSelector(ids: Id64Array): string {\n // Note: `json_array` function only accepts up to 127 arguments and we may have more `ids` than that. As a workaround,\n // we're creating an array of arrays\n const slices = new Array<Id64String[]>();\n for (let sliceStartIndex = 0; sliceStartIndex < ids.length; sliceStartIndex += 127) {\n let sliceEndIndex: number | undefined = sliceStartIndex + 127;\n if (sliceEndIndex > ids.length) {\n sliceEndIndex = undefined;\n }\n slices.push(ids.slice(sliceStartIndex, sliceEndIndex));\n }\n return `json_array(${slices.map((sliceIds) => `json_array(${sliceIds.map((id) => `'${id}'`).join(\",\")})`).join(\",\")})`;\n}\n\n/** @internal */\nexport function parseIdsSelectorResult(selectorResult: any): Id64Array {\n if (!Array.isArray(selectorResult)) {\n return [];\n }\n return selectorResult.reduce((arr, ids: Id64String | Id64String[]) => [...arr, ...(Array.isArray(ids) ? ids : [ids])], new Array<Id64String>());\n}\n\n/** @internal */\nexport function pushToMap<TKey, TValue>(targetMap: Map<TKey, Set<TValue>>, key: TKey, value: TValue) {\n let set = targetMap.get(key);\n if (!set) {\n set = new Set();\n targetMap.set(key, set);\n }\n set.add(value);\n}\n\n/** @internal */\nexport function useLatest<T>(value: T) {\n const ref = useRef(value);\n useEffect(() => {\n ref.current = value;\n }, [value]);\n return ref;\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useSelectionHandler } from "@itwin/presentation-hierarchies-react";
|
|
2
|
+
import type { MarkRequired } from "@itwin/core-bentley";
|
|
2
3
|
import type { FunctionProps } from "../Utils.js";
|
|
3
4
|
import type { ReactNode } from "react";
|
|
4
5
|
import type { IModelConnection } from "@itwin/core-frontend";
|
|
@@ -41,4 +42,8 @@ export type TreeProps = Pick<FunctionProps<typeof useIModelTree>, "getFilteredPa
|
|
|
41
42
|
* @beta
|
|
42
43
|
*/
|
|
43
44
|
export declare function Tree({ getSchemaContext, hierarchyLevelSizeLimit, selectionStorage, imodelAccess: providedIModelAccess, ...props }: TreeProps): JSX.Element;
|
|
45
|
+
/** @internal */
|
|
46
|
+
export declare function TreeBase({ getSchemaContext, ...props }: MarkRequired<TreeProps, "imodelAccess"> & {
|
|
47
|
+
currentHierarchyLevelSizeLimit: number;
|
|
48
|
+
}): JSX.Element;
|
|
44
49
|
//# sourceMappingURL=Tree.d.ts.map
|
|
@@ -3,7 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
4
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
import { useCallback,
|
|
6
|
+
import { useCallback, useState } from "react";
|
|
7
7
|
import { BeEvent } from "@itwin/core-bentley";
|
|
8
8
|
import { Flex, ProgressRadial, Text } from "@itwin/itwinui-react";
|
|
9
9
|
import { SchemaMetadataContextProvider } from "@itwin/presentation-components";
|
|
@@ -11,10 +11,10 @@ import { useIModelUnifiedSelectionTree, useSelectionHandler } from "@itwin/prese
|
|
|
11
11
|
import { TreeWidget } from "../../../../TreeWidget.js";
|
|
12
12
|
import { useHierarchiesLocalization } from "../UseHierarchiesLocalization.js";
|
|
13
13
|
import { useHierarchyLevelFiltering } from "../UseHierarchyFiltering.js";
|
|
14
|
+
import { useIModelAccess } from "../UseIModelAccess.js";
|
|
14
15
|
import { useIModelChangeListener } from "../UseIModelChangeListener.js";
|
|
15
16
|
import { useNodeHighlighting } from "../UseNodeHighlighting.js";
|
|
16
17
|
import { useReportingAction, useTelemetryContext } from "../UseTelemetryContext.js";
|
|
17
|
-
import { createIModelAccess } from "../Utils.js";
|
|
18
18
|
import { Delayed } from "./Delayed.js";
|
|
19
19
|
import { ProgressOverlay } from "./ProgressOverlay.js";
|
|
20
20
|
/**
|
|
@@ -22,13 +22,19 @@ import { ProgressOverlay } from "./ProgressOverlay.js";
|
|
|
22
22
|
* @beta
|
|
23
23
|
*/
|
|
24
24
|
export function Tree({ getSchemaContext, hierarchyLevelSizeLimit, selectionStorage, imodelAccess: providedIModelAccess, ...props }) {
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
const { imodelAccess, currentHierarchyLevelSizeLimit } = useIModelAccess({
|
|
26
|
+
imodel: props.imodel,
|
|
27
|
+
imodelAccess: providedIModelAccess,
|
|
28
|
+
getSchemaContext,
|
|
29
|
+
hierarchyLevelSizeLimit,
|
|
30
|
+
});
|
|
31
|
+
return (_jsx(TreeBase, { ...props, getSchemaContext: getSchemaContext, selectionStorage: selectionStorage, imodelAccess: imodelAccess, currentHierarchyLevelSizeLimit: currentHierarchyLevelSizeLimit }));
|
|
32
|
+
}
|
|
33
|
+
/** @internal */
|
|
34
|
+
export function TreeBase({ getSchemaContext, ...props }) {
|
|
35
|
+
return (_jsx(SchemaMetadataContextProvider, { imodel: props.imodel, schemaContextProvider: getSchemaContext, children: _jsx(TreeBaseImpl, { ...props }) }));
|
|
30
36
|
}
|
|
31
|
-
function
|
|
37
|
+
function TreeBaseImpl({ imodel, imodelAccess, treeName, noDataMessage, getFilteredPaths, currentHierarchyLevelSizeLimit, getHierarchyDefinition, selectionPredicate, selectionMode, onReload, treeRenderer, density, highlight, selectionStorage, }) {
|
|
32
38
|
const localizedStrings = useHierarchiesLocalization();
|
|
33
39
|
const { onFeatureUsed, onPerformanceMeasured } = useTelemetryContext();
|
|
34
40
|
const [imodelChanged] = useState(new BeEvent());
|
|
@@ -62,7 +68,7 @@ function TreeImpl({ imodel, imodelAccess, treeName, noDataMessage, getFilteredPa
|
|
|
62
68
|
const { onNodeClick, onNodeKeyDown } = useSelectionHandler({ rootNodes, selectNodes, selectionMode: selectionMode ?? "single" });
|
|
63
69
|
const { filteringDialog, onFilterClick } = useHierarchyLevelFiltering({
|
|
64
70
|
imodel,
|
|
65
|
-
defaultHierarchyLevelSizeLimit,
|
|
71
|
+
defaultHierarchyLevelSizeLimit: currentHierarchyLevelSizeLimit,
|
|
66
72
|
});
|
|
67
73
|
const reportingExpandNode = useReportingAction({ action: expandNode });
|
|
68
74
|
const reportingOnFilterClicked = useReportingAction({ action: onFilterClick });
|