@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
|
@@ -5,129 +5,129 @@
|
|
|
5
5
|
import { firstValueFrom } from "rxjs";
|
|
6
6
|
import { assert } from "@itwin/core-bentley";
|
|
7
7
|
import { CLASS_NAME_SubCategory } from "../../../common/internal/ClassNameDefinitions.js";
|
|
8
|
-
import {
|
|
8
|
+
import { createSearchResultsTree, SearchResultsNodesHandler } from "../../../common/internal/visibility/BaseSearchResultsTree.js";
|
|
9
9
|
/** @internal */
|
|
10
|
-
export async function
|
|
11
|
-
const { imodelAccess,
|
|
12
|
-
return
|
|
13
|
-
|
|
10
|
+
export async function createCategoriesSearchResultsTree(props) {
|
|
11
|
+
const { imodelAccess, searchPaths, categoryClassName, categoryElementClassName, categoryModelClassName, idsCache } = props;
|
|
12
|
+
return createSearchResultsTree({
|
|
13
|
+
searchResultsNodesHandler: new CategoriesTreeSearchResultsNodesHandler({
|
|
14
14
|
idsCache,
|
|
15
15
|
imodelAccess,
|
|
16
16
|
categoryClassName,
|
|
17
17
|
categoryElementClassName,
|
|
18
18
|
categoryModelClassName,
|
|
19
19
|
}),
|
|
20
|
-
|
|
20
|
+
searchPaths,
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
|
-
class
|
|
23
|
+
class CategoriesTreeSearchResultsNodesHandler extends SearchResultsNodesHandler {
|
|
24
24
|
#props;
|
|
25
25
|
constructor(props) {
|
|
26
26
|
super();
|
|
27
27
|
this.#props = props;
|
|
28
28
|
}
|
|
29
|
-
async
|
|
30
|
-
const
|
|
29
|
+
async getProcessedSearchResultsNodes() {
|
|
30
|
+
const searchResultsTemporaryElements = new Map();
|
|
31
31
|
const result = {
|
|
32
|
-
|
|
32
|
+
searchResultsElements: new Map(),
|
|
33
33
|
};
|
|
34
|
-
this.
|
|
34
|
+
this.searchResultsNodesArr.forEach((node) => {
|
|
35
35
|
if (node.type === "element") {
|
|
36
|
-
|
|
36
|
+
searchResultsTemporaryElements.set(node.id, node);
|
|
37
37
|
}
|
|
38
38
|
});
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
const modelId =
|
|
39
|
+
const searchResultsElementsModels = await firstValueFrom(this.#props.idsCache.getFilteredElementsModels([...searchResultsTemporaryElements.keys()]));
|
|
40
|
+
searchResultsTemporaryElements.forEach((element, id) => {
|
|
41
|
+
const modelId = searchResultsElementsModels.get(element.id);
|
|
42
42
|
assert(modelId !== undefined);
|
|
43
|
-
result.
|
|
43
|
+
result.searchResultsElements.set(id, { ...element, modelId });
|
|
44
44
|
});
|
|
45
45
|
return result;
|
|
46
46
|
}
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
return this.
|
|
47
|
+
convertNodesToSearchTargets(searchResultsNodes, processedSearchResultsNodes) {
|
|
48
|
+
const searchTargets = {};
|
|
49
|
+
searchResultsNodes.forEach((searchResultsNode) => this.collectSearchTargets(searchTargets, searchResultsNode, processedSearchResultsNodes));
|
|
50
|
+
return this.convertInternalSearchTargets(searchTargets);
|
|
51
51
|
}
|
|
52
|
-
|
|
53
|
-
if (!
|
|
54
|
-
!
|
|
55
|
-
!
|
|
56
|
-
!
|
|
57
|
-
!
|
|
52
|
+
convertInternalSearchTargets(searchTargets) {
|
|
53
|
+
if (!searchTargets.categories &&
|
|
54
|
+
!searchTargets.definitionContainerIds &&
|
|
55
|
+
!searchTargets.elements &&
|
|
56
|
+
!searchTargets.modelIds &&
|
|
57
|
+
!searchTargets.subCategories) {
|
|
58
58
|
return undefined;
|
|
59
59
|
}
|
|
60
60
|
return {
|
|
61
|
-
categories:
|
|
62
|
-
? [...
|
|
61
|
+
categories: searchTargets.categories
|
|
62
|
+
? [...searchTargets.categories.entries()].map(([modelId, categoryIds]) => {
|
|
63
63
|
return { modelId, categoryIds };
|
|
64
64
|
})
|
|
65
65
|
: undefined,
|
|
66
|
-
elements:
|
|
67
|
-
? [...
|
|
66
|
+
elements: searchTargets.elements
|
|
67
|
+
? [...searchTargets.elements.entries()].map(([modelCategoryKey, elements]) => {
|
|
68
68
|
const { modelId, categoryId } = this.parseModelCategoryKey(modelCategoryKey);
|
|
69
69
|
return { modelId, categoryId, elements };
|
|
70
70
|
})
|
|
71
71
|
: undefined,
|
|
72
|
-
definitionContainerIds:
|
|
73
|
-
modelIds:
|
|
74
|
-
subCategories:
|
|
75
|
-
? [...
|
|
72
|
+
definitionContainerIds: searchTargets.definitionContainerIds,
|
|
73
|
+
modelIds: searchTargets.modelIds,
|
|
74
|
+
subCategories: searchTargets.subCategories
|
|
75
|
+
? [...searchTargets.subCategories.entries()].map(([categoryId, subCategoryIds]) => {
|
|
76
76
|
return { categoryId, subCategoryIds };
|
|
77
77
|
})
|
|
78
78
|
: undefined,
|
|
79
79
|
};
|
|
80
80
|
}
|
|
81
|
-
|
|
82
|
-
const
|
|
83
|
-
assert(
|
|
84
|
-
if (
|
|
85
|
-
this.addTarget(
|
|
81
|
+
collectSearchTargets(searchTargets, node, processedSearchResultsNodes) {
|
|
82
|
+
const searchResultsNode = node.type !== "element" ? node : processedSearchResultsNodes.searchResultsElements.get(node.id);
|
|
83
|
+
assert(searchResultsNode !== undefined);
|
|
84
|
+
if (searchResultsNode.isSearchTarget) {
|
|
85
|
+
this.addTarget(searchTargets, searchResultsNode);
|
|
86
86
|
return;
|
|
87
87
|
}
|
|
88
|
-
if (
|
|
89
|
-
// need to add parent ids as
|
|
90
|
-
this.addTarget(
|
|
88
|
+
if (searchResultsNode.type === "element") {
|
|
89
|
+
// need to add parent ids as search target will be an element
|
|
90
|
+
this.addTarget(searchTargets, searchResultsNode);
|
|
91
91
|
}
|
|
92
92
|
if (!node.children) {
|
|
93
93
|
return;
|
|
94
94
|
}
|
|
95
95
|
for (const child of node.children.values()) {
|
|
96
|
-
this.
|
|
96
|
+
this.collectSearchTargets(searchTargets, child, processedSearchResultsNodes);
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
|
-
addTarget(
|
|
99
|
+
addTarget(searchTargets, node) {
|
|
100
100
|
switch (node.type) {
|
|
101
101
|
case "definitionContainer":
|
|
102
|
-
(
|
|
102
|
+
(searchTargets.definitionContainerIds ??= new Set()).add(node.id);
|
|
103
103
|
return;
|
|
104
104
|
case "model":
|
|
105
|
-
(
|
|
105
|
+
(searchTargets.modelIds ??= new Set()).add(node.id);
|
|
106
106
|
return;
|
|
107
107
|
case "subCategory":
|
|
108
|
-
const subCategories = (
|
|
108
|
+
const subCategories = (searchTargets.subCategories ??= new Map()).get(node.categoryId);
|
|
109
109
|
if (subCategories) {
|
|
110
110
|
subCategories.add(node.id);
|
|
111
111
|
return;
|
|
112
112
|
}
|
|
113
|
-
|
|
113
|
+
searchTargets.subCategories.set(node.categoryId, new Set([node.id]));
|
|
114
114
|
return;
|
|
115
115
|
case "category":
|
|
116
|
-
const categories = (
|
|
116
|
+
const categories = (searchTargets.categories ??= new Map()).get(node.modelId);
|
|
117
117
|
if (!categories) {
|
|
118
118
|
categories.add(node.id);
|
|
119
119
|
return;
|
|
120
120
|
}
|
|
121
|
-
|
|
121
|
+
searchTargets.categories.set(node.modelId, new Set([node.id]));
|
|
122
122
|
return;
|
|
123
123
|
case "element":
|
|
124
124
|
const modelCategoryKey = this.createModelCategoryKey(node.modelId, node.categoryId);
|
|
125
|
-
const elements = (
|
|
125
|
+
const elements = (searchTargets.elements ??= new Map()).get(modelCategoryKey);
|
|
126
126
|
if (elements) {
|
|
127
|
-
elements.set(node.id, {
|
|
127
|
+
elements.set(node.id, { isSearchTarget: node.isSearchTarget });
|
|
128
128
|
}
|
|
129
129
|
else {
|
|
130
|
-
|
|
130
|
+
searchTargets.elements.set(modelCategoryKey, new Map([[node.id, { isSearchTarget: node.isSearchTarget }]]));
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
}
|
|
@@ -138,11 +138,11 @@ class CategoriesTreeFilteredNodesHandler extends FilteredNodesHandler {
|
|
|
138
138
|
const [modelId, categoryId] = key.split("-");
|
|
139
139
|
return { modelId, categoryId };
|
|
140
140
|
}
|
|
141
|
-
|
|
141
|
+
createSearchResultsTreeNode({ type, id, isSearchTarget, parent, }) {
|
|
142
142
|
if (type === "definitionContainer") {
|
|
143
143
|
return {
|
|
144
144
|
id,
|
|
145
|
-
|
|
145
|
+
isSearchTarget,
|
|
146
146
|
type,
|
|
147
147
|
};
|
|
148
148
|
}
|
|
@@ -150,7 +150,7 @@ class CategoriesTreeFilteredNodesHandler extends FilteredNodesHandler {
|
|
|
150
150
|
assert("id" in parent);
|
|
151
151
|
return {
|
|
152
152
|
id,
|
|
153
|
-
|
|
153
|
+
isSearchTarget,
|
|
154
154
|
type,
|
|
155
155
|
categoryId: parent.id,
|
|
156
156
|
};
|
|
@@ -159,14 +159,14 @@ class CategoriesTreeFilteredNodesHandler extends FilteredNodesHandler {
|
|
|
159
159
|
if ("type" in parent && parent.type === "model") {
|
|
160
160
|
return {
|
|
161
161
|
id,
|
|
162
|
-
|
|
162
|
+
isSearchTarget,
|
|
163
163
|
type,
|
|
164
164
|
modelId: parent.id,
|
|
165
165
|
};
|
|
166
166
|
}
|
|
167
167
|
return {
|
|
168
168
|
id,
|
|
169
|
-
|
|
169
|
+
isSearchTarget,
|
|
170
170
|
type,
|
|
171
171
|
};
|
|
172
172
|
}
|
|
@@ -174,7 +174,7 @@ class CategoriesTreeFilteredNodesHandler extends FilteredNodesHandler {
|
|
|
174
174
|
assert("id" in parent);
|
|
175
175
|
return {
|
|
176
176
|
id,
|
|
177
|
-
|
|
177
|
+
isSearchTarget,
|
|
178
178
|
type,
|
|
179
179
|
categoryId: parent.type === "category" ? parent.id : undefined,
|
|
180
180
|
};
|
|
@@ -183,7 +183,7 @@ class CategoriesTreeFilteredNodesHandler extends FilteredNodesHandler {
|
|
|
183
183
|
if (parent.type === "category") {
|
|
184
184
|
return {
|
|
185
185
|
id,
|
|
186
|
-
|
|
186
|
+
isSearchTarget,
|
|
187
187
|
type,
|
|
188
188
|
categoryId: parent.id,
|
|
189
189
|
modelId: undefined,
|
|
@@ -192,7 +192,7 @@ class CategoriesTreeFilteredNodesHandler extends FilteredNodesHandler {
|
|
|
192
192
|
assert(parent.type === "element");
|
|
193
193
|
return {
|
|
194
194
|
id,
|
|
195
|
-
|
|
195
|
+
isSearchTarget,
|
|
196
196
|
type,
|
|
197
197
|
categoryId: parent.categoryId,
|
|
198
198
|
modelId: undefined,
|
|
@@ -216,4 +216,4 @@ class CategoriesTreeFilteredNodesHandler extends FilteredNodesHandler {
|
|
|
216
216
|
return "definitionContainer";
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
|
-
//# sourceMappingURL=
|
|
219
|
+
//# sourceMappingURL=SearchResultsTree.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchResultsTree.js","sourceRoot":"","sources":["../../../../../../../../src/tree-widget-react/components/trees/categories-tree/internal/visibility/SearchResultsTree.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,kDAAkD,CAAC;AAC1F,OAAO,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,8DAA8D,CAAC;AAkElI,gBAAgB;AAChB,MAAM,CAAC,KAAK,UAAU,iCAAiC,CAAC,KAOvD;IACC,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAC3H,OAAO,uBAAuB,CAAC;QAC7B,yBAAyB,EAAE,IAAI,uCAAuC,CAAC;YACrE,QAAQ;YACR,YAAY;YACZ,iBAAiB;YACjB,wBAAwB;YACxB,sBAAsB;SACvB,CAAC;QACF,WAAW;KACZ,CAAC,CAAC;AACL,CAAC;AAwBD,MAAM,uCAAwC,SAAQ,yBAIrD;IACU,MAAM,CAA+C;IAC9D,YAAY,KAAmD;QAC7D,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAEM,KAAK,CAAC,8BAA8B;QACzC,MAAM,8BAA8B,GAAG,IAAI,GAAG,EAAmE,CAAC;QAClH,MAAM,MAAM,GAAgC;YAC1C,qBAAqB,EAAE,IAAI,GAAG,EAAE;SACjC,CAAC;QACF,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YAC1C,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;gBAC5B,8BAA8B,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AC/B,OAAO;oBACL,EAAE;oBACF,cAAc;oBACd,IAAI;oBACJ,UAAU,EAAE,MAAM,CAAC,EAAE;oBACrB,OAAO,EAAE,SAAS;iBACnB,CAAC;YACJ,CAAC;YACD,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;YAClC,OAAO;gBACL,EAAE;gBACF,cAAc;gBACd,IAAI;gBACJ,UAAU,EAAE,MAAM,CAAC,UAAU;gBAC7B,OAAO,EAAE,SAAS;aACnB,CAAC;QACJ,CAAC;QAED,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAC9C,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,SAAiB;QACpC,IAAI,MAAM,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,gBAAgB,CAAC,SAAS,EAAE,sBAAsB,CAAC,EAAE,CAAC;YACvF,OAAO,aAAa,CAAC;QACvB,CAAC;QACD,IAAI,MAAM,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,gBAAgB,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,wBAAwB,CAAC,EAAE,CAAC;YACrG,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,IAAI,MAAM,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,gBAAgB,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,EAAE,CAAC;YAC9F,OAAO,UAAU,CAAC;QACpB,CAAC;QACD,IAAI,MAAM,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,gBAAgB,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,sBAAsB,CAAC,EAAE,CAAC;YACnG,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,OAAO,qBAAqB,CAAC;IAC/B,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { firstValueFrom } from \"rxjs\";\nimport { assert } from \"@itwin/core-bentley\";\nimport { CLASS_NAME_SubCategory } from \"../../../common/internal/ClassNameDefinitions.js\";\nimport { createSearchResultsTree, SearchResultsNodesHandler } from \"../../../common/internal/visibility/BaseSearchResultsTree.js\";\n\nimport type { Id64Set, Id64String } from \"@itwin/core-bentley\";\nimport type { HierarchySearchPath } from \"@itwin/presentation-hierarchies\";\nimport type { ECClassHierarchyInspector } from \"@itwin/presentation-shared\";\nimport type { CategoryId, ElementId, ModelId, SubCategoryId } from \"../../../common/internal/Types.js\";\nimport type {\n BaseSearchResultsTreeNode,\n SearchResultsTree,\n SearchResultsTreeNodeChildren,\n SearchResultsTreeRootNode,\n} from \"../../../common/internal/visibility/BaseSearchResultsTree.js\";\nimport type { CategoriesTreeIdsCache } from \"../CategoriesTreeIdsCache.js\";\n\n/** @internal */\nexport interface CategoriesTreeSearchTargets {\n categories?: Array<{ modelId: Id64String | undefined; categoryIds: Id64Set }>;\n elements?: Array<{ modelId: Id64String; categoryId: Id64String; elements: Map<ElementId, { isSearchTarget: boolean }> }>;\n definitionContainerIds?: Id64Set;\n modelIds?: Id64Set;\n subCategories?: Array<{ categoryId: Id64String; subCategoryIds: Id64Set }>;\n}\n\ninterface CategorySearchResultsTreeNode extends BaseSearchResultsTreeNode<CategorySearchResultsTreeNode> {\n type: \"category\";\n modelId?: Id64String;\n}\n\ninterface ModelSearchResultsTreeNode extends BaseSearchResultsTreeNode<ModelSearchResultsTreeNode> {\n type: \"model\";\n categoryId?: Id64String;\n}\ninterface SubCategorySearchResultsTreeNode extends BaseSearchResultsTreeNode<SubCategorySearchResultsTreeNode> {\n type: \"subCategory\";\n categoryId: Id64String;\n}\n\ninterface DefinitionContainerSearchResultsTreeNode extends BaseSearchResultsTreeNode<DefinitionContainerSearchResultsTreeNode> {\n type: \"definitionContainer\";\n}\n\ninterface ElementSearchResultsTreeNode extends BaseSearchResultsTreeNode<ElementSearchResultsTreeNode> {\n type: \"element\";\n categoryId: Id64String;\n modelId: Id64String;\n}\n\ntype SearchResultsTreeNode =\n | DefinitionContainerSearchResultsTreeNode\n | SubCategorySearchResultsTreeNode\n | CategorySearchResultsTreeNode\n | ElementSearchResultsTreeNode\n | ModelSearchResultsTreeNode;\n\ntype TemporaryElementSearchResultsNode = Omit<ElementSearchResultsTreeNode, \"modelId\" | \"children\"> & {\n modelId: string | undefined;\n children?: SearchResultsTreeNodeChildren<TemporaryElementSearchResultsNode>;\n};\n\ntype TemporarySearchResultsTreeNode =\n | DefinitionContainerSearchResultsTreeNode\n | SubCategorySearchResultsTreeNode\n | CategorySearchResultsTreeNode\n | TemporaryElementSearchResultsNode\n | ModelSearchResultsTreeNode;\n\n/** @internal */\nexport async function createCategoriesSearchResultsTree(props: {\n imodelAccess: ECClassHierarchyInspector;\n searchPaths: HierarchySearchPath[];\n categoryClassName: string;\n categoryElementClassName: string;\n categoryModelClassName: string;\n idsCache: CategoriesTreeIdsCache;\n}): Promise<SearchResultsTree<CategoriesTreeSearchTargets>> {\n const { imodelAccess, searchPaths, categoryClassName, categoryElementClassName, categoryModelClassName, idsCache } = props;\n return createSearchResultsTree({\n searchResultsNodesHandler: new CategoriesTreeSearchResultsNodesHandler({\n idsCache,\n imodelAccess,\n categoryClassName,\n categoryElementClassName,\n categoryModelClassName,\n }),\n searchPaths,\n });\n}\n\ninterface SearchTargetsInternal {\n elements?: Map<ModelCategoryKey, Map<ElementId, { isSearchTarget: boolean }>>;\n categories?: Map<ModelId | undefined, Set<CategoryId>>;\n definitionContainerIds?: Id64Set;\n modelIds?: Id64Set;\n subCategories?: Map<CategoryId, Set<SubCategoryId>>;\n}\n\ninterface CategoriesTreeSearchResultsNodesHandlerProps {\n idsCache: CategoriesTreeIdsCache;\n imodelAccess: ECClassHierarchyInspector;\n categoryClassName: string;\n categoryElementClassName: string;\n categoryModelClassName: string;\n}\n\ntype ModelCategoryKey = `${ModelId}-${CategoryId}`;\n\ninterface ProcessedSearchResultsNodes {\n searchResultsElements: Map<Id64String, Omit<ElementSearchResultsTreeNode, \"children\">>;\n}\n\nclass CategoriesTreeSearchResultsNodesHandler extends SearchResultsNodesHandler<\n ProcessedSearchResultsNodes,\n CategoriesTreeSearchTargets,\n TemporarySearchResultsTreeNode\n> {\n readonly #props: CategoriesTreeSearchResultsNodesHandlerProps;\n constructor(props: CategoriesTreeSearchResultsNodesHandlerProps) {\n super();\n this.#props = props;\n }\n\n public async getProcessedSearchResultsNodes(): Promise<ProcessedSearchResultsNodes> {\n const searchResultsTemporaryElements = new Map<Id64String, Omit<TemporaryElementSearchResultsNode, \"children\">>();\n const result: ProcessedSearchResultsNodes = {\n searchResultsElements: new Map(),\n };\n this.searchResultsNodesArr.forEach((node) => {\n if (node.type === \"element\") {\n searchResultsTemporaryElements.set(node.id, node);\n }\n });\n\n const searchResultsElementsModels = await firstValueFrom(this.#props.idsCache.getFilteredElementsModels([...searchResultsTemporaryElements.keys()]));\n searchResultsTemporaryElements.forEach((element, id) => {\n const modelId = searchResultsElementsModels.get(element.id);\n assert(modelId !== undefined);\n result.searchResultsElements.set(id, { ...element, modelId });\n });\n return result;\n }\n\n public convertNodesToSearchTargets(\n searchResultsNodes: TemporarySearchResultsTreeNode[],\n processedSearchResultsNodes: ProcessedSearchResultsNodes,\n ): CategoriesTreeSearchTargets | undefined {\n const searchTargets: SearchTargetsInternal = {};\n\n searchResultsNodes.forEach((searchResultsNode) => this.collectSearchTargets(searchTargets, searchResultsNode, processedSearchResultsNodes));\n\n return this.convertInternalSearchTargets(searchTargets);\n }\n\n private convertInternalSearchTargets(searchTargets: SearchTargetsInternal): CategoriesTreeSearchTargets | undefined {\n if (\n !searchTargets.categories &&\n !searchTargets.definitionContainerIds &&\n !searchTargets.elements &&\n !searchTargets.modelIds &&\n !searchTargets.subCategories\n ) {\n return undefined;\n }\n return {\n categories: searchTargets.categories\n ? [...searchTargets.categories.entries()].map(([modelId, categoryIds]) => {\n return { modelId, categoryIds };\n })\n : undefined,\n elements: searchTargets.elements\n ? [...searchTargets.elements.entries()].map(([modelCategoryKey, elements]) => {\n const { modelId, categoryId } = this.parseModelCategoryKey(modelCategoryKey);\n return { modelId, categoryId, elements };\n })\n : undefined,\n definitionContainerIds: searchTargets.definitionContainerIds,\n modelIds: searchTargets.modelIds,\n subCategories: searchTargets.subCategories\n ? [...searchTargets.subCategories.entries()].map(([categoryId, subCategoryIds]) => {\n return { categoryId, subCategoryIds };\n })\n : undefined,\n };\n }\n\n private collectSearchTargets(\n searchTargets: SearchTargetsInternal,\n node: TemporarySearchResultsTreeNode,\n processedSearchResultsNodes: ProcessedSearchResultsNodes,\n ) {\n const searchResultsNode = node.type !== \"element\" ? node : processedSearchResultsNodes.searchResultsElements.get(node.id);\n assert(searchResultsNode !== undefined);\n if (searchResultsNode.isSearchTarget) {\n this.addTarget(searchTargets, searchResultsNode);\n return;\n }\n\n if (searchResultsNode.type === \"element\") {\n // need to add parent ids as search target will be an element\n this.addTarget(searchTargets, searchResultsNode);\n }\n\n if (!node.children) {\n return;\n }\n\n for (const child of node.children.values()) {\n this.collectSearchTargets(searchTargets, child, processedSearchResultsNodes);\n }\n }\n\n private addTarget(searchTargets: SearchTargetsInternal, node: SearchResultsTreeNode) {\n switch (node.type) {\n case \"definitionContainer\":\n (searchTargets.definitionContainerIds ??= new Set()).add(node.id);\n return;\n case \"model\":\n (searchTargets.modelIds ??= new Set()).add(node.id);\n return;\n case \"subCategory\":\n const subCategories = (searchTargets.subCategories ??= new Map()).get(node.categoryId);\n if (subCategories) {\n subCategories.add(node.id);\n return;\n }\n searchTargets.subCategories.set(node.categoryId, new Set([node.id]));\n return;\n case \"category\":\n const categories = (searchTargets.categories ??= new Map()).get(node.modelId);\n if (!categories) {\n categories.add(node.id);\n return;\n }\n searchTargets.categories.set(node.modelId, new Set([node.id]));\n return;\n case \"element\":\n const modelCategoryKey = this.createModelCategoryKey(node.modelId, node.categoryId);\n const elements = (searchTargets.elements ??= new Map()).get(modelCategoryKey);\n if (elements) {\n elements.set(node.id, { isSearchTarget: node.isSearchTarget });\n } else {\n searchTargets.elements.set(modelCategoryKey, new Map([[node.id, { isSearchTarget: node.isSearchTarget }]]));\n }\n }\n }\n\n private createModelCategoryKey(modelId: Id64String, categoryId: Id64String): ModelCategoryKey {\n return `${modelId}-${categoryId}`;\n }\n\n private parseModelCategoryKey(key: ModelCategoryKey): { modelId: Id64String; categoryId: Id64String } {\n const [modelId, categoryId] = key.split(\"-\");\n return { modelId, categoryId };\n }\n\n public createSearchResultsTreeNode({\n type,\n id,\n isSearchTarget,\n parent,\n }: {\n type: SearchResultsTreeNode[\"type\"];\n id: Id64String;\n isSearchTarget: boolean;\n parent: TemporarySearchResultsTreeNode | SearchResultsTreeRootNode<TemporarySearchResultsTreeNode>;\n }): TemporarySearchResultsTreeNode {\n if (type === \"definitionContainer\") {\n return {\n id,\n isSearchTarget,\n type,\n };\n }\n if (type === \"subCategory\") {\n assert(\"id\" in parent);\n return {\n id,\n isSearchTarget,\n type,\n categoryId: parent.id,\n };\n }\n if (type === \"category\") {\n if (\"type\" in parent && parent.type === \"model\") {\n return {\n id,\n isSearchTarget,\n type,\n modelId: parent.id,\n };\n }\n return {\n id,\n isSearchTarget,\n type,\n };\n }\n if (type === \"model\") {\n assert(\"id\" in parent);\n return {\n id,\n isSearchTarget,\n type,\n categoryId: parent.type === \"category\" ? parent.id : undefined,\n };\n }\n\n if (\"type\" in parent) {\n if (parent.type === \"category\") {\n return {\n id,\n isSearchTarget,\n type,\n categoryId: parent.id,\n modelId: undefined,\n };\n }\n assert(parent.type === \"element\");\n return {\n id,\n isSearchTarget,\n type,\n categoryId: parent.categoryId,\n modelId: undefined,\n };\n }\n\n throw new Error(\"Invalid parent node type\");\n }\n\n public async getType(className: string): Promise<TemporarySearchResultsTreeNode[\"type\"]> {\n if (await this.#props.imodelAccess.classDerivesFrom(className, CLASS_NAME_SubCategory)) {\n return \"subCategory\";\n }\n if (await this.#props.imodelAccess.classDerivesFrom(className, this.#props.categoryElementClassName)) {\n return \"element\";\n }\n if (await this.#props.imodelAccess.classDerivesFrom(className, this.#props.categoryClassName)) {\n return \"category\";\n }\n if (await this.#props.imodelAccess.classDerivesFrom(className, this.#props.categoryModelClassName)) {\n return \"model\";\n }\n return \"definitionContainer\";\n }\n}\n"]}
|
package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTree.d.ts
CHANGED
|
@@ -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 { UseClassificationsTreeProps } from "./UseClassificationsTree.js";
|
|
4
4
|
/** @alpha */
|
|
5
|
-
export type ClassificationsTreeProps = Pick<
|
|
5
|
+
export type ClassificationsTreeProps = Pick<ExtendedVisibilityTreeRendererProps, "getInlineActions" | "getMenuActions" | "getContextMenuActions" | "getTreeItemProps" | "getEditingProps" | "treeLabel"> & Pick<VisibilityTreeProps, "imodel" | "selectionStorage" | "selectionMode" | "emptyTreeContent"> & UseClassificationsTreeProps & {
|
|
6
6
|
hierarchyLevelConfig?: {
|
|
7
7
|
sizeLimit?: number;
|
|
8
8
|
};
|
|
9
9
|
};
|
|
10
10
|
/** @alpha */
|
|
11
|
-
export declare function ClassificationsTree({ imodel, selectionStorage, activeView, hierarchyConfig, hierarchyLevelConfig, selectionMode, emptyTreeContent,
|
|
11
|
+
export declare function ClassificationsTree({ imodel, selectionStorage, activeView, hierarchyConfig, hierarchyLevelConfig, selectionMode, emptyTreeContent, getTreeItemProps, getInlineActions, getMenuActions, getContextMenuActions, getEditingProps, searchText, treeLabel, }: ClassificationsTreeProps): import("react/jsx-runtime").JSX.Element;
|
|
12
12
|
//# sourceMappingURL=ClassificationsTree.d.ts.map
|
package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTree.js
CHANGED
|
@@ -7,13 +7,14 @@ import { VisibilityTree } from "../common/components/VisibilityTree.js";
|
|
|
7
7
|
import { VisibilityTreeRenderer } from "../common/components/VisibilityTreeRenderer.js";
|
|
8
8
|
import { useClassificationsTree } from "./UseClassificationsTree.js";
|
|
9
9
|
/** @alpha */
|
|
10
|
-
export function ClassificationsTree({ imodel, selectionStorage, activeView, hierarchyConfig, hierarchyLevelConfig, selectionMode, emptyTreeContent,
|
|
11
|
-
const
|
|
10
|
+
export function ClassificationsTree({ imodel, selectionStorage, activeView, hierarchyConfig, hierarchyLevelConfig, selectionMode, emptyTreeContent, getTreeItemProps, getInlineActions, getMenuActions, getContextMenuActions, getEditingProps, searchText, treeLabel, }) {
|
|
11
|
+
const classificationsTree = useClassificationsTree({
|
|
12
12
|
activeView,
|
|
13
13
|
hierarchyConfig,
|
|
14
14
|
emptyTreeContent,
|
|
15
|
-
|
|
15
|
+
searchText,
|
|
16
|
+
getTreeItemProps,
|
|
16
17
|
});
|
|
17
|
-
return (_jsx(VisibilityTree, { ...
|
|
18
|
+
return (_jsx(VisibilityTree, { ...classificationsTree.treeProps, imodel: imodel, selectionStorage: selectionStorage, hierarchyLevelSizeLimit: hierarchyLevelConfig?.sizeLimit, selectionMode: selectionMode ?? "none", treeRenderer: (treeProps) => (_jsx(VisibilityTreeRenderer, { ...treeProps, treeLabel: treeLabel, getEditingProps: getEditingProps, getInlineActions: getInlineActions ? (node) => getInlineActions(node, treeProps) : undefined, getMenuActions: getMenuActions ? (node) => getMenuActions(node, treeProps) : undefined, getContextMenuActions: getContextMenuActions ? (node) => getContextMenuActions(node, treeProps) : undefined, getTreeItemProps: (node) => classificationsTree.getTreeItemProps(node, treeProps) })) }));
|
|
18
19
|
}
|
|
19
20
|
//# sourceMappingURL=ClassificationsTree.js.map
|
package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTree.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClassificationsTree.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/classifications-tree/ClassificationsTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AACxF,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"ClassificationsTree.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/classifications-tree/ClassificationsTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AACxF,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAkBrE,aAAa;AACb,MAAM,UAAU,mBAAmB,CAAC,EAClC,MAAM,EACN,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,oBAAoB,EACpB,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,qBAAqB,EACrB,eAAe,EACf,UAAU,EACV,SAAS,GACgB;IACzB,MAAM,mBAAmB,GAAG,sBAAsB,CAAC;QACjD,UAAU;QACV,eAAe;QACf,gBAAgB;QAChB,UAAU;QACV,gBAAgB;KACjB,CAAC,CAAC;IAEH,OAAO,CACL,KAAC,cAAc,OACT,mBAAmB,CAAC,SAAS,EACjC,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,gBAAgB,EAClC,uBAAuB,EAAE,oBAAoB,EAAE,SAAS,EACxD,aAAa,EAAE,aAAa,IAAI,MAAM,EACtC,YAAY,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,CAC3B,KAAC,sBAAsB,OACjB,SAAS,EACb,SAAS,EAAE,SAAS,EACpB,eAAe,EAAE,eAAe,EAChC,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,mBAAmB,CAAC,gBAAgB,CAAC,IAAI,EAAE,SAAS,CAAC,GACjF,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 { useClassificationsTree } from \"./UseClassificationsTree.js\";\n\nimport type { VisibilityTreeProps } from \"../common/components/VisibilityTree.js\";\nimport type { ExtendedVisibilityTreeRendererProps } from \"../common/components/VisibilityTreeRenderer.js\";\nimport type { UseClassificationsTreeProps } from \"./UseClassificationsTree.js\";\n\n/** @alpha */\nexport type ClassificationsTreeProps = Pick<\n ExtendedVisibilityTreeRendererProps,\n \"getInlineActions\" | \"getMenuActions\" | \"getContextMenuActions\" | \"getTreeItemProps\" | \"getEditingProps\" | \"treeLabel\"\n> &\n Pick<VisibilityTreeProps, \"imodel\" | \"selectionStorage\" | \"selectionMode\" | \"emptyTreeContent\"> &\n UseClassificationsTreeProps & {\n hierarchyLevelConfig?: {\n sizeLimit?: number;\n };\n };\n\n/** @alpha */\nexport function ClassificationsTree({\n imodel,\n selectionStorage,\n activeView,\n hierarchyConfig,\n hierarchyLevelConfig,\n selectionMode,\n emptyTreeContent,\n getTreeItemProps,\n getInlineActions,\n getMenuActions,\n getContextMenuActions,\n getEditingProps,\n searchText,\n treeLabel,\n}: ClassificationsTreeProps) {\n const classificationsTree = useClassificationsTree({\n activeView,\n hierarchyConfig,\n emptyTreeContent,\n searchText,\n getTreeItemProps,\n });\n\n return (\n <VisibilityTree\n {...classificationsTree.treeProps}\n imodel={imodel}\n selectionStorage={selectionStorage}\n hierarchyLevelSizeLimit={hierarchyLevelConfig?.sizeLimit}\n selectionMode={selectionMode ?? \"none\"}\n treeRenderer={(treeProps) => (\n <VisibilityTreeRenderer\n {...treeProps}\n treeLabel={treeLabel}\n getEditingProps={getEditingProps}\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) => classificationsTree.getTreeItemProps(node, treeProps)}\n />\n )}\n />\n );\n}\n"]}
|
|
@@ -2,7 +2,7 @@ import type { IModelConnection } from "@itwin/core-frontend";
|
|
|
2
2
|
import type { TreeWidgetViewport } from "../common/TreeWidgetViewport.js";
|
|
3
3
|
import type { ClassificationsTreeProps } from "./ClassificationsTree.js";
|
|
4
4
|
/** @alpha */
|
|
5
|
-
interface ClassificationsTreeComponentProps extends Pick<ClassificationsTreeProps, "selectionStorage" | "hierarchyLevelConfig" | "selectionMode" | "
|
|
5
|
+
interface ClassificationsTreeComponentProps extends Pick<ClassificationsTreeProps, "selectionStorage" | "hierarchyLevelConfig" | "selectionMode" | "searchText" | "emptyTreeContent" | "getInlineActions" | "getMenuActions" | "getContextMenuActions" | "getTreeItemProps" | "hierarchyConfig" | "getEditingProps" | "treeLabel"> {
|
|
6
6
|
/**
|
|
7
7
|
* Viewport used for visibility controls.
|
|
8
8
|
*
|
|
@@ -41,7 +41,7 @@ ClassificationsTreeComponent.isSupportedByIModel = async (imodel) => {
|
|
|
41
41
|
return false;
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
|
-
function ClassificationsTreeComponentImpl({ iModel, viewport, onPerformanceMeasured, onFeatureUsed,
|
|
45
|
-
return (_jsx(TelemetryContextProvider, { componentIdentifier: ClassificationsTreeComponent.id, onFeatureUsed: onFeatureUsed, onPerformanceMeasured: onPerformanceMeasured, children: _jsx(SelectableTree, { children: _jsx(ClassificationsTree, { ...treeProps, imodel: iModel, activeView: viewport,
|
|
44
|
+
function ClassificationsTreeComponentImpl({ iModel, viewport, onPerformanceMeasured, onFeatureUsed, searchText, treeLabel, ...treeProps }) {
|
|
45
|
+
return (_jsx(TelemetryContextProvider, { componentIdentifier: ClassificationsTreeComponent.id, onFeatureUsed: onFeatureUsed, onPerformanceMeasured: onPerformanceMeasured, children: _jsx(SelectableTree, { children: _jsx(ClassificationsTree, { ...treeProps, imodel: iModel, activeView: viewport, searchText: searchText, treeLabel: treeLabel }) }) }));
|
|
46
46
|
}
|
|
47
47
|
//# sourceMappingURL=ClassificationsTreeComponent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClassificationsTreeComponent.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeComponent.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,2BAA2B,EAAE,MAAM,mDAAmD,CAAC;AAChG,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAiC/D;;;GAGG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,KAAwC,EAAE,EAAE;IACvF,MAAM,MAAM,GAAG,yBAAyB,EAAE,CAAC;IAC3C,MAAM,QAAQ,GAAG,2BAA2B,CAAC,EAAE,kBAAkB,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;IAErF,IAAI,CAAC,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,KAAC,gCAAgC,OAAK,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAI,CAAC;AAC7F,CAAC,CAAC;AAEF;;;GAGG;AACH,4BAA4B,CAAC,EAAE,GAAG,sBAAsB,CAAC;AAEzD;;;GAGG;AACH,4BAA4B,CAAC,QAAQ,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,2BAA2B,CAAC,CAAC;AAEhG,aAAa;AACb,4BAA4B,CAAC,mBAAmB,GAAG,KAAK,EAAE,MAAwB,EAAE,EAAE;IACpF,IAAI,CAAC;QACH,OAAO,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,aAAa,CAAC,aAAa,CAAC,IAAI,SAAS,CAAC,uBAAuB,CAAC,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC;IACtH,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC,CAAC;AAEF,SAAS,gCAAgC,CAAC,EACxC,MAAM,EACN,QAAQ,EACR,qBAAqB,EACrB,aAAa,EACb,
|
|
1
|
+
{"version":3,"file":"ClassificationsTreeComponent.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeComponent.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,SA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F,SAAS,gCAAgC,CAAC,EACxC,MAAM,EACN,QAAQ,EACR,qBAAqB,EACrB,aAAa,EACb,UAAU,EACV,SAAS,EACT,GAAG,SAAS,EACmF;IAC/F,OAAO,CACL,KAAC,wBAAwB,IAAC,mBAAmB,EAAE,4BAA4B,CAAC,EAAE,EAAE,aAAa,EAAE,aAAa,EAAE,qBAAqB,EAAE,qBAAqB,YACxJ,KAAC,cAAc,cACb,KAAC,mBAAmB,OAAK,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,GAAI,GAC3G,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 { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport { SchemaKey, SchemaMatchType } from \"@itwin/ecschema-metadata\";\nimport { TreeWidget } from \"../../../TreeWidget.js\";\nimport { SelectableTree } from \"../../tree-header/SelectableTree.js\";\nimport { useActiveTreeWidgetViewport } from \"../common/internal/UseActiveTreeWidgetViewport.js\";\nimport { TelemetryContextProvider } from \"../common/UseTelemetryContext.js\";\nimport { ClassificationsTree } from \"./ClassificationsTree.js\";\n\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport type { TreeWidgetViewport } from \"../common/TreeWidgetViewport.js\";\nimport type { ClassificationsTreeProps } from \"./ClassificationsTree.js\";\n\n/** @alpha */\ninterface ClassificationsTreeComponentProps\n extends Pick<\n ClassificationsTreeProps,\n | \"selectionStorage\"\n | \"hierarchyLevelConfig\"\n | \"selectionMode\"\n | \"searchText\"\n | \"emptyTreeContent\"\n | \"getInlineActions\"\n | \"getMenuActions\"\n | \"getContextMenuActions\"\n | \"getTreeItemProps\"\n | \"hierarchyConfig\"\n | \"getEditingProps\"\n | \"treeLabel\"\n > {\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 `ClassificationsTree` with active iModel and viewport.\n * @alpha\n */\nexport const ClassificationsTreeComponent = (props: ClassificationsTreeComponentProps) => {\n const iModel = useActiveIModelConnection();\n const viewport = useActiveTreeWidgetViewport({ treeWidgetViewport: props.viewport });\n\n if (!iModel || !viewport) {\n return null;\n }\n\n return <ClassificationsTreeComponentImpl {...props} iModel={iModel} viewport={viewport} />;\n};\n\n/**\n * Id of the component. May be used when a creating a `TreeDefinition`.\n * @alpha\n */\nClassificationsTreeComponent.id = \"classifications-tree\";\n\n/**\n * Label of the component. May be used when a creating a `TreeDefinition`.\n * @alpha\n */\nClassificationsTreeComponent.getLabel = () => TreeWidget.translate(\"classificationsTree.label\");\n\n/** @alpha */\nClassificationsTreeComponent.isSupportedByIModel = async (imodel: IModelConnection) => {\n try {\n return !!(await imodel.schemaContext.getSchemaInfo(new SchemaKey(\"ClassificationSystems\"), SchemaMatchType.Latest));\n } catch {\n return false;\n }\n};\n\nfunction ClassificationsTreeComponentImpl({\n iModel,\n viewport,\n onPerformanceMeasured,\n onFeatureUsed,\n searchText,\n treeLabel,\n ...treeProps\n}: ClassificationsTreeComponentProps & { iModel: IModelConnection; viewport: TreeWidgetViewport }) {\n return (\n <TelemetryContextProvider componentIdentifier={ClassificationsTreeComponent.id} onFeatureUsed={onFeatureUsed} onPerformanceMeasured={onPerformanceMeasured}>\n <SelectableTree>\n <ClassificationsTree {...treeProps} imodel={iModel} activeView={viewport} searchText={searchText} treeLabel={treeLabel} />\n </SelectableTree>\n </TelemetryContextProvider>\n );\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { GuidString } from "@itwin/core-bentley";
|
|
2
2
|
import type { DefineHierarchyLevelProps, HierarchyDefinition, HierarchyLevelDefinition, LimitingECSqlQueryExecutor } from "@itwin/presentation-hierarchies";
|
|
3
3
|
import type { ECClassHierarchyInspector, ECSchemaProvider, InstanceKey } from "@itwin/presentation-shared";
|
|
4
|
-
import type {
|
|
4
|
+
import type { NormalizedHierarchySearchPath } from "../common/Utils.js";
|
|
5
5
|
import type { ClassificationsTreeIdsCache } from "./internal/ClassificationsTreeIdsCache.js";
|
|
6
6
|
interface ClassificationsTreeDefinitionProps {
|
|
7
7
|
imodelAccess: ECSchemaProvider & ECClassHierarchyInspector & LimitingECSqlQueryExecutor & {
|
|
@@ -39,7 +39,7 @@ export declare class ClassificationsTreeDefinition implements HierarchyDefinitio
|
|
|
39
39
|
#private;
|
|
40
40
|
constructor(props: ClassificationsTreeDefinitionProps);
|
|
41
41
|
defineHierarchyLevel(props: DefineHierarchyLevelProps): Promise<HierarchyLevelDefinition>;
|
|
42
|
-
static createInstanceKeyPaths(props: ClassificationsTreeInstanceKeyPathsFromInstanceLabelProps | ClassificationsTreeInstanceKeyPathsFromInstanceKeysProps): Promise<
|
|
42
|
+
static createInstanceKeyPaths(props: ClassificationsTreeInstanceKeyPathsFromInstanceLabelProps | ClassificationsTreeInstanceKeyPathsFromInstanceKeysProps): Promise<NormalizedHierarchySearchPath[]>;
|
|
43
43
|
}
|
|
44
44
|
export {};
|
|
45
45
|
//# sourceMappingURL=ClassificationsTreeDefinition.d.ts.map
|
|
@@ -7,9 +7,10 @@ import { Guid } from "@itwin/core-bentley";
|
|
|
7
7
|
import { createNodesQueryClauseFactory, createPredicateBasedHierarchyDefinition } from "@itwin/presentation-hierarchies";
|
|
8
8
|
import { createBisInstanceLabelSelectClauseFactory, ECSql, parseFullClassName } from "@itwin/presentation-shared";
|
|
9
9
|
import { CLASS_NAME_Classification, CLASS_NAME_ClassificationSystem, CLASS_NAME_ClassificationTable, CLASS_NAME_Element, CLASS_NAME_ElementHasClassifications, CLASS_NAME_GeometricElement, CLASS_NAME_GeometricElement2d, CLASS_NAME_GeometricElement3d, } from "../common/internal/ClassNameDefinitions.js";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
10
|
+
import { catchBeSQLiteInterrupts } from "../common/internal/UseErrorState.js";
|
|
11
|
+
import { fromWithRelease, getOptimalBatchSize, releaseMainThreadOnItemsCount } from "../common/internal/Utils.js";
|
|
12
|
+
import { SearchLimitExceededError } from "../common/TreeErrors.js";
|
|
13
|
+
const MAX_SEARCH_INSTANCE_KEY_COUNT = 100;
|
|
13
14
|
/** @internal */
|
|
14
15
|
export class ClassificationsTreeDefinition {
|
|
15
16
|
#impl;
|
|
@@ -426,7 +427,7 @@ function createInstanceKeyPathsFromInstanceLabelObs({ label, ...props }) {
|
|
|
426
427
|
`
|
|
427
428
|
: ""}
|
|
428
429
|
)
|
|
429
|
-
${props.limit === undefined ? `LIMIT ${
|
|
430
|
+
${props.limit === undefined ? `LIMIT ${MAX_SEARCH_INSTANCE_KEY_COUNT + 1}` : props.limit !== "unbounded" ? `LIMIT ${props.limit}` : ""}
|
|
430
431
|
`;
|
|
431
432
|
const bindings = [
|
|
432
433
|
{ type: "string", value: adjustedLabel },
|
|
@@ -439,7 +440,7 @@ function createInstanceKeyPathsFromInstanceLabelObs({ label, ...props }) {
|
|
|
439
440
|
: []),
|
|
440
441
|
];
|
|
441
442
|
return { ctes, ecsql, bindings };
|
|
442
|
-
}).pipe(mergeMap((queryProps) => props.imodelAccess.createQueryReader(queryProps, { restartToken: `${props.componentName}/${props.componentId}/filter-by-label`, limit: props.limit })), map((row) => {
|
|
443
|
+
}).pipe(mergeMap((queryProps) => props.imodelAccess.createQueryReader(queryProps, { restartToken: `${props.componentName}/${props.componentId}/filter-by-label`, limit: props.limit })), catchBeSQLiteInterrupts, map((row) => {
|
|
443
444
|
let className;
|
|
444
445
|
switch (row.ClassName) {
|
|
445
446
|
case "ct":
|
|
@@ -462,11 +463,11 @@ function createInstanceKeyPathsFromInstanceLabelObs({ label, ...props }) {
|
|
|
462
463
|
}), toArray(), mergeMap((targetKeys) => createInstanceKeyPathsFromTargetItemsObs({ ...props, targetItems: targetKeys })));
|
|
463
464
|
}
|
|
464
465
|
function createInstanceKeyPathsFromTargetItemsObs({ idsCache, imodelAccess, limit, componentId, targetItems, componentName, }) {
|
|
465
|
-
const actualLimit = limit ??
|
|
466
|
+
const actualLimit = limit ?? MAX_SEARCH_INSTANCE_KEY_COUNT;
|
|
466
467
|
if (actualLimit !== "unbounded" && targetItems.length > actualLimit) {
|
|
467
|
-
throw new
|
|
468
|
+
throw new SearchLimitExceededError(actualLimit);
|
|
468
469
|
}
|
|
469
|
-
return
|
|
470
|
+
return fromWithRelease({ source: targetItems, releaseOnCount: 2000 }).pipe(mergeMap(async (key) => {
|
|
470
471
|
if (await imodelAccess.classDerivesFrom(key.className, CLASS_NAME_ClassificationTable)) {
|
|
471
472
|
return { id: key.id, type: 0 };
|
|
472
473
|
}
|
|
@@ -542,7 +543,7 @@ function createGeometricElementInstanceKeyPaths(props) {
|
|
|
542
543
|
WHERE e.ParentId IS NULL
|
|
543
544
|
`;
|
|
544
545
|
return imodelAccess.createQueryReader({ ctes, ecsql }, { rowFormat: "ECSqlPropertyNames", limit: "unbounded", restartToken: `${componentName}/${componentId}/elements${type}-filter-paths/${chunkIndex}` });
|
|
545
|
-
}).pipe(releaseMainThreadOnItemsCount(300), map((row) => parseQueryRow(row, separator)), mergeMap(({ path, parentClassificationId }) => {
|
|
546
|
+
}).pipe(catchBeSQLiteInterrupts, releaseMainThreadOnItemsCount(300), map((row) => parseQueryRow(row, separator)), mergeMap(({ path, parentClassificationId }) => {
|
|
546
547
|
if (parentClassificationId) {
|
|
547
548
|
return idsCache
|
|
548
549
|
.getClassificationsPathObs(parentClassificationId)
|