@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,58 +5,58 @@
|
|
|
5
5
|
import { useEffect, useMemo, useState } from "react";
|
|
6
6
|
import { firstValueFrom } from "rxjs";
|
|
7
7
|
import { assert } from "@itwin/core-bentley";
|
|
8
|
-
import {
|
|
8
|
+
import { HierarchyNodeIdentifier, HierarchySearchPath } from "@itwin/presentation-hierarchies";
|
|
9
9
|
import { CLASS_NAME_DefinitionContainer, CLASS_NAME_SubCategory } from "../../common/internal/ClassNameDefinitions.js";
|
|
10
10
|
import { getClassesByView } from "../../common/internal/Utils.js";
|
|
11
|
-
import {
|
|
11
|
+
import { SearchLimitExceededError } from "../../common/TreeErrors.js";
|
|
12
12
|
import { useTelemetryContext } from "../../common/UseTelemetryContext.js";
|
|
13
13
|
import { CategoriesTreeDefinition } from "../CategoriesTreeDefinition.js";
|
|
14
14
|
/** @internal */
|
|
15
|
-
export function
|
|
16
|
-
const [
|
|
15
|
+
export function useSearchPaths({ searchText, viewType, hierarchyConfiguration, getCategoriesTreeIdsCache, onCategoriesFiltered, onSearchPathsChanged, componentId, }) {
|
|
16
|
+
const [searchError, setSearchError] = useState();
|
|
17
17
|
const { onFeatureUsed } = useTelemetryContext();
|
|
18
18
|
useEffect(() => {
|
|
19
|
-
|
|
19
|
+
setSearchError(undefined);
|
|
20
20
|
onCategoriesFiltered?.({ categories: undefined, models: undefined });
|
|
21
|
-
if (!
|
|
22
|
-
|
|
21
|
+
if (!searchText) {
|
|
22
|
+
onSearchPathsChanged(undefined);
|
|
23
23
|
}
|
|
24
|
-
}, [
|
|
25
|
-
const
|
|
26
|
-
if (!
|
|
24
|
+
}, [searchText, onCategoriesFiltered, onSearchPathsChanged]);
|
|
25
|
+
const getSearchPaths = useMemo(() => {
|
|
26
|
+
if (!searchText) {
|
|
27
27
|
return undefined;
|
|
28
28
|
}
|
|
29
29
|
return async ({ imodelAccess, abortSignal }) => {
|
|
30
|
-
onFeatureUsed({ featureId: "
|
|
30
|
+
onFeatureUsed({ featureId: "search", reportInteraction: true });
|
|
31
31
|
try {
|
|
32
32
|
const paths = await CategoriesTreeDefinition.createInstanceKeyPaths({
|
|
33
33
|
imodelAccess,
|
|
34
34
|
abortSignal,
|
|
35
|
-
label:
|
|
35
|
+
label: searchText,
|
|
36
36
|
viewType,
|
|
37
37
|
idsCache: getCategoriesTreeIdsCache(),
|
|
38
38
|
hierarchyConfig: hierarchyConfiguration,
|
|
39
39
|
componentId,
|
|
40
40
|
});
|
|
41
|
-
|
|
41
|
+
onSearchPathsChanged(paths);
|
|
42
42
|
const { elementClass, modelClass } = getClassesByView(viewType);
|
|
43
43
|
onCategoriesFiltered?.(await getCategoriesFromPaths(paths, getCategoriesTreeIdsCache(), elementClass, modelClass, hierarchyConfiguration));
|
|
44
44
|
return paths;
|
|
45
45
|
}
|
|
46
46
|
catch (e) {
|
|
47
|
-
const newError = e instanceof
|
|
48
|
-
if (newError !== "
|
|
47
|
+
const newError = e instanceof SearchLimitExceededError ? "tooManySearchMatches" : "unknownSearchError";
|
|
48
|
+
if (newError !== "tooManySearchMatches") {
|
|
49
49
|
const feature = e instanceof Error && e.message.includes("query too long to execute or server is too busy") ? "error-timeout" : "error-unknown";
|
|
50
50
|
onFeatureUsed({ featureId: feature, reportInteraction: false });
|
|
51
51
|
}
|
|
52
|
-
|
|
52
|
+
setSearchError(newError);
|
|
53
53
|
return [];
|
|
54
54
|
}
|
|
55
55
|
};
|
|
56
|
-
}, [onCategoriesFiltered,
|
|
56
|
+
}, [onCategoriesFiltered, searchText, onSearchPathsChanged, onFeatureUsed, viewType, getCategoriesTreeIdsCache, hierarchyConfiguration, componentId]);
|
|
57
57
|
return {
|
|
58
|
-
getPaths:
|
|
59
|
-
|
|
58
|
+
getPaths: getSearchPaths,
|
|
59
|
+
searchError,
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
62
|
async function getCategoriesFromPaths(paths, idsCache, elementClassName, modelsClassName, hierarchyConfig) {
|
|
@@ -67,7 +67,7 @@ async function getCategoriesFromPaths(paths, idsCache, elementClassName, modelsC
|
|
|
67
67
|
const subModelIds = new Set();
|
|
68
68
|
const categories = new Map();
|
|
69
69
|
for (const path of paths) {
|
|
70
|
-
const currPath =
|
|
70
|
+
const currPath = HierarchySearchPath.normalize(path).path;
|
|
71
71
|
if (currPath.length === 0) {
|
|
72
72
|
continue;
|
|
73
73
|
}
|
|
@@ -133,4 +133,4 @@ async function getCategoriesFromPaths(paths, idsCache, elementClassName, modelsC
|
|
|
133
133
|
models,
|
|
134
134
|
};
|
|
135
135
|
}
|
|
136
|
-
//# sourceMappingURL=
|
|
136
|
+
//# sourceMappingURL=UseSearchPaths.js.map
|
package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/UseSearchPaths.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UseSearchPaths.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/categories-tree/internal/UseSearchPaths.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAC/F,OAAO,EAAE,8BAA8B,EAAE,sBAAsB,EAAE,MAAM,+CAA+C,CAAC;AACvH,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAc1E,gBAAgB;AAChB,MAAM,UAAU,cAAc,CAAC,EAC7B,UAAU,EACV,QAAQ,EACR,sBAAsB,EACtB,yBAAyB,EACzB,oBAAoB,EACpB,oBAAoB,EACpB,WAAW,GASZ;IAIC,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,EAAyC,CAAC;IACxF,MAAM,EAAE,aAAa,EAAE,GAAG,mBAAmB,EAAE,CAAC;IAEhD,SAAS,CAAC,GAAG,EAAE;QACb,cAAc,CAAC,SAAS,CAAC,CAAC;QAC1B,oBAAoB,EAAE,CAAC,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE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C,CAAC;IAC1E,OAAO;QACL,UAAU,EAAE,CAAC,GAAG,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,EAAE,cAAc,CAAC,EAAE,EAAE,CAAC,CAAC;YAC3E,UAAU;YACV,cAAc,EAAE,cAAc,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,cAAc;SACzE,CAAC,CAAC;QACH,MAAM;KACP,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 { firstValueFrom } from \"rxjs\";\nimport { assert } from \"@itwin/core-bentley\";\nimport { HierarchyNodeIdentifier, HierarchySearchPath } from \"@itwin/presentation-hierarchies\";\nimport { CLASS_NAME_DefinitionContainer, CLASS_NAME_SubCategory } from \"../../common/internal/ClassNameDefinitions.js\";\nimport { getClassesByView } from \"../../common/internal/Utils.js\";\nimport { SearchLimitExceededError } from \"../../common/TreeErrors.js\";\nimport { useTelemetryContext } from \"../../common/UseTelemetryContext.js\";\nimport { CategoriesTreeDefinition } from \"../CategoriesTreeDefinition.js\";\n\nimport type { GuidString } from \"@itwin/core-bentley\";\nimport type { CategoryInfo } from \"../../common/CategoriesVisibilityUtils.js\";\nimport type { VisibilityTreeProps } from \"../../common/components/VisibilityTree.js\";\nimport type { CategoryId, ElementId, ModelId, SubCategoryId } from \"../../common/internal/Types.js\";\nimport type { CategoriesTreeHierarchyConfiguration } from \"../CategoriesTreeDefinition.js\";\nimport type { CategoriesTreeIdsCache } from \"./CategoriesTreeIdsCache.js\";\n\n/** @internal */\nexport type CategoriesTreeSearchError = \"tooManySearchMatches\" | \"unknownSearchError\";\n\ntype HierarchySearchPaths = Awaited<ReturnType<Required<VisibilityTreeProps>[\"getSearchPaths\"]>>;\n\n/** @internal */\nexport function useSearchPaths({\n searchText,\n viewType,\n hierarchyConfiguration,\n getCategoriesTreeIdsCache,\n onCategoriesFiltered,\n onSearchPathsChanged,\n componentId,\n}: {\n viewType: \"2d\" | \"3d\";\n searchText?: string;\n hierarchyConfiguration: CategoriesTreeHierarchyConfiguration;\n getCategoriesTreeIdsCache: () => CategoriesTreeIdsCache;\n onCategoriesFiltered?: (categories: { categories: CategoryInfo[] | undefined; models?: Array<ModelId> }) => void;\n onSearchPathsChanged: (paths: HierarchySearchPaths | undefined) => void;\n componentId: GuidString;\n}): {\n getPaths: VisibilityTreeProps[\"getSearchPaths\"] | undefined;\n searchError: CategoriesTreeSearchError | undefined;\n} {\n const [searchError, setSearchError] = useState<CategoriesTreeSearchError | undefined>();\n const { onFeatureUsed } = useTelemetryContext();\n\n useEffect(() => {\n setSearchError(undefined);\n onCategoriesFiltered?.({ categories: undefined, models: undefined });\n if (!searchText) {\n onSearchPathsChanged(undefined);\n }\n }, [searchText, onCategoriesFiltered, onSearchPathsChanged]);\n\n const getSearchPaths = useMemo<VisibilityTreeProps[\"getSearchPaths\"] | undefined>(() => {\n if (!searchText) {\n return undefined;\n }\n\n return async ({ imodelAccess, abortSignal }) => {\n onFeatureUsed({ featureId: \"search\", reportInteraction: true });\n try {\n const paths = await CategoriesTreeDefinition.createInstanceKeyPaths({\n imodelAccess,\n abortSignal,\n label: searchText,\n viewType,\n idsCache: getCategoriesTreeIdsCache(),\n hierarchyConfig: hierarchyConfiguration,\n componentId,\n });\n onSearchPathsChanged(paths);\n const { elementClass, modelClass } = getClassesByView(viewType);\n onCategoriesFiltered?.(await getCategoriesFromPaths(paths, getCategoriesTreeIdsCache(), elementClass, modelClass, hierarchyConfiguration));\n return paths;\n } catch (e) {\n const newError = e instanceof SearchLimitExceededError ? \"tooManySearchMatches\" : \"unknownSearchError\";\n if (newError !== \"tooManySearchMatches\") {\n const feature = e instanceof Error && e.message.includes(\"query too long to execute or server is too busy\") ? \"error-timeout\" : \"error-unknown\";\n onFeatureUsed({ featureId: feature, reportInteraction: false });\n }\n setSearchError(newError);\n return [];\n }\n };\n }, [onCategoriesFiltered, searchText, onSearchPathsChanged, onFeatureUsed, viewType, getCategoriesTreeIdsCache, hierarchyConfiguration, componentId]);\n\n return {\n getPaths: getSearchPaths,\n searchError,\n };\n}\n\nasync function getCategoriesFromPaths(\n paths: HierarchySearchPaths,\n idsCache: CategoriesTreeIdsCache,\n elementClassName: string,\n modelsClassName: string,\n hierarchyConfig: CategoriesTreeHierarchyConfiguration,\n): Promise<{ categories: CategoryInfo[] | undefined; models?: Array<ModelId> }> {\n if (!paths) {\n return { categories: undefined };\n }\n\n const rootFilteredElementIds = new Set<ElementId>();\n const subModelIds = new Set<ModelId>();\n\n const categories = new Map<CategoryId, Array<SubCategoryId>>();\n for (const path of paths) {\n const currPath = HierarchySearchPath.normalize(path).path;\n if (currPath.length === 0) {\n continue;\n }\n\n let category: HierarchyNodeIdentifier;\n let subCategory: HierarchyNodeIdentifier | undefined;\n\n let lastNodeInfo: { lastNode: HierarchyNodeIdentifier; nodeIndex: number } | undefined;\n\n for (let i = 0; i < currPath.length; ++i) {\n const currentNode = currPath[i];\n if (!HierarchyNodeIdentifier.isInstanceNodeIdentifier(currentNode)) {\n continue;\n }\n if (currentNode.className === elementClassName) {\n rootFilteredElementIds.add(currentNode.id);\n for (let j = i + 1; j < currPath.length; ++j) {\n const childNode = currPath[j];\n if (!HierarchyNodeIdentifier.isInstanceNodeIdentifier(childNode)) {\n continue;\n }\n if (childNode.className === modelsClassName) {\n subModelIds.add(childNode.id);\n }\n }\n break;\n }\n lastNodeInfo = { lastNode: currentNode, nodeIndex: i };\n }\n\n assert(lastNodeInfo !== undefined && HierarchyNodeIdentifier.isInstanceNodeIdentifier(lastNodeInfo.lastNode));\n\n if (lastNodeInfo.lastNode.className === CLASS_NAME_DefinitionContainer) {\n const definitionContainerCategories = await firstValueFrom(\n idsCache.getAllContainedCategories({ definitionContainerIds: lastNodeInfo.lastNode.id, includeEmptyCategories: hierarchyConfig.showEmptyCategories }),\n );\n for (const categoryId of definitionContainerCategories) {\n const value = categories.get(categoryId);\n if (value === undefined) {\n categories.set(categoryId, []);\n }\n }\n continue;\n }\n\n if (lastNodeInfo.lastNode.className === CLASS_NAME_SubCategory) {\n const secondToLastNode = lastNodeInfo.nodeIndex > 0 ? currPath[lastNodeInfo.nodeIndex - 1] : undefined;\n assert(secondToLastNode !== undefined && HierarchyNodeIdentifier.isInstanceNodeIdentifier(secondToLastNode));\n\n subCategory = lastNodeInfo.lastNode;\n category = secondToLastNode;\n } else {\n category = lastNodeInfo.lastNode;\n }\n\n let entry = categories.get(category.id);\n if (entry === undefined) {\n entry = [];\n categories.set(category.id, entry);\n }\n\n if (subCategory) {\n entry.push(subCategory.id);\n }\n }\n const rootElementModelMap = await firstValueFrom(idsCache.getFilteredElementsModels(rootFilteredElementIds));\n const models = [...subModelIds, ...new Set(rootElementModelMap.values())];\n return {\n categories: [...categories.entries()].map(([categoryId, subCategoryIds]) => ({\n categoryId,\n subCategoryIds: subCategoryIds.length === 0 ? undefined : subCategoryIds,\n })),\n models,\n };\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { HierarchyNode } from "@itwin/presentation-hierarchies";
|
|
2
2
|
import { HierarchyVisibilityHandlerImpl } from "../../../common/internal/useTreeHooks/UseCachedVisibility.js";
|
|
3
3
|
import type { Observable } from "rxjs";
|
|
4
|
-
import type {
|
|
4
|
+
import type { HierarchySearchPath } from "@itwin/presentation-hierarchies";
|
|
5
5
|
import type { ECClassHierarchyInspector } from "@itwin/presentation-shared";
|
|
6
6
|
import type { AlwaysAndNeverDrawnElementInfo } from "../../../common/internal/AlwaysAndNeverDrawnElementInfo.js";
|
|
7
7
|
import type { TreeSpecificVisibilityHandler } from "../../../common/internal/visibility/BaseVisibilityHelper.js";
|
|
@@ -9,7 +9,7 @@ import type { TreeWidgetViewport } from "../../../common/TreeWidgetViewport.js";
|
|
|
9
9
|
import type { VisibilityStatus } from "../../../common/UseHierarchyVisibility.js";
|
|
10
10
|
import type { CategoriesTreeHierarchyConfiguration } from "../../CategoriesTreeDefinition.js";
|
|
11
11
|
import type { CategoriesTreeIdsCache } from "../CategoriesTreeIdsCache.js";
|
|
12
|
-
import type {
|
|
12
|
+
import type { CategoriesTreeSearchTargets } from "./SearchResultsTree.js";
|
|
13
13
|
/** @internal */
|
|
14
14
|
export interface CategoriesTreeVisibilityHandlerProps {
|
|
15
15
|
idsCache: CategoriesTreeIdsCache;
|
|
@@ -23,15 +23,15 @@ export interface CategoriesTreeVisibilityHandlerProps {
|
|
|
23
23
|
* This handler knows how to get and change visibility status of nodes created by hierarchy definition.
|
|
24
24
|
* @internal
|
|
25
25
|
*/
|
|
26
|
-
export declare class CategoriesTreeVisibilityHandler implements Disposable, TreeSpecificVisibilityHandler<
|
|
26
|
+
export declare class CategoriesTreeVisibilityHandler implements Disposable, TreeSpecificVisibilityHandler<CategoriesTreeSearchTargets> {
|
|
27
27
|
#private;
|
|
28
28
|
constructor(constructorProps: CategoriesTreeVisibilityHandlerProps);
|
|
29
29
|
[Symbol.dispose](): void;
|
|
30
|
-
|
|
30
|
+
changeSearchTargetsVisibilityStatus(targets: CategoriesTreeSearchTargets, on: boolean): Observable<void>;
|
|
31
31
|
getVisibilityStatus(node: HierarchyNode): Observable<VisibilityStatus>;
|
|
32
32
|
/** Changes visibility of the items represented by the tree node. */
|
|
33
33
|
changeVisibilityStatus(node: HierarchyNode, on: boolean): Observable<void>;
|
|
34
|
-
|
|
34
|
+
getSearchTargetsVisibilityStatus(targets: CategoriesTreeSearchTargets): Observable<VisibilityStatus>;
|
|
35
35
|
private getCategories;
|
|
36
36
|
private getAllCategories;
|
|
37
37
|
private getElementsCount;
|
|
@@ -48,7 +48,7 @@ export declare function createCategoriesTreeVisibilityHandler(props: {
|
|
|
48
48
|
viewport: TreeWidgetViewport;
|
|
49
49
|
idsCache: CategoriesTreeIdsCache;
|
|
50
50
|
imodelAccess: ECClassHierarchyInspector;
|
|
51
|
-
|
|
51
|
+
searchPaths?: HierarchySearchPath[];
|
|
52
52
|
hierarchyConfig: CategoriesTreeHierarchyConfiguration;
|
|
53
|
-
}): HierarchyVisibilityHandlerImpl<
|
|
53
|
+
}): HierarchyVisibilityHandlerImpl<CategoriesTreeSearchTargets>;
|
|
54
54
|
//# sourceMappingURL=CategoriesTreeVisibilityHandler.d.ts.map
|
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import { concat, defer, EMPTY, from, map, merge, mergeMap, of } from "rxjs";
|
|
6
|
-
import { assert, Id64 } from "@itwin/core-bentley";
|
|
6
|
+
import { assert, Guid, Id64 } from "@itwin/core-bentley";
|
|
7
7
|
import { HierarchyNode } from "@itwin/presentation-hierarchies";
|
|
8
8
|
import { createVisibilityStatus } from "../../../common/internal/Tooltip.js";
|
|
9
9
|
import { HierarchyVisibilityHandlerImpl } from "../../../common/internal/useTreeHooks/UseCachedVisibility.js";
|
|
10
|
-
import {
|
|
10
|
+
import { fromWithRelease, getClassesByView } from "../../../common/internal/Utils.js";
|
|
11
11
|
import { mergeVisibilityStatuses } from "../../../common/internal/VisibilityUtils.js";
|
|
12
12
|
import { CategoriesTreeNode } from "../CategoriesTreeNode.js";
|
|
13
13
|
import { CategoriesTreeVisibilityHelper } from "./CategoriesTreeVisibilityHelper.js";
|
|
14
|
-
import {
|
|
14
|
+
import { createCategoriesSearchResultsTree } from "./SearchResultsTree.js";
|
|
15
15
|
/**
|
|
16
16
|
* Handles visibility status of categories tree nodes.
|
|
17
17
|
*
|
|
@@ -51,7 +51,7 @@ export class CategoriesTreeVisibilityHandler {
|
|
|
51
51
|
[Symbol.dispose]() {
|
|
52
52
|
this.#visibilityHelper[Symbol.dispose]();
|
|
53
53
|
}
|
|
54
|
-
|
|
54
|
+
changeSearchTargetsVisibilityStatus(targets, on) {
|
|
55
55
|
return defer(() => {
|
|
56
56
|
const { definitionContainerIds, subCategories, modelIds, categories, elements } = targets;
|
|
57
57
|
const observables = new Array();
|
|
@@ -68,7 +68,7 @@ export class CategoriesTreeVisibilityHandler {
|
|
|
68
68
|
observables.push(from(subCategories).pipe(mergeMap(({ categoryId, subCategoryIds }) => this.#visibilityHelper.changeSubCategoriesVisibilityStatus({ subCategoryIds, categoryId, on }))));
|
|
69
69
|
}
|
|
70
70
|
if (elements?.length) {
|
|
71
|
-
observables.push(
|
|
71
|
+
observables.push(fromWithRelease({ source: elements, releaseOnCount: 50 }).pipe(mergeMap(({ modelId, elements: elementsMap, categoryId }) => this.#visibilityHelper.changeElementsVisibilityStatus({ modelId, categoryId, elementIds: [...elementsMap.keys()], on }))));
|
|
72
72
|
}
|
|
73
73
|
return merge(...observables);
|
|
74
74
|
});
|
|
@@ -180,7 +180,7 @@ export class CategoriesTreeVisibilityHandler {
|
|
|
180
180
|
}
|
|
181
181
|
return changeObs;
|
|
182
182
|
}
|
|
183
|
-
|
|
183
|
+
getSearchTargetsVisibilityStatus(targets) {
|
|
184
184
|
return defer(() => {
|
|
185
185
|
const { definitionContainerIds, subCategories, modelIds, categories, elements } = targets;
|
|
186
186
|
const observables = new Array();
|
|
@@ -201,7 +201,7 @@ export class CategoriesTreeVisibilityHandler {
|
|
|
201
201
|
observables.push(from(subCategories).pipe(mergeMap(({ categoryId, subCategoryIds }) => this.#visibilityHelper.getSubCategoriesVisibilityStatus({ subCategoryIds, categoryId }))));
|
|
202
202
|
}
|
|
203
203
|
if (elements?.length) {
|
|
204
|
-
observables.push(
|
|
204
|
+
observables.push(fromWithRelease({ source: elements, releaseOnCount: 50 }).pipe(mergeMap(({ modelId, elements: elementsMap, categoryId }) => this.#visibilityHelper.getElementsVisibilityStatus({ modelId, categoryId, elementIds: [...elementsMap.keys()], type: this.#elementType }))));
|
|
205
205
|
}
|
|
206
206
|
return merge(...observables);
|
|
207
207
|
}).pipe(mergeVisibilityStatuses);
|
|
@@ -227,7 +227,7 @@ export class CategoriesTreeVisibilityHandler {
|
|
|
227
227
|
return this.#props.idsCache.getCategoriesElementModels(props.categoryIds, true);
|
|
228
228
|
}
|
|
229
229
|
getSubCategories(props) {
|
|
230
|
-
return
|
|
230
|
+
return this.#props.idsCache.getSubCategories(props.categoryId);
|
|
231
231
|
}
|
|
232
232
|
getSubModels(props) {
|
|
233
233
|
if ("modelIds" in props) {
|
|
@@ -261,14 +261,14 @@ export class CategoriesTreeVisibilityHandler {
|
|
|
261
261
|
*/
|
|
262
262
|
export function createCategoriesTreeVisibilityHandler(props) {
|
|
263
263
|
return new HierarchyVisibilityHandlerImpl({
|
|
264
|
-
|
|
265
|
-
if (!props.
|
|
264
|
+
getSearchResultsTree: () => {
|
|
265
|
+
if (!props.searchPaths) {
|
|
266
266
|
return undefined;
|
|
267
267
|
}
|
|
268
268
|
const { categoryClass, elementClass, modelClass } = getClassesByView(props.viewport.viewType === "2d" ? "2d" : "3d");
|
|
269
|
-
return
|
|
269
|
+
return createCategoriesSearchResultsTree({
|
|
270
270
|
idsCache: props.idsCache,
|
|
271
|
-
|
|
271
|
+
searchPaths: props.searchPaths,
|
|
272
272
|
imodelAccess: props.imodelAccess,
|
|
273
273
|
categoryClassName: categoryClass,
|
|
274
274
|
categoryElementClassName: elementClass,
|
|
@@ -284,7 +284,7 @@ export function createCategoriesTreeVisibilityHandler(props) {
|
|
|
284
284
|
});
|
|
285
285
|
},
|
|
286
286
|
viewport: props.viewport,
|
|
287
|
-
componentId:
|
|
287
|
+
componentId: Guid.createValue(),
|
|
288
288
|
});
|
|
289
289
|
}
|
|
290
290
|
//# sourceMappingURL=CategoriesTreeVisibilityHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CategoriesTreeVisibilityHandler.js","sourceRoot":"","sources":["../../../../../../../../src/tree-widget-react/components/trees/categories-tree/internal/visibility/CategoriesTreeVisibilityHandler.ts"],"names":[],"mappings":"AAAA;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C,KAAK,CAAC,aAAa,EAAE,CAAC;gBACzB,OAAO,SAAS,CAAC;YACnB,CAAC;YACD,MAAM,EAAE,aAAa,EAAE,YAAY,EAAE,UAAU,EAAE,GAAG,gBAAgB,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YACrH,OAAO,4BAA4B,CAAC;gBAClC,QAAQ,EAAE,KAAK,CAAC,QAAQ;gBACxB,cAAc,EAAE,KAAK,CAAC,aAAa;gBACnC,YAAY,EAAE,KAAK,CAAC,YAAY;gBAChC,iBAAiB,EAAE,aAAa;gBAChC,wBAAwB,EAAE,YAAY;gBACtC,sBAAsB,EAAE,UAAU;aACnC,CAAC,CAAC;QACL,CAAC;QACD,gCAAgC,EAAE,CAAC,IAAI,EAAE,EAAE;YACzC,OAAO,IAAI,+BAA+B,CAAC;gBACzC,8BAA8B,EAAE,IAAI;gBACpC,QAAQ,EAAE,KAAK,CAAC,QAAQ;gBACxB,QAAQ,EAAE,KAAK,CAAC,QAAQ;gBACxB,eAAe,EAAE,KAAK,CAAC,eAAe;aACvC,CAAC,CAAC;QACL,CAAC;QACD,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,WAAW,EAAE,MAAM;KACpB,CAAC,CAAC;AACL,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 { concat, defer, EMPTY, from, map, merge, mergeMap, of } from \"rxjs\";\nimport { assert, Id64 } from \"@itwin/core-bentley\";\nimport { HierarchyNode } from \"@itwin/presentation-hierarchies\";\nimport { createVisibilityStatus } from \"../../../common/internal/Tooltip.js\";\nimport { HierarchyVisibilityHandlerImpl } from \"../../../common/internal/useTreeHooks/UseCachedVisibility.js\";\nimport { getClassesByView, releaseMainThreadOnItemsCount } from \"../../../common/internal/Utils.js\";\nimport { mergeVisibilityStatuses } from \"../../../common/internal/VisibilityUtils.js\";\nimport { CategoriesTreeNode } from \"../CategoriesTreeNode.js\";\nimport { CategoriesTreeVisibilityHelper } from \"./CategoriesTreeVisibilityHelper.js\";\nimport { createFilteredCategoriesTree } from \"./FilteredTree.js\";\n\nimport type { Observable } from \"rxjs\";\nimport type { GroupingHierarchyNode, HierarchyFilteringPath } from \"@itwin/presentation-hierarchies\";\nimport type { ECClassHierarchyInspector } from \"@itwin/presentation-shared\";\nimport type { AlwaysAndNeverDrawnElementInfo } from \"../../../common/internal/AlwaysAndNeverDrawnElementInfo.js\";\nimport type { ElementId, ModelId } from \"../../../common/internal/Types.js\";\nimport type { FilteredTree } from \"../../../common/internal/visibility/BaseFilteredTree.js\";\nimport type { BaseIdsCache, TreeSpecificVisibilityHandler } from \"../../../common/internal/visibility/BaseVisibilityHelper.js\";\nimport type { TreeWidgetViewport } from \"../../../common/TreeWidgetViewport.js\";\nimport type { VisibilityStatus } from \"../../../common/UseHierarchyVisibility.js\";\nimport type { CategoriesTreeHierarchyConfiguration } from \"../../CategoriesTreeDefinition.js\";\nimport type { CategoriesTreeIdsCache } from \"../CategoriesTreeIdsCache.js\";\nimport type { CategoriesTreeFilterTargets } from \"./FilteredTree.js\";\n\n/** @internal */\nexport interface CategoriesTreeVisibilityHandlerProps {\n idsCache: CategoriesTreeIdsCache;\n viewport: TreeWidgetViewport;\n alwaysAndNeverDrawnElementInfo: AlwaysAndNeverDrawnElementInfo;\n hierarchyConfig: CategoriesTreeHierarchyConfiguration;\n}\n\n/**\n * Handles visibility status of categories tree nodes.\n *\n * This handler knows how to get and change visibility status of nodes created by hierarchy definition.\n * @internal\n */\nexport class CategoriesTreeVisibilityHandler implements Disposable, TreeSpecificVisibilityHandler<CategoriesTreeFilterTargets> {\n readonly #props: CategoriesTreeVisibilityHandlerProps;\n #visibilityHelper: CategoriesTreeVisibilityHelper;\n #elementType: \"GeometricElement3d\" | \"GeometricElement2d\";\n #categoryType: \"DrawingCategory\" | \"SpatialCategory\";\n #modelType: \"GeometricModel3d\" | \"GeometricModel2d\";\n constructor(constructorProps: CategoriesTreeVisibilityHandlerProps) {\n this.#props = constructorProps;\n // Remove after https://github.com/iTwin/viewer-components-react/issues/1421.\n // We won't need to create a custom base ids cache.\n const baseIdsCache: BaseIdsCache = {\n getCategories: (props) => this.getCategories(props),\n getAllCategories: () => this.getAllCategories(),\n getElementsCount: (props) => this.getElementsCount(props),\n getModels: (props) => this.getModels(props),\n getSubCategories: (props) => this.getSubCategories(props),\n getSubModels: (props) => this.getSubModels(props),\n hasSubModel: (props) => this.#props.idsCache.hasSubModel(props),\n };\n this.#visibilityHelper = new CategoriesTreeVisibilityHelper({\n viewport: this.#props.viewport,\n idsCache: this.#props.idsCache,\n alwaysAndNeverDrawnElementInfo: this.#props.alwaysAndNeverDrawnElementInfo,\n baseIdsCache,\n hierarchyConfig: constructorProps.hierarchyConfig,\n });\n\n this.#elementType = this.#props.viewport.viewType === \"2d\" ? \"GeometricElement2d\" : \"GeometricElement3d\";\n this.#categoryType = this.#props.viewport.viewType === \"2d\" ? \"DrawingCategory\" : \"SpatialCategory\";\n this.#modelType = this.#props.viewport.viewType === \"2d\" ? \"GeometricModel2d\" : \"GeometricModel3d\";\n }\n\n public [Symbol.dispose]() {\n this.#visibilityHelper[Symbol.dispose]();\n }\n\n public changeFilterTargetsVisibilityStatus(targets: CategoriesTreeFilterTargets, on: boolean): Observable<void> {\n return defer(() => {\n const { definitionContainerIds, subCategories, modelIds, categories, elements } = targets;\n const observables = new Array<Observable<void>>();\n if (definitionContainerIds?.size) {\n observables.push(this.#visibilityHelper.changeDefinitionContainersVisibilityStatus({ definitionContainerIds, on }));\n }\n\n if (modelIds?.size) {\n observables.push(this.#visibilityHelper.changeModelsVisibilityStatus({ modelIds, on }));\n }\n\n if (categories?.length) {\n observables.push(\n from(categories).pipe(mergeMap(({ modelId, categoryIds }) => this.#visibilityHelper.changeCategoriesVisibilityStatus({ categoryIds, modelId, on }))),\n );\n }\n\n if (subCategories?.length) {\n observables.push(\n from(subCategories).pipe(\n mergeMap(({ categoryId, subCategoryIds }) => this.#visibilityHelper.changeSubCategoriesVisibilityStatus({ subCategoryIds, categoryId, on })),\n ),\n );\n }\n\n if (elements?.length) {\n observables.push(\n from(elements).pipe(\n releaseMainThreadOnItemsCount(50),\n mergeMap(({ modelId, elements: elementsMap, categoryId }) =>\n this.#visibilityHelper.changeElementsVisibilityStatus({ modelId, categoryId, elementIds: [...elementsMap.keys()], on }),\n ),\n ),\n );\n }\n\n return merge(...observables);\n });\n }\n\n public getVisibilityStatus(node: HierarchyNode): Observable<VisibilityStatus> {\n if (HierarchyNode.isClassGroupingNode(node)) {\n const nodeInfo = this.getGroupingNodeInfo(node);\n return this.#visibilityHelper.getGroupedElementsVisibilityStatus({ categoryId: nodeInfo.categoryId, modelElementsMap: nodeInfo.modelElementsMap });\n }\n\n if (!HierarchyNode.isInstancesNode(node)) {\n return of(createVisibilityStatus(\"disabled\"));\n }\n\n if (CategoriesTreeNode.isDefinitionContainerNode(node)) {\n return this.#visibilityHelper.getDefinitionContainersVisibilityStatus({\n definitionContainerIds: node.key.instanceKeys.map((instanceKey) => instanceKey.id),\n });\n }\n\n if (CategoriesTreeNode.isModelNode(node)) {\n return this.#visibilityHelper.getModelsVisibilityStatus({\n modelIds: node.key.instanceKeys.map((instanceKey) => instanceKey.id),\n type: this.#modelType,\n });\n }\n\n if (CategoriesTreeNode.isCategoryNode(node)) {\n return this.#visibilityHelper.getCategoriesVisibilityStatus({\n categoryIds: node.key.instanceKeys.map((instanceKey) => instanceKey.id),\n modelId: CategoriesTreeNode.getModelId(node),\n type: this.#categoryType,\n });\n }\n\n const categoryId = CategoriesTreeNode.getCategoryId(node);\n if (!categoryId) {\n return of(createVisibilityStatus(\"disabled\"));\n }\n\n if (CategoriesTreeNode.isSubCategoryNode(node)) {\n return this.#visibilityHelper.getSubCategoriesVisibilityStatus({\n categoryId,\n subCategoryIds: node.key.instanceKeys.map((instanceKey) => instanceKey.id),\n });\n }\n\n const modelId = CategoriesTreeNode.getModelId(node);\n if (!modelId) {\n return of(createVisibilityStatus(\"disabled\"));\n }\n return this.#visibilityHelper.getElementsVisibilityStatus({\n elementIds: node.key.instanceKeys.map((instanceKey) => instanceKey.id),\n modelId,\n categoryId,\n type: this.#elementType,\n });\n }\n\n /** Changes visibility of the items represented by the tree node. */\n public changeVisibilityStatus(node: HierarchyNode, on: boolean): Observable<void> {\n const changeObs = defer(() => {\n if (HierarchyNode.isClassGroupingNode(node)) {\n const nodeInfo = this.getGroupingNodeInfo(node);\n return this.#visibilityHelper.changeGroupedElementsVisibilityStatus({\n categoryId: nodeInfo.categoryId,\n modelElementsMap: nodeInfo.modelElementsMap,\n on,\n });\n }\n\n if (!HierarchyNode.isInstancesNode(node)) {\n return EMPTY;\n }\n\n if (CategoriesTreeNode.isDefinitionContainerNode(node)) {\n return this.#visibilityHelper.changeDefinitionContainersVisibilityStatus({\n definitionContainerIds: node.key.instanceKeys.map((instanceKey) => instanceKey.id),\n on,\n });\n }\n\n if (CategoriesTreeNode.isModelNode(node)) {\n return this.#visibilityHelper.changeModelsVisibilityStatus({\n modelIds: node.key.instanceKeys.map(({ id }) => id),\n on,\n });\n }\n\n if (CategoriesTreeNode.isCategoryNode(node)) {\n return this.#visibilityHelper.changeCategoriesVisibilityStatus({\n categoryIds: node.key.instanceKeys.map((instanceKey) => instanceKey.id),\n modelId: CategoriesTreeNode.getModelId(node),\n on,\n });\n }\n\n const categoryId = CategoriesTreeNode.getCategoryId(node);\n if (!categoryId) {\n return EMPTY;\n }\n\n if (CategoriesTreeNode.isSubCategoryNode(node)) {\n return this.#visibilityHelper.changeSubCategoriesVisibilityStatus({\n categoryId,\n subCategoryIds: node.key.instanceKeys.map((instanceKey) => instanceKey.id),\n on,\n });\n }\n\n const modelId = CategoriesTreeNode.getModelId(node);\n if (!modelId) {\n return EMPTY;\n }\n\n return this.#visibilityHelper.changeElementsVisibilityStatus({\n elementIds: node.key.instanceKeys.map(({ id }) => id),\n modelId,\n categoryId,\n on,\n });\n });\n\n if (this.#props.viewport.isAlwaysDrawnExclusive) {\n return concat(this.#visibilityHelper.removeAlwaysDrawnExclusive(), changeObs);\n }\n return changeObs;\n }\n\n public getFilterTargetsVisibilityStatus(targets: CategoriesTreeFilterTargets): Observable<VisibilityStatus> {\n return defer(() => {\n const { definitionContainerIds, subCategories, modelIds, categories, elements } = targets;\n const observables = new Array<Observable<VisibilityStatus>>();\n if (definitionContainerIds?.size) {\n observables.push(this.#visibilityHelper.getDefinitionContainersVisibilityStatus({ definitionContainerIds }));\n }\n\n if (modelIds?.size) {\n observables.push(this.#visibilityHelper.getModelsVisibilityStatus({ modelIds, type: this.#modelType }));\n }\n\n if (categories?.length) {\n observables.push(\n from(categories).pipe(\n mergeMap(({ modelId, categoryIds }) =>\n this.#visibilityHelper.getCategoriesVisibilityStatus({\n categoryIds,\n modelId,\n type: this.#categoryType,\n }),\n ),\n ),\n );\n }\n\n if (subCategories?.length) {\n observables.push(\n from(subCategories).pipe(\n mergeMap(({ categoryId, subCategoryIds }) => this.#visibilityHelper.getSubCategoriesVisibilityStatus({ subCategoryIds, categoryId })),\n ),\n );\n }\n\n if (elements?.length) {\n observables.push(\n from(elements).pipe(\n releaseMainThreadOnItemsCount(50),\n mergeMap(({ modelId, elements: elementsMap, categoryId }) =>\n this.#visibilityHelper.getElementsVisibilityStatus({ modelId, categoryId, elementIds: [...elementsMap.keys()], type: this.#elementType }),\n ),\n ),\n );\n }\n\n return merge(...observables);\n }).pipe(mergeVisibilityStatuses);\n }\n\n private getCategories(props: Parameters<BaseIdsCache[\"getCategories\"]>[0]): ReturnType<BaseIdsCache[\"getCategories\"]> {\n return from(Id64.iterable(props.modelIds)).pipe(\n mergeMap((modelId) =>\n this.#props.idsCache.getModelCategoryIds(modelId).pipe(\n map((categories) => ({\n id: modelId,\n ...(this.#props.viewport.viewType === \"2d\" ? { drawingCategories: categories } : { spatialCategories: categories }),\n })),\n ),\n ),\n );\n }\n\n private getAllCategories(): ReturnType<BaseIdsCache[\"getAllCategories\"]> {\n return this.#props.idsCache.getAllCategories().pipe(\n map((categories) => {\n if (this.#props.viewport.viewType === \"2d\") {\n return { drawingCategories: categories };\n }\n return { spatialCategories: categories };\n }),\n );\n }\n\n private getElementsCount(props: Parameters<BaseIdsCache[\"getElementsCount\"]>[0]): ReturnType<BaseIdsCache[\"getElementsCount\"]> {\n return this.#props.idsCache.getCategoryElementsCount(props.modelId, props.categoryId);\n }\n\n private getModels(props: Parameters<BaseIdsCache[\"getModels\"]>[0]): ReturnType<BaseIdsCache[\"getModels\"]> {\n return this.#props.idsCache.getCategoriesElementModels(props.categoryIds, true);\n }\n\n private getSubCategories(props: Parameters<BaseIdsCache[\"getSubCategories\"]>[0]): ReturnType<BaseIdsCache[\"getSubCategories\"]> {\n return from(Id64.iterable(props.categoryIds)).pipe(\n mergeMap((categoryId) =>\n this.#props.idsCache.getSubCategories(categoryId).pipe(\n mergeMap((categorySubCategoriesMap) => (categorySubCategoriesMap.size > 0 ? categorySubCategoriesMap.values() : of(undefined))),\n map((subCategories) => ({ id: categoryId, subCategories })),\n ),\n ),\n );\n }\n\n private getSubModels(props: Parameters<BaseIdsCache[\"getSubModels\"]>[0]): ReturnType<BaseIdsCache[\"getSubModels\"]> {\n if (\"modelIds\" in props) {\n return from(Id64.iterable(props.modelIds)).pipe(\n mergeMap((modelId) => {\n if (props.categoryId) {\n return this.#props.idsCache.getCategoriesModeledElements(modelId, props.categoryId).pipe(map((subModels) => ({ id: modelId, subModels })));\n }\n return this.#props.idsCache.getModelCategoryIds(modelId).pipe(\n mergeMap((categoryIds) => this.#props.idsCache.getCategoriesModeledElements(modelId, categoryIds)),\n map((subModels) => ({ id: modelId, subModels })),\n );\n }),\n );\n }\n\n if (props.modelId) {\n return from(Id64.iterable(props.categoryIds)).pipe(\n mergeMap((categoryId) =>\n this.#props.idsCache.getCategoriesModeledElements(props.modelId!, categoryId).pipe(map((subModels) => ({ id: categoryId, subModels }))),\n ),\n );\n }\n\n return this.#props.idsCache.getCategoriesElementModels(props.categoryIds).pipe(\n mergeMap(({ id, models }) => {\n if (!models) {\n return of({ id, subModels: undefined });\n }\n return from(models).pipe(\n mergeMap((modelId) => this.#props.idsCache.getCategoriesModeledElements(modelId, id)),\n map((subModels) => ({ id, subModels })),\n );\n }),\n );\n }\n\n private getGroupingNodeInfo(node: GroupingHierarchyNode) {\n const modelElementsMap: Map<ModelId, Set<ElementId>> = node.extendedData?.modelElementsMap;\n const categoryId = node.extendedData?.categoryId;\n assert(!!modelElementsMap && !!categoryId);\n\n return { modelElementsMap, categoryId };\n }\n}\n\n/**\n * Creates categories tree visibility handler. Is used by integration and performance tests.\n * @internal\n */\nexport function createCategoriesTreeVisibilityHandler(props: {\n viewport: TreeWidgetViewport;\n idsCache: CategoriesTreeIdsCache;\n imodelAccess: ECClassHierarchyInspector;\n filteredPaths?: HierarchyFilteringPath[];\n hierarchyConfig: CategoriesTreeHierarchyConfiguration;\n}) {\n return new HierarchyVisibilityHandlerImpl<CategoriesTreeFilterTargets>({\n getFilteredTree: (): undefined | Promise<FilteredTree<CategoriesTreeFilterTargets>> => {\n if (!props.filteredPaths) {\n return undefined;\n }\n const { categoryClass, elementClass, modelClass } = getClassesByView(props.viewport.viewType === \"2d\" ? \"2d\" : \"3d\");\n return createFilteredCategoriesTree({\n idsCache: props.idsCache,\n filteringPaths: props.filteredPaths,\n imodelAccess: props.imodelAccess,\n categoryClassName: categoryClass,\n categoryElementClassName: elementClass,\n categoryModelClassName: modelClass,\n });\n },\n getTreeSpecificVisibilityHandler: (info) => {\n return new CategoriesTreeVisibilityHandler({\n alwaysAndNeverDrawnElementInfo: info,\n idsCache: props.idsCache,\n viewport: props.viewport,\n hierarchyConfig: props.hierarchyConfig,\n });\n },\n viewport: props.viewport,\n componentId: \"Test\",\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CategoriesTreeVisibilityHandler.js","sourceRoot":"","sources":["../../../../../../../../src/tree-widget-react/components/trees/categories-tree/internal/visibility/CategoriesTreeVisibilityHandler.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC5E,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAC7E,OAAO,EAAE,8BAA8B,EAAE,MAAM,8DAA8D,CAAC;AAC9G,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACtF,OAAO,EAAE,uBAAuB,EAAE,MAAM,6CAA6C,CAAC;AACtF,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC;AACrF,OAAO,EAAE,iCAAiC,EAAE,MAAM,wBAAwB,CAAC;AAuB3E;;;;;GAKG;AACH,MAAM,OAAO,+BAA+B;IACjC,MAAM,CAAuC;IACtD,iBAAiB,CAAiC;IAClD,YAAY,CAA8C;IAC1D,aAAa,CAAwC;IACrD,UAAU,CAA0C;IACpD,YAAY,gBAAsD;QAChE,IAAI,CAAC,MAAM,GAAG,gBAAgB,CAAC;QAC/B,6EAA6E;QAC7E,mDAAmD;QACnD,MAAM,YAAY,GAAiB;YACjC,aAAa,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC;YACnD,gBAAgB,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,gBAAgB,EAAE;YAC/C,gBAAgB,EAAE,CAAC,KAAK,EAAE,EAAE,CAA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,EAAE,KAAK,CAAC,QAAQ;gBACxB,WAAW,EAAE,KAAK,CAAC,WAAW;gBAC9B,YAAY,EAAE,KAAK,CAAC,YAAY;gBAChC,iBAAiB,EAAE,aAAa;gBAChC,wBAAwB,EAAE,YAAY;gBACtC,sBAAsB,EAAE,UAAU;aACnC,CAAC,CAAC;QACL,CAAC;QACD,gCAAgC,EAAE,CAAC,IAAI,EAAE,EAAE;YACzC,OAAO,IAAI,+BAA+B,CAAC;gBACzC,8BAA8B,EAAE,IAAI;gBACpC,QAAQ,EAAE,KAAK,CAAC,QAAQ;gBACxB,QAAQ,EAAE,KAAK,CAAC,QAAQ;gBACxB,eAAe,EAAE,KAAK,CAAC,eAAe;aACvC,CAAC,CAAC;QACL,CAAC;QACD,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE;KAChC,CAAC,CAAC;AACL,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 { concat, defer, EMPTY, from, map, merge, mergeMap, of } from \"rxjs\";\nimport { assert, Guid, Id64 } from \"@itwin/core-bentley\";\nimport { HierarchyNode } from \"@itwin/presentation-hierarchies\";\nimport { createVisibilityStatus } from \"../../../common/internal/Tooltip.js\";\nimport { HierarchyVisibilityHandlerImpl } from \"../../../common/internal/useTreeHooks/UseCachedVisibility.js\";\nimport { fromWithRelease, getClassesByView } from \"../../../common/internal/Utils.js\";\nimport { mergeVisibilityStatuses } from \"../../../common/internal/VisibilityUtils.js\";\nimport { CategoriesTreeNode } from \"../CategoriesTreeNode.js\";\nimport { CategoriesTreeVisibilityHelper } from \"./CategoriesTreeVisibilityHelper.js\";\nimport { createCategoriesSearchResultsTree } from \"./SearchResultsTree.js\";\n\nimport type { Observable } from \"rxjs\";\nimport type { GroupingHierarchyNode, HierarchySearchPath } from \"@itwin/presentation-hierarchies\";\nimport type { ECClassHierarchyInspector } from \"@itwin/presentation-shared\";\nimport type { AlwaysAndNeverDrawnElementInfo } from \"../../../common/internal/AlwaysAndNeverDrawnElementInfo.js\";\nimport type { ElementId, ModelId } from \"../../../common/internal/Types.js\";\nimport type { SearchResultsTree } from \"../../../common/internal/visibility/BaseSearchResultsTree.js\";\nimport type { BaseIdsCache, TreeSpecificVisibilityHandler } from \"../../../common/internal/visibility/BaseVisibilityHelper.js\";\nimport type { TreeWidgetViewport } from \"../../../common/TreeWidgetViewport.js\";\nimport type { VisibilityStatus } from \"../../../common/UseHierarchyVisibility.js\";\nimport type { CategoriesTreeHierarchyConfiguration } from \"../../CategoriesTreeDefinition.js\";\nimport type { CategoriesTreeIdsCache } from \"../CategoriesTreeIdsCache.js\";\nimport type { CategoriesTreeSearchTargets } from \"./SearchResultsTree.js\";\n\n/** @internal */\nexport interface CategoriesTreeVisibilityHandlerProps {\n idsCache: CategoriesTreeIdsCache;\n viewport: TreeWidgetViewport;\n alwaysAndNeverDrawnElementInfo: AlwaysAndNeverDrawnElementInfo;\n hierarchyConfig: CategoriesTreeHierarchyConfiguration;\n}\n\n/**\n * Handles visibility status of categories tree nodes.\n *\n * This handler knows how to get and change visibility status of nodes created by hierarchy definition.\n * @internal\n */\nexport class CategoriesTreeVisibilityHandler implements Disposable, TreeSpecificVisibilityHandler<CategoriesTreeSearchTargets> {\n readonly #props: CategoriesTreeVisibilityHandlerProps;\n #visibilityHelper: CategoriesTreeVisibilityHelper;\n #elementType: \"GeometricElement3d\" | \"GeometricElement2d\";\n #categoryType: \"DrawingCategory\" | \"SpatialCategory\";\n #modelType: \"GeometricModel3d\" | \"GeometricModel2d\";\n constructor(constructorProps: CategoriesTreeVisibilityHandlerProps) {\n this.#props = constructorProps;\n // Remove after https://github.com/iTwin/viewer-components-react/issues/1421.\n // We won't need to create a custom base ids cache.\n const baseIdsCache: BaseIdsCache = {\n getCategories: (props) => this.getCategories(props),\n getAllCategories: () => this.getAllCategories(),\n getElementsCount: (props) => this.getElementsCount(props),\n getModels: (props) => this.getModels(props),\n getSubCategories: (props) => this.getSubCategories(props),\n getSubModels: (props) => this.getSubModels(props),\n hasSubModel: (props) => this.#props.idsCache.hasSubModel(props),\n };\n this.#visibilityHelper = new CategoriesTreeVisibilityHelper({\n viewport: this.#props.viewport,\n idsCache: this.#props.idsCache,\n alwaysAndNeverDrawnElementInfo: this.#props.alwaysAndNeverDrawnElementInfo,\n baseIdsCache,\n hierarchyConfig: constructorProps.hierarchyConfig,\n });\n\n this.#elementType = this.#props.viewport.viewType === \"2d\" ? \"GeometricElement2d\" : \"GeometricElement3d\";\n this.#categoryType = this.#props.viewport.viewType === \"2d\" ? \"DrawingCategory\" : \"SpatialCategory\";\n this.#modelType = this.#props.viewport.viewType === \"2d\" ? \"GeometricModel2d\" : \"GeometricModel3d\";\n }\n\n public [Symbol.dispose]() {\n this.#visibilityHelper[Symbol.dispose]();\n }\n\n public changeSearchTargetsVisibilityStatus(targets: CategoriesTreeSearchTargets, on: boolean): Observable<void> {\n return defer(() => {\n const { definitionContainerIds, subCategories, modelIds, categories, elements } = targets;\n const observables = new Array<Observable<void>>();\n if (definitionContainerIds?.size) {\n observables.push(this.#visibilityHelper.changeDefinitionContainersVisibilityStatus({ definitionContainerIds, on }));\n }\n\n if (modelIds?.size) {\n observables.push(this.#visibilityHelper.changeModelsVisibilityStatus({ modelIds, on }));\n }\n\n if (categories?.length) {\n observables.push(\n from(categories).pipe(mergeMap(({ modelId, categoryIds }) => this.#visibilityHelper.changeCategoriesVisibilityStatus({ categoryIds, modelId, on }))),\n );\n }\n\n if (subCategories?.length) {\n observables.push(\n from(subCategories).pipe(\n mergeMap(({ categoryId, subCategoryIds }) => this.#visibilityHelper.changeSubCategoriesVisibilityStatus({ subCategoryIds, categoryId, on })),\n ),\n );\n }\n\n if (elements?.length) {\n observables.push(\n fromWithRelease({ source: elements, releaseOnCount: 50 }).pipe(\n mergeMap(({ modelId, elements: elementsMap, categoryId }) =>\n this.#visibilityHelper.changeElementsVisibilityStatus({ modelId, categoryId, elementIds: [...elementsMap.keys()], on }),\n ),\n ),\n );\n }\n\n return merge(...observables);\n });\n }\n\n public getVisibilityStatus(node: HierarchyNode): Observable<VisibilityStatus> {\n if (HierarchyNode.isClassGroupingNode(node)) {\n const nodeInfo = this.getGroupingNodeInfo(node);\n return this.#visibilityHelper.getGroupedElementsVisibilityStatus({ categoryId: nodeInfo.categoryId, modelElementsMap: nodeInfo.modelElementsMap });\n }\n\n if (!HierarchyNode.isInstancesNode(node)) {\n return of(createVisibilityStatus(\"disabled\"));\n }\n\n if (CategoriesTreeNode.isDefinitionContainerNode(node)) {\n return this.#visibilityHelper.getDefinitionContainersVisibilityStatus({\n definitionContainerIds: node.key.instanceKeys.map((instanceKey) => instanceKey.id),\n });\n }\n\n if (CategoriesTreeNode.isModelNode(node)) {\n return this.#visibilityHelper.getModelsVisibilityStatus({\n modelIds: node.key.instanceKeys.map((instanceKey) => instanceKey.id),\n type: this.#modelType,\n });\n }\n\n if (CategoriesTreeNode.isCategoryNode(node)) {\n return this.#visibilityHelper.getCategoriesVisibilityStatus({\n categoryIds: node.key.instanceKeys.map((instanceKey) => instanceKey.id),\n modelId: CategoriesTreeNode.getModelId(node),\n type: this.#categoryType,\n });\n }\n\n const categoryId = CategoriesTreeNode.getCategoryId(node);\n if (!categoryId) {\n return of(createVisibilityStatus(\"disabled\"));\n }\n\n if (CategoriesTreeNode.isSubCategoryNode(node)) {\n return this.#visibilityHelper.getSubCategoriesVisibilityStatus({\n categoryId,\n subCategoryIds: node.key.instanceKeys.map((instanceKey) => instanceKey.id),\n });\n }\n\n const modelId = CategoriesTreeNode.getModelId(node);\n if (!modelId) {\n return of(createVisibilityStatus(\"disabled\"));\n }\n return this.#visibilityHelper.getElementsVisibilityStatus({\n elementIds: node.key.instanceKeys.map((instanceKey) => instanceKey.id),\n modelId,\n categoryId,\n type: this.#elementType,\n });\n }\n\n /** Changes visibility of the items represented by the tree node. */\n public changeVisibilityStatus(node: HierarchyNode, on: boolean): Observable<void> {\n const changeObs = defer(() => {\n if (HierarchyNode.isClassGroupingNode(node)) {\n const nodeInfo = this.getGroupingNodeInfo(node);\n return this.#visibilityHelper.changeGroupedElementsVisibilityStatus({\n categoryId: nodeInfo.categoryId,\n modelElementsMap: nodeInfo.modelElementsMap,\n on,\n });\n }\n\n if (!HierarchyNode.isInstancesNode(node)) {\n return EMPTY;\n }\n\n if (CategoriesTreeNode.isDefinitionContainerNode(node)) {\n return this.#visibilityHelper.changeDefinitionContainersVisibilityStatus({\n definitionContainerIds: node.key.instanceKeys.map((instanceKey) => instanceKey.id),\n on,\n });\n }\n\n if (CategoriesTreeNode.isModelNode(node)) {\n return this.#visibilityHelper.changeModelsVisibilityStatus({\n modelIds: node.key.instanceKeys.map(({ id }) => id),\n on,\n });\n }\n\n if (CategoriesTreeNode.isCategoryNode(node)) {\n return this.#visibilityHelper.changeCategoriesVisibilityStatus({\n categoryIds: node.key.instanceKeys.map((instanceKey) => instanceKey.id),\n modelId: CategoriesTreeNode.getModelId(node),\n on,\n });\n }\n\n const categoryId = CategoriesTreeNode.getCategoryId(node);\n if (!categoryId) {\n return EMPTY;\n }\n\n if (CategoriesTreeNode.isSubCategoryNode(node)) {\n return this.#visibilityHelper.changeSubCategoriesVisibilityStatus({\n categoryId,\n subCategoryIds: node.key.instanceKeys.map((instanceKey) => instanceKey.id),\n on,\n });\n }\n\n const modelId = CategoriesTreeNode.getModelId(node);\n if (!modelId) {\n return EMPTY;\n }\n\n return this.#visibilityHelper.changeElementsVisibilityStatus({\n elementIds: node.key.instanceKeys.map(({ id }) => id),\n modelId,\n categoryId,\n on,\n });\n });\n\n if (this.#props.viewport.isAlwaysDrawnExclusive) {\n return concat(this.#visibilityHelper.removeAlwaysDrawnExclusive(), changeObs);\n }\n return changeObs;\n }\n\n public getSearchTargetsVisibilityStatus(targets: CategoriesTreeSearchTargets): Observable<VisibilityStatus> {\n return defer(() => {\n const { definitionContainerIds, subCategories, modelIds, categories, elements } = targets;\n const observables = new Array<Observable<VisibilityStatus>>();\n if (definitionContainerIds?.size) {\n observables.push(this.#visibilityHelper.getDefinitionContainersVisibilityStatus({ definitionContainerIds }));\n }\n\n if (modelIds?.size) {\n observables.push(this.#visibilityHelper.getModelsVisibilityStatus({ modelIds, type: this.#modelType }));\n }\n\n if (categories?.length) {\n observables.push(\n from(categories).pipe(\n mergeMap(({ modelId, categoryIds }) =>\n this.#visibilityHelper.getCategoriesVisibilityStatus({\n categoryIds,\n modelId,\n type: this.#categoryType,\n }),\n ),\n ),\n );\n }\n\n if (subCategories?.length) {\n observables.push(\n from(subCategories).pipe(\n mergeMap(({ categoryId, subCategoryIds }) => this.#visibilityHelper.getSubCategoriesVisibilityStatus({ subCategoryIds, categoryId })),\n ),\n );\n }\n\n if (elements?.length) {\n observables.push(\n fromWithRelease({ source: elements, releaseOnCount: 50 }).pipe(\n mergeMap(({ modelId, elements: elementsMap, categoryId }) =>\n this.#visibilityHelper.getElementsVisibilityStatus({ modelId, categoryId, elementIds: [...elementsMap.keys()], type: this.#elementType }),\n ),\n ),\n );\n }\n\n return merge(...observables);\n }).pipe(mergeVisibilityStatuses);\n }\n\n private getCategories(props: Parameters<BaseIdsCache[\"getCategories\"]>[0]): ReturnType<BaseIdsCache[\"getCategories\"]> {\n return from(Id64.iterable(props.modelIds)).pipe(\n mergeMap((modelId) =>\n this.#props.idsCache.getModelCategoryIds(modelId).pipe(\n map((categories) => ({\n id: modelId,\n ...(this.#props.viewport.viewType === \"2d\" ? { drawingCategories: categories } : { spatialCategories: categories }),\n })),\n ),\n ),\n );\n }\n\n private getAllCategories(): ReturnType<BaseIdsCache[\"getAllCategories\"]> {\n return this.#props.idsCache.getAllCategories().pipe(\n map((categories) => {\n if (this.#props.viewport.viewType === \"2d\") {\n return { drawingCategories: categories };\n }\n return { spatialCategories: categories };\n }),\n );\n }\n\n private getElementsCount(props: Parameters<BaseIdsCache[\"getElementsCount\"]>[0]): ReturnType<BaseIdsCache[\"getElementsCount\"]> {\n return this.#props.idsCache.getCategoryElementsCount(props.modelId, props.categoryId);\n }\n\n private getModels(props: Parameters<BaseIdsCache[\"getModels\"]>[0]): ReturnType<BaseIdsCache[\"getModels\"]> {\n return this.#props.idsCache.getCategoriesElementModels(props.categoryIds, true);\n }\n\n private getSubCategories(props: Parameters<BaseIdsCache[\"getSubCategories\"]>[0]): ReturnType<BaseIdsCache[\"getSubCategories\"]> {\n return this.#props.idsCache.getSubCategories(props.categoryId);\n }\n\n private getSubModels(props: Parameters<BaseIdsCache[\"getSubModels\"]>[0]): ReturnType<BaseIdsCache[\"getSubModels\"]> {\n if (\"modelIds\" in props) {\n return from(Id64.iterable(props.modelIds)).pipe(\n mergeMap((modelId) => {\n if (props.categoryId) {\n return this.#props.idsCache.getCategoriesModeledElements(modelId, props.categoryId).pipe(map((subModels) => ({ id: modelId, subModels })));\n }\n return this.#props.idsCache.getModelCategoryIds(modelId).pipe(\n mergeMap((categoryIds) => this.#props.idsCache.getCategoriesModeledElements(modelId, categoryIds)),\n map((subModels) => ({ id: modelId, subModels })),\n );\n }),\n );\n }\n\n if (props.modelId) {\n return from(Id64.iterable(props.categoryIds)).pipe(\n mergeMap((categoryId) =>\n this.#props.idsCache.getCategoriesModeledElements(props.modelId!, categoryId).pipe(map((subModels) => ({ id: categoryId, subModels }))),\n ),\n );\n }\n\n return this.#props.idsCache.getCategoriesElementModels(props.categoryIds).pipe(\n mergeMap(({ id, models }) => {\n if (!models) {\n return of({ id, subModels: undefined });\n }\n return from(models).pipe(\n mergeMap((modelId) => this.#props.idsCache.getCategoriesModeledElements(modelId, id)),\n map((subModels) => ({ id, subModels })),\n );\n }),\n );\n }\n\n private getGroupingNodeInfo(node: GroupingHierarchyNode) {\n const modelElementsMap: Map<ModelId, Set<ElementId>> = node.extendedData?.modelElementsMap;\n const categoryId = node.extendedData?.categoryId;\n assert(!!modelElementsMap && !!categoryId);\n\n return { modelElementsMap, categoryId };\n }\n}\n\n/**\n * Creates categories tree visibility handler. Is used by integration and performance tests.\n * @internal\n */\nexport function createCategoriesTreeVisibilityHandler(props: {\n viewport: TreeWidgetViewport;\n idsCache: CategoriesTreeIdsCache;\n imodelAccess: ECClassHierarchyInspector;\n searchPaths?: HierarchySearchPath[];\n hierarchyConfig: CategoriesTreeHierarchyConfiguration;\n}) {\n return new HierarchyVisibilityHandlerImpl<CategoriesTreeSearchTargets>({\n getSearchResultsTree: (): undefined | Promise<SearchResultsTree<CategoriesTreeSearchTargets>> => {\n if (!props.searchPaths) {\n return undefined;\n }\n const { categoryClass, elementClass, modelClass } = getClassesByView(props.viewport.viewType === \"2d\" ? \"2d\" : \"3d\");\n return createCategoriesSearchResultsTree({\n idsCache: props.idsCache,\n searchPaths: props.searchPaths,\n imodelAccess: props.imodelAccess,\n categoryClassName: categoryClass,\n categoryElementClassName: elementClass,\n categoryModelClassName: modelClass,\n });\n },\n getTreeSpecificVisibilityHandler: (info) => {\n return new CategoriesTreeVisibilityHandler({\n alwaysAndNeverDrawnElementInfo: info,\n idsCache: props.idsCache,\n viewport: props.viewport,\n hierarchyConfig: props.hierarchyConfig,\n });\n },\n viewport: props.viewport,\n componentId: Guid.createValue(),\n });\n}\n"]}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import { concat, EMPTY, from, map, mergeMap, reduce } from "rxjs";
|
|
6
6
|
import { BaseVisibilityHelper } from "../../../common/internal/visibility/BaseVisibilityHelper.js";
|
|
7
|
-
import { enableCategoryDisplay,
|
|
7
|
+
import { enableCategoryDisplay, mergeVisibilityStatuses } from "../../../common/internal/VisibilityUtils.js";
|
|
8
8
|
/**
|
|
9
9
|
* Visibility status helper for categories tree.
|
|
10
10
|
*
|
|
@@ -67,7 +67,7 @@ export class CategoriesTreeVisibilityHelper extends BaseVisibilityHelper {
|
|
|
67
67
|
// make sure parent category and models are enabled
|
|
68
68
|
props.on
|
|
69
69
|
? concat(from(enableCategoryDisplay(this.#props.viewport, props.categoryId, props.on, false)), this.enableCategoriesElementModelsVisibilityStatus(props.categoryId))
|
|
70
|
-
: EMPTY, from(props.subCategoryIds).pipe(map((subCategoryId) =>
|
|
70
|
+
: EMPTY, from(props.subCategoryIds).pipe(map((subCategoryId) => this.#props.viewport.changeSubCategoryDisplay({ subCategoryId, display: props.on }))));
|
|
71
71
|
}
|
|
72
72
|
/** Changes grouped elements visibility status. */
|
|
73
73
|
changeGroupedElementsVisibilityStatus(props) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CategoriesTreeVisibilityHelper.js","sourceRoot":"","sources":["../../../../../../../../src/tree-widget-react/components/trees/categories-tree/internal/visibility/CategoriesTreeVisibilityHelper.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6DAA6D,CAAC;AACnG,OAAO,EAAE,qBAAqB,EAAE,
|
|
1
|
+
{"version":3,"file":"CategoriesTreeVisibilityHelper.js","sourceRoot":"","sources":["../../../../../../../../src/tree-widget-react/components/trees/categories-tree/internal/visibility/CategoriesTreeVisibilityHelper.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6DAA6D,CAAC;AACnG,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,6CAA6C,CAAC;AAgB7G;;;;;GAKG;AACH,MAAM,OAAO,8BAA+B,SAAQ,oBAAoB;IACtE,MAAM,CAAsC;IAC5C,YAAY,KAA0C;QACpD,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,I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I,CAAC,MAAM,CAAC,QAAQ,CAAC,0BAA0B,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC,IAAI,CAC5E,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;YACzB,MAAM,EAAE,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;gBAC1B,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;oBAC9C,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;gBACnB,CAAC;YACH,CAAC,CAAC,CAAC;YACH,OAAO,GAAG,CAAC;QACb,CAAC,EAAE,IAAI,GAAG,EAAc,CAAC,EACzB,GAAG,CAAC,CAAC,YAAY,EAAE,EAAE;YACnB,IAAI,YAAY,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;gBAC1B,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;YACrF,CAAC;QACH,CAAC,CAAC,CACH,CAAC;IACJ,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 { concat, EMPTY, from, map, mergeMap, reduce } from \"rxjs\";\nimport { BaseVisibilityHelper } from \"../../../common/internal/visibility/BaseVisibilityHelper.js\";\nimport { enableCategoryDisplay, mergeVisibilityStatuses } from \"../../../common/internal/VisibilityUtils.js\";\n\nimport type { Observable } from \"rxjs\";\nimport type { Id64Arg, Id64String } from \"@itwin/core-bentley\";\nimport type { ElementId, ModelId } from \"../../../common/internal/Types.js\";\nimport type { BaseVisibilityHelperProps } from \"../../../common/internal/visibility/BaseVisibilityHelper.js\";\nimport type { VisibilityStatus } from \"../../../common/UseHierarchyVisibility.js\";\nimport type { CategoriesTreeHierarchyConfiguration } from \"../../CategoriesTreeDefinition.js\";\nimport type { CategoriesTreeIdsCache } from \"../CategoriesTreeIdsCache.js\";\n\n/** @internal */\nexport type CategoriesTreeVisibilityHelperProps = BaseVisibilityHelperProps & {\n idsCache: CategoriesTreeIdsCache;\n hierarchyConfig: CategoriesTreeHierarchyConfiguration;\n};\n\n/**\n * Visibility status helper for categories tree.\n *\n * It extends base visibility status helper and provides methods to get and change visibility status of definition containers and grouped elements.\n * @internal\n */\nexport class CategoriesTreeVisibilityHelper extends BaseVisibilityHelper {\n #props: CategoriesTreeVisibilityHelperProps;\n constructor(props: CategoriesTreeVisibilityHelperProps) {\n super(props);\n this.#props = props;\n }\n\n /**\n * Gets visibility status of definition containers.\n *\n * Determines visibility status by checking visibility status of related categories.\n */\n public getDefinitionContainersVisibilityStatus(props: { definitionContainerIds: Id64Arg }): Observable<VisibilityStatus> {\n return this.#props.idsCache\n .getAllContainedCategories({\n definitionContainerIds: props.definitionContainerIds,\n includeEmptyCategories: this.#props.hierarchyConfig.showEmptyCategories,\n })\n .pipe(\n mergeMap((categoryIds) =>\n this.getCategoriesVisibilityStatus({\n categoryIds,\n modelId: undefined,\n type: this.#props.viewport.viewType === \"2d\" ? \"DrawingCategory\" : \"SpatialCategory\",\n }),\n ),\n );\n }\n\n /** Gets grouped elements visibility status. */\n public getGroupedElementsVisibilityStatus(props: { modelElementsMap: Map<ModelId, Set<ElementId>>; categoryId: Id64String }): Observable<VisibilityStatus> {\n const { modelElementsMap, categoryId } = props;\n return from(modelElementsMap).pipe(\n mergeMap(([modelId, elementIds]) =>\n this.getElementsVisibilityStatus({\n elementIds,\n modelId,\n categoryId,\n type: this.#props.viewport.viewType === \"2d\" ? \"GeometricElement2d\" : \"GeometricElement3d\",\n }),\n ),\n mergeVisibilityStatuses,\n );\n }\n\n /**\n * Changes visibility status of definition containers.\n *\n * Does this by changing visibility status of related categories.\n */\n public changeDefinitionContainersVisibilityStatus(props: { definitionContainerIds: Id64Arg; on: boolean }): Observable<void> {\n return this.#props.idsCache\n .getAllContainedCategories({\n definitionContainerIds: props.definitionContainerIds,\n includeEmptyCategories: this.#props.hierarchyConfig.showEmptyCategories,\n })\n .pipe(mergeMap((categoryIds) => this.changeCategoriesVisibilityStatus({ categoryIds, modelId: undefined, on: props.on })));\n }\n\n /**\n * Changes visibility status of sub-categories.\n *\n * Also, enables parent categories if `on` is true.\n */\n public changeSubCategoriesVisibilityStatus(props: { categoryId: Id64String; subCategoryIds: Id64Arg; on: boolean }): Observable<void> {\n return concat(\n // make sure parent category and models are enabled\n props.on\n ? concat(\n from(enableCategoryDisplay(this.#props.viewport, props.categoryId, props.on, false)),\n this.enableCategoriesElementModelsVisibilityStatus(props.categoryId),\n )\n : EMPTY,\n from(props.subCategoryIds).pipe(map((subCategoryId) => this.#props.viewport.changeSubCategoryDisplay({ subCategoryId, display: props.on }))),\n );\n }\n\n /** Changes grouped elements visibility status. */\n public changeGroupedElementsVisibilityStatus(props: {\n modelElementsMap: Map<ModelId, Set<ElementId>>;\n categoryId: Id64String;\n on: boolean;\n }): Observable<void> {\n return from(props.modelElementsMap).pipe(\n mergeMap(([modelId, elementIds]) => {\n return this.changeElementsVisibilityStatus({ modelId, elementIds, categoryId: props.categoryId, on: props.on });\n }),\n );\n }\n\n /** Turns on visibility status of models (that are not yet turned on) that are related to categories. */\n private enableCategoriesElementModelsVisibilityStatus(categoryIds: Id64Arg): Observable<void> {\n return this.#props.idsCache.getCategoriesElementModels(categoryIds, true).pipe(\n reduce((acc, { models }) => {\n models?.forEach((modelId) => {\n if (!this.#props.viewport.viewsModel(modelId)) {\n acc.add(modelId);\n }\n });\n return acc;\n }, new Set<Id64String>()),\n map((hiddenModels) => {\n if (hiddenModels.size > 0) {\n this.#props.viewport.changeModelDisplay({ modelIds: hiddenModels, display: true });\n }\n }),\n );\n }\n}\n"]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Id64Set, Id64String } from "@itwin/core-bentley";
|
|
2
|
-
import type {
|
|
2
|
+
import type { HierarchySearchPath } from "@itwin/presentation-hierarchies";
|
|
3
3
|
import type { ECClassHierarchyInspector } from "@itwin/presentation-shared";
|
|
4
4
|
import type { ElementId } from "../../../common/internal/Types.js";
|
|
5
|
-
import type {
|
|
5
|
+
import type { SearchResultsTree } from "../../../common/internal/visibility/BaseSearchResultsTree.js";
|
|
6
6
|
import type { CategoriesTreeIdsCache } from "../CategoriesTreeIdsCache.js";
|
|
7
7
|
/** @internal */
|
|
8
|
-
export interface
|
|
8
|
+
export interface CategoriesTreeSearchTargets {
|
|
9
9
|
categories?: Array<{
|
|
10
10
|
modelId: Id64String | undefined;
|
|
11
11
|
categoryIds: Id64Set;
|
|
@@ -14,7 +14,7 @@ export interface CategoriesTreeFilterTargets {
|
|
|
14
14
|
modelId: Id64String;
|
|
15
15
|
categoryId: Id64String;
|
|
16
16
|
elements: Map<ElementId, {
|
|
17
|
-
|
|
17
|
+
isSearchTarget: boolean;
|
|
18
18
|
}>;
|
|
19
19
|
}>;
|
|
20
20
|
definitionContainerIds?: Id64Set;
|
|
@@ -25,12 +25,12 @@ export interface CategoriesTreeFilterTargets {
|
|
|
25
25
|
}>;
|
|
26
26
|
}
|
|
27
27
|
/** @internal */
|
|
28
|
-
export declare function
|
|
28
|
+
export declare function createCategoriesSearchResultsTree(props: {
|
|
29
29
|
imodelAccess: ECClassHierarchyInspector;
|
|
30
|
-
|
|
30
|
+
searchPaths: HierarchySearchPath[];
|
|
31
31
|
categoryClassName: string;
|
|
32
32
|
categoryElementClassName: string;
|
|
33
33
|
categoryModelClassName: string;
|
|
34
34
|
idsCache: CategoriesTreeIdsCache;
|
|
35
|
-
}): Promise<
|
|
36
|
-
//# sourceMappingURL=
|
|
35
|
+
}): Promise<SearchResultsTree<CategoriesTreeSearchTargets>>;
|
|
36
|
+
//# sourceMappingURL=SearchResultsTree.d.ts.map
|