@itwin/tree-widget-react 4.0.0-alpha.25 → 4.0.0-alpha.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +35 -1
- package/lib/esm/tree-widget-react/components/TreeWidgetUiItemsProvider.js +2 -1
- package/lib/esm/tree-widget-react/components/TreeWidgetUiItemsProvider.js.map +1 -1
- package/lib/esm/tree-widget-react/components/tree-header/WidgetHeader.js +1 -1
- package/lib/esm/tree-widget-react/components/tree-header/WidgetHeader.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTree.d.ts +4 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTree.js +4 -1
- 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.d.ts +1 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.js +36 -47
- 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 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeComponent.js +4 -1
- 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 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js +75 -38
- 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/CategoriesTreeNode.d.ts +3 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeNode.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.d.ts +4 -2
- package/lib/esm/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js +38 -23
- 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 +11 -21
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js +16 -168
- 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/CategoriesTreeNodeInternal.d.ts +65 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeNodeInternal.js +22 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeNodeInternal.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/UseSearchPaths.d.ts +2 -2
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/UseSearchPaths.js +4 -4
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/UseSearchPaths.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/CategoriesTreeVisibilityHandler.d.ts +6 -10
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/CategoriesTreeVisibilityHandler.js +180 -88
- 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.d.ts +14 -5
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/CategoriesTreeVisibilityHelper.js +43 -24
- 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/SearchResultsTree.d.ts +3 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/SearchResultsTree.js +78 -17
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/SearchResultsTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeComponent.d.ts +2 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeComponent.js +4 -1
- 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.js +91 -114
- 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/ClassificationsTreeIcon.d.ts +2 -2
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeIcon.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeNode.d.ts +1 -3
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeNode.js +2 -4
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeNode.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTree.d.ts +13 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTree.js +62 -32
- 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 +12 -9
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTreeDefinition.js +42 -38
- 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 +15 -38
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeIdsCache.js +59 -242
- 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/ClassificationsTreeNodeInternal.d.ts +29 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeNodeInternal.js +19 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeNodeInternal.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/ClassificationsTreeVisibilityHandler.d.ts +4 -8
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/ClassificationsTreeVisibilityHandler.js +154 -78
- 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/ClassificationsTreeVisibilityHelper.js +20 -6
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/ClassificationsTreeVisibilityHelper.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/SearchResultsTree.d.ts +6 -10
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/SearchResultsTree.js +104 -63
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/SearchResultsTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/SharedTreeContextProvider.d.ts +7 -0
- package/lib/esm/tree-widget-react/components/trees/common/SharedTreeContextProvider.js +14 -0
- package/lib/esm/tree-widget-react/components/trees/common/SharedTreeContextProvider.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/TreeWidgetViewport.js +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/TreeWidgetViewport.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/UseHierarchyVisibility.js +2 -2
- package/lib/esm/tree-widget-react/components/trees/common/UseHierarchyVisibility.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/Utils.js +2 -2
- package/lib/esm/tree-widget-react/components/trees/common/Utils.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/Tree.d.ts +4 -4
- package/lib/esm/tree-widget-react/components/trees/common/components/Tree.js +1 -1
- 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/TreeNodeVisibilityButton.d.ts +4 -4
- package/lib/esm/tree-widget-react/components/trees/common/components/TreeNodeVisibilityButton.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/TreeRenderer.js +7 -5
- 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/UseVisibilityButtonHandler.d.ts +2 -2
- package/lib/esm/tree-widget-react/components/trees/common/components/UseVisibilityButtonHandler.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTreeRenderer.js +5 -5
- 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/SharedTreeContextProviderInternal.d.ts +20 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/SharedTreeContextProviderInternal.js +44 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/SharedTreeContextProviderInternal.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/Types.d.ts +4 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/Types.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/UseIModelAccess.d.ts +12 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/UseIModelAccess.js +2 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/UseIModelAccess.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/Utils.d.ts +17 -6
- package/lib/esm/tree-widget-react/components/trees/common/internal/Utils.js +58 -29
- 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 +8 -14
- package/lib/esm/tree-widget-react/components/trees/common/internal/VisibilityUtils.js +22 -26
- 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/{AlwaysAndNeverDrawnElementInfo.d.ts → caches/AlwaysAndNeverDrawnElementInfoCache.d.ts} +15 -21
- package/lib/esm/tree-widget-react/components/trees/common/internal/{AlwaysAndNeverDrawnElementInfo.js → caches/AlwaysAndNeverDrawnElementInfoCache.js} +40 -38
- package/lib/esm/tree-widget-react/components/trees/common/internal/caches/AlwaysAndNeverDrawnElementInfoCache.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/caches/BaseIdsCache.d.ts +68 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/caches/BaseIdsCache.js +148 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/caches/BaseIdsCache.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/caches/ElementChildrenCache.d.ts +30 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/caches/ElementChildrenCache.js +151 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/caches/ElementChildrenCache.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/caches/ElementModelCategoriesCache.d.ts +32 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/caches/ElementModelCategoriesCache.js +106 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/caches/ElementModelCategoriesCache.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/{ModelCategoryElementsCountCache.d.ts → caches/ModelCategoryElementsCountCache.d.ts} +9 -2
- package/lib/esm/tree-widget-react/components/trees/common/internal/{ModelCategoryElementsCountCache.js → caches/ModelCategoryElementsCountCache.js} +17 -21
- package/lib/esm/tree-widget-react/components/trees/common/internal/caches/ModelCategoryElementsCountCache.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/caches/ModeledElementsCache.d.ts +27 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/caches/ModeledElementsCache.js +106 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/caches/ModeledElementsCache.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/caches/SubCategoriesCache.d.ts +23 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/caches/SubCategoriesCache.js +56 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/caches/SubCategoriesCache.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/useTreeHooks/UseCachedVisibility.d.ts +6 -6
- package/lib/esm/tree-widget-react/components/trees/common/internal/useTreeHooks/UseCachedVisibility.js +27 -17
- 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/useTreeHooks/UseIdsCache.d.ts +7 -13
- package/lib/esm/tree-widget-react/components/trees/common/internal/useTreeHooks/UseIdsCache.js +36 -35
- package/lib/esm/tree-widget-react/components/trees/common/internal/useTreeHooks/UseIdsCache.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/visibility/BaseSearchResultsTree.d.ts +18 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/visibility/BaseSearchResultsTree.js +14 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/visibility/BaseSearchResultsTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/visibility/BaseVisibilityHelper.d.ts +46 -70
- package/lib/esm/tree-widget-react/components/trees/common/internal/visibility/BaseVisibilityHelper.js +229 -361
- 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 +2 -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.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.d.ts +2 -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.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeDefinition.js +1 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeDefinition.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/internal/IModelContentTreeIdsCache.js +32 -19
- 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 +2 -1
- package/lib/esm/tree-widget-react/components/trees/index.js +2 -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 +4 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTree.js +4 -1
- 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.d.ts +7 -3
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.js +36 -35
- 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 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.js +3 -1
- 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 +1 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js +56 -26
- 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 +5 -3
- package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.js +25 -12
- 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 +11 -23
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js +56 -189
- 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/ModelsTreeNodeInternal.d.ts +52 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeNodeInternal.js +22 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeNodeInternal.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/UseSearchPaths.d.ts +2 -2
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/UseSearchPaths.js +8 -8
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/UseSearchPaths.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/ModelsTreeVisibilityHandler.d.ts +6 -10
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/ModelsTreeVisibilityHandler.js +179 -72
- 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/ModelsTreeVisibilityHelper.d.ts +6 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/ModelsTreeVisibilityHelper.js +20 -8
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/ModelsTreeVisibilityHelper.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/SearchResultsTree.d.ts +4 -2
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/SearchResultsTree.js +73 -13
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/SearchResultsTree.js.map +1 -1
- package/lib/esm/tree-widget-react-internal.d.ts +1 -0
- package/lib/esm/tree-widget-react-internal.js +1 -0
- package/lib/esm/tree-widget-react-internal.js.map +1 -1
- package/package.json +77 -82
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/UseSearchPaths.d.ts +0 -20
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/UseSearchPaths.js +0 -53
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/UseSearchPaths.js.map +0 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/AlwaysAndNeverDrawnElementInfo.js.map +0 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/ModelCategoryElementsCountCache.js.map +0 -1
|
@@ -12,7 +12,7 @@ import { useTelemetryContext } from "../../common/UseTelemetryContext.js";
|
|
|
12
12
|
import { joinHierarchySearchPaths } from "../../common/Utils.js";
|
|
13
13
|
import { ModelsTreeDefinition } from "../ModelsTreeDefinition.js";
|
|
14
14
|
/** @internal */
|
|
15
|
-
export function useSearchPaths({ hierarchyConfiguration, searchText, getSearchPaths, getSubTreePaths,
|
|
15
|
+
export function useSearchPaths({ hierarchyConfiguration, searchText, getSearchPaths, getSubTreePaths, idsCache, onModelsFiltered, onSearchPathsChanged, componentId, }) {
|
|
16
16
|
const [searchError, setSearchError] = useState(undefined);
|
|
17
17
|
const [subTreeError, setSubTreeError] = useState(undefined);
|
|
18
18
|
const { onFeatureUsed } = useTelemetryContext();
|
|
@@ -36,7 +36,7 @@ export function useSearchPaths({ hierarchyConfiguration, searchText, getSearchPa
|
|
|
36
36
|
createInstanceKeyPaths: async ({ targetItems }) => ModelsTreeDefinition.createInstanceKeyPaths({
|
|
37
37
|
imodelAccess,
|
|
38
38
|
targetItems,
|
|
39
|
-
idsCache
|
|
39
|
+
idsCache,
|
|
40
40
|
hierarchyConfig: hierarchyConfiguration,
|
|
41
41
|
limit: "unbounded",
|
|
42
42
|
abortSignal,
|
|
@@ -51,14 +51,14 @@ export function useSearchPaths({ hierarchyConfiguration, searchText, getSearchPa
|
|
|
51
51
|
return [];
|
|
52
52
|
}
|
|
53
53
|
};
|
|
54
|
-
}, [
|
|
54
|
+
}, [idsCache, hierarchyConfiguration, getSubTreePaths, componentId]);
|
|
55
55
|
const getPaths = useMemo(() => {
|
|
56
56
|
const handlePaths = async (searchPaths, classInspector) => {
|
|
57
57
|
onSearchPathsChanged(searchPaths);
|
|
58
58
|
if (!onModelsFiltered) {
|
|
59
59
|
return;
|
|
60
60
|
}
|
|
61
|
-
const modelIds = searchPaths ? await getModels(searchPaths,
|
|
61
|
+
const modelIds = searchPaths ? await getModels(searchPaths, idsCache, classInspector) : undefined;
|
|
62
62
|
onModelsFiltered(modelIds);
|
|
63
63
|
};
|
|
64
64
|
if (loadFocusedItems) {
|
|
@@ -69,7 +69,7 @@ export function useSearchPaths({ hierarchyConfiguration, searchText, getSearchPa
|
|
|
69
69
|
getSearchPaths: async () => {
|
|
70
70
|
const paths = await ModelsTreeDefinition.createInstanceKeyPaths({
|
|
71
71
|
imodelAccess,
|
|
72
|
-
idsCache
|
|
72
|
+
idsCache,
|
|
73
73
|
targetItems: focusedItems,
|
|
74
74
|
hierarchyConfig: hierarchyConfiguration,
|
|
75
75
|
abortSignal,
|
|
@@ -101,7 +101,7 @@ export function useSearchPaths({ hierarchyConfiguration, searchText, getSearchPa
|
|
|
101
101
|
createInstanceKeyPaths: async (props) => ModelsTreeDefinition.createInstanceKeyPaths({
|
|
102
102
|
...props,
|
|
103
103
|
imodelAccess,
|
|
104
|
-
idsCache
|
|
104
|
+
idsCache,
|
|
105
105
|
hierarchyConfig: hierarchyConfiguration,
|
|
106
106
|
limit: "unbounded",
|
|
107
107
|
abortSignal,
|
|
@@ -135,7 +135,7 @@ export function useSearchPaths({ hierarchyConfiguration, searchText, getSearchPa
|
|
|
135
135
|
const paths = await ModelsTreeDefinition.createInstanceKeyPaths({
|
|
136
136
|
imodelAccess,
|
|
137
137
|
label: searchText,
|
|
138
|
-
idsCache
|
|
138
|
+
idsCache,
|
|
139
139
|
hierarchyConfig: hierarchyConfiguration,
|
|
140
140
|
abortSignal,
|
|
141
141
|
componentId,
|
|
@@ -161,7 +161,7 @@ export function useSearchPaths({ hierarchyConfiguration, searchText, getSearchPa
|
|
|
161
161
|
}, [
|
|
162
162
|
searchText,
|
|
163
163
|
loadFocusedItems,
|
|
164
|
-
|
|
164
|
+
idsCache,
|
|
165
165
|
onFeatureUsed,
|
|
166
166
|
getSearchPaths,
|
|
167
167
|
hierarchyConfiguration,
|
package/lib/esm/tree-widget-react/components/trees/models-tree/internal/UseSearchPaths.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UseSearchPaths.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/models-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,uBAAuB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACjH,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,2BAA2B,EAAE,kBAAkB,EAAE,MAAM,+CAA+C,CAAC;AAChH,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAelE,gBAAgB;AAChB,MAAM,UAAU,cAAc,CAAC,EAC7B,sBAAsB,EACtB,UAAU,EACV,cAAc,EACd,eAAe,EACf,qBAAqB,EACrB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eAAe,EAAE,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC;IAC7F,IAAI,WAA8C,CAAC;IACnD,IAAI,CAAC;QACH,IAAI,YAAY,IAAI,WAAW,EAAE,CAAC;YAChC,OAAO,CAAC,WAAW,GAAG,wBAAwB,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC,CAAC;QAC7E,CAAC;QACD,IAAI,YAAY,EAAE,CAAC;YACjB,OAAO,CAAC,WAAW,GAAG,YAAY,CAAC,CAAC;QACtC,CAAC;QACD,IAAI,WAAW,EAAE,CAAC;YAChB,OAAO,CAAC,WAAW,GAAG,WAAW,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;YAAS,CAAC;QACT,KAAK,WAAW,CAAC,WAAW,CAAC,CAAC;IAChC,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,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 { HierarchyNodeIdentifier, HierarchyNodeKey, HierarchySearchPath } from \"@itwin/presentation-hierarchies\";\nimport { useFocusedInstancesContext } from \"../../common/FocusedInstancesContext.js\";\nimport { CLASS_NAME_GeometricModel3d, CLASS_NAME_Subject } from \"../../common/internal/ClassNameDefinitions.js\";\nimport { SearchLimitExceededError } from \"../../common/TreeErrors.js\";\nimport { useTelemetryContext } from \"../../common/UseTelemetryContext.js\";\nimport { joinHierarchySearchPaths } from \"../../common/Utils.js\";\nimport { ModelsTreeDefinition } from \"../ModelsTreeDefinition.js\";\n\nimport type { GuidString, Id64Array, Id64String } from \"@itwin/core-bentley\";\nimport type { GroupingHierarchyNode, HierarchyNodeIdentifiersPath, InstancesNodeKey } from \"@itwin/presentation-hierarchies\";\nimport type { ECClassHierarchyInspector, InstanceKey } from \"@itwin/presentation-shared\";\nimport type { VisibilityTreeProps } from \"../../common/components/VisibilityTree.js\";\nimport type { NormalizedHierarchySearchPath } from \"../../common/Utils.js\";\nimport type { ClassGroupingHierarchyNode, ElementsGroupInfo, ModelsTreeHierarchyConfiguration } from \"../ModelsTreeDefinition.js\";\nimport type { ModelsTreeIdsCache } from \"./ModelsTreeIdsCache.js\";\n\n/** @internal */\nexport type ModelsTreeSearchError = \"tooManySearchMatches\" | \"tooManyInstancesFocused\" | \"unknownSearchError\" | \"unknownInstanceFocusError\";\n/** @internal */\nexport type ModelsTreeSubTreeError = \"unknownSubTreeError\";\n\n/** @internal */\nexport function useSearchPaths({\n hierarchyConfiguration,\n searchText,\n getSearchPaths,\n getSubTreePaths,\n getModelsTreeIdsCache,\n onModelsFiltered,\n onSearchPathsChanged,\n componentId,\n}: {\n hierarchyConfiguration: ModelsTreeHierarchyConfiguration;\n searchText?: string;\n getSearchPaths?: (props: {\n /** A function that creates search paths based on provided target instance keys or node label. */\n createInstanceKeyPaths: (props: { targetItems: Array<InstanceKey | ElementsGroupInfo> } | { label: string }) => Promise<NormalizedHierarchySearchPath[]>;\n /** Search text which would be used to create search paths if `getSearchPaths` wouldn't be provided. */\n searchText?: string;\n }) => Promise<HierarchySearchPath[] | undefined>;\n getSubTreePaths?: (props: {\n /** A function that creates search paths based on provided target instance keys. */\n createInstanceKeyPaths: (props: { targetItems: Array<InstanceKey | ElementsGroupInfo> }) => Promise<NormalizedHierarchySearchPath[]>;\n }) => Promise<HierarchySearchPath[]>;\n getModelsTreeIdsCache: () => ModelsTreeIdsCache;\n onModelsFiltered?: (modelIds: Id64String[] | undefined) => void;\n onSearchPathsChanged: (paths: HierarchySearchPath[] | undefined) => void;\n componentId: GuidString;\n}): {\n getPaths: VisibilityTreeProps[\"getSearchPaths\"] | undefined;\n searchError: ModelsTreeSearchError | undefined;\n subTreeError: ModelsTreeSubTreeError | undefined;\n} {\n const [searchError, setSearchError] = useState<ModelsTreeSearchError | undefined>(undefined);\n const [subTreeError, setSubTreeError] = useState<ModelsTreeSubTreeError | undefined>(undefined);\n\n const { onFeatureUsed } = useTelemetryContext();\n const { loadFocusedItems } = useFocusedInstancesContext();\n\n useEffect(() => {\n setSearchError(undefined);\n setSubTreeError(undefined);\n onModelsFiltered?.(undefined);\n\n // reset search paths if there is no search applied. This allows to keep current search paths until new paths are loaded.\n if (!loadFocusedItems && !getSearchPaths && !searchText && !getSubTreePaths) {\n onSearchPathsChanged(undefined);\n }\n }, [loadFocusedItems, getSearchPaths, getSubTreePaths, searchText, onModelsFiltered, onSearchPathsChanged]);\n\n const getSubTreePathsInternal = useMemo<\n ((...props: Parameters<Required<VisibilityTreeProps>[\"getSearchPaths\"]>) => Promise<HierarchyNodeIdentifiersPath[]>) | undefined\n >(() => {\n if (!getSubTreePaths) {\n return undefined;\n }\n return async ({ imodelAccess, abortSignal }) => {\n try {\n const paths = await getSubTreePaths({\n createInstanceKeyPaths: async ({ targetItems }) =>\n ModelsTreeDefinition.createInstanceKeyPaths({\n imodelAccess,\n targetItems,\n idsCache: getModelsTreeIdsCache(),\n hierarchyConfig: hierarchyConfiguration,\n limit: \"unbounded\",\n abortSignal,\n componentId: `${componentId}/subTree`,\n }),\n });\n return paths.map(HierarchySearchPath.normalize).map(({ path }) => path);\n } catch {\n const newError = \"unknownSubTreeError\";\n setSubTreeError(newError);\n return [];\n }\n };\n }, [getModelsTreeIdsCache, hierarchyConfiguration, getSubTreePaths, componentId]);\n\n const getPaths = useMemo<VisibilityTreeProps[\"getSearchPaths\"] | undefined>(() => {\n const handlePaths = async (searchPaths: HierarchySearchPath[] | undefined, classInspector: ECClassHierarchyInspector) => {\n onSearchPathsChanged(searchPaths);\n if (!onModelsFiltered) {\n return;\n }\n\n const modelIds = searchPaths ? await getModels(searchPaths, getModelsTreeIdsCache(), classInspector) : undefined;\n onModelsFiltered(modelIds);\n };\n\n if (loadFocusedItems) {\n return async ({ imodelAccess, abortSignal }) => {\n try {\n const focusedItems = await collectFocusedItems(loadFocusedItems);\n return await createSearchPathsResult({\n getSearchPaths: async () => {\n const paths = await ModelsTreeDefinition.createInstanceKeyPaths({\n imodelAccess,\n idsCache: getModelsTreeIdsCache(),\n targetItems: focusedItems,\n hierarchyConfig: hierarchyConfiguration,\n abortSignal,\n componentId,\n });\n return paths.map(({ path, options }) => ({ path, options: { ...options, reveal: true } }));\n },\n getSubTreePaths: async () => (getSubTreePathsInternal ? getSubTreePathsInternal({ imodelAccess, abortSignal }) : undefined),\n handlePaths: async (paths) => handlePaths(paths, imodelAccess),\n });\n } catch (e) {\n const newError = e instanceof SearchLimitExceededError ? \"tooManyInstancesFocused\" : \"unknownInstanceFocusError\";\n if (newError !== \"tooManyInstancesFocused\") {\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 }\n\n if (getSearchPaths) {\n return async ({ imodelAccess, abortSignal }) => {\n try {\n return await createSearchPathsResult({\n getSearchPaths: async () => {\n const paths = await getSearchPaths({\n createInstanceKeyPaths: async (props) =>\n ModelsTreeDefinition.createInstanceKeyPaths({\n ...props,\n imodelAccess,\n idsCache: getModelsTreeIdsCache(),\n hierarchyConfig: hierarchyConfiguration,\n limit: \"unbounded\",\n abortSignal,\n componentId,\n }),\n searchText,\n });\n return paths?.map(HierarchySearchPath.normalize);\n },\n getSubTreePaths: async () => (getSubTreePathsInternal ? getSubTreePathsInternal({ imodelAccess, abortSignal }) : undefined),\n handlePaths: async (paths) => handlePaths(paths, imodelAccess),\n });\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 }\n\n if (searchText) {\n return async ({ imodelAccess, abortSignal }) => {\n onFeatureUsed({ featureId: \"search\", reportInteraction: true });\n try {\n return await createSearchPathsResult({\n getSearchPaths: async () => {\n const paths = await ModelsTreeDefinition.createInstanceKeyPaths({\n imodelAccess,\n label: searchText,\n idsCache: getModelsTreeIdsCache(),\n hierarchyConfig: hierarchyConfiguration,\n abortSignal,\n componentId,\n });\n return paths.map(({ path, options }) => ({ path, options: { ...options, reveal: true } }));\n },\n getSubTreePaths: async () => (getSubTreePathsInternal ? getSubTreePathsInternal({ imodelAccess, abortSignal }) : undefined),\n handlePaths: async (paths) => handlePaths(paths, imodelAccess),\n });\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 }\n return getSubTreePathsInternal;\n }, [\n searchText,\n loadFocusedItems,\n getModelsTreeIdsCache,\n onFeatureUsed,\n getSearchPaths,\n hierarchyConfiguration,\n onModelsFiltered,\n onSearchPathsChanged,\n getSubTreePathsInternal,\n componentId,\n ]);\n\n return {\n getPaths,\n searchError,\n subTreeError,\n };\n}\n\nasync function getModels(paths: HierarchySearchPath[], idsCache: ModelsTreeIdsCache, classInspector: ECClassHierarchyInspector) {\n if (!paths) {\n return undefined;\n }\n\n const targetModelIds = new Set<Id64String>();\n const targetSubjectIds = new Set<Id64String>();\n for (const path of paths) {\n const currPath = Array.isArray(path) ? path : path.path;\n for (let i = 0; i < currPath.length; i++) {\n const currStep = currPath[i];\n if (!HierarchyNodeIdentifier.isInstanceNodeIdentifier(currStep)) {\n break;\n }\n\n // if paths end with subject need to get all models under that subject\n if (i === currPath.length - 1 && currStep.className === CLASS_NAME_Subject) {\n targetSubjectIds.add(currStep.id);\n break;\n }\n\n // collect all the models from the search path\n if (await classInspector.classDerivesFrom(currStep.className, CLASS_NAME_GeometricModel3d)) {\n targetModelIds.add(currStep.id);\n }\n }\n }\n\n const matchingModels = await firstValueFrom(idsCache.getSubjectModelIds(targetSubjectIds));\n return [...targetModelIds, ...matchingModels];\n}\n\nasync function collectFocusedItems(loadFocusedItems: () => AsyncIterableIterator<InstanceKey | GroupingHierarchyNode>) {\n const focusedItems: Array<InstanceKey | ElementsGroupInfo> = [];\n const groupingNodeInfos: Array<{\n parentKey: InstancesNodeKey;\n parentType: \"element\" | \"category\";\n groupingNode: ClassGroupingHierarchyNode;\n modelIds: Id64Array;\n }> = [];\n for await (const key of loadFocusedItems()) {\n if (\"id\" in key) {\n focusedItems.push(key);\n continue;\n }\n\n if (!HierarchyNodeKey.isClassGrouping(key.key)) {\n continue;\n }\n\n const groupingNode = key as ClassGroupingHierarchyNode;\n if (!groupingNode.nonGroupingAncestor || !HierarchyNodeKey.isInstances(groupingNode.nonGroupingAncestor.key)) {\n continue;\n }\n\n const parentKey = groupingNode.nonGroupingAncestor.key;\n const type = groupingNode.nonGroupingAncestor.extendedData?.isCategory ? \"category\" : \"element\";\n const modelIds = ((groupingNode.nonGroupingAncestor.extendedData?.modelIds as Id64String[][]) ?? []).flatMap((ids) => ids);\n groupingNodeInfos.push({ groupingNode, parentType: type, parentKey, modelIds });\n }\n focusedItems.push(\n ...groupingNodeInfos.map(({ parentKey, parentType, groupingNode, modelIds }) => ({\n parent:\n parentType === \"element\"\n ? { type: \"element\" as const, ids: parentKey.instanceKeys.map((key) => key.id) }\n : { type: \"category\" as const, ids: parentKey.instanceKeys.map((key) => key.id), modelIds },\n groupingNode,\n })),\n );\n return focusedItems;\n}\n\nasync function createSearchPathsResult({\n getSubTreePaths,\n getSearchPaths,\n handlePaths,\n}: {\n getSubTreePaths: () => Promise<HierarchyNodeIdentifiersPath[] | undefined>;\n getSearchPaths: () => Promise<NormalizedHierarchySearchPath[] | undefined>;\n handlePaths: (searchPaths: HierarchySearchPath[] | undefined) => Promise<void>;\n}): Promise<HierarchySearchPath[] | undefined> {\n const [subTreePaths, searchPaths] = await Promise.all([getSubTreePaths(), getSearchPaths()]);\n let joinedPaths: HierarchySearchPath[] | undefined;\n try {\n if (subTreePaths && searchPaths) {\n return (joinedPaths = joinHierarchySearchPaths(subTreePaths, searchPaths));\n }\n if (subTreePaths) {\n return (joinedPaths = subTreePaths);\n }\n if (searchPaths) {\n return (joinedPaths = searchPaths);\n }\n } finally {\n void handlePaths(joinedPaths);\n }\n return joinedPaths;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"UseSearchPaths.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/models-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,uBAAuB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACjH,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,2BAA2B,EAAE,kBAAkB,EAAE,MAAM,+CAA+C,CAAC;AAChH,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAelE,gBAAgB;AAChB,MAAM,UAAU,cAAc,CAAC,EAC7B,sBAAsB,EACtB,UAAU,EACV,cAAc,EACd,eAAe,EACf,QAAQ,EACR,gBAAgB,EAChB,oBAAoB,EACpB,WAAW,GAkBZ;IAKC,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAoC,SAAS,CAAC,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C7E,CAAC;QACD,IAAI,YAAY,EAAE,CAAC;YACjB,OAAO,CAAC,WAAW,GAAG,YAAY,CAAC,CAAC;QACtC,CAAC;QACD,IAAI,WAAW,EAAE,CAAC;YAChB,OAAO,CAAC,WAAW,GAAG,WAAW,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;YAAS,CAAC;QACT,KAAK,WAAW,CAAC,WAAW,CAAC,CAAC;IAChC,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,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 { HierarchyNodeIdentifier, HierarchyNodeKey, HierarchySearchPath } from \"@itwin/presentation-hierarchies\";\nimport { useFocusedInstancesContext } from \"../../common/FocusedInstancesContext.js\";\nimport { CLASS_NAME_GeometricModel3d, CLASS_NAME_Subject } from \"../../common/internal/ClassNameDefinitions.js\";\nimport { SearchLimitExceededError } from \"../../common/TreeErrors.js\";\nimport { useTelemetryContext } from \"../../common/UseTelemetryContext.js\";\nimport { joinHierarchySearchPaths } from \"../../common/Utils.js\";\nimport { ModelsTreeDefinition } from \"../ModelsTreeDefinition.js\";\n\nimport type { GuidString, Id64Array, Id64String } from \"@itwin/core-bentley\";\nimport type { GroupingHierarchyNode, HierarchyNodeIdentifiersPath, InstancesNodeKey } from \"@itwin/presentation-hierarchies\";\nimport type { ECClassHierarchyInspector, InstanceKey } from \"@itwin/presentation-shared\";\nimport type { VisibilityTreeProps } from \"../../common/components/VisibilityTree.js\";\nimport type { NormalizedHierarchySearchPath } from \"../../common/Utils.js\";\nimport type { ClassGroupingHierarchyNode, ElementsGroupInfo, ModelsTreeHierarchyConfiguration } from \"../ModelsTreeDefinition.js\";\nimport type { ModelsTreeIdsCache } from \"./ModelsTreeIdsCache.js\";\n\n/** @internal */\nexport type ModelsTreeSearchError = \"tooManySearchMatches\" | \"tooManyInstancesFocused\" | \"unknownSearchError\" | \"unknownInstanceFocusError\";\n/** @internal */\nexport type ModelsTreeSubTreeError = \"unknownSubTreeError\";\n\n/** @internal */\nexport function useSearchPaths({\n hierarchyConfiguration,\n searchText,\n getSearchPaths,\n getSubTreePaths,\n idsCache,\n onModelsFiltered,\n onSearchPathsChanged,\n componentId,\n}: {\n hierarchyConfiguration: ModelsTreeHierarchyConfiguration;\n searchText?: string;\n getSearchPaths?: (props: {\n /** A function that creates search paths based on provided target instance keys or node label. */\n createInstanceKeyPaths: (props: { targetItems: Array<InstanceKey | ElementsGroupInfo> } | { label: string }) => Promise<NormalizedHierarchySearchPath[]>;\n /** Search text which would be used to create search paths if `getSearchPaths` wouldn't be provided. */\n searchText?: string;\n }) => Promise<HierarchySearchPath[] | undefined>;\n getSubTreePaths?: (props: {\n /** A function that creates search paths based on provided target instance keys. */\n createInstanceKeyPaths: (props: { targetItems: Array<InstanceKey | ElementsGroupInfo> }) => Promise<NormalizedHierarchySearchPath[]>;\n }) => Promise<HierarchySearchPath[]>;\n idsCache: ModelsTreeIdsCache;\n onModelsFiltered?: (modelIds: Id64String[] | undefined) => void;\n onSearchPathsChanged: (paths: HierarchySearchPath[] | undefined) => void;\n componentId: GuidString;\n}): {\n getPaths: VisibilityTreeProps[\"getSearchPaths\"] | undefined;\n searchError: ModelsTreeSearchError | undefined;\n subTreeError: ModelsTreeSubTreeError | undefined;\n} {\n const [searchError, setSearchError] = useState<ModelsTreeSearchError | undefined>(undefined);\n const [subTreeError, setSubTreeError] = useState<ModelsTreeSubTreeError | undefined>(undefined);\n\n const { onFeatureUsed } = useTelemetryContext();\n const { loadFocusedItems } = useFocusedInstancesContext();\n\n useEffect(() => {\n setSearchError(undefined);\n setSubTreeError(undefined);\n onModelsFiltered?.(undefined);\n\n // reset search paths if there is no search applied. This allows to keep current search paths until new paths are loaded.\n if (!loadFocusedItems && !getSearchPaths && !searchText && !getSubTreePaths) {\n onSearchPathsChanged(undefined);\n }\n }, [loadFocusedItems, getSearchPaths, getSubTreePaths, searchText, onModelsFiltered, onSearchPathsChanged]);\n\n const getSubTreePathsInternal = useMemo<\n ((...props: Parameters<Required<VisibilityTreeProps>[\"getSearchPaths\"]>) => Promise<HierarchyNodeIdentifiersPath[]>) | undefined\n >(() => {\n if (!getSubTreePaths) {\n return undefined;\n }\n return async ({ imodelAccess, abortSignal }) => {\n try {\n const paths = await getSubTreePaths({\n createInstanceKeyPaths: async ({ targetItems }) =>\n ModelsTreeDefinition.createInstanceKeyPaths({\n imodelAccess,\n targetItems,\n idsCache,\n hierarchyConfig: hierarchyConfiguration,\n limit: \"unbounded\",\n abortSignal,\n componentId: `${componentId}/subTree`,\n }),\n });\n return paths.map(HierarchySearchPath.normalize).map(({ path }) => path);\n } catch {\n const newError = \"unknownSubTreeError\";\n setSubTreeError(newError);\n return [];\n }\n };\n }, [idsCache, hierarchyConfiguration, getSubTreePaths, componentId]);\n\n const getPaths = useMemo<VisibilityTreeProps[\"getSearchPaths\"] | undefined>(() => {\n const handlePaths = async (searchPaths: HierarchySearchPath[] | undefined, classInspector: ECClassHierarchyInspector) => {\n onSearchPathsChanged(searchPaths);\n if (!onModelsFiltered) {\n return;\n }\n\n const modelIds = searchPaths ? await getModels(searchPaths, idsCache, classInspector) : undefined;\n onModelsFiltered(modelIds);\n };\n\n if (loadFocusedItems) {\n return async ({ imodelAccess, abortSignal }) => {\n try {\n const focusedItems = await collectFocusedItems(loadFocusedItems);\n return await createSearchPathsResult({\n getSearchPaths: async () => {\n const paths = await ModelsTreeDefinition.createInstanceKeyPaths({\n imodelAccess,\n idsCache,\n targetItems: focusedItems,\n hierarchyConfig: hierarchyConfiguration,\n abortSignal,\n componentId,\n });\n return paths.map(({ path, options }) => ({ path, options: { ...options, reveal: true } }));\n },\n getSubTreePaths: async () => (getSubTreePathsInternal ? getSubTreePathsInternal({ imodelAccess, abortSignal }) : undefined),\n handlePaths: async (paths) => handlePaths(paths, imodelAccess),\n });\n } catch (e) {\n const newError = e instanceof SearchLimitExceededError ? \"tooManyInstancesFocused\" : \"unknownInstanceFocusError\";\n if (newError !== \"tooManyInstancesFocused\") {\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 }\n\n if (getSearchPaths) {\n return async ({ imodelAccess, abortSignal }) => {\n try {\n return await createSearchPathsResult({\n getSearchPaths: async () => {\n const paths = await getSearchPaths({\n createInstanceKeyPaths: async (props) =>\n ModelsTreeDefinition.createInstanceKeyPaths({\n ...props,\n imodelAccess,\n idsCache,\n hierarchyConfig: hierarchyConfiguration,\n limit: \"unbounded\",\n abortSignal,\n componentId,\n }),\n searchText,\n });\n return paths?.map(HierarchySearchPath.normalize);\n },\n getSubTreePaths: async () => (getSubTreePathsInternal ? getSubTreePathsInternal({ imodelAccess, abortSignal }) : undefined),\n handlePaths: async (paths) => handlePaths(paths, imodelAccess),\n });\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 }\n\n if (searchText) {\n return async ({ imodelAccess, abortSignal }) => {\n onFeatureUsed({ featureId: \"search\", reportInteraction: true });\n try {\n return await createSearchPathsResult({\n getSearchPaths: async () => {\n const paths = await ModelsTreeDefinition.createInstanceKeyPaths({\n imodelAccess,\n label: searchText,\n idsCache,\n hierarchyConfig: hierarchyConfiguration,\n abortSignal,\n componentId,\n });\n return paths.map(({ path, options }) => ({ path, options: { ...options, reveal: true } }));\n },\n getSubTreePaths: async () => (getSubTreePathsInternal ? getSubTreePathsInternal({ imodelAccess, abortSignal }) : undefined),\n handlePaths: async (paths) => handlePaths(paths, imodelAccess),\n });\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 }\n return getSubTreePathsInternal;\n }, [\n searchText,\n loadFocusedItems,\n idsCache,\n onFeatureUsed,\n getSearchPaths,\n hierarchyConfiguration,\n onModelsFiltered,\n onSearchPathsChanged,\n getSubTreePathsInternal,\n componentId,\n ]);\n\n return {\n getPaths,\n searchError,\n subTreeError,\n };\n}\n\nasync function getModels(paths: HierarchySearchPath[], idsCache: ModelsTreeIdsCache, classInspector: ECClassHierarchyInspector) {\n if (!paths) {\n return undefined;\n }\n\n const targetModelIds = new Set<Id64String>();\n const targetSubjectIds = new Set<Id64String>();\n for (const path of paths) {\n const currPath = Array.isArray(path) ? path : path.path;\n for (let i = 0; i < currPath.length; i++) {\n const currStep = currPath[i];\n if (!HierarchyNodeIdentifier.isInstanceNodeIdentifier(currStep)) {\n break;\n }\n\n // if paths end with subject need to get all models under that subject\n if (i === currPath.length - 1 && currStep.className === CLASS_NAME_Subject) {\n targetSubjectIds.add(currStep.id);\n break;\n }\n\n // collect all the models from the search path\n if (await classInspector.classDerivesFrom(currStep.className, CLASS_NAME_GeometricModel3d)) {\n targetModelIds.add(currStep.id);\n }\n }\n }\n\n const matchingModels = await firstValueFrom(idsCache.getSubjectModelIds(targetSubjectIds));\n return [...targetModelIds, ...matchingModels];\n}\n\nasync function collectFocusedItems(loadFocusedItems: () => AsyncIterableIterator<InstanceKey | GroupingHierarchyNode>) {\n const focusedItems: Array<InstanceKey | ElementsGroupInfo> = [];\n const groupingNodeInfos: Array<{\n parentKey: InstancesNodeKey;\n parentType: \"element\" | \"category\";\n groupingNode: ClassGroupingHierarchyNode;\n modelIds: Id64Array;\n }> = [];\n for await (const key of loadFocusedItems()) {\n if (\"id\" in key) {\n focusedItems.push(key);\n continue;\n }\n\n if (!HierarchyNodeKey.isClassGrouping(key.key)) {\n continue;\n }\n\n const groupingNode = key as ClassGroupingHierarchyNode;\n if (!groupingNode.nonGroupingAncestor || !HierarchyNodeKey.isInstances(groupingNode.nonGroupingAncestor.key)) {\n continue;\n }\n\n const parentKey = groupingNode.nonGroupingAncestor.key;\n const type = groupingNode.nonGroupingAncestor.extendedData?.isCategory ? \"category\" : \"element\";\n const modelIds = ((groupingNode.nonGroupingAncestor.extendedData?.modelIds as Id64String[][]) ?? []).flatMap((ids) => ids);\n groupingNodeInfos.push({ groupingNode, parentType: type, parentKey, modelIds });\n }\n focusedItems.push(\n ...groupingNodeInfos.map(({ parentKey, parentType, groupingNode, modelIds }) => ({\n parent:\n parentType === \"element\"\n ? { type: \"element\" as const, ids: parentKey.instanceKeys.map((key) => key.id) }\n : { type: \"category\" as const, ids: parentKey.instanceKeys.map((key) => key.id), modelIds },\n groupingNode,\n })),\n );\n return focusedItems;\n}\n\nasync function createSearchPathsResult({\n getSubTreePaths,\n getSearchPaths,\n handlePaths,\n}: {\n getSubTreePaths: () => Promise<HierarchyNodeIdentifiersPath[] | undefined>;\n getSearchPaths: () => Promise<NormalizedHierarchySearchPath[] | undefined>;\n handlePaths: (searchPaths: HierarchySearchPath[] | undefined) => Promise<void>;\n}): Promise<HierarchySearchPath[] | undefined> {\n const [subTreePaths, searchPaths] = await Promise.all([getSubTreePaths(), getSearchPaths()]);\n let joinedPaths: HierarchySearchPath[] | undefined;\n try {\n if (subTreePaths && searchPaths) {\n return (joinedPaths = joinHierarchySearchPaths(subTreePaths, searchPaths));\n }\n if (subTreePaths) {\n return (joinedPaths = subTreePaths);\n }\n if (searchPaths) {\n return (joinedPaths = searchPaths);\n }\n } finally {\n void handlePaths(joinedPaths);\n }\n return joinedPaths;\n}\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { HierarchyVisibilityHandlerImpl } from "../../../common/internal/useTreeHooks/UseCachedVisibility.js";
|
|
2
2
|
import type { Observable } from "rxjs";
|
|
3
3
|
import type { Id64Arg } from "@itwin/core-bentley";
|
|
4
|
-
import type { GroupingHierarchyNode, HierarchyNode, HierarchySearchPath } from "@itwin/presentation-hierarchies";
|
|
4
|
+
import type { ClassGroupingNodeKey, GroupingHierarchyNode, HierarchyNode, HierarchySearchPath, InstancesNodeKey } from "@itwin/presentation-hierarchies";
|
|
5
5
|
import type { ECClassHierarchyInspector } from "@itwin/presentation-shared";
|
|
6
|
-
import type {
|
|
6
|
+
import type { AlwaysAndNeverDrawnElementInfoCache } from "../../../common/internal/caches/AlwaysAndNeverDrawnElementInfoCache.js";
|
|
7
7
|
import type { BaseTreeVisibilityHandlerOverrides, TreeSpecificVisibilityHandler } from "../../../common/internal/visibility/BaseVisibilityHelper.js";
|
|
8
8
|
import type { TreeWidgetViewport } from "../../../common/TreeWidgetViewport.js";
|
|
9
9
|
import type { HierarchyVisibilityHandlerOverridableMethod, HierarchyVisibilityOverrideHandler, VisibilityStatus } from "../../../common/UseHierarchyVisibility.js";
|
|
@@ -34,7 +34,7 @@ export interface ModelsTreeVisibilityHandlerOverrides extends BaseTreeVisibility
|
|
|
34
34
|
export interface ModelsTreeVisibilityHandlerProps {
|
|
35
35
|
idsCache: ModelsTreeIdsCache;
|
|
36
36
|
viewport: TreeWidgetViewport;
|
|
37
|
-
alwaysAndNeverDrawnElementInfo:
|
|
37
|
+
alwaysAndNeverDrawnElementInfo: AlwaysAndNeverDrawnElementInfoCache;
|
|
38
38
|
overrideHandler: HierarchyVisibilityOverrideHandler;
|
|
39
39
|
overrides?: ModelsTreeVisibilityHandlerOverrides;
|
|
40
40
|
}
|
|
@@ -52,13 +52,9 @@ export declare class ModelsTreeVisibilityHandler implements Disposable, TreeSpec
|
|
|
52
52
|
getVisibilityStatus(node: HierarchyNode): Observable<VisibilityStatus>;
|
|
53
53
|
/** Changes visibility of the items represented by the tree node. */
|
|
54
54
|
changeVisibilityStatus(node: HierarchyNode, on: boolean): Observable<void>;
|
|
55
|
-
getSearchTargetsVisibilityStatus(targets: ModelsTreeSearchTargets
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
private getElementsCount;
|
|
59
|
-
private getModels;
|
|
60
|
-
private getSubCategories;
|
|
61
|
-
private getSubModels;
|
|
55
|
+
getSearchTargetsVisibilityStatus(targets: ModelsTreeSearchTargets, node: HierarchyNode & {
|
|
56
|
+
key: ClassGroupingNodeKey | InstancesNodeKey;
|
|
57
|
+
}): Observable<VisibilityStatus>;
|
|
62
58
|
}
|
|
63
59
|
/**
|
|
64
60
|
* Creates models tree visibility handler. Is used by integration and performance tests.
|
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
import { concat, defer, from, map, merge, mergeMap, of } from "rxjs";
|
|
6
|
-
import { assert, Guid
|
|
5
|
+
import { concat, defer, EMPTY, from, map, merge, mergeAll, mergeMap, of } from "rxjs";
|
|
6
|
+
import { assert, Guid } from "@itwin/core-bentley";
|
|
7
|
+
import { HierarchyNodeKey } from "@itwin/presentation-hierarchies";
|
|
8
|
+
import { createVisibilityStatus } from "../../../common/internal/Tooltip.js";
|
|
7
9
|
import { HierarchyVisibilityHandlerImpl } from "../../../common/internal/useTreeHooks/UseCachedVisibility.js";
|
|
8
|
-
import { fromWithRelease } from "../../../common/internal/Utils.js";
|
|
10
|
+
import { fromWithRelease, getIdsFromChildrenTree, getParentElementsIdsPath, setDifference, setIntersection } from "../../../common/internal/Utils.js";
|
|
9
11
|
import { mergeVisibilityStatuses } from "../../../common/internal/VisibilityUtils.js";
|
|
10
|
-
import {
|
|
12
|
+
import { ModelsTreeNodeInternal } from "../ModelsTreeNodeInternal.js";
|
|
11
13
|
import { ModelsTreeVisibilityHelper } from "./ModelsTreeVisibilityHelper.js";
|
|
12
14
|
import { createModelsSearchResultsTree } from "./SearchResultsTree.js";
|
|
13
15
|
/**
|
|
@@ -21,23 +23,12 @@ export class ModelsTreeVisibilityHandler {
|
|
|
21
23
|
#props;
|
|
22
24
|
constructor(constructorProps) {
|
|
23
25
|
this.#props = constructorProps;
|
|
24
|
-
// Remove after https://github.com/iTwin/viewer-components-react/issues/1421.
|
|
25
|
-
// We won't need to create a custom base ids cache.
|
|
26
|
-
const baseIdsCache = {
|
|
27
|
-
getCategories: (props) => this.getCategories(props),
|
|
28
|
-
getElementsCount: (props) => this.getElementsCount(props),
|
|
29
|
-
getModels: (props) => this.getModels(props),
|
|
30
|
-
getSubCategories: (props) => this.getSubCategories(props),
|
|
31
|
-
getSubModels: (props) => this.getSubModels(props),
|
|
32
|
-
hasSubModel: (props) => this.#props.idsCache.hasSubModel(props),
|
|
33
|
-
getAllCategories: () => this.getAllCategories(),
|
|
34
|
-
};
|
|
35
26
|
this.#visibilityHelper = new ModelsTreeVisibilityHelper({
|
|
36
27
|
viewport: this.#props.viewport,
|
|
37
28
|
idsCache: this.#props.idsCache,
|
|
38
29
|
alwaysAndNeverDrawnElementInfo: this.#props.alwaysAndNeverDrawnElementInfo,
|
|
39
30
|
overrideHandler: this.#props.overrideHandler,
|
|
40
|
-
baseIdsCache,
|
|
31
|
+
baseIdsCache: this.#props.idsCache,
|
|
41
32
|
overrides: this.#props.overrides,
|
|
42
33
|
});
|
|
43
34
|
}
|
|
@@ -48,6 +39,9 @@ export class ModelsTreeVisibilityHandler {
|
|
|
48
39
|
return defer(() => {
|
|
49
40
|
const { subjectIds, modelIds, categories, elements } = targets;
|
|
50
41
|
const observables = new Array();
|
|
42
|
+
if (this.#props.viewport.viewType !== "3d") {
|
|
43
|
+
return EMPTY;
|
|
44
|
+
}
|
|
51
45
|
if (subjectIds?.size) {
|
|
52
46
|
observables.push(this.#visibilityHelper.changeSubjectsVisibilityStatus({ subjectIds, on }));
|
|
53
47
|
}
|
|
@@ -62,17 +56,76 @@ export class ModelsTreeVisibilityHandler {
|
|
|
62
56
|
}))));
|
|
63
57
|
}
|
|
64
58
|
if (elements?.length) {
|
|
65
|
-
|
|
59
|
+
const searchTargetElements = new Array();
|
|
60
|
+
const elementIdsSet = new Set();
|
|
61
|
+
const modelCategoryElementMap = new Map();
|
|
62
|
+
// elements is an array that stores elements grouped by:
|
|
63
|
+
// 1. Their path
|
|
64
|
+
// 2. Their modelId and categoryId
|
|
65
|
+
// When changing visibility of elements, visibility handler does not care about the path.
|
|
66
|
+
// So we can first get all elements and group them only by modelId and categoryId.
|
|
67
|
+
for (const { elements: elementsMap, categoryId, modelId } of elements) {
|
|
68
|
+
const key = `${modelId}-${categoryId}`;
|
|
69
|
+
let mapEntry = modelCategoryElementMap.get(key);
|
|
70
|
+
if (!mapEntry) {
|
|
71
|
+
mapEntry = [];
|
|
72
|
+
modelCategoryElementMap.set(key, mapEntry);
|
|
73
|
+
}
|
|
74
|
+
for (const [elementId, { isSearchTarget }] of elementsMap) {
|
|
75
|
+
mapEntry.push(elementId);
|
|
76
|
+
elementIdsSet.add(elementId);
|
|
77
|
+
if (isSearchTarget) {
|
|
78
|
+
searchTargetElements.push(elementId);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
observables.push(
|
|
83
|
+
// Get children for search targets, since non search targets don't have all the children present in the hierarchy.
|
|
84
|
+
this.#props.idsCache.getChildElementsTree({ elementIds: searchTargetElements }).pipe(
|
|
85
|
+
// Need to filter out and keep only those children ids that are not part of elements that are present in search paths.
|
|
86
|
+
// Elements in search paths will have their visibility changed directly: they will be provided as elementIds to changeElementsVisibilityStatus.
|
|
87
|
+
map((childrenTree) => ({
|
|
88
|
+
childrenNotInSearchPaths: setDifference(getIdsFromChildrenTree({ tree: childrenTree, predicate: ({ depth }) => depth > 0 }), elementIdsSet),
|
|
89
|
+
childrenTree,
|
|
90
|
+
})), mergeMap(({ childrenNotInSearchPaths, childrenTree }) => fromWithRelease({ source: modelCategoryElementMap.entries(), size: modelCategoryElementMap.size, releaseOnCount: 50 }).pipe(mergeMap(([key, elementsInSearchPathsGroupedByModelAndCategory]) => {
|
|
91
|
+
const [modelId, categoryId] = key.split("-");
|
|
92
|
+
const childrenIds = new Set();
|
|
93
|
+
// A shared children tree was created, need to get the children for each element in the group.
|
|
94
|
+
for (const elementId of elementsInSearchPathsGroupedByModelAndCategory) {
|
|
95
|
+
const elementChildrenTree = childrenTree.get(elementId)?.children;
|
|
96
|
+
if (!elementChildrenTree) {
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
for (const childId of getIdsFromChildrenTree({ tree: elementChildrenTree })) {
|
|
100
|
+
childrenIds.add(childId);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return this.#visibilityHelper.changeElementsVisibilityStatus({
|
|
104
|
+
modelId,
|
|
105
|
+
categoryId,
|
|
106
|
+
elementIds: elementsInSearchPathsGroupedByModelAndCategory,
|
|
107
|
+
// Pass only those children that are not part of search paths.
|
|
108
|
+
children: setIntersection(childrenIds, childrenNotInSearchPaths),
|
|
109
|
+
on,
|
|
110
|
+
});
|
|
111
|
+
})))));
|
|
66
112
|
}
|
|
67
113
|
return merge(...observables);
|
|
68
114
|
});
|
|
69
115
|
}
|
|
70
116
|
getVisibilityStatus(node) {
|
|
71
|
-
if (
|
|
117
|
+
if (this.#props.viewport.viewType !== "3d") {
|
|
118
|
+
return of(createVisibilityStatus("disabled"));
|
|
119
|
+
}
|
|
120
|
+
if (ModelsTreeNodeInternal.isElementClassGroupingNode(node)) {
|
|
72
121
|
const result = this.#visibilityHelper.getGroupedElementsVisibilityStatus({
|
|
73
122
|
categoryId: node.extendedData.categoryId,
|
|
74
123
|
modelId: node.extendedData.modelId,
|
|
75
124
|
elementIds: node.groupedInstanceKeys.map((key) => key.id),
|
|
125
|
+
parentKeys: node.parentKeys,
|
|
126
|
+
childrenCount: node.extendedData.childrenCount,
|
|
127
|
+
categoryOfTopMostParentElement: node.extendedData.categoryOfTopMostParentElement,
|
|
128
|
+
topMostParentElementId: node.extendedData.topMostParentElementId,
|
|
76
129
|
});
|
|
77
130
|
return this.#props.overrideHandler.createVisibilityHandlerResult({
|
|
78
131
|
overrideProps: { node },
|
|
@@ -80,32 +133,40 @@ export class ModelsTreeVisibilityHandler {
|
|
|
80
133
|
override: this.#props.overrides?.getElementGroupingNodeVisibilityStatus,
|
|
81
134
|
});
|
|
82
135
|
}
|
|
83
|
-
if (
|
|
136
|
+
if (ModelsTreeNodeInternal.isSubjectNode(node)) {
|
|
84
137
|
// note: subject nodes may be merged to represent multiple subject instances
|
|
85
138
|
return this.#visibilityHelper.getSubjectsVisibilityStatus({ subjectIds: node.key.instanceKeys.map((key) => key.id) });
|
|
86
139
|
}
|
|
87
|
-
if (
|
|
88
|
-
return this.#visibilityHelper.getModelsVisibilityStatus({ modelIds: node.key.instanceKeys.map(({ id }) => id)
|
|
140
|
+
if (ModelsTreeNodeInternal.isModelNode(node)) {
|
|
141
|
+
return this.#visibilityHelper.getModelsVisibilityStatus({ modelIds: node.key.instanceKeys.map(({ id }) => id) });
|
|
89
142
|
}
|
|
90
|
-
if (
|
|
143
|
+
if (ModelsTreeNodeInternal.isCategoryNode(node)) {
|
|
91
144
|
return this.#visibilityHelper.getCategoriesVisibilityStatus({
|
|
92
145
|
categoryIds: node.key.instanceKeys.map(({ id }) => id),
|
|
93
146
|
modelId: node.extendedData.modelIds[0],
|
|
94
|
-
type: "SpatialCategory",
|
|
95
147
|
});
|
|
96
148
|
}
|
|
97
|
-
assert(
|
|
149
|
+
assert(ModelsTreeNodeInternal.isElementNode(node));
|
|
150
|
+
const parentElementsIdsPath = getParentElementsIdsPath({
|
|
151
|
+
parentInstanceKeys: node.parentKeys.filter((key) => HierarchyNodeKey.isInstances(key)).map((key) => key.instanceKeys),
|
|
152
|
+
topMostParentElementId: node.extendedData.topMostParentElementId,
|
|
153
|
+
});
|
|
98
154
|
return this.#visibilityHelper.getElementsVisibilityStatus({
|
|
99
155
|
elementIds: node.key.instanceKeys.map(({ id }) => id),
|
|
100
156
|
modelId: node.extendedData.modelId,
|
|
101
157
|
categoryId: node.extendedData.categoryId,
|
|
102
|
-
|
|
158
|
+
parentElementsIdsPath,
|
|
159
|
+
childrenCount: node.extendedData?.childrenCount,
|
|
160
|
+
categoryOfTopMostParentElement: node.extendedData.categoryOfTopMostParentElement,
|
|
103
161
|
});
|
|
104
162
|
}
|
|
105
163
|
/** Changes visibility of the items represented by the tree node. */
|
|
106
164
|
changeVisibilityStatus(node, on) {
|
|
107
165
|
const changeObs = defer(() => {
|
|
108
|
-
if (
|
|
166
|
+
if (this.#props.viewport.viewType !== "3d") {
|
|
167
|
+
return EMPTY;
|
|
168
|
+
}
|
|
169
|
+
if (ModelsTreeNodeInternal.isElementClassGroupingNode(node)) {
|
|
109
170
|
const result = this.#visibilityHelper.changeGroupedElementsVisibilityStatus({
|
|
110
171
|
categoryId: node.extendedData.categoryId,
|
|
111
172
|
modelId: node.extendedData.modelId,
|
|
@@ -118,36 +179,45 @@ export class ModelsTreeVisibilityHandler {
|
|
|
118
179
|
override: this.#props.overrides?.changeElementGroupingNodeVisibilityStatus,
|
|
119
180
|
});
|
|
120
181
|
}
|
|
121
|
-
if (
|
|
182
|
+
if (ModelsTreeNodeInternal.isSubjectNode(node)) {
|
|
122
183
|
return this.#visibilityHelper.changeSubjectsVisibilityStatus({
|
|
123
184
|
subjectIds: node.key.instanceKeys.map((key) => key.id),
|
|
124
185
|
on,
|
|
125
186
|
});
|
|
126
187
|
}
|
|
127
|
-
if (
|
|
188
|
+
if (ModelsTreeNodeInternal.isModelNode(node)) {
|
|
128
189
|
return this.#visibilityHelper.changeModelsVisibilityStatus({ modelIds: node.key.instanceKeys.map(({ id }) => id), on });
|
|
129
190
|
}
|
|
130
|
-
if (
|
|
191
|
+
if (ModelsTreeNodeInternal.isCategoryNode(node)) {
|
|
131
192
|
return this.#visibilityHelper.changeCategoriesVisibilityStatus({
|
|
132
193
|
categoryIds: node.key.instanceKeys.map(({ id }) => id),
|
|
133
194
|
modelId: node.extendedData.modelIds[0],
|
|
134
195
|
on,
|
|
135
196
|
});
|
|
136
197
|
}
|
|
137
|
-
assert(
|
|
138
|
-
|
|
139
|
-
|
|
198
|
+
assert(ModelsTreeNodeInternal.isElementNode(node));
|
|
199
|
+
const elementIds = node.key.instanceKeys.map(({ id }) => id);
|
|
200
|
+
return this.#props.idsCache.getChildElementsTree({ elementIds }).pipe(map((childrenTree) => {
|
|
201
|
+
// Children tree contains provided elementIds, they are at the root of this tree.
|
|
202
|
+
// We want to skip them and only get ids of children.
|
|
203
|
+
return getIdsFromChildrenTree({ tree: childrenTree, predicate: ({ depth }) => depth > 0 });
|
|
204
|
+
}), mergeMap((children) => this.#visibilityHelper.changeElementsVisibilityStatus({
|
|
205
|
+
elementIds,
|
|
140
206
|
modelId: node.extendedData.modelId,
|
|
207
|
+
children: children.size > 0 ? children : undefined,
|
|
141
208
|
categoryId: node.extendedData.categoryId,
|
|
142
209
|
on,
|
|
143
|
-
});
|
|
210
|
+
})));
|
|
144
211
|
});
|
|
145
212
|
if (this.#props.viewport.isAlwaysDrawnExclusive) {
|
|
146
213
|
return concat(this.#visibilityHelper.removeAlwaysDrawnExclusive(), changeObs);
|
|
147
214
|
}
|
|
148
215
|
return changeObs;
|
|
149
216
|
}
|
|
150
|
-
getSearchTargetsVisibilityStatus(targets) {
|
|
217
|
+
getSearchTargetsVisibilityStatus(targets, node) {
|
|
218
|
+
if (this.#props.viewport.viewType !== "3d") {
|
|
219
|
+
return of(createVisibilityStatus("disabled"));
|
|
220
|
+
}
|
|
151
221
|
return defer(() => {
|
|
152
222
|
const { subjectIds, modelIds, categories, elements } = targets;
|
|
153
223
|
const observables = new Array();
|
|
@@ -155,54 +225,91 @@ export class ModelsTreeVisibilityHandler {
|
|
|
155
225
|
observables.push(this.#visibilityHelper.getSubjectsVisibilityStatus({ subjectIds }));
|
|
156
226
|
}
|
|
157
227
|
if (modelIds?.size) {
|
|
158
|
-
observables.push(this.#visibilityHelper.getModelsVisibilityStatus({ modelIds
|
|
228
|
+
observables.push(this.#visibilityHelper.getModelsVisibilityStatus({ modelIds }));
|
|
159
229
|
}
|
|
160
230
|
if (categories?.length) {
|
|
161
231
|
observables.push(from(categories).pipe(mergeMap(({ modelId, categoryIds }) => this.#visibilityHelper.getCategoriesVisibilityStatus({
|
|
162
232
|
categoryIds,
|
|
163
233
|
modelId,
|
|
164
|
-
type: "SpatialCategory",
|
|
165
234
|
}))));
|
|
166
235
|
}
|
|
167
236
|
if (elements?.length) {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
}
|
|
176
|
-
getAllCategories() {
|
|
177
|
-
return this.#props.idsCache.getAllCategories().pipe(map((categories) => ({ spatialCategories: categories })));
|
|
178
|
-
}
|
|
179
|
-
getElementsCount(props) {
|
|
180
|
-
return this.#props.idsCache.getCategoryElementsCount(props.modelId, props.categoryId);
|
|
181
|
-
}
|
|
182
|
-
getModels(props) {
|
|
183
|
-
return this.#props.idsCache.getCategoriesElementModels(props.categoryIds);
|
|
184
|
-
}
|
|
185
|
-
getSubCategories(props) {
|
|
186
|
-
return this.#props.idsCache.getSubCategories(props.categoryId);
|
|
187
|
-
}
|
|
188
|
-
getSubModels(props) {
|
|
189
|
-
if ("modelIds" in props) {
|
|
190
|
-
return from(Id64.iterable(props.modelIds)).pipe(mergeMap((modelId) => {
|
|
191
|
-
if (props.categoryId) {
|
|
192
|
-
return this.#props.idsCache.getCategoriesModeledElements(modelId, props.categoryId).pipe(map((subModels) => ({ id: modelId, subModels })));
|
|
237
|
+
const searchTargetElements = new Array();
|
|
238
|
+
for (const { elements: elementsMap } of elements) {
|
|
239
|
+
for (const [elementId, { isSearchTarget }] of elementsMap) {
|
|
240
|
+
if (isSearchTarget) {
|
|
241
|
+
searchTargetElements.push(elementId);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
193
244
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
245
|
+
let childrenCountMapObs;
|
|
246
|
+
if (ModelsTreeNodeInternal.isElementClassGroupingNode(node)) {
|
|
247
|
+
const groupingNodesSearchTargets = node.extendedData.searchTargets;
|
|
248
|
+
const nestedSearchTargetElements = searchTargetElements.filter((searchTarget) => !groupingNodesSearchTargets?.has(searchTarget));
|
|
249
|
+
// Only need to request children count for indirect children search targets.
|
|
250
|
+
childrenCountMapObs = this.#props.idsCache.getAllChildElementsCount({ elementIds: nestedSearchTargetElements }).pipe(map((elementCountMap) => {
|
|
251
|
+
// Direct children search targets already have children count stored in grouping nodes extended data.
|
|
252
|
+
for (const [key, value] of node.extendedData.searchTargets ?? []) {
|
|
253
|
+
elementCountMap.set(key, value.childrenCount);
|
|
254
|
+
}
|
|
255
|
+
return elementCountMap;
|
|
256
|
+
}));
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
childrenCountMapObs = this.#props.idsCache.getAllChildElementsCount({ elementIds: searchTargetElements });
|
|
260
|
+
}
|
|
261
|
+
observables.push(childrenCountMapObs.pipe(mergeMap((elementsChildrenCountMap) => fromWithRelease({ source: elements, releaseOnCount: 50 }).pipe(mergeMap(({ modelId, elements: elementsMap, categoryId, pathToElements, topMostParentElementId }) => {
|
|
262
|
+
const parentElementsIdsPath = topMostParentElementId
|
|
263
|
+
? getParentElementsIdsPath({
|
|
264
|
+
parentInstanceKeys: pathToElements.map((instanceKey) => [instanceKey]),
|
|
265
|
+
topMostParentElementId,
|
|
266
|
+
})
|
|
267
|
+
: [];
|
|
268
|
+
let totalSearchTargetsChildrenCount = 0;
|
|
269
|
+
const nonSearchTargetIds = new Array();
|
|
270
|
+
const searchTargetIds = new Array();
|
|
271
|
+
for (const [elementId, { isSearchTarget }] of elementsMap) {
|
|
272
|
+
if (!isSearchTarget) {
|
|
273
|
+
nonSearchTargetIds.push(elementId);
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
276
|
+
searchTargetIds.push(elementId);
|
|
277
|
+
const childCount = elementsChildrenCountMap.get(elementId);
|
|
278
|
+
if (childCount) {
|
|
279
|
+
totalSearchTargetsChildrenCount += childCount;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
return merge(searchTargetIds.length > 0
|
|
283
|
+
? this.#visibilityHelper.getElementsVisibilityStatus({
|
|
284
|
+
modelId,
|
|
285
|
+
categoryId,
|
|
286
|
+
elementIds: searchTargetIds,
|
|
287
|
+
parentElementsIdsPath,
|
|
288
|
+
childrenCount: totalSearchTargetsChildrenCount,
|
|
289
|
+
// Search results tree is created on search paths. Since search paths contain only categories that are directly under models
|
|
290
|
+
// or at the root, categoryId can be used here here.
|
|
291
|
+
categoryOfTopMostParentElement: categoryId,
|
|
292
|
+
})
|
|
293
|
+
: EMPTY,
|
|
294
|
+
// Set childrenCount to undefined for non search targets, as some of their child elements might be filtered out.
|
|
295
|
+
// Since childrenCount is set to undefined, these elements won't check child always/never drawn child elements status.
|
|
296
|
+
// Child always/never drawn elements will be in search paths, and their visibility status will be handled separately.
|
|
297
|
+
nonSearchTargetIds.length > 0
|
|
298
|
+
? this.#visibilityHelper.getElementsVisibilityStatus({
|
|
299
|
+
modelId,
|
|
300
|
+
categoryId,
|
|
301
|
+
elementIds: nonSearchTargetIds,
|
|
302
|
+
parentElementsIdsPath,
|
|
303
|
+
childrenCount: undefined,
|
|
304
|
+
// Search results tree is created on search paths. Since search paths contain only categories that are directly under models
|
|
305
|
+
// or at the root, categoryId can be used here here.
|
|
306
|
+
categoryOfTopMostParentElement: categoryId,
|
|
307
|
+
})
|
|
308
|
+
: EMPTY).pipe(mergeVisibilityStatuses());
|
|
309
|
+
})))));
|
|
203
310
|
}
|
|
204
|
-
return from(
|
|
205
|
-
})
|
|
311
|
+
return from(observables).pipe(mergeAll(), mergeVisibilityStatuses());
|
|
312
|
+
});
|
|
206
313
|
}
|
|
207
314
|
}
|
|
208
315
|
/**
|