@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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import type { Id64Array } from "@itwin/core-bentley";
|
|
3
|
-
import type {
|
|
3
|
+
import type { TreeNode } from "@itwin/presentation-hierarchies-react";
|
|
4
4
|
import type { CategoryInfo } from "../common/CategoriesVisibilityUtils.js";
|
|
5
5
|
import type { VisibilityTreeProps } from "../common/components/VisibilityTree.js";
|
|
6
6
|
import type { ExtendedVisibilityTreeRendererProps } from "../common/components/VisibilityTreeRenderer.js";
|
|
@@ -25,12 +25,14 @@ interface UseCategoriesTreeResult {
|
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
27
|
* Custom hook to create and manage state for the categories tree.
|
|
28
|
+
*
|
|
29
|
+
* **Note:** Requires `SharedTreeContextProvider` to be present in components tree above.
|
|
28
30
|
* @beta
|
|
29
31
|
*/
|
|
30
32
|
export declare function useCategoriesTree({ searchText, activeView, onCategoriesFiltered, emptyTreeContent, hierarchyConfig, getTreeItemProps, }: UseCategoriesTreeProps): UseCategoriesTreeResult;
|
|
31
33
|
/** @beta */
|
|
32
34
|
export declare function CategoriesTreeIcon({ node }: {
|
|
33
|
-
node:
|
|
35
|
+
node: TreeNode;
|
|
34
36
|
}): import("react/jsx-runtime").JSX.Element | undefined;
|
|
35
37
|
export {};
|
|
36
38
|
//# sourceMappingURL=UseCategoriesTree.d.ts.map
|
|
@@ -3,7 +3,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
4
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
import { useCallback, useEffect, useMemo } from "react";
|
|
6
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
7
7
|
import { createECSqlQueryExecutor } from "@itwin/presentation-core-interop";
|
|
8
8
|
import { Icon } from "@stratakit/foundations";
|
|
9
9
|
import categorySvg from "@stratakit/icons/bis-category-3d.svg";
|
|
@@ -12,9 +12,9 @@ import classSvg from "@stratakit/icons/bis-class.svg";
|
|
|
12
12
|
import definitionContainerSvg from "@stratakit/icons/bis-definitions-container.svg";
|
|
13
13
|
import elementSvg from "@stratakit/icons/bis-element.svg";
|
|
14
14
|
import { EmptyTreeContent, NoSearchMatches, SearchUnknownError, TooManySearchMatches } from "../common/components/EmptyTree.js";
|
|
15
|
+
import { useSharedTreeContextInternal } from "../common/internal/SharedTreeContextProviderInternal.js";
|
|
15
16
|
import { useGuid } from "../common/internal/useGuid.js";
|
|
16
17
|
import { useCachedVisibility } from "../common/internal/useTreeHooks/UseCachedVisibility.js";
|
|
17
|
-
import { useIdsCache } from "../common/internal/useTreeHooks/UseIdsCache.js";
|
|
18
18
|
import { getClassesByView } from "../common/internal/Utils.js";
|
|
19
19
|
import { CategoriesTreeDefinition, defaultHierarchyConfiguration } from "./CategoriesTreeDefinition.js";
|
|
20
20
|
import { CategoriesTreeIdsCache } from "./internal/CategoriesTreeIdsCache.js";
|
|
@@ -23,6 +23,8 @@ import { CategoriesTreeVisibilityHandler } from "./internal/visibility/Categorie
|
|
|
23
23
|
import { createCategoriesSearchResultsTree } from "./internal/visibility/SearchResultsTree.js";
|
|
24
24
|
/**
|
|
25
25
|
* Custom hook to create and manage state for the categories tree.
|
|
26
|
+
*
|
|
27
|
+
* **Note:** Requires `SharedTreeContextProvider` to be present in components tree above.
|
|
26
28
|
* @beta
|
|
27
29
|
*/
|
|
28
30
|
export function useCategoriesTree({ searchText, activeView, onCategoriesFiltered, emptyTreeContent, hierarchyConfig, getTreeItemProps, }) {
|
|
@@ -32,28 +34,34 @@ export function useCategoriesTree({ searchText, activeView, onCategoriesFiltered
|
|
|
32
34
|
}),
|
|
33
35
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
34
36
|
Object.values(hierarchyConfig ?? {}));
|
|
35
|
-
const viewType = activeView.viewType === "2d" ? "2d" : "3d";
|
|
37
|
+
const [viewType, setViewType] = useState(activeView.viewType === "2d" ? "2d" : "3d");
|
|
36
38
|
const componentId = useGuid();
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
});
|
|
39
|
+
// Listen for view type changes
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
return activeView.onDisplayStyleChanged.addListener(() => {
|
|
42
|
+
setViewType(activeView.viewType === "2d" ? "2d" : "3d");
|
|
43
|
+
});
|
|
44
|
+
}, [activeView]);
|
|
45
|
+
const idsCache = useCategoriesTreeIdsCache({ imodel: activeView.iModel, activeViewType: viewType });
|
|
43
46
|
const { visibilityHandlerFactory, onSearchPathsChanged } = useCategoriesCachedVisibility({
|
|
44
47
|
activeView,
|
|
45
48
|
viewType,
|
|
46
|
-
|
|
49
|
+
idsCache,
|
|
47
50
|
componentId,
|
|
48
51
|
hierarchyConfig: hierarchyConfiguration,
|
|
49
52
|
});
|
|
50
53
|
const getHierarchyDefinition = useCallback((props) => {
|
|
51
|
-
return new CategoriesTreeDefinition({
|
|
52
|
-
|
|
54
|
+
return new CategoriesTreeDefinition({
|
|
55
|
+
...props,
|
|
56
|
+
viewType,
|
|
57
|
+
idsCache,
|
|
58
|
+
hierarchyConfig: hierarchyConfiguration,
|
|
59
|
+
});
|
|
60
|
+
}, [viewType, idsCache, hierarchyConfiguration]);
|
|
53
61
|
const { getPaths, searchError } = useSearchPaths({
|
|
54
62
|
hierarchyConfiguration,
|
|
55
63
|
searchText,
|
|
56
|
-
|
|
64
|
+
idsCache,
|
|
57
65
|
onSearchPathsChanged,
|
|
58
66
|
viewType,
|
|
59
67
|
onCategoriesFiltered,
|
|
@@ -115,43 +123,50 @@ export function CategoriesTreeIcon({ node }) {
|
|
|
115
123
|
return _jsx(Icon, { href: getIcon() });
|
|
116
124
|
}
|
|
117
125
|
function useCategoriesCachedVisibility(props) {
|
|
118
|
-
const { activeView,
|
|
126
|
+
const { activeView, idsCache, viewType, componentId } = props;
|
|
119
127
|
const { visibilityHandlerFactory, searchPaths, onSearchPathsChanged } = useCachedVisibility({
|
|
120
128
|
activeView,
|
|
121
|
-
|
|
129
|
+
idsCache,
|
|
122
130
|
createSearchResultsTree: useCallback(async (filteredTreeProps) => createSearchResultsTree({ ...filteredTreeProps, viewClasses: getClassesByView(viewType) }), [viewType]),
|
|
123
131
|
createTreeSpecificVisibilityHandler: useCallback((specificProps) => createTreeSpecificVisibilityHandler({ ...specificProps, hierarchyConfig: props.hierarchyConfig }), [props.hierarchyConfig]),
|
|
124
132
|
componentId,
|
|
125
133
|
});
|
|
126
134
|
useEffect(() => {
|
|
127
|
-
|
|
128
|
-
}, [searchPaths,
|
|
135
|
+
idsCache.clearFilteredElementsModels();
|
|
136
|
+
}, [searchPaths, idsCache]);
|
|
129
137
|
return {
|
|
130
138
|
visibilityHandlerFactory,
|
|
131
139
|
onSearchPathsChanged,
|
|
132
140
|
};
|
|
133
141
|
}
|
|
134
142
|
function createTreeSpecificVisibilityHandler(props) {
|
|
135
|
-
const { info,
|
|
143
|
+
const { info, idsCache, viewport, hierarchyConfig } = props;
|
|
136
144
|
return new CategoriesTreeVisibilityHandler({
|
|
137
145
|
alwaysAndNeverDrawnElementInfo: info,
|
|
138
|
-
idsCache
|
|
146
|
+
idsCache,
|
|
139
147
|
viewport,
|
|
140
148
|
hierarchyConfig,
|
|
141
149
|
});
|
|
142
150
|
}
|
|
143
151
|
async function createSearchResultsTree(props) {
|
|
144
|
-
const { searchPaths, imodelAccess,
|
|
152
|
+
const { searchPaths, imodelAccess, idsCache, viewClasses } = props;
|
|
145
153
|
return createCategoriesSearchResultsTree({
|
|
146
154
|
imodelAccess,
|
|
147
155
|
searchPaths,
|
|
148
|
-
idsCache
|
|
156
|
+
idsCache,
|
|
149
157
|
categoryClassName: viewClasses.categoryClass,
|
|
150
158
|
categoryElementClassName: viewClasses.elementClass,
|
|
151
159
|
categoryModelClassName: viewClasses.modelClass,
|
|
152
160
|
});
|
|
153
161
|
}
|
|
154
|
-
function
|
|
155
|
-
|
|
162
|
+
function useCategoriesTreeIdsCache({ imodel, activeViewType }) {
|
|
163
|
+
const { getBaseIdsCache, getCache } = useSharedTreeContextInternal();
|
|
164
|
+
const baseIdsCache = getBaseIdsCache({ type: activeViewType, elementClassName: getClassesByView(activeViewType).elementClass, imodel });
|
|
165
|
+
const categoriesTreeIdsCache = getCache({
|
|
166
|
+
imodel,
|
|
167
|
+
createCache: () => new CategoriesTreeIdsCache({ baseIdsCache, type: activeViewType, queryExecutor: createECSqlQueryExecutor(imodel) }),
|
|
168
|
+
cacheKey: `${activeViewType}-CategoriesTreeIdsCache`,
|
|
169
|
+
});
|
|
170
|
+
return categoriesTreeIdsCache;
|
|
156
171
|
}
|
|
157
172
|
//# sourceMappingURL=UseCategoriesTree.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UseCategoriesTree.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACxD,OAAO,EAAE,wBAAwB,EAAE,MAA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E,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,eAAe,EAAE,GAAG,KAAK,CAAC;IAC5D,OAAO,IAAI,+BAA+B,CAAC;QACzC,8BAA8B,EAAE,IAAI;QACpC,QAAQ,EAAE,QAAQ,EAAE;QACpB,QAAQ;QACR,eAAe;KAChB,CAAC,CAAC;AACL,CAAC;AAED,KAAK,UAAU,uBAAuB,CACpC,KAAkH;IAElH,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC;IACnE,OAAO,iCAAiC,CAAC;QACvC,YAAY;QACZ,WAAW;QACX,QAAQ,EAAE,QAAQ,EAAE;QACpB,iBAAiB,EAAE,WAAW,CAAC,aAAa;QAC5C,wBAAwB,EAAE,WAAW,CAAC,YAAY;QAClD,sBAAsB,EAAE,WAAW,CAAC,UAAU;KAC/C,CAAC,CAAC;AACL,CAAC;AAED,SAAS,WAAW,CAAC,KAAkD;IACrE,OAAO,IAAI,sBAAsB,CAAC,wBAAwB,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,QAAQ,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;AAC7H,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 { useCallback, useEffect, useMemo } from \"react\";\nimport { createECSqlQueryExecutor } from \"@itwin/presentation-core-interop\";\nimport { Icon } from \"@stratakit/foundations\";\nimport categorySvg from \"@stratakit/icons/bis-category-3d.svg\";\nimport subcategorySvg from \"@stratakit/icons/bis-category-subcategory.svg\";\nimport classSvg from \"@stratakit/icons/bis-class.svg\";\nimport definitionContainerSvg from \"@stratakit/icons/bis-definitions-container.svg\";\nimport elementSvg from \"@stratakit/icons/bis-element.svg\";\nimport { EmptyTreeContent, NoSearchMatches, SearchUnknownError, TooManySearchMatches } from \"../common/components/EmptyTree.js\";\nimport { useGuid } from \"../common/internal/useGuid.js\";\nimport { useCachedVisibility } from \"../common/internal/useTreeHooks/UseCachedVisibility.js\";\nimport { useIdsCache } from \"../common/internal/useTreeHooks/UseIdsCache.js\";\nimport { getClassesByView } from \"../common/internal/Utils.js\";\nimport { CategoriesTreeDefinition, defaultHierarchyConfiguration } from \"./CategoriesTreeDefinition.js\";\nimport { CategoriesTreeIdsCache } from \"./internal/CategoriesTreeIdsCache.js\";\nimport { useSearchPaths } from \"./internal/UseSearchPaths.js\";\nimport { CategoriesTreeVisibilityHandler } from \"./internal/visibility/CategoriesTreeVisibilityHandler.js\";\nimport { createCategoriesSearchResultsTree } from \"./internal/visibility/SearchResultsTree.js\";\n\nimport type { ReactNode } from \"react\";\nimport type { GuidString, Id64Array } from \"@itwin/core-bentley\";\nimport type { PresentationHierarchyNode } from \"@itwin/presentation-hierarchies-react\";\nimport type { CategoryInfo } from \"../common/CategoriesVisibilityUtils.js\";\nimport type { VisibilityTreeProps } from \"../common/components/VisibilityTree.js\";\nimport type { ExtendedVisibilityTreeRendererProps } from \"../common/components/VisibilityTreeRenderer.js\";\nimport type { CreateSearchResultsTreeProps, CreateTreeSpecificVisibilityHandlerProps } from \"../common/internal/useTreeHooks/UseCachedVisibility.js\";\nimport type { CreateCacheProps } from \"../common/internal/useTreeHooks/UseIdsCache.js\";\nimport type { SearchResultsTree } from \"../common/internal/visibility/BaseSearchResultsTree.js\";\nimport type { TreeWidgetViewport } from \"../common/TreeWidgetViewport.js\";\nimport type { CategoriesTreeHierarchyConfiguration } from \"./CategoriesTreeDefinition.js\";\nimport type { CategoriesTreeSearchError } from \"./internal/UseSearchPaths.js\";\nimport type { CategoriesTreeSearchTargets } from \"./internal/visibility/SearchResultsTree.js\";\n\n/** @beta */\nexport interface UseCategoriesTreeProps {\n activeView: TreeWidgetViewport;\n onCategoriesFiltered?: (props: { categories: CategoryInfo[] | undefined; models?: Id64Array }) => void;\n searchText?: string;\n emptyTreeContent?: ReactNode;\n hierarchyConfig?: Partial<CategoriesTreeHierarchyConfiguration>;\n getTreeItemProps?: ExtendedVisibilityTreeRendererProps[\"getTreeItemProps\"];\n}\n\n/** @beta */\ninterface UseCategoriesTreeResult {\n treeProps: Pick<\n VisibilityTreeProps,\n \"treeName\" | \"getHierarchyDefinition\" | \"getSearchPaths\" | \"visibilityHandlerFactory\" | \"highlightText\" | \"emptyTreeContent\"\n >;\n getTreeItemProps: Required<ExtendedVisibilityTreeRendererProps>[\"getTreeItemProps\"];\n}\n\n/**\n * Custom hook to create and manage state for the categories tree.\n * @beta\n */\nexport function useCategoriesTree({\n searchText,\n activeView,\n onCategoriesFiltered,\n emptyTreeContent,\n hierarchyConfig,\n getTreeItemProps,\n}: UseCategoriesTreeProps): UseCategoriesTreeResult {\n const hierarchyConfiguration = useMemo<CategoriesTreeHierarchyConfiguration>(\n () => ({\n ...defaultHierarchyConfiguration,\n ...hierarchyConfig,\n }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n Object.values(hierarchyConfig ?? {}),\n );\n const viewType = activeView.viewType === \"2d\" ? \"2d\" : \"3d\";\n const componentId = useGuid();\n\n const { getCache: getCategoriesTreeIdsCache } = useIdsCache<CategoriesTreeIdsCache, { viewType: \"2d\" | \"3d\" }>({\n imodel: activeView.iModel,\n createCache,\n cacheSpecificProps: useMemo(() => ({ viewType }), [viewType]),\n componentId,\n });\n\n const { visibilityHandlerFactory, onSearchPathsChanged } = useCategoriesCachedVisibility({\n activeView,\n viewType,\n getCache: getCategoriesTreeIdsCache,\n componentId,\n hierarchyConfig: hierarchyConfiguration,\n });\n\n const getHierarchyDefinition = useCallback<VisibilityTreeProps[\"getHierarchyDefinition\"]>(\n (props) => {\n return new CategoriesTreeDefinition({ ...props, viewType, idsCache: getCategoriesTreeIdsCache(), hierarchyConfig: hierarchyConfiguration });\n },\n [viewType, getCategoriesTreeIdsCache, hierarchyConfiguration],\n );\n\n const { getPaths, searchError } = useSearchPaths({\n hierarchyConfiguration,\n searchText,\n getCategoriesTreeIdsCache,\n onSearchPathsChanged,\n viewType,\n onCategoriesFiltered,\n componentId,\n });\n\n return {\n treeProps: {\n treeName: \"categories-tree-v2\",\n getHierarchyDefinition,\n getSearchPaths: getPaths,\n visibilityHandlerFactory,\n emptyTreeContent: useMemo(() => getEmptyTreeContentComponent(searchText, searchError, emptyTreeContent), [searchText, searchError, emptyTreeContent]),\n highlightText: searchText,\n },\n getTreeItemProps: (node, rendererProps) => ({\n ...rendererProps.getTreeItemProps?.(node),\n decorations: <CategoriesTreeIcon node={node} />,\n description: node.nodeData.extendedData?.description,\n ...getTreeItemProps?.(node, rendererProps),\n }),\n };\n}\n\nfunction getEmptyTreeContentComponent(searchText?: string, error?: CategoriesTreeSearchError, emptyTreeContent?: React.ReactNode) {\n if (error) {\n if (error === \"tooManySearchMatches\") {\n return <TooManySearchMatches base={\"categoriesTree\"} />;\n }\n return <SearchUnknownError base={\"categoriesTree\"} />;\n }\n if (searchText) {\n return <NoSearchMatches base={\"categoriesTree\"} />;\n }\n if (emptyTreeContent) {\n return emptyTreeContent;\n }\n return <EmptyTreeContent icon={categorySvg} />;\n}\n\n/** @beta */\nexport function CategoriesTreeIcon({ node }: { node: PresentationHierarchyNode }) {\n if (node.nodeData.extendedData?.imageId === undefined) {\n return undefined;\n }\n\n const getIcon = () => {\n switch (node.nodeData.extendedData!.imageId) {\n case \"icon-layers\":\n return categorySvg;\n case \"icon-layers-isolate\":\n return subcategorySvg;\n case \"icon-definition-container\":\n return definitionContainerSvg;\n case \"icon-item\":\n return elementSvg;\n case \"icon-ec-class\":\n return classSvg;\n default:\n return undefined;\n }\n };\n\n return <Icon href={getIcon()} />;\n}\n\nfunction useCategoriesCachedVisibility(props: {\n activeView: TreeWidgetViewport;\n getCache: () => CategoriesTreeIdsCache;\n viewType: \"2d\" | \"3d\";\n componentId: GuidString;\n hierarchyConfig: CategoriesTreeHierarchyConfiguration;\n}) {\n const { activeView, getCache, viewType, componentId } = props;\n const { visibilityHandlerFactory, searchPaths, onSearchPathsChanged } = useCachedVisibility<CategoriesTreeIdsCache, CategoriesTreeSearchTargets>({\n activeView,\n getCache,\n createSearchResultsTree: useCallback(\n async (filteredTreeProps: CreateSearchResultsTreeProps<CategoriesTreeIdsCache>) =>\n createSearchResultsTree({ ...filteredTreeProps, viewClasses: getClassesByView(viewType) }),\n [viewType],\n ),\n createTreeSpecificVisibilityHandler: useCallback(\n (specificProps) => createTreeSpecificVisibilityHandler({ ...specificProps, hierarchyConfig: props.hierarchyConfig }),\n [props.hierarchyConfig],\n ),\n componentId,\n });\n\n useEffect(() => {\n getCache().clearFilteredElementsModels();\n }, [searchPaths, getCache]);\n\n return {\n visibilityHandlerFactory,\n onSearchPathsChanged,\n };\n}\n\nfunction createTreeSpecificVisibilityHandler(\n props: CreateTreeSpecificVisibilityHandlerProps<CategoriesTreeIdsCache> & { hierarchyConfig: CategoriesTreeHierarchyConfiguration },\n) {\n const { info, getCache, viewport, hierarchyConfig } = props;\n return new CategoriesTreeVisibilityHandler({\n alwaysAndNeverDrawnElementInfo: info,\n idsCache: getCache(),\n viewport,\n hierarchyConfig,\n });\n}\n\nasync function createSearchResultsTree(\n props: CreateSearchResultsTreeProps<CategoriesTreeIdsCache> & { viewClasses: ReturnType<typeof getClassesByView> },\n): Promise<SearchResultsTree<CategoriesTreeSearchTargets>> {\n const { searchPaths, imodelAccess, getCache, viewClasses } = props;\n return createCategoriesSearchResultsTree({\n imodelAccess,\n searchPaths,\n idsCache: getCache(),\n categoryClassName: viewClasses.categoryClass,\n categoryElementClassName: viewClasses.elementClass,\n categoryModelClassName: viewClasses.modelClass,\n });\n}\n\nfunction createCache(props: CreateCacheProps<{ viewType: \"2d\" | \"3d\" }>) {\n return new CategoriesTreeIdsCache(createECSqlQueryExecutor(props.imodel), props.specificProps.viewType, props.componentId);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"UseCategoriesTree.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/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AAC,EAAE,YAAY,EAAE,IAAI,EAAE,cAAc,EAAE,aAAa,EAAE,wBAAwB,CAAC,MAAM,CAAC,EAAE,CAAC;QACtI,QAAQ,EAAE,GAAG,cAAc,yBAAyB;KACrD,CAAC,CAAC;IACH,OAAO,sBAAsB,CAAC;AAChC,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 { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { createECSqlQueryExecutor } from \"@itwin/presentation-core-interop\";\nimport { Icon } from \"@stratakit/foundations\";\nimport categorySvg from \"@stratakit/icons/bis-category-3d.svg\";\nimport subcategorySvg from \"@stratakit/icons/bis-category-subcategory.svg\";\nimport classSvg from \"@stratakit/icons/bis-class.svg\";\nimport definitionContainerSvg from \"@stratakit/icons/bis-definitions-container.svg\";\nimport elementSvg from \"@stratakit/icons/bis-element.svg\";\nimport { EmptyTreeContent, NoSearchMatches, SearchUnknownError, TooManySearchMatches } from \"../common/components/EmptyTree.js\";\nimport { useSharedTreeContextInternal } from \"../common/internal/SharedTreeContextProviderInternal.js\";\nimport { useGuid } from \"../common/internal/useGuid.js\";\nimport { useCachedVisibility } from \"../common/internal/useTreeHooks/UseCachedVisibility.js\";\nimport { getClassesByView } from \"../common/internal/Utils.js\";\nimport { CategoriesTreeDefinition, defaultHierarchyConfiguration } from \"./CategoriesTreeDefinition.js\";\nimport { CategoriesTreeIdsCache } from \"./internal/CategoriesTreeIdsCache.js\";\nimport { useSearchPaths } from \"./internal/UseSearchPaths.js\";\nimport { CategoriesTreeVisibilityHandler } from \"./internal/visibility/CategoriesTreeVisibilityHandler.js\";\nimport { createCategoriesSearchResultsTree } from \"./internal/visibility/SearchResultsTree.js\";\n\nimport type { ReactNode } from \"react\";\nimport type { GuidString, Id64Array } from \"@itwin/core-bentley\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport type { TreeNode } from \"@itwin/presentation-hierarchies-react\";\nimport type { CategoryInfo } from \"../common/CategoriesVisibilityUtils.js\";\nimport type { VisibilityTreeProps } from \"../common/components/VisibilityTree.js\";\nimport type { ExtendedVisibilityTreeRendererProps } from \"../common/components/VisibilityTreeRenderer.js\";\nimport type { CreateSearchResultsTreeProps, CreateTreeSpecificVisibilityHandlerProps } from \"../common/internal/useTreeHooks/UseCachedVisibility.js\";\nimport type { SearchResultsTree } from \"../common/internal/visibility/BaseSearchResultsTree.js\";\nimport type { TreeWidgetViewport } from \"../common/TreeWidgetViewport.js\";\nimport type { CategoriesTreeHierarchyConfiguration } from \"./CategoriesTreeDefinition.js\";\nimport type { CategoriesTreeSearchError } from \"./internal/UseSearchPaths.js\";\nimport type { CategoriesTreeSearchTargets } from \"./internal/visibility/SearchResultsTree.js\";\n\n/** @beta */\nexport interface UseCategoriesTreeProps {\n activeView: TreeWidgetViewport;\n onCategoriesFiltered?: (props: { categories: CategoryInfo[] | undefined; models?: Id64Array }) => void;\n searchText?: string;\n emptyTreeContent?: ReactNode;\n hierarchyConfig?: Partial<CategoriesTreeHierarchyConfiguration>;\n getTreeItemProps?: ExtendedVisibilityTreeRendererProps[\"getTreeItemProps\"];\n}\n\n/** @beta */\ninterface UseCategoriesTreeResult {\n treeProps: Pick<\n VisibilityTreeProps,\n \"treeName\" | \"getHierarchyDefinition\" | \"getSearchPaths\" | \"visibilityHandlerFactory\" | \"highlightText\" | \"emptyTreeContent\"\n >;\n getTreeItemProps: Required<ExtendedVisibilityTreeRendererProps>[\"getTreeItemProps\"];\n}\n\n/**\n * Custom hook to create and manage state for the categories tree.\n *\n * **Note:** Requires `SharedTreeContextProvider` to be present in components tree above.\n * @beta\n */\nexport function useCategoriesTree({\n searchText,\n activeView,\n onCategoriesFiltered,\n emptyTreeContent,\n hierarchyConfig,\n getTreeItemProps,\n}: UseCategoriesTreeProps): UseCategoriesTreeResult {\n const hierarchyConfiguration = useMemo<CategoriesTreeHierarchyConfiguration>(\n () => ({\n ...defaultHierarchyConfiguration,\n ...hierarchyConfig,\n }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n Object.values(hierarchyConfig ?? {}),\n );\n const [viewType, setViewType] = useState<\"2d\" | \"3d\">(activeView.viewType === \"2d\" ? \"2d\" : \"3d\");\n const componentId = useGuid();\n\n // Listen for view type changes\n useEffect(() => {\n return activeView.onDisplayStyleChanged.addListener(() => {\n setViewType(activeView.viewType === \"2d\" ? \"2d\" : \"3d\");\n });\n }, [activeView]);\n\n const idsCache = useCategoriesTreeIdsCache({ imodel: activeView.iModel, activeViewType: viewType });\n\n const { visibilityHandlerFactory, onSearchPathsChanged } = useCategoriesCachedVisibility({\n activeView,\n viewType,\n idsCache,\n componentId,\n hierarchyConfig: hierarchyConfiguration,\n });\n\n const getHierarchyDefinition = useCallback<VisibilityTreeProps[\"getHierarchyDefinition\"]>(\n (props) => {\n return new CategoriesTreeDefinition({\n ...props,\n viewType,\n idsCache,\n hierarchyConfig: hierarchyConfiguration,\n });\n },\n [viewType, idsCache, hierarchyConfiguration],\n );\n\n const { getPaths, searchError } = useSearchPaths({\n hierarchyConfiguration,\n searchText,\n idsCache,\n onSearchPathsChanged,\n viewType,\n onCategoriesFiltered,\n componentId,\n });\n\n return {\n treeProps: {\n treeName: \"categories-tree-v2\",\n getHierarchyDefinition,\n getSearchPaths: getPaths,\n visibilityHandlerFactory,\n emptyTreeContent: useMemo(() => getEmptyTreeContentComponent(searchText, searchError, emptyTreeContent), [searchText, searchError, emptyTreeContent]),\n highlightText: searchText,\n },\n getTreeItemProps: (node, rendererProps) => ({\n ...rendererProps.getTreeItemProps?.(node),\n decorations: <CategoriesTreeIcon node={node} />,\n description: node.nodeData.extendedData?.description,\n ...getTreeItemProps?.(node, rendererProps),\n }),\n };\n}\n\nfunction getEmptyTreeContentComponent(searchText?: string, error?: CategoriesTreeSearchError, emptyTreeContent?: React.ReactNode) {\n if (error) {\n if (error === \"tooManySearchMatches\") {\n return <TooManySearchMatches base={\"categoriesTree\"} />;\n }\n return <SearchUnknownError base={\"categoriesTree\"} />;\n }\n if (searchText) {\n return <NoSearchMatches base={\"categoriesTree\"} />;\n }\n if (emptyTreeContent) {\n return emptyTreeContent;\n }\n return <EmptyTreeContent icon={categorySvg} />;\n}\n\n/** @beta */\nexport function CategoriesTreeIcon({ node }: { node: TreeNode }) {\n if (node.nodeData.extendedData?.imageId === undefined) {\n return undefined;\n }\n\n const getIcon = () => {\n switch (node.nodeData.extendedData!.imageId) {\n case \"icon-layers\":\n return categorySvg;\n case \"icon-layers-isolate\":\n return subcategorySvg;\n case \"icon-definition-container\":\n return definitionContainerSvg;\n case \"icon-item\":\n return elementSvg;\n case \"icon-ec-class\":\n return classSvg;\n default:\n return undefined;\n }\n };\n\n return <Icon href={getIcon()} />;\n}\n\nfunction useCategoriesCachedVisibility(props: {\n activeView: TreeWidgetViewport;\n idsCache: CategoriesTreeIdsCache;\n viewType: \"2d\" | \"3d\";\n componentId: GuidString;\n hierarchyConfig: CategoriesTreeHierarchyConfiguration;\n}) {\n const { activeView, idsCache, viewType, componentId } = props;\n const { visibilityHandlerFactory, searchPaths, onSearchPathsChanged } = useCachedVisibility<CategoriesTreeIdsCache, CategoriesTreeSearchTargets>({\n activeView,\n idsCache,\n createSearchResultsTree: useCallback(\n async (filteredTreeProps: CreateSearchResultsTreeProps<CategoriesTreeIdsCache>) =>\n createSearchResultsTree({ ...filteredTreeProps, viewClasses: getClassesByView(viewType) }),\n [viewType],\n ),\n createTreeSpecificVisibilityHandler: useCallback(\n (specificProps) => createTreeSpecificVisibilityHandler({ ...specificProps, hierarchyConfig: props.hierarchyConfig }),\n [props.hierarchyConfig],\n ),\n componentId,\n });\n\n useEffect(() => {\n idsCache.clearFilteredElementsModels();\n }, [searchPaths, idsCache]);\n\n return {\n visibilityHandlerFactory,\n onSearchPathsChanged,\n };\n}\n\nfunction createTreeSpecificVisibilityHandler(\n props: CreateTreeSpecificVisibilityHandlerProps<CategoriesTreeIdsCache> & {\n hierarchyConfig: CategoriesTreeHierarchyConfiguration;\n },\n) {\n const { info, idsCache, viewport, hierarchyConfig } = props;\n return new CategoriesTreeVisibilityHandler({\n alwaysAndNeverDrawnElementInfo: info,\n idsCache,\n viewport,\n hierarchyConfig,\n });\n}\n\nasync function createSearchResultsTree(\n props: CreateSearchResultsTreeProps<CategoriesTreeIdsCache> & { viewClasses: ReturnType<typeof getClassesByView> },\n): Promise<SearchResultsTree<CategoriesTreeSearchTargets>> {\n const { searchPaths, imodelAccess, idsCache, viewClasses } = props;\n return createCategoriesSearchResultsTree({\n imodelAccess,\n searchPaths,\n idsCache,\n categoryClassName: viewClasses.categoryClass,\n categoryElementClassName: viewClasses.elementClass,\n categoryModelClassName: viewClasses.modelClass,\n });\n}\n\nfunction useCategoriesTreeIdsCache({ imodel, activeViewType }: { imodel: IModelConnection; activeViewType: \"2d\" | \"3d\" }): CategoriesTreeIdsCache {\n const { getBaseIdsCache, getCache } = useSharedTreeContextInternal();\n\n const baseIdsCache = getBaseIdsCache({ type: activeViewType, elementClassName: getClassesByView(activeViewType).elementClass, imodel });\n const categoriesTreeIdsCache = getCache({\n imodel,\n createCache: () => new CategoriesTreeIdsCache({ baseIdsCache, type: activeViewType, queryExecutor: createECSqlQueryExecutor(imodel) }),\n cacheKey: `${activeViewType}-CategoriesTreeIdsCache`,\n });\n return categoriesTreeIdsCache;\n}\n"]}
|
|
@@ -1,33 +1,31 @@
|
|
|
1
|
+
import { BaseIdsCacheImpl } from "../../common/internal/caches/BaseIdsCache.js";
|
|
1
2
|
import type { Observable } from "rxjs";
|
|
2
|
-
import type {
|
|
3
|
+
import type { Id64Arg, Id64Set, Id64String } from "@itwin/core-bentley";
|
|
3
4
|
import type { LimitingECSqlQueryExecutor } from "@itwin/presentation-hierarchies";
|
|
4
5
|
import type { InstanceKey } from "@itwin/presentation-shared";
|
|
5
|
-
import type {
|
|
6
|
+
import type { BaseIdsCacheImplProps } from "../../common/internal/caches/BaseIdsCache.js";
|
|
7
|
+
import type { CategoryId, DefinitionContainerId } from "../../common/internal/Types.js";
|
|
6
8
|
/** @internal */
|
|
7
9
|
export interface CategoryInfo {
|
|
8
10
|
id: CategoryId;
|
|
9
11
|
subCategoryChildCount: number;
|
|
10
12
|
hasElements: boolean;
|
|
11
13
|
}
|
|
14
|
+
interface CategoriesTreeIdsCacheProps extends BaseIdsCacheImplProps {
|
|
15
|
+
queryExecutor: LimitingECSqlQueryExecutor;
|
|
16
|
+
type: "2d" | "3d";
|
|
17
|
+
}
|
|
12
18
|
/** @internal */
|
|
13
|
-
export declare class CategoriesTreeIdsCache
|
|
19
|
+
export declare class CategoriesTreeIdsCache extends BaseIdsCacheImpl {
|
|
14
20
|
#private;
|
|
15
|
-
constructor(
|
|
16
|
-
[Symbol.dispose](): void;
|
|
21
|
+
constructor(props: CategoriesTreeIdsCacheProps);
|
|
17
22
|
private queryFilteredElementsModels;
|
|
18
23
|
getFilteredElementsModels(filteredElementIds: Id64Arg): Observable<Map<string, string>>;
|
|
19
24
|
clearFilteredElementsModels(): void;
|
|
20
|
-
private queryElementModelCategories;
|
|
21
25
|
private queryCategories;
|
|
22
26
|
private queryIsDefinitionContainersSupported;
|
|
23
27
|
private queryDefinitionContainers;
|
|
24
|
-
private querySubCategories;
|
|
25
28
|
private getModelsCategoriesInfo;
|
|
26
|
-
private getElementModelsCategories;
|
|
27
|
-
private queryModeledElements;
|
|
28
|
-
private getModelWithCategoryModeledElements;
|
|
29
|
-
getCategoriesModeledElements(modelId: Id64String, categoryIds: Id64Arg): Observable<Id64Array>;
|
|
30
|
-
private getSubCategoriesInfo;
|
|
31
29
|
private getDefinitionContainersInfo;
|
|
32
30
|
getDirectChildDefinitionContainersAndCategories({ parentDefinitionContainerIds, includeEmpty, }: {
|
|
33
31
|
parentDefinitionContainerIds: Id64Arg;
|
|
@@ -36,13 +34,6 @@ export declare class CategoriesTreeIdsCache implements Disposable {
|
|
|
36
34
|
categories: CategoryInfo[];
|
|
37
35
|
definitionContainers: Array<DefinitionContainerId>;
|
|
38
36
|
}>;
|
|
39
|
-
getCategoriesElementModels(categoryIds: Id64Arg, includeSubModels?: boolean): Observable<{
|
|
40
|
-
id: CategoryId;
|
|
41
|
-
models: Array<ModelId> | undefined;
|
|
42
|
-
}>;
|
|
43
|
-
getModelCategoryIds(modelId: Id64String): Observable<Id64Array>;
|
|
44
|
-
getAllCategories(): Observable<Id64Set>;
|
|
45
|
-
hasSubModel(elementId: Id64String): Observable<boolean>;
|
|
46
37
|
getAllContainedCategories({ definitionContainerIds, includeEmptyCategories, }: {
|
|
47
38
|
definitionContainerIds: Id64Arg;
|
|
48
39
|
includeEmptyCategories?: boolean;
|
|
@@ -54,7 +45,6 @@ export declare class CategoriesTreeIdsCache implements Disposable {
|
|
|
54
45
|
} | {
|
|
55
46
|
subCategoryId: Id64String;
|
|
56
47
|
}): Observable<InstanceKey[]>;
|
|
57
|
-
getCategoryElementsCount(modelId: Id64String, categoryId: Id64String): Observable<number>;
|
|
58
48
|
getAllDefinitionContainersAndCategories(props?: {
|
|
59
49
|
includeEmpty?: boolean;
|
|
60
50
|
}): Observable<{
|
|
@@ -67,7 +57,7 @@ export declare class CategoriesTreeIdsCache implements Disposable {
|
|
|
67
57
|
categories: CategoryInfo[];
|
|
68
58
|
definitionContainers: Array<DefinitionContainerId>;
|
|
69
59
|
}>;
|
|
70
|
-
getSubCategories(categoryId: Id64String): Observable<Array<SubCategoryId>>;
|
|
71
60
|
getIsDefinitionContainerSupported(): Observable<boolean>;
|
|
72
61
|
}
|
|
62
|
+
export {};
|
|
73
63
|
//# sourceMappingURL=CategoriesTreeIdsCache.d.ts.map
|
|
@@ -2,40 +2,31 @@
|
|
|
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 { defer,
|
|
5
|
+
import { defer, forkJoin, from, map, mergeMap, of, reduce, shareReplay, toArray } from "rxjs";
|
|
6
6
|
import { Guid, Id64 } from "@itwin/core-bentley";
|
|
7
|
+
import { BaseIdsCacheImpl } from "../../common/internal/caches/BaseIdsCache.js";
|
|
7
8
|
import { CLASS_NAME_DefinitionContainer, CLASS_NAME_Model, CLASS_NAME_SubCategory } from "../../common/internal/ClassNameDefinitions.js";
|
|
8
|
-
import { ModelCategoryElementsCountCache } from "../../common/internal/ModelCategoryElementsCountCache.js";
|
|
9
9
|
import { catchBeSQLiteInterrupts } from "../../common/internal/UseErrorState.js";
|
|
10
10
|
import { getClassesByView, joinId64Arg } from "../../common/internal/Utils.js";
|
|
11
11
|
/** @internal */
|
|
12
|
-
export class CategoriesTreeIdsCache {
|
|
12
|
+
export class CategoriesTreeIdsCache extends BaseIdsCacheImpl {
|
|
13
13
|
#definitionContainersInfo;
|
|
14
14
|
#modelsCategoriesInfo;
|
|
15
|
-
#elementModelsCategories;
|
|
16
|
-
#subCategoriesInfo;
|
|
17
|
-
#categoryElementCounts;
|
|
18
|
-
#modelWithCategoryModeledElements;
|
|
19
15
|
#categoryClass;
|
|
20
16
|
#categoryElementClass;
|
|
21
|
-
#categoryModelClass;
|
|
22
17
|
#isDefinitionContainerSupported;
|
|
23
18
|
#filteredElementsModels;
|
|
24
19
|
#queryExecutor;
|
|
25
20
|
#componentId;
|
|
26
21
|
#componentName;
|
|
27
|
-
constructor(
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
constructor(props) {
|
|
23
|
+
super(props);
|
|
24
|
+
this.#queryExecutor = props.queryExecutor;
|
|
25
|
+
const { categoryClass, elementClass } = getClassesByView(props.type);
|
|
30
26
|
this.#categoryClass = categoryClass;
|
|
31
27
|
this.#categoryElementClass = elementClass;
|
|
32
|
-
this.#
|
|
33
|
-
this.#componentId = componentId ?? Guid.createValue();
|
|
28
|
+
this.#componentId = Guid.createValue();
|
|
34
29
|
this.#componentName = "CategoriesTreeIdsCache";
|
|
35
|
-
this.#categoryElementCounts = new ModelCategoryElementsCountCache(this.#queryExecutor, [elementClass], this.#componentId);
|
|
36
|
-
}
|
|
37
|
-
[Symbol.dispose]() {
|
|
38
|
-
this.#categoryElementCounts[Symbol.dispose]();
|
|
39
30
|
}
|
|
40
31
|
queryFilteredElementsModels(filteredElementIds) {
|
|
41
32
|
return defer(() => {
|
|
@@ -66,20 +57,6 @@ export class CategoriesTreeIdsCache {
|
|
|
66
57
|
clearFilteredElementsModels() {
|
|
67
58
|
this.#filteredElementsModels = undefined;
|
|
68
59
|
}
|
|
69
|
-
queryElementModelCategories() {
|
|
70
|
-
return defer(() => {
|
|
71
|
-
const query = `
|
|
72
|
-
SELECT this.Model.Id modelId, this.Category.Id categoryId
|
|
73
|
-
FROM ${this.#categoryModelClass} m
|
|
74
|
-
JOIN ${this.#categoryElementClass} this ON m.ECInstanceId = this.Model.Id
|
|
75
|
-
WHERE this.Parent.Id IS NULL AND m.IsPrivate = false
|
|
76
|
-
GROUP BY modelId, categoryId
|
|
77
|
-
`;
|
|
78
|
-
return this.#queryExecutor.createQueryReader({ ecsql: query }, { rowFormat: "ECSqlPropertyNames", limit: "unbounded", restartToken: `${this.#componentName}/${this.#componentId}/element-models-and-categories` });
|
|
79
|
-
}).pipe(catchBeSQLiteInterrupts, map((row) => {
|
|
80
|
-
return { modelId: row.modelId, categoryId: row.categoryId };
|
|
81
|
-
}));
|
|
82
|
-
}
|
|
83
60
|
queryCategories() {
|
|
84
61
|
return this.getIsDefinitionContainerSupported().pipe(mergeMap((isDefinitionContainerSupported) => defer(() => {
|
|
85
62
|
const categoriesQuery = `
|
|
@@ -187,22 +164,6 @@ export class CategoriesTreeIdsCache {
|
|
|
187
164
|
return { id: row.id, modelId: row.modelId, hasElements: !!row.hasElements };
|
|
188
165
|
}));
|
|
189
166
|
}
|
|
190
|
-
querySubCategories() {
|
|
191
|
-
return defer(() => {
|
|
192
|
-
const definitionsQuery = `
|
|
193
|
-
SELECT
|
|
194
|
-
sc.ECInstanceId id,
|
|
195
|
-
sc.Parent.Id categoryId
|
|
196
|
-
FROM
|
|
197
|
-
${CLASS_NAME_SubCategory} sc
|
|
198
|
-
WHERE
|
|
199
|
-
NOT sc.IsPrivate
|
|
200
|
-
`;
|
|
201
|
-
return this.#queryExecutor.createQueryReader({ ecsql: definitionsQuery }, { rowFormat: "ECSqlPropertyNames", limit: "unbounded", restartToken: `${this.#componentName}/${this.#componentId}/visible-sub-categories` });
|
|
202
|
-
}).pipe(catchBeSQLiteInterrupts, map((row) => {
|
|
203
|
-
return { id: row.id, parentId: row.categoryId };
|
|
204
|
-
}));
|
|
205
|
-
}
|
|
206
167
|
getModelsCategoriesInfo() {
|
|
207
168
|
this.#modelsCategoriesInfo ??= this.queryCategories()
|
|
208
169
|
.pipe(reduce((acc, queriedCategory) => {
|
|
@@ -221,92 +182,6 @@ export class CategoriesTreeIdsCache {
|
|
|
221
182
|
.pipe(shareReplay());
|
|
222
183
|
return this.#modelsCategoriesInfo;
|
|
223
184
|
}
|
|
224
|
-
getElementModelsCategories() {
|
|
225
|
-
this.#elementModelsCategories ??= forkJoin({
|
|
226
|
-
modelCategories: this.queryElementModelCategories().pipe(reduce((acc, queriedCategory) => {
|
|
227
|
-
let modelEntry = acc.get(queriedCategory.modelId);
|
|
228
|
-
if (modelEntry === undefined) {
|
|
229
|
-
modelEntry = { categoryIds: new Set() };
|
|
230
|
-
acc.set(queriedCategory.modelId, modelEntry);
|
|
231
|
-
}
|
|
232
|
-
modelEntry.categoryIds.add(queriedCategory.categoryId);
|
|
233
|
-
return acc;
|
|
234
|
-
}, new Map())),
|
|
235
|
-
modelWithCategoryModeledElements: this.getModelWithCategoryModeledElements(),
|
|
236
|
-
}).pipe(map(({ modelCategories, modelWithCategoryModeledElements }) => {
|
|
237
|
-
const result = new Map();
|
|
238
|
-
const subModels = new Set();
|
|
239
|
-
modelWithCategoryModeledElements.forEach((categoryMap) => categoryMap.forEach((categorySubModels) => categorySubModels.forEach((subModelId) => subModels.add(subModelId))));
|
|
240
|
-
for (const [modelId, modelEntry] of modelCategories) {
|
|
241
|
-
const isSubModel = subModels.has(modelId);
|
|
242
|
-
result.set(modelId, { categoryIds: modelEntry.categoryIds, isSubModel });
|
|
243
|
-
}
|
|
244
|
-
return result;
|
|
245
|
-
}), shareReplay());
|
|
246
|
-
return this.#elementModelsCategories;
|
|
247
|
-
}
|
|
248
|
-
queryModeledElements() {
|
|
249
|
-
return defer(() => {
|
|
250
|
-
const query = `
|
|
251
|
-
SELECT
|
|
252
|
-
pe.ECInstanceId modeledElementId,
|
|
253
|
-
pe.Category.Id categoryId,
|
|
254
|
-
pe.Model.Id modelId
|
|
255
|
-
FROM ${this.#categoryModelClass} m
|
|
256
|
-
JOIN ${this.#categoryElementClass} pe ON pe.ECInstanceId = m.ModeledElement.Id
|
|
257
|
-
WHERE
|
|
258
|
-
m.IsPrivate = false
|
|
259
|
-
AND m.ECInstanceId IN (SELECT Model.Id FROM ${this.#categoryElementClass})
|
|
260
|
-
`;
|
|
261
|
-
return this.#queryExecutor.createQueryReader({ ecsql: query }, { rowFormat: "ECSqlPropertyNames", limit: "unbounded", restartToken: `${this.#componentName}/${this.#componentId}/modeled-elements` });
|
|
262
|
-
}).pipe(catchBeSQLiteInterrupts, map((row) => {
|
|
263
|
-
return { modelId: row.modelId, categoryId: row.categoryId, modeledElementId: row.modeledElementId, rootCategoryId: row.rootCategoryId };
|
|
264
|
-
}));
|
|
265
|
-
}
|
|
266
|
-
getModelWithCategoryModeledElements() {
|
|
267
|
-
this.#modelWithCategoryModeledElements ??= this.queryModeledElements().pipe(reduce((acc, { modelId, categoryId, modeledElementId }) => {
|
|
268
|
-
let modelEntry = acc.get(modelId);
|
|
269
|
-
if (!modelEntry) {
|
|
270
|
-
modelEntry = new Map();
|
|
271
|
-
acc.set(modelId, modelEntry);
|
|
272
|
-
}
|
|
273
|
-
const categoryEntry = modelEntry.get(categoryId);
|
|
274
|
-
if (!categoryEntry) {
|
|
275
|
-
modelEntry.set(categoryId, new Set([modeledElementId]));
|
|
276
|
-
}
|
|
277
|
-
else {
|
|
278
|
-
categoryEntry.add(modeledElementId);
|
|
279
|
-
}
|
|
280
|
-
return acc;
|
|
281
|
-
}, new Map()), shareReplay());
|
|
282
|
-
return this.#modelWithCategoryModeledElements;
|
|
283
|
-
}
|
|
284
|
-
getCategoriesModeledElements(modelId, categoryIds) {
|
|
285
|
-
return this.getModelWithCategoryModeledElements().pipe(mergeMap((modelWithCategoryModeledElements) => {
|
|
286
|
-
const result = new Array();
|
|
287
|
-
const categoryMap = modelWithCategoryModeledElements.get(modelId);
|
|
288
|
-
if (!categoryMap) {
|
|
289
|
-
return of(result);
|
|
290
|
-
}
|
|
291
|
-
return from(Id64.iterable(categoryIds)).pipe(map((categoryId) => categoryMap.get(categoryId)), mergeMap((elementsSet) => (elementsSet ? from(elementsSet) : EMPTY)), toArray());
|
|
292
|
-
}));
|
|
293
|
-
}
|
|
294
|
-
getSubCategoriesInfo() {
|
|
295
|
-
this.#subCategoriesInfo ??= this.querySubCategories()
|
|
296
|
-
.pipe(reduce((acc, queriedSubCategory) => {
|
|
297
|
-
acc.subCategoryCategories.set(queriedSubCategory.id, queriedSubCategory.parentId);
|
|
298
|
-
const entry = acc.categorySubCategories.get(queriedSubCategory.parentId);
|
|
299
|
-
if (entry) {
|
|
300
|
-
entry.push(queriedSubCategory.id);
|
|
301
|
-
}
|
|
302
|
-
else {
|
|
303
|
-
acc.categorySubCategories.set(queriedSubCategory.parentId, [queriedSubCategory.id]);
|
|
304
|
-
}
|
|
305
|
-
return acc;
|
|
306
|
-
}, { subCategoryCategories: new Map(), categorySubCategories: new Map() }))
|
|
307
|
-
.pipe(shareReplay());
|
|
308
|
-
return this.#subCategoriesInfo;
|
|
309
|
-
}
|
|
310
185
|
getDefinitionContainersInfo() {
|
|
311
186
|
this.#definitionContainersInfo ??= forkJoin({
|
|
312
187
|
isDefinitionContainerSupported: this.getIsDefinitionContainerSupported(),
|
|
@@ -346,37 +221,12 @@ export class CategoriesTreeIdsCache {
|
|
|
346
221
|
return this.getDefinitionContainersInfo().pipe(mergeMap((definitionContainersInfo) => from(Id64.iterable(parentDefinitionContainerIds)).pipe(reduce((acc, parentDefinitionContainerId) => {
|
|
347
222
|
const parentDefinitionContainerInfo = definitionContainersInfo.get(parentDefinitionContainerId);
|
|
348
223
|
if (parentDefinitionContainerInfo !== undefined) {
|
|
349
|
-
|
|
350
|
-
|
|
224
|
+
applyElementsFilter(parentDefinitionContainerInfo.childDefinitionContainers, includeEmpty).forEach((dc) => acc.definitionContainers.push(dc.id));
|
|
225
|
+
applyElementsFilter(parentDefinitionContainerInfo.childCategories, includeEmpty).forEach((category) => acc.categories.push(category));
|
|
351
226
|
}
|
|
352
227
|
return acc;
|
|
353
228
|
}, { definitionContainers: new Array(), categories: new Array() }))));
|
|
354
229
|
}
|
|
355
|
-
getCategoriesElementModels(categoryIds, includeSubModels) {
|
|
356
|
-
return this.getElementModelsCategories().pipe(mergeMap((elementModelsCategories) => from(Id64.iterable(categoryIds)).pipe(map((categoryId) => {
|
|
357
|
-
const categoryModels = new Array();
|
|
358
|
-
elementModelsCategories.forEach(({ categoryIds: categories, isSubModel }, modelId) => {
|
|
359
|
-
if ((includeSubModels || !isSubModel) && categories.has(categoryId)) {
|
|
360
|
-
categoryModels.push(modelId);
|
|
361
|
-
}
|
|
362
|
-
});
|
|
363
|
-
return { id: categoryId, models: categoryModels.length > 0 ? categoryModels : undefined };
|
|
364
|
-
}))));
|
|
365
|
-
}
|
|
366
|
-
getModelCategoryIds(modelId) {
|
|
367
|
-
return this.getElementModelsCategories().pipe(map((elementModelsCategories) => {
|
|
368
|
-
return [...(elementModelsCategories.get(modelId)?.categoryIds ?? [])];
|
|
369
|
-
}));
|
|
370
|
-
}
|
|
371
|
-
getAllCategories() {
|
|
372
|
-
return this.getModelsCategoriesInfo().pipe(mergeMap((modelsCategoriesInfo) => modelsCategoriesInfo.values()), reduce((acc, { childCategories }) => {
|
|
373
|
-
childCategories.forEach(({ id }) => acc.add(id));
|
|
374
|
-
return acc;
|
|
375
|
-
}, new Set()));
|
|
376
|
-
}
|
|
377
|
-
hasSubModel(elementId) {
|
|
378
|
-
return this.getElementModelsCategories().pipe(map((elementModelsCategories) => elementModelsCategories.has(elementId)));
|
|
379
|
-
}
|
|
380
230
|
getAllContainedCategories({ definitionContainerIds, includeEmptyCategories, }) {
|
|
381
231
|
return this.getDefinitionContainersInfo().pipe(mergeMap((definitionContainersInfo) => from(Id64.iterable(definitionContainerIds)).pipe(mergeMap((definitionContainerId) => {
|
|
382
232
|
const definitionContainerInfo = definitionContainersInfo.get(definitionContainerId);
|
|
@@ -396,8 +246,12 @@ export class CategoriesTreeIdsCache {
|
|
|
396
246
|
};
|
|
397
247
|
}));
|
|
398
248
|
}), reduce((acc, { directCategories, indirectCategories }) => {
|
|
399
|
-
|
|
400
|
-
|
|
249
|
+
for (const categoryId of directCategories ?? []) {
|
|
250
|
+
acc.add(categoryId);
|
|
251
|
+
}
|
|
252
|
+
for (const categoryId of indirectCategories ?? []) {
|
|
253
|
+
acc.add(categoryId);
|
|
254
|
+
}
|
|
401
255
|
return acc;
|
|
402
256
|
}, new Set()))));
|
|
403
257
|
}
|
|
@@ -441,9 +295,6 @@ export class CategoriesTreeIdsCache {
|
|
|
441
295
|
return this.getInstanceKeyPaths({ definitionContainerId: definitionContainerInfo.modelId }).pipe(map((pathToParentDefinitionContainer) => [...pathToParentDefinitionContainer, instanceKey]));
|
|
442
296
|
}));
|
|
443
297
|
}
|
|
444
|
-
getCategoryElementsCount(modelId, categoryId) {
|
|
445
|
-
return this.#categoryElementCounts.getCategoryElementsCount(modelId, categoryId);
|
|
446
|
-
}
|
|
447
298
|
getAllDefinitionContainersAndCategories(props) {
|
|
448
299
|
return forkJoin({
|
|
449
300
|
categories: this.getModelsCategoriesInfo().pipe(mergeMap((modelsCategoriesInfo) => modelsCategoriesInfo.values()), reduce((acc, modelCategoriesInfo) => {
|
|
@@ -474,9 +325,6 @@ export class CategoriesTreeIdsCache {
|
|
|
474
325
|
}, new Array())),
|
|
475
326
|
});
|
|
476
327
|
}
|
|
477
|
-
getSubCategories(categoryId) {
|
|
478
|
-
return this.getSubCategoriesInfo().pipe(map(({ categorySubCategories }) => categorySubCategories.get(categoryId) ?? []));
|
|
479
|
-
}
|
|
480
328
|
getIsDefinitionContainerSupported() {
|
|
481
329
|
this.#isDefinitionContainerSupported ??= this.queryIsDefinitionContainersSupported().pipe(shareReplay());
|
|
482
330
|
return this.#isDefinitionContainerSupported;
|