@itwin/tree-widget-react 4.0.0-alpha.22 → 4.0.0-alpha.24
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/README.md +48 -37
- package/lib/esm/tree-widget-react/components/TreeWidgetComponentImpl.d.ts +1 -1
- package/lib/esm/tree-widget-react/components/TreeWidgetComponentImpl.js +1 -1
- package/lib/esm/tree-widget-react/components/TreeWidgetComponentImpl.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTree.d.ts +3 -3
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTree.js +5 -4
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.js +43 -18
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeComponent.d.ts +2 -2
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeComponent.js +3 -3
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeComponent.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.d.ts +2 -2
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js +14 -13
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.d.ts +6 -5
- package/lib/esm/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js +32 -33
- package/lib/esm/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.d.ts +2 -2
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js +31 -46
- 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/{UseFilteredPaths.d.ts → UseSearchPaths.d.ts} +8 -8
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/{UseFilteredPaths.js → UseSearchPaths.js} +21 -21
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/UseSearchPaths.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/CategoriesTreeVisibilityHandler.d.ts +7 -7
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/CategoriesTreeVisibilityHandler.js +13 -13
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/CategoriesTreeVisibilityHandler.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/CategoriesTreeVisibilityHelper.js +2 -2
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/CategoriesTreeVisibilityHelper.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/{FilteredTree.d.ts → SearchResultsTree.d.ts} +8 -8
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/{FilteredTree.js → SearchResultsTree.js} +62 -62
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/SearchResultsTree.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTree.d.ts +3 -3
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTree.js +5 -4
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeComponent.d.ts +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeComponent.js +2 -2
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeComponent.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeDefinition.d.ts +2 -2
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeDefinition.js +10 -9
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeDefinition.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTree.d.ts +6 -5
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTree.js +30 -29
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTreeDefinition.d.ts +4 -4
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTreeDefinition.js +2 -2
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTreeDefinition.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeIdsCache.d.ts +4 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeIdsCache.js +41 -5
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeIdsCache.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/UseSearchPaths.d.ts +20 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/{UseFilteredPaths.js → UseSearchPaths.js} +19 -19
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/UseSearchPaths.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/ClassificationsTreeVisibilityHandler.d.ts +4 -4
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/ClassificationsTreeVisibilityHandler.js +8 -8
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/ClassificationsTreeVisibilityHandler.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/{FilteredTree.d.ts → SearchResultsTree.d.ts} +9 -9
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/SearchResultsTree.js +168 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/SearchResultsTree.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/TreeErrors.d.ts +2 -2
- package/lib/esm/tree-widget-react/components/trees/common/TreeErrors.js +3 -3
- package/lib/esm/tree-widget-react/components/trees/common/TreeErrors.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/UseHierarchyVisibility.js +14 -4
- package/lib/esm/tree-widget-react/components/trees/common/UseHierarchyVisibility.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/UseTelemetryContext.d.ts +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/UseTelemetryContext.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/Utils.d.ts +3 -3
- package/lib/esm/tree-widget-react/components/trees/common/Utils.js +20 -20
- package/lib/esm/tree-widget-react/components/trees/common/Utils.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/EmptyTree.css +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/EmptyTree.d.ts +6 -6
- package/lib/esm/tree-widget-react/components/trees/common/components/EmptyTree.js +11 -11
- package/lib/esm/tree-widget-react/components/trees/common/components/EmptyTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/ProgressOverlay.js +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/ProgressOverlay.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/Tree.d.ts +9 -3
- package/lib/esm/tree-widget-react/components/trees/common/components/Tree.js +5 -3
- 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/TreeRenderer.d.ts +4 -4
- package/lib/esm/tree-widget-react/components/trees/common/components/TreeRenderer.js +5 -8
- package/lib/esm/tree-widget-react/components/trees/common/components/TreeRenderer.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTreeRenderer.d.ts +4 -3
- package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTreeRenderer.js +5 -8
- package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTreeRenderer.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/AlwaysAndNeverDrawnElementInfo.js +2 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/AlwaysAndNeverDrawnElementInfo.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/ModelCategoryElementsCountCache.js +2 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/ModelCategoryElementsCountCache.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/UseErrorState.d.ts +15 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/UseErrorState.js +37 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/UseErrorState.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/Utils.d.ts +21 -5
- package/lib/esm/tree-widget-react/components/trees/common/internal/Utils.js +24 -8
- package/lib/esm/tree-widget-react/components/trees/common/internal/Utils.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/VisibilityUtils.d.ts +1 -6
- package/lib/esm/tree-widget-react/components/trees/common/internal/VisibilityUtils.js +20 -17
- package/lib/esm/tree-widget-react/components/trees/common/internal/VisibilityUtils.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/useTreeHooks/UseCachedVisibility.d.ts +18 -18
- package/lib/esm/tree-widget-react/components/trees/common/internal/useTreeHooks/UseCachedVisibility.js +32 -32
- package/lib/esm/tree-widget-react/components/trees/common/internal/useTreeHooks/UseCachedVisibility.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/visibility/BaseSearchResultsTree.d.ts +91 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/visibility/BaseSearchResultsTree.js +112 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/visibility/BaseSearchResultsTree.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/visibility/BaseVisibilityHelper.d.ts +6 -10
- package/lib/esm/tree-widget-react/components/trees/common/internal/visibility/BaseVisibilityHelper.js +27 -15
- package/lib/esm/tree-widget-react/components/trees/common/internal/visibility/BaseVisibilityHelper.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.d.ts +3 -3
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.js +5 -2
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeComponent.d.ts +1 -1
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.d.ts +3 -3
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.js +5 -2
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeComponent.d.ts +1 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeComponent.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/internal/IModelContentTreeIdsCache.js +65 -43
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/internal/IModelContentTreeIdsCache.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/index.d.ts +1 -1
- package/lib/esm/tree-widget-react/components/trees/index.js +1 -1
- package/lib/esm/tree-widget-react/components/trees/index.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTree.d.ts +3 -3
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTree.js +6 -5
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.js +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.d.ts +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.js +5 -5
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.d.ts +2 -2
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js +15 -14
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.d.ts +32 -31
- package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.js +32 -31
- package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.d.ts +4 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js +41 -5
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/UseSearchPaths.d.ts +41 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/{UseFilteredPaths.js → UseSearchPaths.js} +47 -47
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/UseSearchPaths.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/ModelsTreeVisibilityHandler.d.ts +7 -7
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/ModelsTreeVisibilityHandler.js +13 -13
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/ModelsTreeVisibilityHandler.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/{FilteredTree.d.ts → SearchResultsTree.d.ts} +8 -8
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/{FilteredTree.js → SearchResultsTree.js} +43 -43
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/SearchResultsTree.js.map +1 -0
- package/lib/public/locales/en/TreeWidget.json +13 -13
- package/package.json +7 -7
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/UseFilteredPaths.js.map +0 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/FilteredTree.js.map +0 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/UseFilteredPaths.d.ts +0 -20
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/UseFilteredPaths.js.map +0 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/FilteredTree.js +0 -168
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/FilteredTree.js.map +0 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/visibility/BaseFilteredTree.d.ts +0 -91
- package/lib/esm/tree-widget-react/components/trees/common/internal/visibility/BaseFilteredTree.js +0 -112
- package/lib/esm/tree-widget-react/components/trees/common/internal/visibility/BaseFilteredTree.js.map +0 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/UseFilteredPaths.d.ts +0 -41
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/UseFilteredPaths.js.map +0 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/FilteredTree.js.map +0 -1
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import { assert, Guid } from "@itwin/core-bentley";
|
|
6
6
|
import { CLASS_NAME_GeometricElement2d, CLASS_NAME_GeometricElement3d, CLASS_NAME_InformationPartitionElement, CLASS_NAME_Model, CLASS_NAME_Subject, } from "../../common/internal/ClassNameDefinitions.js";
|
|
7
|
+
import { isBeSqliteInterruptError } from "../../common/internal/UseErrorState.js";
|
|
7
8
|
import { pushToMap } from "../../common/internal/Utils.js";
|
|
8
9
|
/** @internal */
|
|
9
10
|
export class IModelContentTreeIdsCache {
|
|
@@ -19,39 +20,53 @@ export class IModelContentTreeIdsCache {
|
|
|
19
20
|
this.#componentName = "IModelContentTreeIdsCache";
|
|
20
21
|
}
|
|
21
22
|
async *querySubjects() {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
23
|
+
try {
|
|
24
|
+
const subjectsQuery = `
|
|
25
|
+
SELECT
|
|
26
|
+
s.ECInstanceId id,
|
|
27
|
+
s.Parent.Id parentId,
|
|
28
|
+
(
|
|
29
|
+
SELECT m.ECInstanceId
|
|
30
|
+
FROM ${CLASS_NAME_Model} m
|
|
31
|
+
WHERE
|
|
32
|
+
m.ECInstanceId = HexToId(json_extract(s.JsonProperties, '$.Subject.Model.TargetPartition'))
|
|
33
|
+
AND NOT m.IsPrivate
|
|
34
|
+
) targetPartitionId,
|
|
35
|
+
CASE
|
|
36
|
+
WHEN (
|
|
37
|
+
json_extract(s.JsonProperties, '$.Subject.Job.Bridge') IS NOT NULL
|
|
38
|
+
OR json_extract(s.JsonProperties, '$.Subject.Model.Type') = 'Hierarchy'
|
|
39
|
+
) THEN 1
|
|
40
|
+
ELSE 0
|
|
41
|
+
END hideInHierarchy
|
|
42
|
+
FROM ${CLASS_NAME_Subject} s
|
|
43
|
+
`;
|
|
44
|
+
for await (const row of this.#queryExecutor.createQueryReader({ ecsql: subjectsQuery }, { rowFormat: "ECSqlPropertyNames", limit: "unbounded", restartToken: `${this.#componentName}/${this.#componentId}/subjects` })) {
|
|
45
|
+
yield { id: row.id, parentId: row.parentId, targetPartitionId: row.targetPartitionId, hideInHierarchy: !!row.hideInHierarchy };
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
if (!isBeSqliteInterruptError(error)) {
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
44
52
|
}
|
|
45
53
|
}
|
|
46
54
|
async *queryModels() {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
try {
|
|
56
|
+
const modelsQuery = `
|
|
57
|
+
SELECT p.ECInstanceId id, p.Parent.Id parentId
|
|
58
|
+
FROM ${CLASS_NAME_InformationPartitionElement} p
|
|
59
|
+
INNER JOIN ${CLASS_NAME_Model} m ON m.ModeledElement.Id = p.ECInstanceId
|
|
60
|
+
WHERE NOT m.IsPrivate
|
|
61
|
+
`;
|
|
62
|
+
for await (const row of this.#queryExecutor.createQueryReader({ ecsql: modelsQuery }, { rowFormat: "ECSqlPropertyNames", limit: "unbounded", restartToken: `${this.#componentName}/${this.#componentId}/models` })) {
|
|
63
|
+
yield { id: row.id, parentId: row.parentId };
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
if (!isBeSqliteInterruptError(error)) {
|
|
68
|
+
throw error;
|
|
69
|
+
}
|
|
55
70
|
}
|
|
56
71
|
}
|
|
57
72
|
async getSubjectInfos() {
|
|
@@ -158,19 +173,26 @@ export class IModelContentTreeIdsCache {
|
|
|
158
173
|
return modelIds;
|
|
159
174
|
}
|
|
160
175
|
async *queryModelCategories() {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
176
|
+
try {
|
|
177
|
+
const query = `
|
|
178
|
+
SELECT Model.Id modelId, Category.Id categoryId
|
|
179
|
+
FROM ${CLASS_NAME_GeometricElement3d}
|
|
180
|
+
WHERE Parent.Id IS NULL
|
|
181
|
+
GROUP BY Model.Id, Category.Id
|
|
182
|
+
UNION ALL
|
|
183
|
+
SELECT Model.Id modelId, Category.Id categoryId
|
|
184
|
+
FROM ${CLASS_NAME_GeometricElement2d}
|
|
185
|
+
WHERE Parent.Id IS NULL
|
|
186
|
+
GROUP BY Model.Id, Category.Id
|
|
187
|
+
`;
|
|
188
|
+
for await (const row of this.#queryExecutor.createQueryReader({ ecsql: query }, { rowFormat: "ECSqlPropertyNames", limit: "unbounded", restartToken: `${this.#componentName}/${this.#componentId}/model-categories` })) {
|
|
189
|
+
yield { modelId: row.modelId, categoryId: row.categoryId };
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
catch (error) {
|
|
193
|
+
if (!isBeSqliteInterruptError(error)) {
|
|
194
|
+
throw error;
|
|
195
|
+
}
|
|
174
196
|
}
|
|
175
197
|
}
|
|
176
198
|
async getModelInfos() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelContentTreeIdsCache.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/imodel-content-tree/internal/IModelContentTreeIdsCache.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EACL,6BAA6B,EAC7B,6BAA6B,EAC7B,sCAAsC,EACtC,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,+CAA+C,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAiB3D,gBAAgB;AAChB,MAAM,OAAO,yBAAyB;IACpC,aAAa,CAAmD;IAChE,iBAAiB,CAAiC,CAAC,sFAAsF;IACzI,WAAW,CAA+C;IAC1D,cAAc,CAA6B;IAC3C,YAAY,CAAa;IACzB,cAAc,CAAS;IAEvB,YAAY,aAAy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OAAO,EAAE,CAAC;gBACrD,OAAO;YACT,CAAC;YACD,mBAAmB,CAAC,YAAY,EAAE,gBAAgB,EAAE,EAAE,CAAC,CAAC;QAC1D,CAAC,CAAC,CAAC;AACP,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 { assert, Guid } from \"@itwin/core-bentley\";\nimport {\n CLASS_NAME_GeometricElement2d,\n CLASS_NAME_GeometricElement3d,\n CLASS_NAME_InformationPartitionElement,\n CLASS_NAME_Model,\n CLASS_NAME_Subject,\n} from \"../../common/internal/ClassNameDefinitions.js\";\nimport { pushToMap } from \"../../common/internal/Utils.js\";\n\nimport type { GuidString, Id64Array, Id64Set, Id64String } from \"@itwin/core-bentley\";\nimport type { LimitingECSqlQueryExecutor } from \"@itwin/presentation-hierarchies\";\nimport type { ModelId, SubjectId } from \"../../common/internal/Types.js\";\n\ninterface SubjectInfo {\n parentSubjectId: Id64String | undefined;\n hideInHierarchy: boolean;\n childSubjectIds: Id64Set;\n childModelIds: Id64Set;\n}\n\ninterface ModelInfo {\n categoryIds: Id64Set;\n}\n\n/** @internal */\nexport class IModelContentTreeIdsCache {\n #subjectInfos: Promise<Map<SubjectId, SubjectInfo>> | undefined;\n #parentSubjectIds: Promise<Id64Array> | undefined; // the list should contain a subject id if its node should be shown as having children\n #modelInfos: Promise<Map<ModelId, ModelInfo>> | undefined;\n #queryExecutor: LimitingECSqlQueryExecutor;\n #componentId: GuidString;\n #componentName: string;\n\n constructor(queryExecutor: LimitingECSqlQueryExecutor, componentId?: GuidString) {\n this.#queryExecutor = queryExecutor;\n this.#componentId = componentId ?? Guid.createValue();\n this.#componentName = \"IModelContentTreeIdsCache\";\n }\n\n private async *querySubjects(): AsyncIterableIterator<{ id: SubjectId; parentId?: SubjectId; targetPartitionId?: ModelId; hideInHierarchy: boolean }> {\n const subjectsQuery = `\n SELECT\n s.ECInstanceId id,\n s.Parent.Id parentId,\n (\n SELECT m.ECInstanceId\n FROM ${CLASS_NAME_Model} m\n WHERE\n m.ECInstanceId = HexToId(json_extract(s.JsonProperties, '$.Subject.Model.TargetPartition'))\n AND NOT m.IsPrivate\n ) targetPartitionId,\n CASE\n WHEN (\n json_extract(s.JsonProperties, '$.Subject.Job.Bridge') IS NOT NULL\n OR json_extract(s.JsonProperties, '$.Subject.Model.Type') = 'Hierarchy'\n ) THEN 1\n ELSE 0\n END hideInHierarchy\n FROM ${CLASS_NAME_Subject} s\n `;\n for await (const row of this.#queryExecutor.createQueryReader(\n { ecsql: subjectsQuery },\n { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\", restartToken: `${this.#componentName}/${this.#componentId}/subjects` },\n )) {\n yield { id: row.id, parentId: row.parentId, targetPartitionId: row.targetPartitionId, hideInHierarchy: !!row.hideInHierarchy };\n }\n }\n\n private async *queryModels(): AsyncIterableIterator<{ id: ModelId; parentId: SubjectId }> {\n const modelsQuery = `\n SELECT p.ECInstanceId id, p.Parent.Id parentId\n FROM ${CLASS_NAME_InformationPartitionElement} p\n INNER JOIN ${CLASS_NAME_Model} m ON m.ModeledElement.Id = p.ECInstanceId\n WHERE NOT m.IsPrivate\n `;\n for await (const row of this.#queryExecutor.createQueryReader(\n { ecsql: modelsQuery },\n { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\", restartToken: `${this.#componentName}/${this.#componentId}/models` },\n )) {\n yield { id: row.id, parentId: row.parentId };\n }\n }\n\n private async getSubjectInfos() {\n this.#subjectInfos ??= (async () => {\n const [subjectInfos, targetPartitionSubjects] = await Promise.all([\n (async () => {\n const result = new Map<SubjectId, SubjectInfo>();\n for await (const subject of this.querySubjects()) {\n const subjectInfo: SubjectInfo = {\n parentSubjectId: subject.parentId,\n hideInHierarchy: subject.hideInHierarchy,\n childSubjectIds: new Set(),\n childModelIds: new Set(),\n };\n if (subject.targetPartitionId) {\n subjectInfo.childModelIds.add(subject.targetPartitionId);\n }\n result.set(subject.id, subjectInfo);\n }\n return result;\n })(),\n (async () => {\n const result = new Map<ModelId, Set<SubjectId>>();\n for await (const model of this.queryModels()) {\n pushToMap(result, model.id, model.parentId);\n }\n return result;\n })(),\n ]);\n\n for (const [subjectId, { parentSubjectId }] of subjectInfos.entries()) {\n if (parentSubjectId) {\n const parentSubjectInfo = subjectInfos.get(parentSubjectId);\n assert(!!parentSubjectInfo);\n parentSubjectInfo.childSubjectIds.add(subjectId);\n }\n }\n\n for (const [partitionId, subjectIds] of targetPartitionSubjects) {\n subjectIds.forEach((subjectId) => {\n const subjectInfo = subjectInfos.get(subjectId);\n assert(!!subjectInfo);\n subjectInfo.childModelIds.add(partitionId);\n });\n }\n\n return subjectInfos;\n })();\n return this.#subjectInfos;\n }\n\n /** Returns ECInstanceIDs of Subjects that either have direct Model or at least one child Subject with a Model. */\n public async getParentSubjectIds(): Promise<Id64Array> {\n this.#parentSubjectIds ??= (async () => {\n const subjectInfos = await this.getSubjectInfos();\n const parentSubjectIds = new Set<SubjectId>();\n subjectInfos.forEach((subjectInfo, subjectId) => {\n if (subjectInfo.childModelIds.size === 0 && subjectInfo.childSubjectIds.size === 0) {\n return;\n }\n parentSubjectIds.add(subjectId);\n let currParentId = subjectInfo.parentSubjectId;\n while (currParentId) {\n parentSubjectIds.add(currParentId);\n currParentId = subjectInfos.get(currParentId)?.parentSubjectId;\n }\n });\n return [...parentSubjectIds];\n })();\n return this.#parentSubjectIds;\n }\n\n /**\n * Returns child subjects of the specified parent subjects as they're displayed in the hierarchy - taking into\n * account `hideInHierarchy` flag.\n */\n public async getChildSubjectIds(parentSubjectIds: Id64Array): Promise<Id64Array> {\n const childSubjectIds = new Array<SubjectId>();\n const subjectInfos = await this.getSubjectInfos();\n parentSubjectIds.forEach((subjectId) => {\n forEachChildSubject(subjectInfos, subjectId, (childSubjectId, childSubjectInfo) => {\n if (!childSubjectInfo.hideInHierarchy) {\n childSubjectIds.push(childSubjectId);\n return \"break\";\n }\n return \"continue\";\n });\n });\n return childSubjectIds;\n }\n\n /** Returns ECInstanceIDs of Models under specific parent Subjects as they are displayed in the hierarchy. */\n public async getChildSubjectModelIds(parentSubjectIds: Id64Array): Promise<Id64Array> {\n const subjectInfos = await this.getSubjectInfos();\n\n const hiddenSubjectIds = new Array<SubjectId>();\n parentSubjectIds.forEach((subjectId) => {\n forEachChildSubject(subjectInfos, subjectId, (childSubjectId, childSubjectInfo) => {\n if (childSubjectInfo.hideInHierarchy) {\n hiddenSubjectIds.push(childSubjectId);\n return \"continue\";\n }\n return \"break\";\n });\n });\n\n const modelIds = new Array<ModelId>();\n [...parentSubjectIds, ...hiddenSubjectIds].forEach((subjectId) => {\n const subjectInfo = subjectInfos.get(subjectId);\n subjectInfo && modelIds.push(...subjectInfo.childModelIds);\n });\n return modelIds;\n }\n\n private async *queryModelCategories(): AsyncIterableIterator<{ modelId: Id64String; categoryId: Id64String }> {\n const query = `\n SELECT Model.Id modelId, Category.Id categoryId\n FROM ${CLASS_NAME_GeometricElement3d}\n WHERE Parent.Id IS NULL\n GROUP BY Model.Id, Category.Id\n UNION ALL\n SELECT Model.Id modelId, Category.Id categoryId\n FROM ${CLASS_NAME_GeometricElement2d}\n WHERE Parent.Id IS NULL\n GROUP BY Model.Id, Category.Id\n `;\n for await (const row of this.#queryExecutor.createQueryReader(\n { ecsql: query },\n { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\", restartToken: `${this.#componentName}/${this.#componentId}/model-categories` },\n )) {\n yield { modelId: row.modelId, categoryId: row.categoryId };\n }\n }\n\n private async getModelInfos() {\n this.#modelInfos ??= (async () => {\n const modelInfos = new Map<ModelId, { categoryIds: Id64Set; elementCount: number }>();\n for await (const { modelId, categoryId } of this.queryModelCategories()) {\n const entry = modelInfos.get(modelId);\n if (entry) {\n entry.categoryIds.add(categoryId);\n } else {\n modelInfos.set(modelId, { categoryIds: new Set([categoryId]), elementCount: 0 });\n }\n }\n return modelInfos;\n })();\n return this.#modelInfos;\n }\n\n public async getModelCategoryIds(modelIds: Id64Array): Promise<Id64Array> {\n const modelInfos = await this.getModelInfos();\n return modelIds.map((modelId) => modelInfos.get(modelId)?.categoryIds).flatMap((categories) => (categories ? [...categories] : []));\n }\n}\n\nfunction forEachChildSubject(\n subjectInfos: Map<SubjectId, SubjectInfo>,\n parentSubject: SubjectId | SubjectInfo,\n cb: (childSubjectId: Id64String, childSubjectInfo: SubjectInfo) => \"break\" | \"continue\",\n) {\n const parentSubjectInfo = typeof parentSubject === \"string\" ? subjectInfos.get(parentSubject) : parentSubject;\n parentSubjectInfo &&\n parentSubjectInfo.childSubjectIds.forEach((childSubjectId) => {\n const childSubjectInfo = subjectInfos.get(childSubjectId)!;\n if (cb(childSubjectId, childSubjectInfo) === \"break\") {\n return;\n }\n forEachChildSubject(subjectInfos, childSubjectInfo, cb);\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"IModelContentTreeIdsCache.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/imodel-content-tree/internal/IModelContentTreeIdsCache.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EACL,6BAA6B,EAC7B,6BAA6B,EAC7B,sCAAsC,EACtC,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,+CAA+C,CAAC;AACvD,OAAO,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAC;AAClF,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAiB3D,gBAAgB;AAChB,MAAM,OAAO,yBAAyB;IACpC,aAAa,CAAmD;IAChE,iBAAiB,CAAiC,CAAC,sFAAsF;IACzI,WAAW,CAA+C;IAC1D,cAAc,CAA6B;IAC3C,YAAY,CAAa;IACzB,cAAc,CAAS;IAEvB,YAAY,aAAyC,EAAE,WAAwB;QAC7E,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;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IACtI,CAAC;CACF;AAED,SAAS,mBAAmB,CAC1B,YAAyC,EACzC,aAAsC,EACtC,EAAuF;IAEvF,MAAM,iBAAiB,GAAG,OAAO,aAAa,KAAK,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC;IAC9G,iBAAiB;QACf,iBAAiB,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,cAAc,EAAE,EAAE;YAC3D,MAAM,gBAAgB,GAAG,YAAY,CAAC,GAAG,CAAC,cAAc,CAAE,CAAC;YAC3D,IAAI,EAAE,CAAC,cAAc,EAAE,gBAAgB,CAAC,KAAK,OAAO,EAAE,CAAC;gBACrD,OAAO;YACT,CAAC;YACD,mBAAmB,CAAC,YAAY,EAAE,gBAAgB,EAAE,EAAE,CAAC,CAAC;QAC1D,CAAC,CAAC,CAAC;AACP,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 { assert, Guid } from \"@itwin/core-bentley\";\nimport {\n CLASS_NAME_GeometricElement2d,\n CLASS_NAME_GeometricElement3d,\n CLASS_NAME_InformationPartitionElement,\n CLASS_NAME_Model,\n CLASS_NAME_Subject,\n} from \"../../common/internal/ClassNameDefinitions.js\";\nimport { isBeSqliteInterruptError } from \"../../common/internal/UseErrorState.js\";\nimport { pushToMap } from \"../../common/internal/Utils.js\";\n\nimport type { GuidString, Id64Array, Id64Set, Id64String } from \"@itwin/core-bentley\";\nimport type { LimitingECSqlQueryExecutor } from \"@itwin/presentation-hierarchies\";\nimport type { ModelId, SubjectId } from \"../../common/internal/Types.js\";\n\ninterface SubjectInfo {\n parentSubjectId: Id64String | undefined;\n hideInHierarchy: boolean;\n childSubjectIds: Id64Set;\n childModelIds: Id64Set;\n}\n\ninterface ModelInfo {\n categoryIds: Id64Set;\n}\n\n/** @internal */\nexport class IModelContentTreeIdsCache {\n #subjectInfos: Promise<Map<SubjectId, SubjectInfo>> | undefined;\n #parentSubjectIds: Promise<Id64Array> | undefined; // the list should contain a subject id if its node should be shown as having children\n #modelInfos: Promise<Map<ModelId, ModelInfo>> | undefined;\n #queryExecutor: LimitingECSqlQueryExecutor;\n #componentId: GuidString;\n #componentName: string;\n\n constructor(queryExecutor: LimitingECSqlQueryExecutor, componentId?: GuidString) {\n this.#queryExecutor = queryExecutor;\n this.#componentId = componentId ?? Guid.createValue();\n this.#componentName = \"IModelContentTreeIdsCache\";\n }\n\n private async *querySubjects(): AsyncIterableIterator<{ id: SubjectId; parentId?: SubjectId; targetPartitionId?: ModelId; hideInHierarchy: boolean }> {\n try {\n const subjectsQuery = `\n SELECT\n s.ECInstanceId id,\n s.Parent.Id parentId,\n (\n SELECT m.ECInstanceId\n FROM ${CLASS_NAME_Model} m\n WHERE\n m.ECInstanceId = HexToId(json_extract(s.JsonProperties, '$.Subject.Model.TargetPartition'))\n AND NOT m.IsPrivate\n ) targetPartitionId,\n CASE\n WHEN (\n json_extract(s.JsonProperties, '$.Subject.Job.Bridge') IS NOT NULL\n OR json_extract(s.JsonProperties, '$.Subject.Model.Type') = 'Hierarchy'\n ) THEN 1\n ELSE 0\n END hideInHierarchy\n FROM ${CLASS_NAME_Subject} s\n `;\n for await (const row of this.#queryExecutor.createQueryReader(\n { ecsql: subjectsQuery },\n { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\", restartToken: `${this.#componentName}/${this.#componentId}/subjects` },\n )) {\n yield { id: row.id, parentId: row.parentId, targetPartitionId: row.targetPartitionId, hideInHierarchy: !!row.hideInHierarchy };\n }\n } catch (error) {\n if (!isBeSqliteInterruptError(error)) {\n throw error;\n }\n }\n }\n\n private async *queryModels(): AsyncIterableIterator<{ id: ModelId; parentId: SubjectId }> {\n try {\n const modelsQuery = `\n SELECT p.ECInstanceId id, p.Parent.Id parentId\n FROM ${CLASS_NAME_InformationPartitionElement} p\n INNER JOIN ${CLASS_NAME_Model} m ON m.ModeledElement.Id = p.ECInstanceId\n WHERE NOT m.IsPrivate\n `;\n for await (const row of this.#queryExecutor.createQueryReader(\n { ecsql: modelsQuery },\n { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\", restartToken: `${this.#componentName}/${this.#componentId}/models` },\n )) {\n yield { id: row.id, parentId: row.parentId };\n }\n } catch (error) {\n if (!isBeSqliteInterruptError(error)) {\n throw error;\n }\n }\n }\n\n private async getSubjectInfos() {\n this.#subjectInfos ??= (async () => {\n const [subjectInfos, targetPartitionSubjects] = await Promise.all([\n (async () => {\n const result = new Map<SubjectId, SubjectInfo>();\n for await (const subject of this.querySubjects()) {\n const subjectInfo: SubjectInfo = {\n parentSubjectId: subject.parentId,\n hideInHierarchy: subject.hideInHierarchy,\n childSubjectIds: new Set(),\n childModelIds: new Set(),\n };\n if (subject.targetPartitionId) {\n subjectInfo.childModelIds.add(subject.targetPartitionId);\n }\n result.set(subject.id, subjectInfo);\n }\n return result;\n })(),\n (async () => {\n const result = new Map<ModelId, Set<SubjectId>>();\n for await (const model of this.queryModels()) {\n pushToMap(result, model.id, model.parentId);\n }\n return result;\n })(),\n ]);\n\n for (const [subjectId, { parentSubjectId }] of subjectInfos.entries()) {\n if (parentSubjectId) {\n const parentSubjectInfo = subjectInfos.get(parentSubjectId);\n assert(!!parentSubjectInfo);\n parentSubjectInfo.childSubjectIds.add(subjectId);\n }\n }\n\n for (const [partitionId, subjectIds] of targetPartitionSubjects) {\n subjectIds.forEach((subjectId) => {\n const subjectInfo = subjectInfos.get(subjectId);\n assert(!!subjectInfo);\n subjectInfo.childModelIds.add(partitionId);\n });\n }\n\n return subjectInfos;\n })();\n return this.#subjectInfos;\n }\n\n /** Returns ECInstanceIDs of Subjects that either have direct Model or at least one child Subject with a Model. */\n public async getParentSubjectIds(): Promise<Id64Array> {\n this.#parentSubjectIds ??= (async () => {\n const subjectInfos = await this.getSubjectInfos();\n const parentSubjectIds = new Set<SubjectId>();\n subjectInfos.forEach((subjectInfo, subjectId) => {\n if (subjectInfo.childModelIds.size === 0 && subjectInfo.childSubjectIds.size === 0) {\n return;\n }\n parentSubjectIds.add(subjectId);\n let currParentId = subjectInfo.parentSubjectId;\n while (currParentId) {\n parentSubjectIds.add(currParentId);\n currParentId = subjectInfos.get(currParentId)?.parentSubjectId;\n }\n });\n return [...parentSubjectIds];\n })();\n return this.#parentSubjectIds;\n }\n\n /**\n * Returns child subjects of the specified parent subjects as they're displayed in the hierarchy - taking into\n * account `hideInHierarchy` flag.\n */\n public async getChildSubjectIds(parentSubjectIds: Id64Array): Promise<Id64Array> {\n const childSubjectIds = new Array<SubjectId>();\n const subjectInfos = await this.getSubjectInfos();\n parentSubjectIds.forEach((subjectId) => {\n forEachChildSubject(subjectInfos, subjectId, (childSubjectId, childSubjectInfo) => {\n if (!childSubjectInfo.hideInHierarchy) {\n childSubjectIds.push(childSubjectId);\n return \"break\";\n }\n return \"continue\";\n });\n });\n return childSubjectIds;\n }\n\n /** Returns ECInstanceIDs of Models under specific parent Subjects as they are displayed in the hierarchy. */\n public async getChildSubjectModelIds(parentSubjectIds: Id64Array): Promise<Id64Array> {\n const subjectInfos = await this.getSubjectInfos();\n\n const hiddenSubjectIds = new Array<SubjectId>();\n parentSubjectIds.forEach((subjectId) => {\n forEachChildSubject(subjectInfos, subjectId, (childSubjectId, childSubjectInfo) => {\n if (childSubjectInfo.hideInHierarchy) {\n hiddenSubjectIds.push(childSubjectId);\n return \"continue\";\n }\n return \"break\";\n });\n });\n\n const modelIds = new Array<ModelId>();\n [...parentSubjectIds, ...hiddenSubjectIds].forEach((subjectId) => {\n const subjectInfo = subjectInfos.get(subjectId);\n subjectInfo && modelIds.push(...subjectInfo.childModelIds);\n });\n return modelIds;\n }\n\n private async *queryModelCategories(): AsyncIterableIterator<{ modelId: Id64String; categoryId: Id64String }> {\n try {\n const query = `\n SELECT Model.Id modelId, Category.Id categoryId\n FROM ${CLASS_NAME_GeometricElement3d}\n WHERE Parent.Id IS NULL\n GROUP BY Model.Id, Category.Id\n UNION ALL\n SELECT Model.Id modelId, Category.Id categoryId\n FROM ${CLASS_NAME_GeometricElement2d}\n WHERE Parent.Id IS NULL\n GROUP BY Model.Id, Category.Id\n `;\n for await (const row of this.#queryExecutor.createQueryReader(\n { ecsql: query },\n { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\", restartToken: `${this.#componentName}/${this.#componentId}/model-categories` },\n )) {\n yield { modelId: row.modelId, categoryId: row.categoryId };\n }\n } catch (error) {\n if (!isBeSqliteInterruptError(error)) {\n throw error;\n }\n }\n }\n\n private async getModelInfos() {\n this.#modelInfos ??= (async () => {\n const modelInfos = new Map<ModelId, { categoryIds: Id64Set; elementCount: number }>();\n for await (const { modelId, categoryId } of this.queryModelCategories()) {\n const entry = modelInfos.get(modelId);\n if (entry) {\n entry.categoryIds.add(categoryId);\n } else {\n modelInfos.set(modelId, { categoryIds: new Set([categoryId]), elementCount: 0 });\n }\n }\n return modelInfos;\n })();\n return this.#modelInfos;\n }\n\n public async getModelCategoryIds(modelIds: Id64Array): Promise<Id64Array> {\n const modelInfos = await this.getModelInfos();\n return modelIds.map((modelId) => modelInfos.get(modelId)?.categoryIds).flatMap((categories) => (categories ? [...categories] : []));\n }\n}\n\nfunction forEachChildSubject(\n subjectInfos: Map<SubjectId, SubjectInfo>,\n parentSubject: SubjectId | SubjectInfo,\n cb: (childSubjectId: Id64String, childSubjectInfo: SubjectInfo) => \"break\" | \"continue\",\n) {\n const parentSubjectInfo = typeof parentSubject === \"string\" ? subjectInfos.get(parentSubject) : parentSubject;\n parentSubjectInfo &&\n parentSubjectInfo.childSubjectIds.forEach((childSubjectId) => {\n const childSubjectInfo = subjectInfos.get(childSubjectId)!;\n if (cb(childSubjectId, childSubjectInfo) === \"break\") {\n return;\n }\n forEachChildSubject(subjectInfos, childSubjectInfo, cb);\n });\n}\n"]}
|
|
@@ -23,7 +23,7 @@ export { VisibilityTreeRenderer } from "./common/components/VisibilityTreeRender
|
|
|
23
23
|
export { SkeletonTree } from "./common/components/SkeletonTree.js";
|
|
24
24
|
export { HierarchyVisibilityHandler, VisibilityStatus } from "./common/UseHierarchyVisibility.js";
|
|
25
25
|
export { TelemetryContextProvider } from "./common/UseTelemetryContext.js";
|
|
26
|
-
export {
|
|
26
|
+
export { SearchLimitExceededError } from "./common/TreeErrors.js";
|
|
27
27
|
export { ModelsTreeVisibilityHandlerOverrides } from "./models-tree/internal/visibility/ModelsTreeVisibilityHandler.js";
|
|
28
28
|
export { RenameAction, FilterAction, TreeActionBase, TreeActionBaseAttributes } from "@itwin/presentation-hierarchies-react";
|
|
29
29
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -25,7 +25,7 @@ export { TreeRenderer } from "./common/components/TreeRenderer.js";
|
|
|
25
25
|
export { VisibilityTreeRenderer } from "./common/components/VisibilityTreeRenderer.js";
|
|
26
26
|
export { SkeletonTree } from "./common/components/SkeletonTree.js";
|
|
27
27
|
export { TelemetryContextProvider } from "./common/UseTelemetryContext.js";
|
|
28
|
-
export {
|
|
28
|
+
export { SearchLimitExceededError } from "./common/TreeErrors.js";
|
|
29
29
|
// reexport actions from presentation-hierarchies-react to keep naming consistent
|
|
30
30
|
// reexport TreeActionBase to allow consumers defining custom actions without @itwin/presentation-hierarchies-react dependency
|
|
31
31
|
export { RenameAction, FilterAction, TreeActionBase } from "@itwin/presentation-hierarchies-react";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/tree-widget-react/components/trees/index.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAC/E,OAAO,EAAE,wBAAwB,EAAE,MAAM,oCAAoC,CAAC;AAE9E,OAAO,EAAE,uBAAuB,EAAE,MAAM,8CAA8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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\nexport { ModelsTreeComponent } from \"./models-tree/ModelsTreeComponent.js\";\nexport { useModelsTree, ModelsTreeIcon } from \"./models-tree/UseModelsTree.js\";\nexport { useModelsTreeButtonProps } from \"./models-tree/ModelsTreeButtons.js\";\n\nexport { CategoriesTreeComponent } from \"./categories-tree/CategoriesTreeComponent.js\";\nexport { useCategoriesTree, CategoriesTreeIcon } from \"./categories-tree/UseCategoriesTree.js\";\nexport { useCategoriesTreeButtonProps } from \"./categories-tree/CategoriesTreeButtons.js\";\n\nexport { ClassificationsTreeComponent } from \"./classifications-tree/ClassificationsTreeComponent.js\";\nexport { ClassificationsTreeIcon } from \"./classifications-tree/ClassificationsTreeIcon.js\";\nexport { useClassificationsTree } from \"./classifications-tree/UseClassificationsTree.js\";\nexport { useClassificationsTreeDefinition } from \"./classifications-tree/UseClassificationsTreeDefinition.js\";\n\nexport { IModelContentTreeComponent } from \"./imodel-content-tree/IModelContentTreeComponent.js\";\nexport { IModelContentTreeIcon } from \"./imodel-content-tree/IModelContentTree.js\";\n\nexport { ExternalSourcesTreeComponent } from \"./external-sources-tree/ExternalSourcesTreeComponent.js\";\nexport { ExternalSourcesTreeIcon } from \"./external-sources-tree/ExternalSourcesTree.js\";\n\nexport { BaseTreeRendererProps } from \"./common/components/BaseTreeRenderer.js\";\nexport { FocusedInstancesContextProvider, useFocusedInstancesContext } from \"./common/FocusedInstancesContext.js\";\n\nexport { Tree } from \"./common/components/Tree.js\";\nexport { TreeWidgetViewport, createTreeWidgetViewport } from \"./common/TreeWidgetViewport.js\";\nexport { VisibilityTree } from \"./common/components/VisibilityTree.js\";\nexport { VisibilityAction } from \"./common/components/TreeNodeVisibilityButton.js\";\nexport { TreeRenderer } from \"./common/components/TreeRenderer.js\";\nexport { VisibilityTreeRenderer } from \"./common/components/VisibilityTreeRenderer.js\";\nexport { SkeletonTree } from \"./common/components/SkeletonTree.js\";\nexport { HierarchyVisibilityHandler, VisibilityStatus } from \"./common/UseHierarchyVisibility.js\";\nexport { TelemetryContextProvider } from \"./common/UseTelemetryContext.js\";\nexport {
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/tree-widget-react/components/trees/index.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAC/E,OAAO,EAAE,wBAAwB,EAAE,MAAM,oCAAoC,CAAC;AAE9E,OAAO,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AACvF,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC/F,OAAO,EAAE,4BAA4B,EAAE,MAAM,4CAA4C,CAAC;AAE1F,OAAO,EAAE,4BAA4B,EAAE,MAAM,wDAAwD,CAAC;AACtG,OAAO,EAAE,uBAAuB,EAAE,MAAM,mDAAmD,CAAC;AAC5F,OAAO,EAAE,sBAAsB,EAAE,MAAM,kDAAkD,CAAC;AAC1F,OAAO,EAAE,gCAAgC,EAAE,MAAM,4DAA4D,CAAC;AAE9G,OAAO,EAAE,0BAA0B,EAAE,MAAM,qDAAqD,CAAC;AACjG,OAAO,EAAE,qBAAqB,EAAE,MAAM,4CAA4C,CAAC;AAEnF,OAAO,EAAE,4BAA4B,EAAE,MAAM,yDAAyD,CAAC;AACvG,OAAO,EAAE,uBAAuB,EAAE,MAAM,gDAAgD,CAAC;AAGzF,OAAO,EAAE,+BAA+B,EAAE,0BAA0B,EAAE,MAAM,qCAAqC,CAAC;AAElH,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AACnD,OAAO,EAAsB,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC9F,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iDAAiD,CAAC;AACnF,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,+CAA+C,CAAC;AACvF,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAEnE,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAIlE,iFAAiF;AACjF,8HAA8H;AAC9H,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,cAAc,EAA4B,MAAM,uCAAuC,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\nexport { ModelsTreeComponent } from \"./models-tree/ModelsTreeComponent.js\";\nexport { useModelsTree, ModelsTreeIcon } from \"./models-tree/UseModelsTree.js\";\nexport { useModelsTreeButtonProps } from \"./models-tree/ModelsTreeButtons.js\";\n\nexport { CategoriesTreeComponent } from \"./categories-tree/CategoriesTreeComponent.js\";\nexport { useCategoriesTree, CategoriesTreeIcon } from \"./categories-tree/UseCategoriesTree.js\";\nexport { useCategoriesTreeButtonProps } from \"./categories-tree/CategoriesTreeButtons.js\";\n\nexport { ClassificationsTreeComponent } from \"./classifications-tree/ClassificationsTreeComponent.js\";\nexport { ClassificationsTreeIcon } from \"./classifications-tree/ClassificationsTreeIcon.js\";\nexport { useClassificationsTree } from \"./classifications-tree/UseClassificationsTree.js\";\nexport { useClassificationsTreeDefinition } from \"./classifications-tree/UseClassificationsTreeDefinition.js\";\n\nexport { IModelContentTreeComponent } from \"./imodel-content-tree/IModelContentTreeComponent.js\";\nexport { IModelContentTreeIcon } from \"./imodel-content-tree/IModelContentTree.js\";\n\nexport { ExternalSourcesTreeComponent } from \"./external-sources-tree/ExternalSourcesTreeComponent.js\";\nexport { ExternalSourcesTreeIcon } from \"./external-sources-tree/ExternalSourcesTree.js\";\n\nexport { BaseTreeRendererProps } from \"./common/components/BaseTreeRenderer.js\";\nexport { FocusedInstancesContextProvider, useFocusedInstancesContext } from \"./common/FocusedInstancesContext.js\";\n\nexport { Tree } from \"./common/components/Tree.js\";\nexport { TreeWidgetViewport, createTreeWidgetViewport } from \"./common/TreeWidgetViewport.js\";\nexport { VisibilityTree } from \"./common/components/VisibilityTree.js\";\nexport { VisibilityAction } from \"./common/components/TreeNodeVisibilityButton.js\";\nexport { TreeRenderer } from \"./common/components/TreeRenderer.js\";\nexport { VisibilityTreeRenderer } from \"./common/components/VisibilityTreeRenderer.js\";\nexport { SkeletonTree } from \"./common/components/SkeletonTree.js\";\nexport { HierarchyVisibilityHandler, VisibilityStatus } from \"./common/UseHierarchyVisibility.js\";\nexport { TelemetryContextProvider } from \"./common/UseTelemetryContext.js\";\nexport { SearchLimitExceededError } from \"./common/TreeErrors.js\";\n\nexport { ModelsTreeVisibilityHandlerOverrides } from \"./models-tree/internal/visibility/ModelsTreeVisibilityHandler.js\";\n\n// reexport actions from presentation-hierarchies-react to keep naming consistent\n// reexport TreeActionBase to allow consumers defining custom actions without @itwin/presentation-hierarchies-react dependency\nexport { RenameAction, FilterAction, TreeActionBase, TreeActionBaseAttributes } from \"@itwin/presentation-hierarchies-react\";\n"]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { VisibilityTreeProps } from "../common/components/VisibilityTree.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ExtendedVisibilityTreeRendererProps } from "../common/components/VisibilityTreeRenderer.js";
|
|
3
3
|
import type { UseModelsTreeProps } from "./UseModelsTree.js";
|
|
4
4
|
/** @beta */
|
|
5
|
-
export type ModelsTreeProps = Pick<
|
|
5
|
+
export type ModelsTreeProps = Pick<ExtendedVisibilityTreeRendererProps, "getInlineActions" | "getMenuActions" | "getContextMenuActions" | "getTreeItemProps" | "treeLabel"> & Pick<VisibilityTreeProps, "imodel" | "selectionStorage" | "selectionMode" | "emptyTreeContent"> & UseModelsTreeProps & {
|
|
6
6
|
hierarchyLevelConfig?: {
|
|
7
7
|
sizeLimit?: number;
|
|
8
8
|
};
|
|
9
9
|
};
|
|
10
10
|
/** @beta */
|
|
11
|
-
export declare function ModelsTree({ imodel, selectionStorage, activeView,
|
|
11
|
+
export declare function ModelsTree({ imodel, selectionStorage, activeView, searchText, hierarchyLevelConfig, hierarchyConfig, selectionMode, selectionPredicate, visibilityHandlerOverrides, getSearchPaths, onModelsFiltered, getInlineActions, getMenuActions, getContextMenuActions, emptyTreeContent, getSubTreePaths, getTreeItemProps, treeLabel, }: ModelsTreeProps): import("react/jsx-runtime").JSX.Element;
|
|
12
12
|
//# sourceMappingURL=ModelsTree.d.ts.map
|
|
@@ -7,18 +7,19 @@ import { VisibilityTree } from "../common/components/VisibilityTree.js";
|
|
|
7
7
|
import { VisibilityTreeRenderer } from "../common/components/VisibilityTreeRenderer.js";
|
|
8
8
|
import { useModelsTree } from "./UseModelsTree.js";
|
|
9
9
|
/** @beta */
|
|
10
|
-
export function ModelsTree({ imodel, selectionStorage, activeView,
|
|
11
|
-
const
|
|
10
|
+
export function ModelsTree({ imodel, selectionStorage, activeView, searchText, hierarchyLevelConfig, hierarchyConfig, selectionMode, selectionPredicate, visibilityHandlerOverrides, getSearchPaths, onModelsFiltered, getInlineActions, getMenuActions, getContextMenuActions, emptyTreeContent, getSubTreePaths, getTreeItemProps, treeLabel, }) {
|
|
11
|
+
const modelsTree = useModelsTree({
|
|
12
12
|
activeView,
|
|
13
|
-
|
|
13
|
+
searchText,
|
|
14
14
|
hierarchyConfig,
|
|
15
15
|
visibilityHandlerOverrides,
|
|
16
|
-
|
|
16
|
+
getSearchPaths,
|
|
17
17
|
onModelsFiltered,
|
|
18
18
|
selectionPredicate,
|
|
19
19
|
emptyTreeContent,
|
|
20
20
|
getSubTreePaths,
|
|
21
|
+
getTreeItemProps,
|
|
21
22
|
});
|
|
22
|
-
return (_jsx(VisibilityTree, { ...
|
|
23
|
+
return (_jsx(VisibilityTree, { ...modelsTree.treeProps, imodel: imodel, selectionStorage: selectionStorage, hierarchyLevelSizeLimit: hierarchyLevelConfig?.sizeLimit, selectionMode: selectionMode, treeRenderer: (treeProps) => (_jsx(VisibilityTreeRenderer, { ...treeProps, treeLabel: treeLabel, getInlineActions: getInlineActions ? (node) => getInlineActions(node, treeProps) : undefined, getMenuActions: getMenuActions ? (node) => getMenuActions(node, treeProps) : undefined, getContextMenuActions: getContextMenuActions ? (node) => getContextMenuActions(node, treeProps) : undefined, getTreeItemProps: (node) => modelsTree.getTreeItemProps(node, treeProps) })) }));
|
|
23
24
|
}
|
|
24
25
|
//# sourceMappingURL=ModelsTree.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelsTree.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/models-tree/ModelsTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AACxF,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"ModelsTree.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/models-tree/ModelsTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AACxF,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAkBnD,YAAY;AACZ,MAAM,UAAU,UAAU,CAAC,EACzB,MAAM,EACN,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,oBAAoB,EACpB,eAAe,EACf,aAAa,EACb,kBAAkB,EAClB,0BAA0B,EAC1B,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,qBAAqB,EACrB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,SAAS,GACO;IAChB,MAAM,UAAU,GAAG,aAAa,CAAC;QAC/B,UAAU;QACV,UAAU;QACV,eAAe;QACf,0BAA0B;QAC1B,cAAc;QACd,gBAAgB;QAChB,kBAAkB;QAClB,gBAAgB;QAChB,eAAe;QACf,gBAAgB;KACjB,CAAC,CAAC;IAEH,OAAO,CACL,KAAC,cAAc,OACT,UAAU,CAAC,SAAS,EACxB,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,gBAAgB,EAClC,uBAAuB,EAAE,oBAAoB,EAAE,SAAS,EACxD,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,CAC3B,KAAC,sBAAsB,OACjB,SAAS,EACb,SAAS,EAAE,SAAS,EACpB,gBAAgB,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,gBAAgB,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,EAC5F,cAAc,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,cAAc,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,EACtF,qBAAqB,EAAE,qBAAqB,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,qBAAqB,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,EAC3G,gBAAgB,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,IAAI,EAAE,SAAS,CAAC,GACxE,CACH,GACD,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 *--------------------------------------------------------------------------------------------*/\n\nimport { VisibilityTree } from \"../common/components/VisibilityTree.js\";\nimport { VisibilityTreeRenderer } from \"../common/components/VisibilityTreeRenderer.js\";\nimport { useModelsTree } from \"./UseModelsTree.js\";\n\nimport type { VisibilityTreeProps } from \"../common/components/VisibilityTree.js\";\nimport type { ExtendedVisibilityTreeRendererProps } from \"../common/components/VisibilityTreeRenderer.js\";\nimport type { UseModelsTreeProps } from \"./UseModelsTree.js\";\n\n/** @beta */\nexport type ModelsTreeProps = Pick<\n ExtendedVisibilityTreeRendererProps,\n \"getInlineActions\" | \"getMenuActions\" | \"getContextMenuActions\" | \"getTreeItemProps\" | \"treeLabel\"\n> &\n Pick<VisibilityTreeProps, \"imodel\" | \"selectionStorage\" | \"selectionMode\" | \"emptyTreeContent\"> &\n UseModelsTreeProps & {\n hierarchyLevelConfig?: {\n sizeLimit?: number;\n };\n };\n\n/** @beta */\nexport function ModelsTree({\n imodel,\n selectionStorage,\n activeView,\n searchText,\n hierarchyLevelConfig,\n hierarchyConfig,\n selectionMode,\n selectionPredicate,\n visibilityHandlerOverrides,\n getSearchPaths,\n onModelsFiltered,\n getInlineActions,\n getMenuActions,\n getContextMenuActions,\n emptyTreeContent,\n getSubTreePaths,\n getTreeItemProps,\n treeLabel,\n}: ModelsTreeProps) {\n const modelsTree = useModelsTree({\n activeView,\n searchText,\n hierarchyConfig,\n visibilityHandlerOverrides,\n getSearchPaths,\n onModelsFiltered,\n selectionPredicate,\n emptyTreeContent,\n getSubTreePaths,\n getTreeItemProps,\n });\n\n return (\n <VisibilityTree\n {...modelsTree.treeProps}\n imodel={imodel}\n selectionStorage={selectionStorage}\n hierarchyLevelSizeLimit={hierarchyLevelConfig?.sizeLimit}\n selectionMode={selectionMode}\n treeRenderer={(treeProps) => (\n <VisibilityTreeRenderer\n {...treeProps}\n treeLabel={treeLabel}\n getInlineActions={getInlineActions ? (node) => getInlineActions(node, treeProps) : undefined}\n getMenuActions={getMenuActions ? (node) => getMenuActions(node, treeProps) : undefined}\n getContextMenuActions={getContextMenuActions ? (node) => getContextMenuActions(node, treeProps) : undefined}\n getTreeItemProps={(node) => modelsTree.getTreeItemProps(node, treeProps)}\n />\n )}\n />\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelsTreeButtons.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,WAAW,MAAM,yBAAyB,CAAC;AAClD,OAAO,WAAW,MAAM,yBAAyB,CAAC;AAClD,OAAO,YAAY,MAAM,mCAAmC,CAAC;AAC7D,OAAO,iBAAiB,MAAM,sCAAsC,CAAC;AACrE,OAAO,mBAAmB,MAAM,wCAAwC,CAAC;AACzE,OAAO,iBAAiB,MAAM,sCAAsC,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAClF,OAAO,EACL,kBAAkB,EAClB,6BAA6B,EAC7B,2BAA2B,EAC3B,sCAAsC,GACvC,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,eAAe,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AA2BhH;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,wBAAwB,CAAC,EAAE,MAAM,EAAE,QAAQ,EAA8D;IAIvH,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,EAA4B,CAAC;IAEjF,MAAM,MAAM,GA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AAE,OAAO,EAChB,KAAK,EAAE,UAAU,CAAC,SAAS,CAAC,qCAAqC,CAAC,EAClE,OAAO,EAAE,GAAG,EAAE;YACZ,KAAK,CAAC,aAAa,EAAE,CAAC,oBAAoB,CAAC,CAAC;YAC5C,YAAY,CAAC,QAAQ,EAAE,gBAAgB,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;QAC3D,CAAC,mBACc,QAAQ,CAAC,MAAM,KAAK,CAAC,EACpC,MAAM,EAAE,gBAAgB,EACxB,IAAI,EAAE,WAAW,GACjB,CACH,CAAC;AACJ,CAAC;AAED,cAAc;AACd,MAAM,UAAU,0BAA0B,CAAC,EAAE,aAAa,EAAE,QAAQ,EAAqE;IACvI,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,0BAA0B,EAAE,CAAC;IACzD,MAAM,KAAK,GAAG,QAAQ;QACpB,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,qDAAqD,CAAC;QAC7E,CAAC,CAAC,OAAO;YACP,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,oDAAoD,CAAC;YAC5E,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,mDAAmD,CAAC,CAAC;IAChF,OAAO,CACL,KAAC,UAAU,IACT,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,GAAG,EAAE;YACZ,2BAA2B;YAC3B,aAAa,EAAE,CAAC,4BAA4B,CAAC,CAAC;YAC9C,MAAM,EAAE,CAAC;QACX,CAAC,mBACc,QAAQ,EACvB,MAAM,EAAE,OAAO,EACf,IAAI,EAAE,YAAY,GAClB,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 *--------------------------------------------------------------------------------------------*/\n\nimport { useEffect, useMemo, useState } from \"react\";\nimport { IconButton } from \"@stratakit/bricks\";\nimport toggle2DSvg from \"@stratakit/icons/2d.svg\";\nimport toggle3DSvg from \"@stratakit/icons/3d.svg\";\nimport focusModeSvg from \"@stratakit/icons/cursor-click.svg\";\nimport visibilityHideSvg from \"@stratakit/icons/visibility-hide.svg\";\nimport visibilityInvertSvg from \"@stratakit/icons/visibility-invert.svg\";\nimport visibilityShowSvg from \"@stratakit/icons/visibility-show.svg\";\nimport { TreeWidget } from \"../../../TreeWidget.js\";\nimport { useFocusedInstancesContext } from \"../common/FocusedInstancesContext.js\";\nimport {\n CLASS_NAME_Element,\n CLASS_NAME_GeometricElement3d,\n CLASS_NAME_GeometricModel3d,\n CLASS_NAME_InformationPartitionElement,\n} from \"../common/internal/ClassNameDefinitions.js\";\nimport { useGuid } from \"../common/internal/useGuid.js\";\nimport { areAllModelsVisible, hideAllModels, invertAllModels, showAll, toggleModels } from \"../common/Utils.js\";\n\nimport type { Id64String } from \"@itwin/core-bentley\";\nimport type { GeometricModel3dProps, ModelQueryParams } from \"@itwin/core-common\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport type { TreeToolbarButtonProps } from \"../../tree-header/SelectableTree.js\";\nimport type { TreeWidgetViewport } from \"../common/TreeWidgetViewport.js\";\n\n/**\n * Information about a single Model.\n * @public\n */\nexport interface ModelInfo {\n id: string;\n isPlanProjection?: boolean;\n}\n\n/**\n * Props that get passed to `ModelsTreeComponent` header button renderer.\n * @see ModelTreeComponentProps.headerButtons\n * @public\n */\nexport interface ModelsTreeHeaderButtonProps extends TreeToolbarButtonProps {\n /** A list of models available in the iModel. */\n models: ModelInfo[];\n}\n\n/**\n * Custom hook that creates props required to render `ModelsTreeComponent` header button.\n *\n * Example:\n * ```tsx\n * const { buttonProps, onModelsFiltered } = useModelsTreeButtonProps({ imodel, viewport });\n * <TreeWithHeader\n * buttons={[\n * <ModelsTreeComponent.ShowAllButton {...buttonProps} />,\n * <ModelsTreeComponent.HideAllButton {...buttonProps} />,\n * ]}\n * >\n * <ModelsTree {...treeProps} onModelsFiltered={onModelsFiltered} />\n * </TreeWithHeader>\n * ```\n *\n *\n * @public\n */\nexport function useModelsTreeButtonProps({ imodel, viewport }: { imodel: IModelConnection; viewport: TreeWidgetViewport }): {\n buttonProps: Pick<ModelsTreeHeaderButtonProps, \"models\" | \"viewport\">;\n onModelsFiltered: (models: Id64String[] | undefined) => void;\n} {\n const [filteredModels, setFilteredModels] = useState<Id64String[] | undefined>();\n\n const models = useAvailableModels(imodel);\n const availableModels = useMemo(() => (!filteredModels ? models : models.filter((model) => filteredModels.includes(model.id))), [models, filteredModels]);\n return {\n buttonProps: {\n models: availableModels,\n viewport,\n },\n onModelsFiltered: setFilteredModels,\n };\n}\n\nfunction useAvailableModels(imodel: IModelConnection): ModelInfo[] {\n const [availableModels, setAvailableModels] = useState<ModelInfo[]>([]);\n\n useEffect(() => {\n queryModelsForHeaderActions(imodel)\n .then((modelInfos: ModelInfo[]) => {\n setAvailableModels(modelInfos);\n })\n .catch(() => {\n setAvailableModels([]);\n });\n }, [imodel]);\n\n return availableModels;\n}\n\nasync function queryModelsForHeaderActions(iModel: IModelConnection) {\n const queryParams: ModelQueryParams = {\n from: CLASS_NAME_GeometricModel3d,\n where: `\n EXISTS (\n SELECT 1\n FROM ${CLASS_NAME_Element} e\n WHERE e.ECClassId IS (${CLASS_NAME_GeometricElement3d}, ${CLASS_NAME_InformationPartitionElement})\n AND e.ECInstanceId = GeometricModel3d.ModeledElement.Id\n )\n `,\n wantPrivate: false,\n };\n\n const modelProps = await iModel.models.queryProps(queryParams);\n return modelProps.map(({ id, isPlanProjection }: GeometricModel3dProps) => ({ id, isPlanProjection })).filter(({ id }) => id) as ModelInfo[];\n}\n\n/** @public */\nexport type ModelsTreeHeaderButtonType = (props: ModelsTreeHeaderButtonProps) => React.ReactElement | null;\n\n/** @public */\nexport function ShowAllButton(props: ModelsTreeHeaderButtonProps) {\n const componentId = useGuid();\n return (\n <IconButton\n variant={\"ghost\"}\n label={TreeWidget.translate(\"modelsTree.buttons.showAll.tooltip\")}\n onClick={() => {\n // cspell:disable-next-line\n props.onFeatureUsed?.(\"models-tree-showall\");\n void showAll({\n models: props.models.map((model) => model.id),\n viewport: props.viewport,\n componentId,\n });\n }}\n icon={visibilityShowSvg}\n />\n );\n}\n\n/** @public */\nexport function HideAllButton(props: ModelsTreeHeaderButtonProps) {\n return (\n <IconButton\n variant={\"ghost\"}\n label={TreeWidget.translate(\"modelsTree.buttons.hideAll.tooltip\")}\n onClick={() => {\n // cspell:disable-next-line\n props.onFeatureUsed?.(\"models-tree-hideall\");\n hideAllModels(\n props.models.map((model) => model.id),\n props.viewport,\n );\n }}\n icon={visibilityHideSvg}\n />\n );\n}\n\n/** @public */\nexport function InvertButton(props: ModelsTreeHeaderButtonProps) {\n return (\n <IconButton\n variant={\"ghost\"}\n label={TreeWidget.translate(\"modelsTree.buttons.invert.tooltip\")}\n onClick={() => {\n props.onFeatureUsed?.(\"models-tree-invert\");\n invertAllModels(\n props.models.map((model) => model.id),\n props.viewport,\n );\n }}\n icon={visibilityInvertSvg}\n />\n );\n}\n\n/** @public */\nexport function View2DButton(props: ModelsTreeHeaderButtonProps) {\n const models2d = useMemo(() => {\n return props.models.filter((model) => model.isPlanProjection).map((model) => model.id);\n }, [props.models]);\n\n const [is2dToggleActive, setIs2dToggleActive] = useState(false);\n\n useEffect(() => {\n setIs2dToggleActive(areAllModelsVisible(models2d, props.viewport));\n return props.viewport.onDisplayedModelsChanged.addListener(() => setIs2dToggleActive(areAllModelsVisible(models2d, props.viewport)));\n }, [models2d, props.viewport]);\n\n return (\n <IconButton\n variant={\"ghost\"}\n label={TreeWidget.translate(\"modelsTree.buttons.toggle2d.tooltip\")}\n onClick={() => {\n props.onFeatureUsed?.(\"models-tree-view2d\");\n toggleModels(models2d, is2dToggleActive, props.viewport);\n }}\n aria-disabled={models2d.length === 0}\n active={is2dToggleActive}\n icon={toggle2DSvg}\n />\n );\n}\n\n/** @public */\nexport function View3DButton(props: ModelsTreeHeaderButtonProps) {\n const models3d = useMemo(() => {\n return props.models.filter((model) => !model.isPlanProjection).map((model) => model.id);\n }, [props.models]);\n\n const [is3dToggleActive, setIs3dToggleActive] = useState(false);\n\n useEffect(() => {\n setIs3dToggleActive(areAllModelsVisible(models3d, props.viewport));\n return props.viewport.onDisplayedModelsChanged.addListener(() => setIs3dToggleActive(areAllModelsVisible(models3d, props.viewport)));\n }, [models3d, props.viewport]);\n\n return (\n <IconButton\n variant={\"ghost\"}\n label={TreeWidget.translate(\"modelsTree.buttons.toggle3d.tooltip\")}\n onClick={() => {\n props.onFeatureUsed?.(\"models-tree-view3d\");\n toggleModels(models3d, is3dToggleActive, props.viewport);\n }}\n aria-disabled={models3d.length === 0}\n active={is3dToggleActive}\n icon={toggle3DSvg}\n />\n );\n}\n\n/** @public */\nexport function ToggleInstancesFocusButton({ onFeatureUsed, disabled }: { onFeatureUsed?: (feature: string) => void; disabled?: boolean }) {\n const { enabled, toggle } = useFocusedInstancesContext();\n const label = disabled\n ? TreeWidget.translate(\"modelsTree.buttons.toggleFocusMode.disabled.tooltip\")\n : enabled\n ? TreeWidget.translate(\"modelsTree.buttons.toggleFocusMode.disable.tooltip\")\n : TreeWidget.translate(\"modelsTree.buttons.toggleFocusMode.enable.tooltip\");\n return (\n <IconButton\n variant={\"ghost\"}\n label={label}\n onClick={() => {\n // cspell:disable-next-line\n onFeatureUsed?.(\"models-tree-instancesfocus\");\n toggle();\n }}\n aria-disabled={disabled}\n active={enabled}\n icon={focusModeSvg}\n />\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ModelsTreeButtons.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,WAAW,MAAM,yBAAyB,CAAC;AAClD,OAAO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M,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,0BAA0B,EAAE,CAAC;IACzD,MAAM,KAAK,GAAG,QAAQ;QACpB,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,qDAAqD,CAAC;QAC7E,CAAC,CAAC,OAAO;YACP,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,oDAAoD,CAAC;YAC5E,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,mDAAmD,CAAC,CAAC;IAChF,OAAO,CACL,KAAC,UAAU,IACT,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,GAAG,EAAE;YACZ,2BAA2B;YAC3B,aAAa,EAAE,CAAC,4BAA4B,CAAC,CAAC;YAC9C,MAAM,EAAE,CAAC;QACX,CAAC,mBACc,QAAQ,EACvB,MAAM,EAAE,OAAO,EACf,IAAI,EAAE,YAAY,GAClB,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 *--------------------------------------------------------------------------------------------*/\n\nimport { useEffect, useMemo, useState } from \"react\";\nimport { IconButton } from \"@stratakit/bricks\";\nimport toggle2DSvg from \"@stratakit/icons/2d.svg\";\nimport toggle3DSvg from \"@stratakit/icons/3d.svg\";\nimport focusModeSvg from \"@stratakit/icons/cursor-click.svg\";\nimport visibilityHideSvg from \"@stratakit/icons/visibility-hide.svg\";\nimport visibilityInvertSvg from \"@stratakit/icons/visibility-invert.svg\";\nimport visibilityShowSvg from \"@stratakit/icons/visibility-show.svg\";\nimport { TreeWidget } from \"../../../TreeWidget.js\";\nimport { useFocusedInstancesContext } from \"../common/FocusedInstancesContext.js\";\nimport {\n CLASS_NAME_Element,\n CLASS_NAME_GeometricElement3d,\n CLASS_NAME_GeometricModel3d,\n CLASS_NAME_InformationPartitionElement,\n} from \"../common/internal/ClassNameDefinitions.js\";\nimport { useGuid } from \"../common/internal/useGuid.js\";\nimport { areAllModelsVisible, hideAllModels, invertAllModels, showAll, toggleModels } from \"../common/Utils.js\";\n\nimport type { Id64String } from \"@itwin/core-bentley\";\nimport type { GeometricModel3dProps, ModelQueryParams } from \"@itwin/core-common\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport type { TreeToolbarButtonProps } from \"../../tree-header/SelectableTree.js\";\nimport type { TreeWidgetViewport } from \"../common/TreeWidgetViewport.js\";\n\n/**\n * Information about a single Model.\n * @public\n */\nexport interface ModelInfo {\n id: string;\n isPlanProjection?: boolean;\n}\n\n/**\n * Props that get passed to `ModelsTreeComponent` header button renderer.\n * @see ModelTreeComponentProps.headerButtons\n * @public\n */\nexport interface ModelsTreeHeaderButtonProps extends TreeToolbarButtonProps {\n /** A list of models available in the iModel. */\n models: ModelInfo[];\n}\n\n/**\n * Custom hook that creates props required to render `ModelsTreeComponent` header button.\n *\n * Example:\n * ```tsx\n * const { buttonProps, onModelsFiltered } = useModelsTreeButtonProps({ imodel, viewport });\n * <TreeWithHeader\n * buttons={[\n * <ModelsTreeComponent.ShowAllButton {...buttonProps} />,\n * <ModelsTreeComponent.HideAllButton {...buttonProps} />,\n * ]}\n * >\n * <ModelsTree {...treeProps} onModelsFiltered={onModelsFiltered} />\n * </TreeWithHeader>\n * ```\n *\n *\n * @public\n */\nexport function useModelsTreeButtonProps({ imodel, viewport }: { imodel: IModelConnection; viewport: TreeWidgetViewport }): {\n buttonProps: Pick<ModelsTreeHeaderButtonProps, \"models\" | \"viewport\">;\n onModelsFiltered: (models: Id64String[] | undefined) => void;\n} {\n const [filteredModels, setFilteredModels] = useState<Id64String[] | undefined>();\n\n const models = useAvailableModels(imodel);\n const availableModels = useMemo(() => (!filteredModels ? models : models.filter((model) => filteredModels.includes(model.id))), [models, filteredModels]);\n return {\n buttonProps: {\n models: availableModels,\n viewport,\n },\n onModelsFiltered: setFilteredModels,\n };\n}\n\nfunction useAvailableModels(imodel: IModelConnection): ModelInfo[] {\n const [availableModels, setAvailableModels] = useState<ModelInfo[]>([]);\n\n useEffect(() => {\n queryModelsForHeaderActions(imodel)\n .then((modelInfos: ModelInfo[]) => {\n setAvailableModels(modelInfos);\n })\n .catch(() => {\n setAvailableModels([]);\n });\n }, [imodel]);\n\n return availableModels;\n}\n\nasync function queryModelsForHeaderActions(iModel: IModelConnection) {\n const queryParams: ModelQueryParams = {\n from: CLASS_NAME_GeometricModel3d,\n where: `\n EXISTS (\n SELECT 1\n FROM ${CLASS_NAME_Element} e\n WHERE e.ECClassId IS (${CLASS_NAME_GeometricElement3d}, ${CLASS_NAME_InformationPartitionElement})\n AND e.ECInstanceId = GeometricModel3d.ModeledElement.Id\n )\n `,\n wantPrivate: false,\n };\n\n const modelProps = await iModel.models.queryProps(queryParams);\n return modelProps.map(({ id, isPlanProjection }: GeometricModel3dProps) => ({ id, isPlanProjection })).filter(({ id }) => id) as ModelInfo[];\n}\n\n/** @public */\nexport type ModelsTreeHeaderButtonType = (props: ModelsTreeHeaderButtonProps) => React.ReactElement | null;\n\n/** @public */\nexport function ShowAllButton(props: ModelsTreeHeaderButtonProps) {\n const componentId = useGuid();\n return (\n <IconButton\n variant={\"ghost\"}\n label={TreeWidget.translate(\"modelsTree.buttons.showAll.tooltip\")}\n onClick={() => {\n // cspell:disable-next-line\n props.onFeatureUsed?.(\"models-tree-showall\");\n void showAll({\n models: props.models.map((model) => model.id),\n viewport: props.viewport,\n componentId,\n }).catch(() => {});\n }}\n icon={visibilityShowSvg}\n />\n );\n}\n\n/** @public */\nexport function HideAllButton(props: ModelsTreeHeaderButtonProps) {\n return (\n <IconButton\n variant={\"ghost\"}\n label={TreeWidget.translate(\"modelsTree.buttons.hideAll.tooltip\")}\n onClick={() => {\n // cspell:disable-next-line\n props.onFeatureUsed?.(\"models-tree-hideall\");\n hideAllModels(\n props.models.map((model) => model.id),\n props.viewport,\n );\n }}\n icon={visibilityHideSvg}\n />\n );\n}\n\n/** @public */\nexport function InvertButton(props: ModelsTreeHeaderButtonProps) {\n return (\n <IconButton\n variant={\"ghost\"}\n label={TreeWidget.translate(\"modelsTree.buttons.invert.tooltip\")}\n onClick={() => {\n props.onFeatureUsed?.(\"models-tree-invert\");\n invertAllModels(\n props.models.map((model) => model.id),\n props.viewport,\n );\n }}\n icon={visibilityInvertSvg}\n />\n );\n}\n\n/** @public */\nexport function View2DButton(props: ModelsTreeHeaderButtonProps) {\n const models2d = useMemo(() => {\n return props.models.filter((model) => model.isPlanProjection).map((model) => model.id);\n }, [props.models]);\n\n const [is2dToggleActive, setIs2dToggleActive] = useState(false);\n\n useEffect(() => {\n setIs2dToggleActive(areAllModelsVisible(models2d, props.viewport));\n return props.viewport.onDisplayedModelsChanged.addListener(() => setIs2dToggleActive(areAllModelsVisible(models2d, props.viewport)));\n }, [models2d, props.viewport]);\n\n return (\n <IconButton\n variant={\"ghost\"}\n label={TreeWidget.translate(\"modelsTree.buttons.toggle2d.tooltip\")}\n onClick={() => {\n props.onFeatureUsed?.(\"models-tree-view2d\");\n toggleModels(models2d, is2dToggleActive, props.viewport);\n }}\n aria-disabled={models2d.length === 0}\n active={is2dToggleActive}\n icon={toggle2DSvg}\n />\n );\n}\n\n/** @public */\nexport function View3DButton(props: ModelsTreeHeaderButtonProps) {\n const models3d = useMemo(() => {\n return props.models.filter((model) => !model.isPlanProjection).map((model) => model.id);\n }, [props.models]);\n\n const [is3dToggleActive, setIs3dToggleActive] = useState(false);\n\n useEffect(() => {\n setIs3dToggleActive(areAllModelsVisible(models3d, props.viewport));\n return props.viewport.onDisplayedModelsChanged.addListener(() => setIs3dToggleActive(areAllModelsVisible(models3d, props.viewport)));\n }, [models3d, props.viewport]);\n\n return (\n <IconButton\n variant={\"ghost\"}\n label={TreeWidget.translate(\"modelsTree.buttons.toggle3d.tooltip\")}\n onClick={() => {\n props.onFeatureUsed?.(\"models-tree-view3d\");\n toggleModels(models3d, is3dToggleActive, props.viewport);\n }}\n aria-disabled={models3d.length === 0}\n active={is3dToggleActive}\n icon={toggle3DSvg}\n />\n );\n}\n\n/** @public */\nexport function ToggleInstancesFocusButton({ onFeatureUsed, disabled }: { onFeatureUsed?: (feature: string) => void; disabled?: boolean }) {\n const { enabled, toggle } = useFocusedInstancesContext();\n const label = disabled\n ? TreeWidget.translate(\"modelsTree.buttons.toggleFocusMode.disabled.tooltip\")\n : enabled\n ? TreeWidget.translate(\"modelsTree.buttons.toggleFocusMode.disable.tooltip\")\n : TreeWidget.translate(\"modelsTree.buttons.toggleFocusMode.enable.tooltip\");\n return (\n <IconButton\n variant={\"ghost\"}\n label={label}\n onClick={() => {\n // cspell:disable-next-line\n onFeatureUsed?.(\"models-tree-instancesfocus\");\n toggle();\n }}\n aria-disabled={disabled}\n active={enabled}\n icon={focusModeSvg}\n />\n );\n}\n"]}
|
|
@@ -2,7 +2,7 @@ import type { TreeWidgetViewport } from "../common/TreeWidgetViewport.js";
|
|
|
2
2
|
import type { ModelsTreeProps } from "./ModelsTree.js";
|
|
3
3
|
import type { ModelsTreeHeaderButtonProps, ModelsTreeHeaderButtonType } from "./ModelsTreeButtons.js";
|
|
4
4
|
/** @public */
|
|
5
|
-
interface ModelsTreeComponentProps extends Pick<ModelsTreeProps, "selectionStorage" | "hierarchyLevelConfig" | "selectionMode" | "selectionPredicate" | "hierarchyConfig" | "visibilityHandlerOverrides" | "
|
|
5
|
+
interface ModelsTreeComponentProps extends Pick<ModelsTreeProps, "selectionStorage" | "hierarchyLevelConfig" | "selectionMode" | "selectionPredicate" | "hierarchyConfig" | "visibilityHandlerOverrides" | "getSearchPaths" | "searchText" | "emptyTreeContent" | "getInlineActions" | "getMenuActions" | "getContextMenuActions" | "getTreeItemProps" | "getSubTreePaths" | "treeLabel"> {
|
|
6
6
|
/**
|
|
7
7
|
* Renderers of header buttons. Defaults to:
|
|
8
8
|
* ```ts
|
|
@@ -72,7 +72,7 @@ ModelsTreeComponent.id = "models-tree-v2";
|
|
|
72
72
|
* @public
|
|
73
73
|
*/
|
|
74
74
|
ModelsTreeComponent.getLabel = () => TreeWidget.translate("modelsTree.label");
|
|
75
|
-
function ModelsTreeComponentImpl({ iModel, viewport, headerButtons, onFeatureUsed, onPerformanceMeasured,
|
|
75
|
+
function ModelsTreeComponentImpl({ iModel, viewport, headerButtons, onFeatureUsed, onPerformanceMeasured, searchText, treeLabel, ...treeProps }) {
|
|
76
76
|
const { buttonProps, onModelsFiltered } = useModelsTreeButtonProps({ imodel: iModel, viewport });
|
|
77
77
|
const { enabled: instanceFocusEnabled, toggle: toggleInstanceFocus } = useFocusedInstancesContext();
|
|
78
78
|
const buttons = headerButtons
|
|
@@ -83,13 +83,13 @@ function ModelsTreeComponentImpl({ iModel, viewport, headerButtons, onFeatureUse
|
|
|
83
83
|
_createElement(InvertButton, { ...buttonProps, key: "invert-all-btn", onFeatureUsed: onFeatureUsed }),
|
|
84
84
|
_createElement(View2DButton, { ...buttonProps, key: "view-2d-btn", onFeatureUsed: onFeatureUsed }),
|
|
85
85
|
_createElement(View3DButton, { ...buttonProps, key: "view-3d-btn", onFeatureUsed: onFeatureUsed }),
|
|
86
|
-
_jsx(ToggleInstancesFocusButton, { disabled:
|
|
86
|
+
_jsx(ToggleInstancesFocusButton, { disabled: searchText !== undefined, onFeatureUsed: onFeatureUsed }, "toggle-instances-focus-btn"),
|
|
87
87
|
];
|
|
88
88
|
useEffect(() => {
|
|
89
|
-
if (instanceFocusEnabled &&
|
|
89
|
+
if (instanceFocusEnabled && searchText !== undefined) {
|
|
90
90
|
toggleInstanceFocus();
|
|
91
91
|
}
|
|
92
|
-
}, [instanceFocusEnabled,
|
|
93
|
-
return (_jsx(TelemetryContextProvider, { componentIdentifier: ModelsTreeComponent.id, onFeatureUsed: onFeatureUsed, onPerformanceMeasured: onPerformanceMeasured, children: _jsx(SelectableTree, { buttons: buttons, children: _jsx(ModelsTree, { ...treeProps, imodel: iModel, activeView: viewport,
|
|
92
|
+
}, [instanceFocusEnabled, searchText, toggleInstanceFocus]);
|
|
93
|
+
return (_jsx(TelemetryContextProvider, { componentIdentifier: ModelsTreeComponent.id, onFeatureUsed: onFeatureUsed, onPerformanceMeasured: onPerformanceMeasured, children: _jsx(SelectableTree, { buttons: buttons, children: _jsx(ModelsTree, { ...treeProps, imodel: iModel, activeView: viewport, searchText: searchText, treeLabel: treeLabel, onModelsFiltered: onModelsFiltered }) }) }));
|
|
94
94
|
}
|
|
95
95
|
//# sourceMappingURL=ModelsTreeComponent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelsTreeComponent.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.tsx"],"names":[],"mappings":";;AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,+BAA+B,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AACnH,OAAO,EAAE,2BAA2B,EAAE,MAAM,mDAAmD,CAAC;AAChG,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EACL,aAAa,EACb,YAAY,EACZ,aAAa,EACb,0BAA0B,EAC1B,wBAAwB,EACxB,YAAY,EACZ,YAAY,GACb,MAAM,wBAAwB,CAAC;AAoDhC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,KAA+B,EAAE,EAAE;IACrE,MAAM,MAAM,GAAG,yBAAyB,EAAE,CAAC;IAC3C,MAAM,QAAQ,GAAG,2BAA2B,CAAC,EAAE,kBAAkB,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;IAErF,IAAI,CAAC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AAE,SAAS,EAAE,gBAAgB,EAAE,gBAAgB,GAAI,GAC9H,GACQ,CAC5B,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 { Fragment, useEffect } from \"react\";\nimport { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport { TreeWidget } from \"../../../TreeWidget.js\";\nimport { SelectableTree } from \"../../tree-header/SelectableTree.js\";\nimport { FocusedInstancesContextProvider, useFocusedInstancesContext } from \"../common/FocusedInstancesContext.js\";\nimport { useActiveTreeWidgetViewport } from \"../common/internal/UseActiveTreeWidgetViewport.js\";\nimport { TelemetryContextProvider } from \"../common/UseTelemetryContext.js\";\nimport { ModelsTree } from \"./ModelsTree.js\";\nimport {\n HideAllButton,\n InvertButton,\n ShowAllButton,\n ToggleInstancesFocusButton,\n useModelsTreeButtonProps,\n View2DButton,\n View3DButton,\n} from \"./ModelsTreeButtons.js\";\n\nimport type { ReactNode } from \"react\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport type { TreeWidgetViewport } from \"../common/TreeWidgetViewport.js\";\nimport type { ModelsTreeProps } from \"./ModelsTree.js\";\nimport type { ModelsTreeHeaderButtonProps, ModelsTreeHeaderButtonType } from \"./ModelsTreeButtons.js\";\n\n/** @public */\ninterface ModelsTreeComponentProps\n extends Pick<\n ModelsTreeProps,\n | \"selectionStorage\"\n | \"hierarchyLevelConfig\"\n | \"selectionMode\"\n | \"selectionPredicate\"\n | \"hierarchyConfig\"\n | \"visibilityHandlerOverrides\"\n | \"getFilteredPaths\"\n | \"filter\"\n | \"emptyTreeContent\"\n | \"getInlineActions\"\n | \"getMenuActions\"\n | \"getContextMenuActions\"\n | \"getDecorations\"\n | \"getSubTreePaths\"\n | \"treeLabel\"\n > {\n /**\n * Renderers of header buttons. Defaults to:\n * ```ts\n * [\n * ModelsTreeComponent.ShowAllButton,\n * ModelsTreeComponent.HideAllButton,\n * ModelsTreeComponent.InvertButton,\n * ModelsTreeComponent.View2DButton,\n * ModelsTreeComponent.View3DButton,\n * ModelsTreeComponent.ToggleInstancesFocusButton,\n * ]\n * ```\n */\n headerButtons?: Array<(props: ModelsTreeHeaderButtonProps) => React.ReactNode>;\n /**\n * Viewport used for visibility controls.\n *\n * When viewport is not provided, `IModelApp.viewManager.selectedView` will be used.\n */\n viewport?: TreeWidgetViewport;\n onPerformanceMeasured?: (featureId: string, duration: number) => void;\n onFeatureUsed?: (feature: string) => void;\n}\n\n/**\n * A component that renders `ModelsTree` and a header with filtering capabilities\n * and header buttons.\n *\n * @public\n */\nexport const ModelsTreeComponent = (props: ModelsTreeComponentProps) => {\n const iModel = useActiveIModelConnection();\n const viewport = useActiveTreeWidgetViewport({ treeWidgetViewport: props.viewport });\n\n if (!iModel || !viewport) {\n return null;\n }\n\n return (\n <FocusedInstancesContextProvider selectionStorage={props.selectionStorage} imodelKey={iModel.key}>\n <ModelsTreeComponentImpl {...props} iModel={iModel} viewport={viewport} />\n </FocusedInstancesContextProvider>\n );\n};\n\n/**\n * Renders a \"Show all\" button that enables display of all models.\n * @public\n */\nModelsTreeComponent.ShowAllButton = ShowAllButton as ModelsTreeHeaderButtonType;\n\n/**\n * Renders a \"Hide all\" button that disables display of all models.\n * @public\n */\nModelsTreeComponent.HideAllButton = HideAllButton as ModelsTreeHeaderButtonType;\n\n/**\n * Renders an \"Invert all\" button that inverts display of all models.\n * @public\n */\nModelsTreeComponent.InvertButton = InvertButton as ModelsTreeHeaderButtonType;\n\n/**\n * Renders a \"View 2D\" button that enables display of all plan projection models and disables all others.\n * @public\n */\nModelsTreeComponent.View2DButton = View2DButton as ModelsTreeHeaderButtonType;\n\n/**\n * Renders a \"View 3D\" button that enables display of all non-plan projection models and disables all plan projection ones.\n * @public\n */\nModelsTreeComponent.View3DButton = View3DButton as ModelsTreeHeaderButtonType;\n\n/**\n * Renders an \"Instance focus\" toggle button that enables/disables instances focusing mode.\n *\n * Requires instances focus context to be provided using `FocusedInstancesContextProvider`. The context\n * is provided automatically, when using `ModelsTreeComponent`, but needs to be provided by consumers\n * when rendering `ToggleInstancesFocusButton` outside of `ModelsTreeComponent`.\n *\n * @public\n */\nModelsTreeComponent.ToggleInstancesFocusButton = ToggleInstancesFocusButton as ModelsTreeHeaderButtonType;\n\n/**\n * Id of the component. May be used when a creating a `TreeDefinition` for `SelectableTree`.\n * @public\n */\nModelsTreeComponent.id = \"models-tree-v2\";\n\n/**\n * Label of the component. May be used when a creating a `TreeDefinition` for `SelectableTree`.\n * @public\n */\nModelsTreeComponent.getLabel = () => TreeWidget.translate(\"modelsTree.label\");\n\nfunction ModelsTreeComponentImpl({\n iModel,\n viewport,\n headerButtons,\n onFeatureUsed,\n onPerformanceMeasured,\n filter,\n treeLabel,\n ...treeProps\n}: ModelsTreeComponentProps & { iModel: IModelConnection; viewport: TreeWidgetViewport }) {\n const { buttonProps, onModelsFiltered } = useModelsTreeButtonProps({ imodel: iModel, viewport });\n const { enabled: instanceFocusEnabled, toggle: toggleInstanceFocus } = useFocusedInstancesContext();\n\n const buttons: ReactNode = headerButtons\n ? headerButtons.map((btn, index) => <Fragment key={index}>{btn({ ...buttonProps, onFeatureUsed })}</Fragment>)\n : [\n <ShowAllButton {...buttonProps} key=\"show-all-btn\" onFeatureUsed={onFeatureUsed} />,\n <HideAllButton {...buttonProps} key=\"hide-all-btn\" onFeatureUsed={onFeatureUsed} />,\n <InvertButton {...buttonProps} key=\"invert-all-btn\" onFeatureUsed={onFeatureUsed} />,\n <View2DButton {...buttonProps} key=\"view-2d-btn\" onFeatureUsed={onFeatureUsed} />,\n <View3DButton {...buttonProps} key=\"view-3d-btn\" onFeatureUsed={onFeatureUsed} />,\n <ToggleInstancesFocusButton disabled={filter !== undefined} key=\"toggle-instances-focus-btn\" onFeatureUsed={onFeatureUsed} />,\n ];\n\n useEffect(() => {\n if (instanceFocusEnabled && filter !== undefined) {\n toggleInstanceFocus();\n }\n }, [instanceFocusEnabled, filter, toggleInstanceFocus]);\n\n return (\n <TelemetryContextProvider componentIdentifier={ModelsTreeComponent.id} onFeatureUsed={onFeatureUsed} onPerformanceMeasured={onPerformanceMeasured}>\n <SelectableTree buttons={buttons}>\n <ModelsTree {...treeProps} imodel={iModel} activeView={viewport} filter={filter} treeLabel={treeLabel} onModelsFiltered={onModelsFiltered} />\n </SelectableTree>\n </TelemetryContextProvider>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ModelsTreeComponent.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.tsx"],"names":[],"mappings":";;AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,+BAA+B,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AACnH,OAAO,EAAE,2BAA2B,EAAE,MAAM,mDAAmD,CAAC;AAChG,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EACL,aAAa,EACb,YAAY,EACZ,aAAa,EACb,0BAA0B,EAC1B,wBAAwB,EACxB,YAAY,EACZ,YAAY,GACb,MAAM,wBAAwB,CAAC;AAoDhC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,KAA+B,EAAE,EAAE;IACrE,MAAM,MAAM,GAAG,yBAAyB,EAAE,CAAC;IAC3C,MAAM,QAAQ,GAAG,2BAA2B,CAAC,EAAE,kBAAkB,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAA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UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,gBAAgB,EAAE,gBAAgB,GAAI,GACtI,GACQ,CAC5B,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 { Fragment, useEffect } from \"react\";\nimport { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport { TreeWidget } from \"../../../TreeWidget.js\";\nimport { SelectableTree } from \"../../tree-header/SelectableTree.js\";\nimport { FocusedInstancesContextProvider, useFocusedInstancesContext } from \"../common/FocusedInstancesContext.js\";\nimport { useActiveTreeWidgetViewport } from \"../common/internal/UseActiveTreeWidgetViewport.js\";\nimport { TelemetryContextProvider } from \"../common/UseTelemetryContext.js\";\nimport { ModelsTree } from \"./ModelsTree.js\";\nimport {\n HideAllButton,\n InvertButton,\n ShowAllButton,\n ToggleInstancesFocusButton,\n useModelsTreeButtonProps,\n View2DButton,\n View3DButton,\n} from \"./ModelsTreeButtons.js\";\n\nimport type { ReactNode } from \"react\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport type { TreeWidgetViewport } from \"../common/TreeWidgetViewport.js\";\nimport type { ModelsTreeProps } from \"./ModelsTree.js\";\nimport type { ModelsTreeHeaderButtonProps, ModelsTreeHeaderButtonType } from \"./ModelsTreeButtons.js\";\n\n/** @public */\ninterface ModelsTreeComponentProps\n extends Pick<\n ModelsTreeProps,\n | \"selectionStorage\"\n | \"hierarchyLevelConfig\"\n | \"selectionMode\"\n | \"selectionPredicate\"\n | \"hierarchyConfig\"\n | \"visibilityHandlerOverrides\"\n | \"getSearchPaths\"\n | \"searchText\"\n | \"emptyTreeContent\"\n | \"getInlineActions\"\n | \"getMenuActions\"\n | \"getContextMenuActions\"\n | \"getTreeItemProps\"\n | \"getSubTreePaths\"\n | \"treeLabel\"\n > {\n /**\n * Renderers of header buttons. Defaults to:\n * ```ts\n * [\n * ModelsTreeComponent.ShowAllButton,\n * ModelsTreeComponent.HideAllButton,\n * ModelsTreeComponent.InvertButton,\n * ModelsTreeComponent.View2DButton,\n * ModelsTreeComponent.View3DButton,\n * ModelsTreeComponent.ToggleInstancesFocusButton,\n * ]\n * ```\n */\n headerButtons?: Array<(props: ModelsTreeHeaderButtonProps) => React.ReactNode>;\n /**\n * Viewport used for visibility controls.\n *\n * When viewport is not provided, `IModelApp.viewManager.selectedView` will be used.\n */\n viewport?: TreeWidgetViewport;\n onPerformanceMeasured?: (featureId: string, duration: number) => void;\n onFeatureUsed?: (feature: string) => void;\n}\n\n/**\n * A component that renders `ModelsTree` and a header with filtering capabilities\n * and header buttons.\n *\n * @public\n */\nexport const ModelsTreeComponent = (props: ModelsTreeComponentProps) => {\n const iModel = useActiveIModelConnection();\n const viewport = useActiveTreeWidgetViewport({ treeWidgetViewport: props.viewport });\n\n if (!iModel || !viewport) {\n return null;\n }\n\n return (\n <FocusedInstancesContextProvider selectionStorage={props.selectionStorage} imodelKey={iModel.key}>\n <ModelsTreeComponentImpl {...props} iModel={iModel} viewport={viewport} />\n </FocusedInstancesContextProvider>\n );\n};\n\n/**\n * Renders a \"Show all\" button that enables display of all models.\n * @public\n */\nModelsTreeComponent.ShowAllButton = ShowAllButton as ModelsTreeHeaderButtonType;\n\n/**\n * Renders a \"Hide all\" button that disables display of all models.\n * @public\n */\nModelsTreeComponent.HideAllButton = HideAllButton as ModelsTreeHeaderButtonType;\n\n/**\n * Renders an \"Invert all\" button that inverts display of all models.\n * @public\n */\nModelsTreeComponent.InvertButton = InvertButton as ModelsTreeHeaderButtonType;\n\n/**\n * Renders a \"View 2D\" button that enables display of all plan projection models and disables all others.\n * @public\n */\nModelsTreeComponent.View2DButton = View2DButton as ModelsTreeHeaderButtonType;\n\n/**\n * Renders a \"View 3D\" button that enables display of all non-plan projection models and disables all plan projection ones.\n * @public\n */\nModelsTreeComponent.View3DButton = View3DButton as ModelsTreeHeaderButtonType;\n\n/**\n * Renders an \"Instance focus\" toggle button that enables/disables instances focusing mode.\n *\n * Requires instances focus context to be provided using `FocusedInstancesContextProvider`. The context\n * is provided automatically, when using `ModelsTreeComponent`, but needs to be provided by consumers\n * when rendering `ToggleInstancesFocusButton` outside of `ModelsTreeComponent`.\n *\n * @public\n */\nModelsTreeComponent.ToggleInstancesFocusButton = ToggleInstancesFocusButton as ModelsTreeHeaderButtonType;\n\n/**\n * Id of the component. May be used when a creating a `TreeDefinition` for `SelectableTree`.\n * @public\n */\nModelsTreeComponent.id = \"models-tree-v2\";\n\n/**\n * Label of the component. May be used when a creating a `TreeDefinition` for `SelectableTree`.\n * @public\n */\nModelsTreeComponent.getLabel = () => TreeWidget.translate(\"modelsTree.label\");\n\nfunction ModelsTreeComponentImpl({\n iModel,\n viewport,\n headerButtons,\n onFeatureUsed,\n onPerformanceMeasured,\n searchText,\n treeLabel,\n ...treeProps\n}: ModelsTreeComponentProps & { iModel: IModelConnection; viewport: TreeWidgetViewport }) {\n const { buttonProps, onModelsFiltered } = useModelsTreeButtonProps({ imodel: iModel, viewport });\n const { enabled: instanceFocusEnabled, toggle: toggleInstanceFocus } = useFocusedInstancesContext();\n\n const buttons: ReactNode = headerButtons\n ? headerButtons.map((btn, index) => <Fragment key={index}>{btn({ ...buttonProps, onFeatureUsed })}</Fragment>)\n : [\n <ShowAllButton {...buttonProps} key=\"show-all-btn\" onFeatureUsed={onFeatureUsed} />,\n <HideAllButton {...buttonProps} key=\"hide-all-btn\" onFeatureUsed={onFeatureUsed} />,\n <InvertButton {...buttonProps} key=\"invert-all-btn\" onFeatureUsed={onFeatureUsed} />,\n <View2DButton {...buttonProps} key=\"view-2d-btn\" onFeatureUsed={onFeatureUsed} />,\n <View3DButton {...buttonProps} key=\"view-3d-btn\" onFeatureUsed={onFeatureUsed} />,\n <ToggleInstancesFocusButton disabled={searchText !== undefined} key=\"toggle-instances-focus-btn\" onFeatureUsed={onFeatureUsed} />,\n ];\n\n useEffect(() => {\n if (instanceFocusEnabled && searchText !== undefined) {\n toggleInstanceFocus();\n }\n }, [instanceFocusEnabled, searchText, toggleInstanceFocus]);\n\n return (\n <TelemetryContextProvider componentIdentifier={ModelsTreeComponent.id} onFeatureUsed={onFeatureUsed} onPerformanceMeasured={onPerformanceMeasured}>\n <SelectableTree buttons={buttons}>\n <ModelsTree {...treeProps} imodel={iModel} activeView={viewport} searchText={searchText} treeLabel={treeLabel} onModelsFiltered={onModelsFiltered} />\n </SelectableTree>\n </TelemetryContextProvider>\n );\n}\n"]}
|
|
@@ -2,7 +2,7 @@ import { ProcessedHierarchyNode } from "@itwin/presentation-hierarchies";
|
|
|
2
2
|
import type { GuidString, Id64String } from "@itwin/core-bentley";
|
|
3
3
|
import type { ClassGroupingNodeKey, DefineHierarchyLevelProps, GroupingHierarchyNode, HierarchyDefinition, HierarchyLevelDefinition, LimitingECSqlQueryExecutor } from "@itwin/presentation-hierarchies";
|
|
4
4
|
import type { ECClassHierarchyInspector, ECSchemaProvider, InstanceKey } from "@itwin/presentation-shared";
|
|
5
|
-
import type {
|
|
5
|
+
import type { NormalizedHierarchySearchPath } from "../common/Utils.js";
|
|
6
6
|
import type { ModelsTreeIdsCache } from "./internal/ModelsTreeIdsCache.js";
|
|
7
7
|
/** @beta */
|
|
8
8
|
export type ClassGroupingHierarchyNode = GroupingHierarchyNode & {
|
|
@@ -74,7 +74,7 @@ export declare class ModelsTreeDefinition implements HierarchyDefinition {
|
|
|
74
74
|
private createGeometricModel3dChildrenQuery;
|
|
75
75
|
private createSpatialCategoryChildrenQuery;
|
|
76
76
|
private createGeometricElement3dChildrenQuery;
|
|
77
|
-
static createInstanceKeyPaths(props: ModelsTreeInstanceKeyPathsProps): Promise<
|
|
77
|
+
static createInstanceKeyPaths(props: ModelsTreeInstanceKeyPathsProps): Promise<NormalizedHierarchySearchPath[]>;
|
|
78
78
|
private supportsFiltering;
|
|
79
79
|
private isSupported;
|
|
80
80
|
}
|