@itwin/tree-widget-react 4.0.0-alpha.17 → 4.0.0-alpha.19
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 +51 -1
- package/lib/esm/tree-widget-react/TreeWidget.d.ts +1 -3
- package/lib/esm/tree-widget-react/TreeWidget.js +19 -19
- package/lib/esm/tree-widget-react/TreeWidget.js.map +1 -1
- package/lib/esm/tree-widget-react/components/TreeWidgetComponentImpl.d.ts +1 -0
- package/lib/esm/tree-widget-react/components/TreeWidgetComponentImpl.js +1 -1
- package/lib/esm/tree-widget-react/components/TreeWidgetComponentImpl.js.map +1 -1
- package/lib/esm/tree-widget-react/components/TreeWidgetUiItemsProvider.js +1 -1
- package/lib/esm/tree-widget-react/components/TreeWidgetUiItemsProvider.js.map +1 -1
- package/lib/esm/tree-widget-react/components/tree-header/SearchBox.js +2 -2
- package/lib/esm/tree-widget-react/components/tree-header/SearchBox.js.map +1 -1
- package/lib/esm/tree-widget-react/components/tree-header/SelectableTree.js.map +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 +3 -3
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTree.js +2 -2
- 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 +0 -2
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.js +13 -11
- 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 +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeComponent.js +2 -2
- 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 +6 -10
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js +137 -92
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js +12 -4
- 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 +30 -29
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js +405 -355
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/UseFilteredPaths.d.ts +5 -3
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/UseFilteredPaths.js +8 -6
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/UseFilteredPaths.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/CategoriesTreeVisibilityHandler.d.ts +4 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/CategoriesTreeVisibilityHandler.js +20 -12
- 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 +3 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/CategoriesTreeVisibilityHelper.js +13 -3
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/CategoriesTreeVisibilityHelper.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/FilteredTree.d.ts +4 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/FilteredTree.js +8 -7
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/FilteredTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTree.d.ts +2 -2
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTree.js +6 -2
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeComponent.d.ts +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeComponent.js +2 -2
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeComponent.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeDefinition.d.ts +3 -5
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeDefinition.js +45 -38
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeDefinition.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTree.js +8 -2
- 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/internal/ClassificationsTreeIdsCache.d.ts +14 -20
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeIdsCache.js +271 -275
- 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/UseFilteredPaths.d.ts +4 -2
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/UseFilteredPaths.js +3 -2
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/UseFilteredPaths.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/ClassificationsTreeVisibilityHandler.js +22 -15
- 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 +5 -5
- 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/FilteredTree.d.ts +7 -2
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/FilteredTree.js +15 -12
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/FilteredTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/UseHierarchyVisibility.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/Utils.d.ts +2 -1
- package/lib/esm/tree-widget-react/components/trees/common/Utils.js +8 -3
- package/lib/esm/tree-widget-react/components/trees/common/Utils.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/EmptyTree.js +4 -4
- package/lib/esm/tree-widget-react/components/trees/common/components/EmptyTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/ProgressOverlay.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/SkeletonTree.d.ts +4 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/SkeletonTree.js +4 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/SkeletonTree.js.map +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.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTree.d.ts +2 -2
- package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/AlwaysAndNeverDrawnElementInfo.d.ts +55 -18
- package/lib/esm/tree-widget-react/components/trees/common/internal/AlwaysAndNeverDrawnElementInfo.js +96 -76
- package/lib/esm/tree-widget-react/components/trees/common/internal/AlwaysAndNeverDrawnElementInfo.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/ModelCategoryElementsCountCache.d.ts +5 -8
- package/lib/esm/tree-widget-react/components/trees/common/internal/ModelCategoryElementsCountCache.js +52 -39
- package/lib/esm/tree-widget-react/components/trees/common/internal/ModelCategoryElementsCountCache.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/UseIModelAccess.d.ts +1 -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 +29 -4
- package/lib/esm/tree-widget-react/components/trees/common/internal/Utils.js +49 -4
- 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 +2 -7
- package/lib/esm/tree-widget-react/components/trees/common/internal/VisibilityUtils.js +30 -39
- 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/useGuid.d.ts +3 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/useGuid.js +12 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/useGuid.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/useTreeHooks/UseCachedVisibility.d.ts +5 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/useTreeHooks/UseCachedVisibility.js +25 -13
- 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 +3 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/useTreeHooks/UseIdsCache.js +7 -7
- 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/BaseFilteredTree.d.ts +8 -4
- package/lib/esm/tree-widget-react/components/trees/common/internal/visibility/BaseFilteredTree.js +16 -11
- package/lib/esm/tree-widget-react/components/trees/common/internal/visibility/BaseFilteredTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/visibility/BaseVisibilityHelper.d.ts +2 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/visibility/BaseVisibilityHelper.js +44 -28
- package/lib/esm/tree-widget-react/components/trees/common/internal/visibility/BaseVisibilityHelper.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/useGuid.d.ts +2 -0
- package/lib/esm/tree-widget-react/components/trees/common/useGuid.js +11 -0
- package/lib/esm/tree-widget-react/components/trees/common/useGuid.js.map +1 -0
- 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 +5 -2
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeComponent.d.ts +2 -2
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js +2 -2
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeDefinition.d.ts +4 -6
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeDefinition.js +31 -26
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeDefinition.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.d.ts +3 -3
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.js +6 -4
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeComponent.d.ts +2 -2
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeComponent.js +2 -2
- 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.d.ts +1 -5
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeDefinition.js +44 -44
- 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.d.ts +3 -6
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/internal/IModelContentTreeIdsCache.js +20 -16
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/internal/IModelContentTreeIdsCache.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/index.d.ts +1 -0
- package/lib/esm/tree-widget-react/components/trees/index.js +1 -0
- package/lib/esm/tree-widget-react/components/trees/index.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTree.d.ts +3 -3
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTree.js +2 -2
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.js +6 -3
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.d.ts +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.js +2 -2
- 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 +6 -10
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js +111 -69
- 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.js +7 -2
- 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 +17 -25
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js +246 -265
- 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/ModelsTreeNode.d.ts +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeNode.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/UseFilteredPaths.d.ts +3 -2
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/UseFilteredPaths.js +9 -3
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/UseFilteredPaths.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/FilteredTree.d.ts +4 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/FilteredTree.js +6 -6
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/FilteredTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/ModelsTreeVisibilityHandler.js +17 -11
- 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.js +3 -3
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/ModelsTreeVisibilityHelper.js.map +1 -1
- package/lib/esm/tree-widget-react-internal.d.ts +2 -1
- package/lib/esm/tree-widget-react-internal.js +2 -1
- package/lib/esm/tree-widget-react-internal.js.map +1 -1
- package/lib/public/locales/en/TreeWidget.json +1 -1
- package/package.json +12 -12
|
@@ -2,6 +2,7 @@
|
|
|
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 { firstValueFrom } from "rxjs";
|
|
5
6
|
import { assert } from "@itwin/core-bentley";
|
|
6
7
|
import { CLASS_NAME_Classification, CLASS_NAME_ClassificationTable, CLASS_NAME_GeometricElement2d } from "../../../common/internal/ClassNameDefinitions.js";
|
|
7
8
|
import { createFilteredTree, FilteredNodesHandler } from "../../../common/internal/visibility/BaseFilteredTree.js";
|
|
@@ -34,10 +35,10 @@ class ClassificationsTreeFilteredNodesHandler extends FilteredNodesHandler {
|
|
|
34
35
|
filteredTemporary3dElements.set(node.id, node);
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
|
-
const filteredElementsModels = await this.#props.idsCache.getFilteredElementsData({
|
|
38
|
+
const filteredElementsModels = await firstValueFrom(this.#props.idsCache.getFilteredElementsData({
|
|
38
39
|
element2dIds: [...filteredTemporary2dElements.keys()],
|
|
39
40
|
element3dIds: [...filteredTemporary3dElements.keys()],
|
|
40
|
-
});
|
|
41
|
+
}));
|
|
41
42
|
filteredTemporary2dElements.forEach((element, id) => {
|
|
42
43
|
const entry = filteredElementsModels.get(element.id);
|
|
43
44
|
assert(entry !== undefined);
|
|
@@ -63,15 +64,15 @@ class ClassificationsTreeFilteredNodesHandler extends FilteredNodesHandler {
|
|
|
63
64
|
classificationIds: filterTargets.classificationIds,
|
|
64
65
|
classificationTableIds: filterTargets.classificationIds,
|
|
65
66
|
elements2d: filterTargets.elements2d
|
|
66
|
-
? [...filterTargets.elements2d?.entries()].map(([modelCategoryKey,
|
|
67
|
+
? [...filterTargets.elements2d?.entries()].map(([modelCategoryKey, elements]) => {
|
|
67
68
|
const { modelId, categoryId } = this.parseModelCategoryKey(modelCategoryKey);
|
|
68
|
-
return { modelId, categoryId,
|
|
69
|
+
return { modelId, categoryId, elements };
|
|
69
70
|
})
|
|
70
71
|
: undefined,
|
|
71
72
|
elements3d: filterTargets.elements3d
|
|
72
|
-
? [...filterTargets.elements3d?.entries()].map(([modelCategoryKey,
|
|
73
|
+
? [...filterTargets.elements3d?.entries()].map(([modelCategoryKey, elements]) => {
|
|
73
74
|
const { modelId, categoryId } = this.parseModelCategoryKey(modelCategoryKey);
|
|
74
|
-
return { modelId, categoryId,
|
|
75
|
+
return { modelId, categoryId, elements };
|
|
75
76
|
})
|
|
76
77
|
: undefined,
|
|
77
78
|
};
|
|
@@ -110,19 +111,21 @@ class ClassificationsTreeFilteredNodesHandler extends FilteredNodesHandler {
|
|
|
110
111
|
const element2dKey = this.createModelCategoryKey(node.modelId, node.categoryId);
|
|
111
112
|
const elements2d = (filterTargets.elements2d ??= new Map()).get(element2dKey);
|
|
112
113
|
if (elements2d) {
|
|
113
|
-
elements2d.
|
|
114
|
-
|
|
114
|
+
elements2d.set(node.id, { isFilterTarget: node.isFilterTarget });
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
filterTargets.elements2d.set(element2dKey, new Map([[node.id, { isFilterTarget: node.isFilterTarget }]]));
|
|
115
118
|
}
|
|
116
|
-
filterTargets.elements2d.set(element2dKey, new Set([node.id]));
|
|
117
119
|
return;
|
|
118
120
|
case "element3d":
|
|
119
121
|
const element3dKey = this.createModelCategoryKey(node.modelId, node.categoryId);
|
|
120
122
|
const elements3d = (filterTargets.elements3d ??= new Map()).get(element3dKey);
|
|
121
123
|
if (elements3d) {
|
|
122
|
-
elements3d.
|
|
123
|
-
|
|
124
|
+
elements3d.set(node.id, { isFilterTarget: node.isFilterTarget });
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
filterTargets.elements3d.set(element3dKey, new Map([[node.id, { isFilterTarget: node.isFilterTarget }]]));
|
|
124
128
|
}
|
|
125
|
-
filterTargets.elements3d.set(element3dKey, new Set([node.id]));
|
|
126
129
|
return;
|
|
127
130
|
}
|
|
128
131
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilteredTree.js","sourceRoot":"","sources":["../../../../../../../../src/tree-widget-react/components/trees/classifications-tree/internal/visibility/FilteredTree.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,yBAAyB,EAAE,8BAA8B,EAAE,6BAA6B,EAAE,MAAM,kDAAkD,CAAC;AAC5J,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,yDAAyD,CAAC;AAyDnH,gBAAgB;AAChB,MAAM,CAAC,KAAK,UAAU,iCAAiC,CAAC,KAIvD;IACC,MAAM,EAAE,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IACzD,OAAO,kBAAkB,CAAC;QACxB,oBAAoB,EAAE,IAAI,uCAAuC,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC;QAC7F,cAAc;KACf,CAAC,CAAC;AACL,CAAC;AAqBD,MAAM,uCAAwC,SAAQ,oBAIrD;IACU,MAAM,CAA+C;IAC9D,YAAY,KAAmD;QAC7D,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAEM,KAAK,CAAC,yBAAyB;QACpC,MAAM,2BAA2B,GAAG,IAAI,GAAG,EAAgE,CAAC;QAC5G,MAAM,2BAA2B,GAAG,IAAI,GAAG,EAAgE,CAAC;QAC5G,MAAM,MAAM,GAA2B;YACrC,kBAAkB,EAAE,IAAI,GAAG,EAAE;YAC7B,kBAAkB,EAAE,IAAI,GAAG,EAAE;SAC9B,CAAC;QACF,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACzC,IAAI,IAAI,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;gBAC9B,2BAA2B,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;YACjD,CAAC;iBAAM,IAAI,IAAI,CAAC,IAAI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AAG,OAAO,IAAI,UAAU,EAAE,CAAC;IACpC,CAAC;IAEO,qBAAqB,CAAC,GAAqB;QACjD,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC7C,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;IACjC,CAAC;IAEM,sBAAsB,CAAC,EAC5B,IAAI,EACJ,EAAE,EACF,cAAc,GAKf;QACC,IAAI,IAAI,KAAK,WAAW,IAAI,IAAI,KAAK,WAAW,EAAE,CAAC;YACjD,OAAO;gBACL,EAAE;gBACF,cAAc;gBACd,IAAI;gBACJ,OAAO,EAAE,SAAS;gBAClB,UAAU,EAAE,SAAS;aACtB,CAAC;QACJ,CAAC;QACD,OAAO;YACL,EAAE;YACF,cAAc;YACd,IAAI;SACL,CAAC;IACJ,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,SAAiB;QACpC,IAAI,MAAM,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,gBAAgB,CAAC,SAAS,EAAE,8BAA8B,CAAC,EAAE,CAAC;YAC/F,OAAO,qBAAqB,CAAC;QAC/B,CAAC;QACD,IAAI,MAAM,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,gBAAgB,CAAC,SAAS,EAAE,yBAAyB,CAAC,EAAE,CAAC;YAC1F,OAAO,gBAAgB,CAAC;QAC1B,CAAC;QACD,IAAI,MAAM,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,gBAAgB,CAAC,SAAS,EAAE,6BAA6B,CAAC,EAAE,CAAC;YAC9F,OAAO,WAAW,CAAC;QACrB,CAAC;QACD,OAAO,WAAW,CAAC;IACrB,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { assert } from \"@itwin/core-bentley\";\nimport { CLASS_NAME_Classification, CLASS_NAME_ClassificationTable, CLASS_NAME_GeometricElement2d } from \"../../../common/internal/ClassNameDefinitions.js\";\nimport { createFilteredTree, FilteredNodesHandler } from \"../../../common/internal/visibility/BaseFilteredTree.js\";\n\nimport type { Id64Set, Id64String } from \"@itwin/core-bentley\";\nimport type { HierarchyFilteringPath } from \"@itwin/presentation-hierarchies\";\nimport type { ECClassHierarchyInspector } from \"@itwin/presentation-shared\";\nimport type { CategoryId, ElementId, ModelId } from \"../../../common/internal/Types.js\";\nimport type { BaseFilteredTreeNode, FilteredTree, FilteredTreeNodeChildren } from \"../../../common/internal/visibility/BaseFilteredTree.js\";\nimport type { ClassificationsTreeIdsCache } from \"../ClassificationsTreeIdsCache.js\";\n\ninterface ClassificationTableFilteredTreeNode extends BaseFilteredTreeNode<ClassificationTableFilteredTreeNode> {\n type: \"classificationTable\";\n}\n\ninterface ClassificationFilteredTreeNode extends BaseFilteredTreeNode<ClassificationFilteredTreeNode> {\n type: \"classification\";\n}\n\ninterface Element2dFilteredTreeNode extends BaseFilteredTreeNode<Element2dFilteredTreeNode> {\n type: \"element2d\";\n categoryId: Id64String;\n modelId: Id64String;\n}\n\ninterface Element3dFilteredTreeNode extends BaseFilteredTreeNode<Element3dFilteredTreeNode> {\n type: \"element3d\";\n categoryId: Id64String;\n modelId: Id64String;\n}\n\ntype FilteredTreeNode = ClassificationTableFilteredTreeNode | ClassificationFilteredTreeNode | Element2dFilteredTreeNode | Element3dFilteredTreeNode;\n\ntype TemporaryElement2dFilteredNode = Omit<Element2dFilteredTreeNode, \"modelId\" | \"categoryId\" | \"children\"> & {\n modelId: string | undefined;\n categoryId: string | undefined;\n children?: FilteredTreeNodeChildren<TemporaryElement2dFilteredNode>;\n};\n\ntype TemporaryElement3dFilteredNode = Omit<Element3dFilteredTreeNode, \"modelId\" | \"categoryId\" | \"children\"> & {\n modelId: string | undefined;\n categoryId: string | undefined;\n children?: FilteredTreeNodeChildren<TemporaryElement3dFilteredNode>;\n};\n\ntype TemporaryFilteredTreeNode =\n | ClassificationTableFilteredTreeNode\n | ClassificationFilteredTreeNode\n | TemporaryElement2dFilteredNode\n | TemporaryElement3dFilteredNode;\n\n/** @internal */\nexport interface ClassificationsTreeFilterTargets {\n elements2d?: Array<{ modelId: Id64String; categoryId: Id64String; elementIds: Set<Id64String> }>;\n elements3d?: Array<{ modelId: Id64String; categoryId: Id64String; elementIds: Set<Id64String> }>;\n classificationTableIds?: Id64Set;\n classificationIds?: Id64Set;\n}\n\n/** @internal */\nexport async function createFilteredClassificationsTree(props: {\n imodelAccess: ECClassHierarchyInspector;\n filteringPaths: HierarchyFilteringPath[];\n idsCache: ClassificationsTreeIdsCache;\n}): Promise<FilteredTree<ClassificationsTreeFilterTargets>> {\n const { imodelAccess, filteringPaths, idsCache } = props;\n return createFilteredTree({\n filteredNodesHandler: new ClassificationsTreeFilteredNodesHandler({ idsCache, imodelAccess }),\n filteringPaths,\n });\n}\n\ninterface FilterTargetsInternal {\n elements2d?: Map<ModelCategoryKey, Set<ElementId>>;\n elements3d?: Map<ModelCategoryKey, Set<ElementId>>;\n classificationTableIds?: Id64Set;\n classificationIds?: Id64Set;\n}\n\ninterface ClassificationsTreeFilteredNodesHandlerProps {\n idsCache: ClassificationsTreeIdsCache;\n imodelAccess: ECClassHierarchyInspector;\n}\n\ntype ModelCategoryKey = `${ModelId}-${CategoryId}`;\n\ninterface ProcessedFilteredNodes {\n filtered2dElements: Map<Id64String, Omit<Element2dFilteredTreeNode, \"children\">>;\n filtered3dElements: Map<Id64String, Omit<Element3dFilteredTreeNode, \"children\">>;\n}\n\nclass ClassificationsTreeFilteredNodesHandler extends FilteredNodesHandler<\n ProcessedFilteredNodes,\n ClassificationsTreeFilterTargets,\n TemporaryFilteredTreeNode\n> {\n readonly #props: ClassificationsTreeFilteredNodesHandlerProps;\n constructor(props: ClassificationsTreeFilteredNodesHandlerProps) {\n super();\n this.#props = props;\n }\n\n public async getProcessedFilteredNodes(): Promise<ProcessedFilteredNodes> {\n const filteredTemporary2dElements = new Map<Id64String, Omit<TemporaryElement2dFilteredNode, \"children\">>();\n const filteredTemporary3dElements = new Map<Id64String, Omit<TemporaryElement3dFilteredNode, \"children\">>();\n const result: ProcessedFilteredNodes = {\n filtered2dElements: new Map(),\n filtered3dElements: new Map(),\n };\n for (const node of this.filteredNodesArr) {\n if (node.type === \"element2d\") {\n filteredTemporary2dElements.set(node.id, node);\n } else if (node.type === \"element3d\") {\n filteredTemporary3dElements.set(node.id, node);\n }\n }\n\n const filteredElementsModels = await this.#props.idsCache.getFilteredElementsData({\n element2dIds: [...filteredTemporary2dElements.keys()],\n element3dIds: [...filteredTemporary3dElements.keys()],\n });\n filteredTemporary2dElements.forEach((element, id) => {\n const entry = filteredElementsModels.get(element.id);\n assert(entry !== undefined);\n result.filtered2dElements.set(id, { ...element, modelId: entry.modelId, categoryId: entry.categoryId });\n });\n filteredTemporary3dElements.forEach((element, id) => {\n const entry = filteredElementsModels.get(element.id);\n assert(entry !== undefined);\n result.filtered3dElements.set(id, { ...element, modelId: entry.modelId, categoryId: entry.categoryId });\n });\n return result;\n }\n\n public convertNodesToFilterTargets(\n filteredNodes: TemporaryFilteredTreeNode[],\n processedFilteredNodes: ProcessedFilteredNodes,\n ): ClassificationsTreeFilterTargets | undefined {\n const filterTargets: FilterTargetsInternal = {};\n\n filteredNodes.forEach((filteredNode) => this.collectFilterTargets(filterTargets, filteredNode, processedFilteredNodes));\n\n return this.convertInternalFilterTargets(filterTargets);\n }\n\n private convertInternalFilterTargets(filterTargets: FilterTargetsInternal): ClassificationsTreeFilterTargets | undefined {\n if (!filterTargets.classificationIds && !filterTargets.classificationIds && !filterTargets.elements2d && !filterTargets.elements3d) {\n return undefined;\n }\n\n return {\n classificationIds: filterTargets.classificationIds,\n classificationTableIds: filterTargets.classificationIds,\n elements2d: filterTargets.elements2d\n ? [...filterTargets.elements2d?.entries()].map(([modelCategoryKey, elementIds]) => {\n const { modelId, categoryId } = this.parseModelCategoryKey(modelCategoryKey);\n return { modelId, categoryId, elementIds };\n })\n : undefined,\n elements3d: filterTargets.elements3d\n ? [...filterTargets.elements3d?.entries()].map(([modelCategoryKey, elementIds]) => {\n const { modelId, categoryId } = this.parseModelCategoryKey(modelCategoryKey);\n return { modelId, categoryId, elementIds };\n })\n : undefined,\n };\n }\n\n private collectFilterTargets(changeTargets: FilterTargetsInternal, node: TemporaryFilteredTreeNode, processedFilteredNodes: ProcessedFilteredNodes) {\n const filteredNode =\n node.type === \"element2d\"\n ? processedFilteredNodes.filtered2dElements.get(node.id)\n : node.type === \"element3d\"\n ? processedFilteredNodes.filtered3dElements.get(node.id)\n : node;\n assert(filteredNode !== undefined);\n if (filteredNode.isFilterTarget) {\n this.addTarget(changeTargets, filteredNode);\n return;\n }\n\n if (filteredNode.type === \"element2d\" || filteredNode.type === \"element3d\") {\n // need to add parent ids as filter target will be an element\n this.addTarget(changeTargets, filteredNode);\n }\n\n if (!node.children) {\n return;\n }\n\n for (const child of node.children.values()) {\n this.collectFilterTargets(changeTargets, child, processedFilteredNodes);\n }\n }\n\n private addTarget(filterTargets: FilterTargetsInternal, node: FilteredTreeNode) {\n switch (node.type) {\n case \"classificationTable\":\n (filterTargets.classificationTableIds ??= new Set()).add(node.id);\n return;\n case \"classification\":\n (filterTargets.classificationIds ??= new Set()).add(node.id);\n return;\n case \"element2d\":\n const element2dKey = this.createModelCategoryKey(node.modelId, node.categoryId);\n const elements2d = (filterTargets.elements2d ??= new Map()).get(element2dKey);\n if (elements2d) {\n elements2d.add(node.id);\n return;\n }\n filterTargets.elements2d.set(element2dKey, new Set([node.id]));\n return;\n case \"element3d\":\n const element3dKey = this.createModelCategoryKey(node.modelId, node.categoryId);\n const elements3d = (filterTargets.elements3d ??= new Map()).get(element3dKey);\n if (elements3d) {\n elements3d.add(node.id);\n return;\n }\n filterTargets.elements3d.set(element3dKey, new Set([node.id]));\n return;\n }\n }\n\n private createModelCategoryKey(modelId: Id64String, categoryId: Id64String): ModelCategoryKey {\n return `${modelId}-${categoryId}`;\n }\n\n private parseModelCategoryKey(key: ModelCategoryKey): { modelId: Id64String; categoryId: Id64String } {\n const [modelId, categoryId] = key.split(\"-\");\n return { modelId, categoryId };\n }\n\n public createFilteredTreeNode({\n type,\n id,\n isFilterTarget,\n }: {\n type: FilteredTreeNode[\"type\"];\n id: Id64String;\n isFilterTarget: boolean;\n }): TemporaryFilteredTreeNode {\n if (type === \"element2d\" || type === \"element3d\") {\n return {\n id,\n isFilterTarget,\n type,\n modelId: undefined,\n categoryId: undefined,\n };\n }\n return {\n id,\n isFilterTarget,\n type,\n };\n }\n\n public async getType(className: string): Promise<TemporaryFilteredTreeNode[\"type\"]> {\n if (await this.#props.imodelAccess.classDerivesFrom(className, CLASS_NAME_ClassificationTable)) {\n return \"classificationTable\";\n }\n if (await this.#props.imodelAccess.classDerivesFrom(className, CLASS_NAME_Classification)) {\n return \"classification\";\n }\n if (await this.#props.imodelAccess.classDerivesFrom(className, CLASS_NAME_GeometricElement2d)) {\n return \"element2d\";\n }\n return \"element3d\";\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"FilteredTree.js","sourceRoot":"","sources":["../../../../../../../../src/tree-widget-react/components/trees/classifications-tree/internal/visibility/FilteredTree.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,yBAAyB,EAAE,8BAA8B,EAAE,6BAA6B,EAAE,MAAM,kDAAkD,CAAC;AAC5J,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,yDAAyD,CAAC;AAyDnH,gBAAgB;AAChB,MAAM,CAAC,KAAK,UAAU,iCAAiC,CAAC,KAIvD;IACC,MAAM,EAAE,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IACzD,OAAO,kBAAkB,CAAC;QACxB,oBAAoB,EAAE,IAA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BAAsB,CAAC,EAC5B,IAAI,EACJ,EAAE,EACF,cAAc,GAKf;QACC,IAAI,IAAI,KAAK,WAAW,IAAI,IAAI,KAAK,WAAW,EAAE,CAAC;YACjD,OAAO;gBACL,EAAE;gBACF,cAAc;gBACd,IAAI;gBACJ,OAAO,EAAE,SAAS;gBAClB,UAAU,EAAE,SAAS;aACtB,CAAC;QACJ,CAAC;QACD,OAAO;YACL,EAAE;YACF,cAAc;YACd,IAAI;SACL,CAAC;IACJ,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,SAAiB;QACpC,IAAI,MAAM,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,gBAAgB,CAAC,SAAS,EAAE,8BAA8B,CAAC,EAAE,CAAC;YAC/F,OAAO,qBAAqB,CAAC;QAC/B,CAAC;QACD,IAAI,MAAM,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,gBAAgB,CAAC,SAAS,EAAE,yBAAyB,CAAC,EAAE,CAAC;YAC1F,OAAO,gBAAgB,CAAC;QAC1B,CAAC;QACD,IAAI,MAAM,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,gBAAgB,CAAC,SAAS,EAAE,6BAA6B,CAAC,EAAE,CAAC;YAC9F,OAAO,WAAW,CAAC;QACrB,CAAC;QACD,OAAO,WAAW,CAAC;IACrB,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { firstValueFrom } from \"rxjs\";\nimport { assert } from \"@itwin/core-bentley\";\nimport { CLASS_NAME_Classification, CLASS_NAME_ClassificationTable, CLASS_NAME_GeometricElement2d } from \"../../../common/internal/ClassNameDefinitions.js\";\nimport { createFilteredTree, FilteredNodesHandler } from \"../../../common/internal/visibility/BaseFilteredTree.js\";\n\nimport type { Id64Set, Id64String } from \"@itwin/core-bentley\";\nimport type { HierarchyFilteringPath } from \"@itwin/presentation-hierarchies\";\nimport type { ECClassHierarchyInspector } from \"@itwin/presentation-shared\";\nimport type { CategoryId, ElementId, ModelId } from \"../../../common/internal/Types.js\";\nimport type { BaseFilteredTreeNode, FilteredTree, FilteredTreeNodeChildren } from \"../../../common/internal/visibility/BaseFilteredTree.js\";\nimport type { ClassificationsTreeIdsCache } from \"../ClassificationsTreeIdsCache.js\";\n\ninterface ClassificationTableFilteredTreeNode extends BaseFilteredTreeNode<ClassificationTableFilteredTreeNode> {\n type: \"classificationTable\";\n}\n\ninterface ClassificationFilteredTreeNode extends BaseFilteredTreeNode<ClassificationFilteredTreeNode> {\n type: \"classification\";\n}\n\ninterface Element2dFilteredTreeNode extends BaseFilteredTreeNode<Element2dFilteredTreeNode> {\n type: \"element2d\";\n categoryId: Id64String;\n modelId: Id64String;\n}\n\ninterface Element3dFilteredTreeNode extends BaseFilteredTreeNode<Element3dFilteredTreeNode> {\n type: \"element3d\";\n categoryId: Id64String;\n modelId: Id64String;\n}\n\ntype FilteredTreeNode = ClassificationTableFilteredTreeNode | ClassificationFilteredTreeNode | Element2dFilteredTreeNode | Element3dFilteredTreeNode;\n\ntype TemporaryElement2dFilteredNode = Omit<Element2dFilteredTreeNode, \"modelId\" | \"categoryId\" | \"children\"> & {\n modelId: string | undefined;\n categoryId: string | undefined;\n children?: FilteredTreeNodeChildren<TemporaryElement2dFilteredNode>;\n};\n\ntype TemporaryElement3dFilteredNode = Omit<Element3dFilteredTreeNode, \"modelId\" | \"categoryId\" | \"children\"> & {\n modelId: string | undefined;\n categoryId: string | undefined;\n children?: FilteredTreeNodeChildren<TemporaryElement3dFilteredNode>;\n};\n\ntype TemporaryFilteredTreeNode =\n | ClassificationTableFilteredTreeNode\n | ClassificationFilteredTreeNode\n | TemporaryElement2dFilteredNode\n | TemporaryElement3dFilteredNode;\n\n/** @internal */\nexport interface ClassificationsTreeFilterTargets {\n elements2d?: Array<{ modelId: Id64String; categoryId: Id64String; elements: Map<ElementId, { isFilterTarget: boolean }> }>;\n elements3d?: Array<{ modelId: Id64String; categoryId: Id64String; elements: Map<ElementId, { isFilterTarget: boolean }> }>;\n classificationTableIds?: Id64Set;\n classificationIds?: Id64Set;\n}\n\n/** @internal */\nexport async function createFilteredClassificationsTree(props: {\n imodelAccess: ECClassHierarchyInspector;\n filteringPaths: HierarchyFilteringPath[];\n idsCache: ClassificationsTreeIdsCache;\n}): Promise<FilteredTree<ClassificationsTreeFilterTargets>> {\n const { imodelAccess, filteringPaths, idsCache } = props;\n return createFilteredTree({\n filteredNodesHandler: new ClassificationsTreeFilteredNodesHandler({ idsCache, imodelAccess }),\n filteringPaths,\n });\n}\n\ninterface FilterTargetsInternal {\n elements2d?: Map<ModelCategoryKey, Map<ElementId, { isFilterTarget: boolean }>>;\n elements3d?: Map<ModelCategoryKey, Map<ElementId, { isFilterTarget: boolean }>>;\n classificationTableIds?: Id64Set;\n classificationIds?: Id64Set;\n}\n\ninterface ClassificationsTreeFilteredNodesHandlerProps {\n idsCache: ClassificationsTreeIdsCache;\n imodelAccess: ECClassHierarchyInspector;\n}\n\ntype ModelCategoryKey = `${ModelId}-${CategoryId}`;\n\ninterface ProcessedFilteredNodes {\n filtered2dElements: Map<Id64String, Omit<Element2dFilteredTreeNode, \"children\">>;\n filtered3dElements: Map<Id64String, Omit<Element3dFilteredTreeNode, \"children\">>;\n}\n\nclass ClassificationsTreeFilteredNodesHandler extends FilteredNodesHandler<\n ProcessedFilteredNodes,\n ClassificationsTreeFilterTargets,\n TemporaryFilteredTreeNode\n> {\n readonly #props: ClassificationsTreeFilteredNodesHandlerProps;\n constructor(props: ClassificationsTreeFilteredNodesHandlerProps) {\n super();\n this.#props = props;\n }\n\n public async getProcessedFilteredNodes(): Promise<ProcessedFilteredNodes> {\n const filteredTemporary2dElements = new Map<Id64String, Omit<TemporaryElement2dFilteredNode, \"children\">>();\n const filteredTemporary3dElements = new Map<Id64String, Omit<TemporaryElement3dFilteredNode, \"children\">>();\n const result: ProcessedFilteredNodes = {\n filtered2dElements: new Map(),\n filtered3dElements: new Map(),\n };\n for (const node of this.filteredNodesArr) {\n if (node.type === \"element2d\") {\n filteredTemporary2dElements.set(node.id, node);\n } else if (node.type === \"element3d\") {\n filteredTemporary3dElements.set(node.id, node);\n }\n }\n\n const filteredElementsModels = await firstValueFrom(\n this.#props.idsCache.getFilteredElementsData({\n element2dIds: [...filteredTemporary2dElements.keys()],\n element3dIds: [...filteredTemporary3dElements.keys()],\n }),\n );\n filteredTemporary2dElements.forEach((element, id) => {\n const entry = filteredElementsModels.get(element.id);\n assert(entry !== undefined);\n result.filtered2dElements.set(id, { ...element, modelId: entry.modelId, categoryId: entry.categoryId });\n });\n filteredTemporary3dElements.forEach((element, id) => {\n const entry = filteredElementsModels.get(element.id);\n assert(entry !== undefined);\n result.filtered3dElements.set(id, { ...element, modelId: entry.modelId, categoryId: entry.categoryId });\n });\n return result;\n }\n\n public convertNodesToFilterTargets(\n filteredNodes: TemporaryFilteredTreeNode[],\n processedFilteredNodes: ProcessedFilteredNodes,\n ): ClassificationsTreeFilterTargets | undefined {\n const filterTargets: FilterTargetsInternal = {};\n\n filteredNodes.forEach((filteredNode) => this.collectFilterTargets(filterTargets, filteredNode, processedFilteredNodes));\n\n return this.convertInternalFilterTargets(filterTargets);\n }\n\n private convertInternalFilterTargets(filterTargets: FilterTargetsInternal): ClassificationsTreeFilterTargets | undefined {\n if (!filterTargets.classificationIds && !filterTargets.classificationIds && !filterTargets.elements2d && !filterTargets.elements3d) {\n return undefined;\n }\n\n return {\n classificationIds: filterTargets.classificationIds,\n classificationTableIds: filterTargets.classificationIds,\n elements2d: filterTargets.elements2d\n ? [...filterTargets.elements2d?.entries()].map(([modelCategoryKey, elements]) => {\n const { modelId, categoryId } = this.parseModelCategoryKey(modelCategoryKey);\n return { modelId, categoryId, elements };\n })\n : undefined,\n elements3d: filterTargets.elements3d\n ? [...filterTargets.elements3d?.entries()].map(([modelCategoryKey, elements]) => {\n const { modelId, categoryId } = this.parseModelCategoryKey(modelCategoryKey);\n return { modelId, categoryId, elements };\n })\n : undefined,\n };\n }\n\n private collectFilterTargets(changeTargets: FilterTargetsInternal, node: TemporaryFilteredTreeNode, processedFilteredNodes: ProcessedFilteredNodes) {\n const filteredNode =\n node.type === \"element2d\"\n ? processedFilteredNodes.filtered2dElements.get(node.id)\n : node.type === \"element3d\"\n ? processedFilteredNodes.filtered3dElements.get(node.id)\n : node;\n assert(filteredNode !== undefined);\n if (filteredNode.isFilterTarget) {\n this.addTarget(changeTargets, filteredNode);\n return;\n }\n\n if (filteredNode.type === \"element2d\" || filteredNode.type === \"element3d\") {\n // need to add parent ids as filter target will be an element\n this.addTarget(changeTargets, filteredNode);\n }\n\n if (!node.children) {\n return;\n }\n\n for (const child of node.children.values()) {\n this.collectFilterTargets(changeTargets, child, processedFilteredNodes);\n }\n }\n\n private addTarget(filterTargets: FilterTargetsInternal, node: FilteredTreeNode) {\n switch (node.type) {\n case \"classificationTable\":\n (filterTargets.classificationTableIds ??= new Set()).add(node.id);\n return;\n case \"classification\":\n (filterTargets.classificationIds ??= new Set()).add(node.id);\n return;\n case \"element2d\":\n const element2dKey = this.createModelCategoryKey(node.modelId, node.categoryId);\n const elements2d = (filterTargets.elements2d ??= new Map()).get(element2dKey);\n if (elements2d) {\n elements2d.set(node.id, { isFilterTarget: node.isFilterTarget });\n } else {\n filterTargets.elements2d.set(element2dKey, new Map([[node.id, { isFilterTarget: node.isFilterTarget }]]));\n }\n return;\n case \"element3d\":\n const element3dKey = this.createModelCategoryKey(node.modelId, node.categoryId);\n const elements3d = (filterTargets.elements3d ??= new Map()).get(element3dKey);\n if (elements3d) {\n elements3d.set(node.id, { isFilterTarget: node.isFilterTarget });\n } else {\n filterTargets.elements3d.set(element3dKey, new Map([[node.id, { isFilterTarget: node.isFilterTarget }]]));\n }\n return;\n }\n }\n\n private createModelCategoryKey(modelId: Id64String, categoryId: Id64String): ModelCategoryKey {\n return `${modelId}-${categoryId}`;\n }\n\n private parseModelCategoryKey(key: ModelCategoryKey): { modelId: Id64String; categoryId: Id64String } {\n const [modelId, categoryId] = key.split(\"-\");\n return { modelId, categoryId };\n }\n\n public createFilteredTreeNode({\n type,\n id,\n isFilterTarget,\n }: {\n type: FilteredTreeNode[\"type\"];\n id: Id64String;\n isFilterTarget: boolean;\n }): TemporaryFilteredTreeNode {\n if (type === \"element2d\" || type === \"element3d\") {\n return {\n id,\n isFilterTarget,\n type,\n modelId: undefined,\n categoryId: undefined,\n };\n }\n return {\n id,\n isFilterTarget,\n type,\n };\n }\n\n public async getType(className: string): Promise<TemporaryFilteredTreeNode[\"type\"]> {\n if (await this.#props.imodelAccess.classDerivesFrom(className, CLASS_NAME_ClassificationTable)) {\n return \"classificationTable\";\n }\n if (await this.#props.imodelAccess.classDerivesFrom(className, CLASS_NAME_Classification)) {\n return \"classification\";\n }\n if (await this.#props.imodelAccess.classDerivesFrom(className, CLASS_NAME_GeometricElement2d)) {\n return \"element2d\";\n }\n return \"element3d\";\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UseHierarchyVisibility.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/common/UseHierarchyVisibility.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EACL,cAAc,EACd,KAAK,EACL,QAAQ,EACR,KAAK,EACL,IAAI,EACJ,aAAa,EACb,QAAQ,EACR,SAAS,EACT,qBAAqB,EACrB,OAAO,EACP,SAAS,EACT,GAAG,EACH,YAAY,GACb,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAoC/D,gBAAgB;AAChB,MAAM,UAAU,sBAAsB,CAAC,EAAE,wBAAwB,EAA+B;IAC9F,MAAM,mBAAmB,GAAG,MAA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IAAI,CAAC,CAAC;QAC5B,CAAC;QAED,OAAO,KAAK,CAAC,MAAM,CAAC;IACtB,CAAC,CAAC;AACJ,CAAC;AA0BD,gBAAgB;AAChB,MAAM,OAAO,kCAAkC;IAC7C,YAAY,CAA6B;IACzC,YAAY,WAAuC;QACjD,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;IAClC,CAAC;IACM,6BAA6B,CAA0B,KAI7D;QACC,MAAM,EAAE,mBAAmB,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAG,KAAK,CAAC;QAC/D,OAAO,QAAQ;YACb,CAAC,CAAC,IAAI,CACF,QAAQ,CAAC;gBACP,GAAG,aAAa;gBAChB,sBAAsB,EAAE,KAAK,IAAI,EAAE,CAAC,aAAa,CAAC,mBAAmB,EAAE,EAAE,YAAY,EAAE,SAAoB,EAAE,CAAC;gBAC9G,OAAO,EAAE,IAAI,CAAC,YAAY;aAC3B,CAAC,CACH;YACH,CAAC,CAAC,mBAAmB,CAAC;IAC1B,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useEffect, useRef, useState } from \"react\";\nimport {\n asyncScheduler,\n defer,\n distinct,\n EMPTY,\n from,\n lastValueFrom,\n mergeMap,\n observeOn,\n onErrorResumeNextWith,\n Subject,\n takeUntil,\n tap,\n throttleTime,\n} from \"rxjs\";\nimport { createTooltip } from \"./internal/Tooltip.js\";\nimport { useTelemetryContext } from \"./UseTelemetryContext.js\";\n\nimport type { Observable } from \"rxjs\";\nimport type { MutableRefObject } from \"react\";\nimport type { BeEvent } from \"@itwin/core-bentley\";\nimport type { HierarchyNode, PresentationHierarchyNode } from \"@itwin/presentation-hierarchies-react\";\nimport type { TreeItemVisibilityButtonState, VisibilityContext } from \"./components/TreeNodeVisibilityButton.js\";\n\n/**\n * Data structure that describes instance visibility status.\n * @beta\n */\nexport interface VisibilityStatus {\n /** Instance visibility state. */\n state: \"visible\" | \"partial\" | \"hidden\";\n /** Specifies whether visibility changing is disabled or not. */\n isDisabled?: boolean;\n}\n\n/**\n * Handler that can be used to determine and change visibility of instances represented by tree nodes.\n * @beta\n */\nexport interface HierarchyVisibilityHandler extends Disposable {\n /** Event used to notify tree about visibility changes from outside. */\n readonly onVisibilityChange: BeEvent<() => void>;\n /** Returns current visibility status for tree node. */\n getVisibilityStatus(node: HierarchyNode): Promise<VisibilityStatus> | VisibilityStatus;\n /** Changes visibility of the instance represented by tree node. */\n changeVisibility(node: HierarchyNode, on: boolean): Promise<void>;\n}\n\ninterface UseHierarchyVisibilityProps {\n visibilityHandlerFactory: () => HierarchyVisibilityHandler;\n}\n\n/** @internal */\nexport function useHierarchyVisibility({ visibilityHandlerFactory }: UseHierarchyVisibilityProps): VisibilityContext & { triggerRefresh: () => void } {\n const visibilityStatusMap = useRef(new Map<string, { node: PresentationHierarchyNode; status: TreeItemVisibilityButtonState; needsRefresh: boolean }>());\n const [state, setState] = useState<VisibilityContext & { triggerRefresh: () => void }>({\n getVisibilityButtonState: () => ({ isLoading: true }),\n onVisibilityButtonClick: () => {},\n triggerRefresh: () => {},\n });\n const { onFeatureUsed } = useTelemetryContext();\n\n useEffect(() => {\n visibilityStatusMap.current.clear();\n const handler = visibilityHandlerFactory();\n\n const visibilityChanged = new Subject<void>();\n const calculate = new Subject<PresentationHierarchyNode>();\n const calculateNodeStatus = (node: PresentationHierarchyNode) => {\n calculate.next(node);\n };\n\n const resetCache = () => {\n visibilityStatusMap.current.forEach((value) => {\n value.needsRefresh = true;\n });\n visibilityChanged.next();\n };\n\n const triggerCheckboxUpdate = () => {\n setState((prev) => ({\n ...prev,\n getVisibilityButtonState: createStateGetter(visibilityStatusMap, calculateNodeStatus),\n }));\n };\n\n const subscription = calculate\n .pipe(\n distinct(undefined, visibilityChanged),\n observeOn(asyncScheduler),\n mergeMap((node) =>\n defer(async () => handler.getVisibilityStatus(node.nodeData)).pipe(\n tap({\n next: (status) => {\n visibilityStatusMap.current.set(node.id, {\n node,\n status: {\n ...status,\n tooltip: createTooltip(status.state),\n },\n needsRefresh: false,\n });\n },\n }),\n takeUntil(visibilityChanged),\n onErrorResumeNextWith(EMPTY),\n ),\n ),\n throttleTime(100, undefined, { leading: false, trailing: true }),\n )\n .subscribe({\n next: () => {\n triggerCheckboxUpdate();\n },\n });\n\n const changeVisibility: VisibilityContext[\"onVisibilityButtonClick\"] = (node, visibilityState) => {\n onFeatureUsed({ featureId: \"visibility-change\", reportInteraction: true });\n // visible should become hidden, partial and hidden should become visible TODO: redo for clarity\n const on = visibilityState === \"visible\" ? false : true;\n void handler.changeVisibility(node.nodeData, on);\n const entry = visibilityStatusMap.current.get(node.id);\n if (!entry) {\n return;\n }\n entry.status = {\n ...entry.status,\n state: visibilityState,\n tooltip: createTooltip(\"determining\"),\n };\n triggerCheckboxUpdate();\n };\n\n setState({\n onVisibilityButtonClick: changeVisibility,\n getVisibilityButtonState: createStateGetter(visibilityStatusMap, calculateNodeStatus),\n triggerRefresh: () => {\n resetCache();\n triggerCheckboxUpdate();\n },\n });\n\n const removeListener = handler.onVisibilityChange.addListener(() => {\n resetCache();\n triggerCheckboxUpdate();\n });\n\n return () => {\n subscription.unsubscribe();\n removeListener();\n handler[Symbol.dispose]();\n };\n }, [visibilityHandlerFactory, onFeatureUsed]);\n\n return state;\n}\n\nfunction createStateGetter(\n map: MutableRefObject<Map<string, { node: PresentationHierarchyNode; status: TreeItemVisibilityButtonState; needsRefresh: boolean }>>,\n calculateVisibility: (node: PresentationHierarchyNode) => void,\n): VisibilityContext[\"getVisibilityButtonState\"] {\n return (node) => {\n const entry = map.current.get(node.id);\n if (entry === undefined) {\n calculateVisibility(node);\n return { isLoading: true };\n }\n\n if (entry.needsRefresh) {\n calculateVisibility(node);\n }\n\n return entry.status;\n };\n}\n\n/**\n * Properties for an overridden method of a `HierarchyVisibilityHandler` implementation.\n * @beta\n */\nexport type HierarchyVisibilityHandlerOverridableMethodProps<TFunc> = TFunc extends (props: infer TProps) => infer TResult\n ? TProps & {\n /** A callback that produces the value from the original implementation. */\n readonly originalImplementation: () => TResult;\n /**\n * Reference to the hierarchy based handler.\n * @note Calling `getVisibility` or `changeVisibility` of this object invokes the overridden implementation as well.\n */\n readonly handler: HierarchyVisibilityHandler;\n }\n : never;\n\n/**\n * Function type for an overridden method of `HierarchyVisibilityHandler`.\n * @beta\n */\nexport type HierarchyVisibilityHandlerOverridableMethod<TFunc> = TFunc extends (...args: any[]) => infer TResult\n ? (props: HierarchyVisibilityHandlerOverridableMethodProps<TFunc>) => TResult\n : never;\n\n/** @internal */\nexport class HierarchyVisibilityOverrideHandler {\n #baseHandler: HierarchyVisibilityHandler;\n constructor(baseHandler: HierarchyVisibilityHandler) {\n this.#baseHandler = baseHandler;\n }\n public createVisibilityHandlerResult<TResult, TOverrideProps>(props: {\n nonOverriddenResult: Observable<TResult>;\n override: HierarchyVisibilityHandlerOverridableMethod<(props: TOverrideProps) => Promise<TResult>> | undefined;\n overrideProps: TOverrideProps;\n }): Observable<TResult> {\n const { nonOverriddenResult, override, overrideProps } = props;\n return override\n ? from(\n override({\n ...overrideProps,\n originalImplementation: async () => lastValueFrom(nonOverriddenResult, { defaultValue: undefined as TResult }),\n handler: this.#baseHandler,\n }),\n )\n : nonOverriddenResult;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"UseHierarchyVisibility.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/common/UseHierarchyVisibility.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EACL,cAAc,EACd,KAAK,EACL,QAAQ,EACR,KAAK,EACL,IAAI,EACJ,aAAa,EACb,QAAQ,EACR,SAAS,EACT,qBAAqB,EACrB,OAAO,EACP,SAAS,EACT,GAAG,EACH,YAAY,GACb,MAA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E,CAAC,CAAC;QACvC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,mBAAmB,CAAC,IAAI,CAAC,CAAC;YAC1B,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;QAC7B,CAAC;QAED,IAAI,KAAK,CAAC,YAAY,EAAE,CAAC;YACvB,mBAAmB,CAAC,IAAI,CAAC,CAAC;QAC5B,CAAC;QAED,OAAO,KAAK,CAAC,MAAM,CAAC;IACtB,CAAC,CAAC;AACJ,CAAC;AA0BD,gBAAgB;AAChB,MAAM,OAAO,kCAAkC;IAC7C,YAAY,CAA6B;IACzC,YAAY,WAAuC;QACjD,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;IAClC,CAAC;IACM,6BAA6B,CAA0B,KAI7D;QACC,MAAM,EAAE,mBAAmB,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAG,KAAK,CAAC;QAC/D,OAAO,QAAQ;YACb,CAAC,CAAC,IAAI,CACF,QAAQ,CAAC;gBACP,GAAG,aAAa;gBAChB,sBAAsB,EAAE,KAAK,IAAI,EAAE,CAAC,aAAa,CAAC,mBAAmB,EAAE,EAAE,YAAY,EAAE,SAAoB,EAAE,CAAC;gBAC9G,OAAO,EAAE,IAAI,CAAC,YAAY;aAC3B,CAAC,CACH;YACH,CAAC,CAAC,mBAAmB,CAAC;IAC1B,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useEffect, useRef, useState } from \"react\";\nimport {\n asyncScheduler,\n defer,\n distinct,\n EMPTY,\n from,\n lastValueFrom,\n mergeMap,\n observeOn,\n onErrorResumeNextWith,\n Subject,\n takeUntil,\n tap,\n throttleTime,\n} from \"rxjs\";\nimport { createTooltip } from \"./internal/Tooltip.js\";\nimport { useTelemetryContext } from \"./UseTelemetryContext.js\";\n\nimport type { MutableRefObject } from \"react\";\nimport type { Observable } from \"rxjs\";\nimport type { BeEvent } from \"@itwin/core-bentley\";\nimport type { HierarchyNode, PresentationHierarchyNode } from \"@itwin/presentation-hierarchies-react\";\nimport type { TreeItemVisibilityButtonState, VisibilityContext } from \"./components/TreeNodeVisibilityButton.js\";\n\n/**\n * Data structure that describes instance visibility status.\n * @beta\n */\nexport interface VisibilityStatus {\n /** Instance visibility state. */\n state: \"visible\" | \"partial\" | \"hidden\";\n /** Specifies whether visibility changing is disabled or not. */\n isDisabled?: boolean;\n}\n\n/**\n * Handler that can be used to determine and change visibility of instances represented by tree nodes.\n * @beta\n */\nexport interface HierarchyVisibilityHandler extends Disposable {\n /** Event used to notify tree about visibility changes from outside. */\n readonly onVisibilityChange: BeEvent<() => void>;\n /** Returns current visibility status for tree node. */\n getVisibilityStatus(node: HierarchyNode): Promise<VisibilityStatus> | VisibilityStatus;\n /** Changes visibility of the instance represented by tree node. */\n changeVisibility(node: HierarchyNode, on: boolean): Promise<void>;\n}\n\ninterface UseHierarchyVisibilityProps {\n visibilityHandlerFactory: () => HierarchyVisibilityHandler;\n}\n\n/** @internal */\nexport function useHierarchyVisibility({ visibilityHandlerFactory }: UseHierarchyVisibilityProps): VisibilityContext & { triggerRefresh: () => void } {\n const visibilityStatusMap = useRef(new Map<string, { node: PresentationHierarchyNode; status: TreeItemVisibilityButtonState; needsRefresh: boolean }>());\n const [state, setState] = useState<VisibilityContext & { triggerRefresh: () => void }>({\n getVisibilityButtonState: () => ({ isLoading: true }),\n onVisibilityButtonClick: () => {},\n triggerRefresh: () => {},\n });\n const { onFeatureUsed } = useTelemetryContext();\n\n useEffect(() => {\n visibilityStatusMap.current.clear();\n const handler = visibilityHandlerFactory();\n\n const visibilityChanged = new Subject<void>();\n const calculate = new Subject<PresentationHierarchyNode>();\n const calculateNodeStatus = (node: PresentationHierarchyNode) => {\n calculate.next(node);\n };\n\n const resetCache = () => {\n visibilityStatusMap.current.forEach((value) => {\n value.needsRefresh = true;\n });\n visibilityChanged.next();\n };\n\n const triggerCheckboxUpdate = () => {\n setState((prev) => ({\n ...prev,\n getVisibilityButtonState: createStateGetter(visibilityStatusMap, calculateNodeStatus),\n }));\n };\n\n const subscription = calculate\n .pipe(\n distinct(undefined, visibilityChanged),\n observeOn(asyncScheduler),\n mergeMap((node) =>\n defer(async () => handler.getVisibilityStatus(node.nodeData)).pipe(\n tap({\n next: (status) => {\n visibilityStatusMap.current.set(node.id, {\n node,\n status: {\n ...status,\n tooltip: createTooltip(status.state),\n },\n needsRefresh: false,\n });\n },\n }),\n takeUntil(visibilityChanged),\n onErrorResumeNextWith(EMPTY),\n ),\n ),\n throttleTime(100, undefined, { leading: false, trailing: true }),\n )\n .subscribe({\n next: () => {\n triggerCheckboxUpdate();\n },\n });\n\n const changeVisibility: VisibilityContext[\"onVisibilityButtonClick\"] = (node, visibilityState) => {\n onFeatureUsed({ featureId: \"visibility-change\", reportInteraction: true });\n // visible should become hidden, partial and hidden should become visible TODO: redo for clarity\n const on = visibilityState === \"visible\" ? false : true;\n void handler.changeVisibility(node.nodeData, on);\n const entry = visibilityStatusMap.current.get(node.id);\n if (!entry) {\n return;\n }\n entry.status = {\n ...entry.status,\n state: visibilityState,\n tooltip: createTooltip(\"determining\"),\n };\n triggerCheckboxUpdate();\n };\n\n setState({\n onVisibilityButtonClick: changeVisibility,\n getVisibilityButtonState: createStateGetter(visibilityStatusMap, calculateNodeStatus),\n triggerRefresh: () => {\n resetCache();\n triggerCheckboxUpdate();\n },\n });\n\n const removeListener = handler.onVisibilityChange.addListener(() => {\n resetCache();\n triggerCheckboxUpdate();\n });\n\n return () => {\n subscription.unsubscribe();\n removeListener();\n handler[Symbol.dispose]();\n };\n }, [visibilityHandlerFactory, onFeatureUsed]);\n\n return state;\n}\n\nfunction createStateGetter(\n map: MutableRefObject<Map<string, { node: PresentationHierarchyNode; status: TreeItemVisibilityButtonState; needsRefresh: boolean }>>,\n calculateVisibility: (node: PresentationHierarchyNode) => void,\n): VisibilityContext[\"getVisibilityButtonState\"] {\n return (node) => {\n const entry = map.current.get(node.id);\n if (entry === undefined) {\n calculateVisibility(node);\n return { isLoading: true };\n }\n\n if (entry.needsRefresh) {\n calculateVisibility(node);\n }\n\n return entry.status;\n };\n}\n\n/**\n * Properties for an overridden method of a `HierarchyVisibilityHandler` implementation.\n * @beta\n */\nexport type HierarchyVisibilityHandlerOverridableMethodProps<TFunc> = TFunc extends (props: infer TProps) => infer TResult\n ? TProps & {\n /** A callback that produces the value from the original implementation. */\n readonly originalImplementation: () => TResult;\n /**\n * Reference to the hierarchy based handler.\n * @note Calling `getVisibility` or `changeVisibility` of this object invokes the overridden implementation as well.\n */\n readonly handler: HierarchyVisibilityHandler;\n }\n : never;\n\n/**\n * Function type for an overridden method of `HierarchyVisibilityHandler`.\n * @beta\n */\nexport type HierarchyVisibilityHandlerOverridableMethod<TFunc> = TFunc extends (...args: any[]) => infer TResult\n ? (props: HierarchyVisibilityHandlerOverridableMethodProps<TFunc>) => TResult\n : never;\n\n/** @internal */\nexport class HierarchyVisibilityOverrideHandler {\n #baseHandler: HierarchyVisibilityHandler;\n constructor(baseHandler: HierarchyVisibilityHandler) {\n this.#baseHandler = baseHandler;\n }\n public createVisibilityHandlerResult<TResult, TOverrideProps>(props: {\n nonOverriddenResult: Observable<TResult>;\n override: HierarchyVisibilityHandlerOverridableMethod<(props: TOverrideProps) => Promise<TResult>> | undefined;\n overrideProps: TOverrideProps;\n }): Observable<TResult> {\n const { nonOverriddenResult, override, overrideProps } = props;\n return override\n ? from(\n override({\n ...overrideProps,\n originalImplementation: async () => lastValueFrom(nonOverriddenResult, { defaultValue: undefined as TResult }),\n handler: this.#baseHandler,\n }),\n )\n : nonOverriddenResult;\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HierarchyFilteringPath } from "@itwin/presentation-hierarchies";
|
|
2
|
-
import type { Id64Array } from "@itwin/core-bentley";
|
|
2
|
+
import type { GuidString, Id64Array } from "@itwin/core-bentley";
|
|
3
3
|
import type { HierarchyNodeIdentifiersPath } from "@itwin/presentation-hierarchies";
|
|
4
4
|
import type { TreeWidgetViewport } from "./TreeWidgetViewport.js";
|
|
5
5
|
/**
|
|
@@ -25,6 +25,7 @@ export declare function showAll(props: {
|
|
|
25
25
|
/** ID's of categories to enable, if set to undefined, all categories will be enabled */
|
|
26
26
|
categories?: Id64Array;
|
|
27
27
|
viewport: TreeWidgetViewport;
|
|
28
|
+
componentId?: GuidString;
|
|
28
29
|
}): Promise<void>;
|
|
29
30
|
/**
|
|
30
31
|
* Inverts display of all given models.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import { HierarchyFilteringPath, HierarchyNodeIdentifier } from "@itwin/presentation-hierarchies";
|
|
6
6
|
import { showAllCategories } from "./CategoriesVisibilityUtils.js";
|
|
7
|
-
import {
|
|
7
|
+
import { enableCategoryDisplay, loadCategoriesFromViewport } from "./internal/VisibilityUtils.js";
|
|
8
8
|
/**
|
|
9
9
|
* This is a logging namespace for public log messages that may be interesting to consumers.
|
|
10
10
|
* @internal
|
|
@@ -23,7 +23,7 @@ export function hideAllModels(models, viewport) {
|
|
|
23
23
|
* @public
|
|
24
24
|
*/
|
|
25
25
|
export async function showAll(props) {
|
|
26
|
-
const { models, categories, viewport } = props;
|
|
26
|
+
const { models, categories, viewport, componentId } = props;
|
|
27
27
|
viewport.changeModelDisplay({ modelIds: models, display: true });
|
|
28
28
|
viewport.clearNeverDrawn();
|
|
29
29
|
viewport.clearAlwaysDrawn();
|
|
@@ -31,7 +31,12 @@ export async function showAll(props) {
|
|
|
31
31
|
await showAllCategories(categories, viewport);
|
|
32
32
|
}
|
|
33
33
|
else {
|
|
34
|
-
await
|
|
34
|
+
const categoryInfos = await loadCategoriesFromViewport(viewport, componentId);
|
|
35
|
+
if (categoryInfos.length === 0) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const ids = categoryInfos.map((categoryInfo) => categoryInfo.categoryId);
|
|
39
|
+
await enableCategoryDisplay(viewport, ids, true);
|
|
35
40
|
}
|
|
36
41
|
}
|
|
37
42
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/common/Utils.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAClG,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/common/Utils.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAClG,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAMlG;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,YAAY,CAAC;AAK9C;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,MAAgB,EAAE,QAA4B;IAC1E,QAAQ,CAAC,kBAAkB,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;AACpE,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,KAO7B;IACC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC;IAC5D,QAAQ,CAAC,kBAAkB,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IACjE,QAAQ,CAAC,eAAe,EAAE,CAAC;IAC3B,QAAQ,CAA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C,CAAC,EAAE,UAAU,CAAC,EAAE,CAAC;oBACxG,MAAM;gBACR,CAAC;gBAED,2GAA2G;gBAC3G,IAAI,aAAa,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;oBACxC,sBAAsB,GAAG,IAAI,CAAC;oBAC9B,kHAAkH;oBAClH,sCAAsC;oBACtC,OAAO;wBACL,aAAa,CAAC,OAAO,EAAE,UAAU,KAAK,IAAI;4BACxC,CAAC,CAAC,sBAAsB,CAAC,YAAY,CAAC,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC;4BACrE,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,WAAW,EAAE,aAAa,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;oBACjE,MAAM;gBACR,CAAC;gBAED,oFAAoF;gBACpF,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;oBACjC,sBAAsB,GAAG,IAAI,CAAC;oBAC9B,8BAA8B,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;gBACxC,CAAC;YACH,CAAC;QACH,CAAC;QAED,IAAI,sBAAsB,EAAE,CAAC;YAC3B,MAAM,CAAC,IAAI,CAAC;gBACV,IAAI,EAAE,WAAW;gBACjB,OAAO;aACR,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC,CAAC;IACH,KAAK,MAAM,KAAK,IAAI,8BAA8B,EAAE,CAAC;QACnD,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,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 { HierarchyFilteringPath, HierarchyNodeIdentifier } from \"@itwin/presentation-hierarchies\";\nimport { showAllCategories } from \"./CategoriesVisibilityUtils.js\";\nimport { enableCategoryDisplay, loadCategoriesFromViewport } from \"./internal/VisibilityUtils.js\";\n\nimport type { GuidString, Id64Array, Id64String } from \"@itwin/core-bentley\";\nimport type { HierarchyFilteringPathOptions, HierarchyNodeIdentifiersPath } from \"@itwin/presentation-hierarchies\";\nimport type { TreeWidgetViewport } from \"./TreeWidgetViewport.js\";\n\n/**\n * This is a logging namespace for public log messages that may be interesting to consumers.\n * @internal\n */\nexport const LOGGING_NAMESPACE = \"TreeWidget\";\n\n/** @beta */\nexport type FunctionProps<THook extends (props: any) => any> = Parameters<THook>[0];\n\n/**\n * Disables display of all given models.\n * @public\n */\nexport function hideAllModels(models: string[], viewport: TreeWidgetViewport) {\n viewport.changeModelDisplay({ modelIds: models, display: false });\n}\n\n/**\n * Enables display of all given models. Also enables display of all categories and clears always and\n * never drawn lists in the viewport.\n * @public\n */\nexport async function showAll(props: {\n /** ID's of models to enable */\n models: Id64Array;\n /** ID's of categories to enable, if set to undefined, all categories will be enabled */\n categories?: Id64Array;\n viewport: TreeWidgetViewport;\n componentId?: GuidString;\n}) {\n const { models, categories, viewport, componentId } = props;\n viewport.changeModelDisplay({ modelIds: models, display: true });\n viewport.clearNeverDrawn();\n viewport.clearAlwaysDrawn();\n if (categories) {\n await showAllCategories(categories, viewport);\n } else {\n const categoryInfos = await loadCategoriesFromViewport(viewport, componentId);\n if (categoryInfos.length === 0) {\n return;\n }\n const ids = categoryInfos.map((categoryInfo) => categoryInfo.categoryId);\n await enableCategoryDisplay(viewport, ids, true);\n }\n}\n\n/**\n * Inverts display of all given models.\n * @public\n */\nexport function invertAllModels(models: Id64Array, viewport: TreeWidgetViewport) {\n const notViewedModels = new Array<Id64String>();\n const viewedModels = new Array<Id64String>();\n models.forEach((modelId) => {\n if (viewport.viewsModel(modelId)) {\n viewedModels.push(modelId);\n } else {\n notViewedModels.push(modelId);\n }\n });\n viewport.changeModelDisplay({ modelIds: notViewedModels, display: true });\n viewport.changeModelDisplay({ modelIds: viewedModels, display: false });\n}\n\n/**\n * Based on the value of `enable` argument, either enables or disables display of given models.\n * @public\n */\nexport function toggleModels(models: string[], enable: boolean, viewport: TreeWidgetViewport) {\n if (!models) {\n return;\n }\n viewport.changeModelDisplay({ modelIds: models, display: enable });\n}\n\n/**\n * Checks if all given models are displayed in given viewport.\n * @public\n */\nexport function areAllModelsVisible(models: string[], viewport: TreeWidgetViewport) {\n return models.length !== 0 ? models.every((id) => viewport.viewsModel(id)) : false;\n}\n\n/** @public */\nexport type NormalizedHierarchyFilteringPath = ReturnType<(typeof HierarchyFilteringPath)[\"normalize\"]>;\n\n/** @internal */\nexport function joinHierarchyFilteringPaths(\n subTreePaths: HierarchyNodeIdentifiersPath[],\n filteringPaths: NormalizedHierarchyFilteringPath[],\n): NormalizedHierarchyFilteringPath[] {\n const result = new Array<NormalizedHierarchyFilteringPath>();\n const filteringPathsToIncludeIndexes = new Set<number>();\n\n subTreePaths.forEach((subTreePath) => {\n let options: HierarchyFilteringPathOptions | undefined;\n let addSubTreePathToResult = false;\n\n for (let i = 0; i < filteringPaths.length; ++i) {\n const filteringPath = filteringPaths[i];\n if (filteringPath.path.length === 0) {\n continue;\n }\n\n for (let j = 0; j < subTreePath.length; ++j) {\n const identifier = subTreePath[j];\n if (filteringPath.path.length <= j || !HierarchyNodeIdentifier.equal(filteringPath.path[j], identifier)) {\n break;\n }\n\n // filtering paths that are shorter or equal than subTree paths length don't need to be added to the result\n if (filteringPath.path.length === j + 1) {\n addSubTreePathToResult = true;\n // If filtering path has autoExpand set to true, it means that we should expand only to the targeted filtered node\n // This is done by setting depthInPath\n options =\n filteringPath.options?.autoExpand !== true\n ? HierarchyFilteringPath.mergeOptions(options, filteringPath.options)\n : { autoExpand: { depthInPath: filteringPath.path.length } };\n break;\n }\n\n // filtering paths that are longer than subTree paths need to be added to the result\n if (subTreePath.length === j + 1) {\n addSubTreePathToResult = true;\n filteringPathsToIncludeIndexes.add(i);\n }\n }\n }\n\n if (addSubTreePathToResult) {\n result.push({\n path: subTreePath,\n options,\n });\n }\n });\n for (const index of filteringPathsToIncludeIndexes) {\n result.push(filteringPaths[index]);\n }\n return result;\n}\n"]}
|
|
@@ -23,18 +23,18 @@ export function FilterUnknownError({ base }) {
|
|
|
23
23
|
/** @internal */
|
|
24
24
|
export function TooManyInstancesFocused({ base }) {
|
|
25
25
|
const { toggle } = useFocusedInstancesContext();
|
|
26
|
-
return (_jsxs("
|
|
26
|
+
return (_jsxs(Text, { variant: "body-sm", className: "tw-filter-empty-tree-container", children: [TreeWidget.translate(`${base}.filtering.tooManyInstancesFocused`), _jsx(Anchor, { onClick: (e) => {
|
|
27
27
|
e.stopPropagation();
|
|
28
28
|
toggle();
|
|
29
|
-
}, children: TreeWidget.translate(`${base}.filtering.disableInstanceFocusMode`) })] }));
|
|
29
|
+
}, render: _jsx("button", {}), children: TreeWidget.translate(`${base}.filtering.disableInstanceFocusMode`) })] }));
|
|
30
30
|
}
|
|
31
31
|
/** @internal */
|
|
32
32
|
export function UnknownInstanceFocusError({ base }) {
|
|
33
33
|
const { toggle } = useFocusedInstancesContext();
|
|
34
|
-
return (_jsxs("
|
|
34
|
+
return (_jsxs(Text, { variant: "body-sm", className: "tw-filter-empty-tree-container", children: [TreeWidget.translate(`${base}.filtering.unknownInstanceFocusError`), _jsx(Anchor, { onClick: (e) => {
|
|
35
35
|
e.stopPropagation();
|
|
36
36
|
toggle();
|
|
37
|
-
}, children: TreeWidget.translate(`${base}.filtering.disableInstanceFocusMode`) })] }));
|
|
37
|
+
}, render: _jsx("button", {}), children: TreeWidget.translate(`${base}.filtering.disableInstanceFocusMode`) })] }));
|
|
38
38
|
}
|
|
39
39
|
/** @internal */
|
|
40
40
|
export function SubTreeError({ base, error }) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmptyTree.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/components/EmptyTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"EmptyTree.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/components/EmptyTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,iBAAiB,CAAC;AAEzB,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAM3E,gBAAgB;AAChB,MAAM,UAAU,oBAAoB,CAAC,EAAE,IAAI,EAAwB;IACjE,OAAO,CACL,eAAK,SAAS,EAAE,gCAAgC,aAC9C,KAAC,IAAI,IAAC,OAAO,EAAE,SAAS,YAAG,UAAU,CAAC,SAAS,CAAC,GAAG,IAAI,iCAAiC,CAAC,GAAQ,EACjG,KAAC,IAAI,IAAC,OAAO,EAAE,SAAS,YAAG,UAAU,CAAC,SAAS,CAAC,GAAG,IAAI,sCAAsC,CAAC,GAAQ,IAClG,CACP,CAAC;AACJ,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,eAAe,CAAC,EAAE,IAAI,EAAwB;IAC5D,OAAO,CACL,eAAK,SAAS,EAAE,gCAAgC,aAC9C,KAAC,IAAI,IAAC,OAAO,EAAE,SAAS,YAAG,UAAU,CAAC,SAAS,CAAC,GAAG,IAAI,sBAAsB,CAAC,GAAQ,EACtF,KAAC,IAAI,IAAC,OAAO,EAAE,SAAS,YAAG,UAAU,CAAC,SAAS,CAAC,GAAG,IAAI,2BAA2B,CAAC,GAAQ,IACvF,CACP,CAAC;AACJ,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,kBAAkB,CAAC,EAAE,IAAI,EAAwB;IAC/D,OAAO,CACL,cAAK,SAAS,EAAE,gCAAgC,YAC9C,KAAC,IAAI,IAAC,OAAO,EAA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AAgC,YAC9C,KAAC,IAAI,IAAC,OAAO,EAAE,SAAS,YAAG,UAAU,CAAC,SAAS,CAAC,GAAG,IAAI,YAAY,KAAK,EAAE,CAAC,GAAQ,GAC/E,CACP,CAAC;AACJ,CAAC;AAMD,gBAAgB;AAChB,MAAM,UAAU,gBAAgB,CAAC,EAAE,IAAI,EAAyB;IAC9D,OAAO,CACL,eAAK,SAAS,EAAE,yBAAyB,aACtC,IAAI,CAAC,CAAC,CAAC,KAAC,IAAI,IAAC,IAAI,EAAC,OAAO,EAAC,IAAI,EAAE,IAAI,GAAI,CAAC,CAAC,CAAC,IAAI,EAChD,KAAC,IAAI,IAAC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,YACrD,UAAU,CAAC,SAAS,CAAC,6BAA6B,CAAC,GAC/C,IACH,CACP,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport \"./EmptyTree.css\";\n\nimport { Anchor, Text } from \"@stratakit/bricks\";\nimport { Icon } from \"@stratakit/foundations\";\nimport { TreeWidget } from \"../../../../TreeWidget.js\";\nimport { useFocusedInstancesContext } from \"../FocusedInstancesContext.js\";\n\ninterface FilterEmptyTreeProps {\n base: string;\n}\n\n/** @internal */\nexport function TooManyFilterMatches({ base }: FilterEmptyTreeProps) {\n return (\n <div className={\"tw-filter-empty-tree-container\"}>\n <Text variant={\"body-sm\"}>{TreeWidget.translate(`${base}.filtering.tooManyFilterMatches`)}</Text>\n <Text variant={\"body-sm\"}>{TreeWidget.translate(`${base}.filtering.tooManyFilterMatchesRetry`)}</Text>\n </div>\n );\n}\n\n/** @internal */\nexport function NoFilterMatches({ base }: FilterEmptyTreeProps) {\n return (\n <div className={\"tw-filter-empty-tree-container\"}>\n <Text variant={\"body-sm\"}>{TreeWidget.translate(`${base}.filtering.noMatches`)}</Text>\n <Text variant={\"body-sm\"}>{TreeWidget.translate(`${base}.filtering.noMatchesRetry`)}</Text>\n </div>\n );\n}\n\n/** @internal */\nexport function FilterUnknownError({ base }: FilterEmptyTreeProps) {\n return (\n <div className={\"tw-filter-empty-tree-container\"}>\n <Text variant={\"body-sm\"}>{TreeWidget.translate(`${base}.filtering.unknownFilterError`)}</Text>\n </div>\n );\n}\n\n/** @internal */\nexport function TooManyInstancesFocused({ base }: FilterEmptyTreeProps) {\n const { toggle } = useFocusedInstancesContext();\n return (\n <Text variant=\"body-sm\" className={\"tw-filter-empty-tree-container\"}>\n {TreeWidget.translate(`${base}.filtering.tooManyInstancesFocused`)}\n <Anchor\n onClick={(e) => {\n e.stopPropagation();\n toggle();\n }}\n render={<button />}\n >\n {TreeWidget.translate(`${base}.filtering.disableInstanceFocusMode`)}\n </Anchor>\n </Text>\n );\n}\n\n/** @internal */\nexport function UnknownInstanceFocusError({ base }: FilterEmptyTreeProps) {\n const { toggle } = useFocusedInstancesContext();\n return (\n <Text variant=\"body-sm\" className={\"tw-filter-empty-tree-container\"}>\n {TreeWidget.translate(`${base}.filtering.unknownInstanceFocusError`)}\n <Anchor\n onClick={(e) => {\n e.stopPropagation();\n toggle();\n }}\n render={<button />}\n >\n {TreeWidget.translate(`${base}.filtering.disableInstanceFocusMode`)}\n </Anchor>\n </Text>\n );\n}\n\ninterface SubTreeErrorProps {\n base: string;\n error: string;\n}\n\n/** @internal */\nexport function SubTreeError({ base, error }: SubTreeErrorProps) {\n return (\n <div className={\"tw-filter-empty-tree-container\"}>\n <Text variant={\"body-sm\"}>{TreeWidget.translate(`${base}.subTree.${error}`)}</Text>\n </div>\n );\n}\n\ninterface EmptyTreeContentProps {\n icon?: string;\n}\n\n/** @internal */\nexport function EmptyTreeContent({ icon }: EmptyTreeContentProps) {\n return (\n <div className={\"tw-empty-tree-container\"}>\n {icon ? <Icon size=\"large\" href={icon} /> : null}\n <Text variant={\"body-sm\"} style={{ textAlign: \"center\" }}>\n {TreeWidget.translate(\"baseTree.dataIsNotAvailable\")}\n </Text>\n </div>\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProgressOverlay.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/components/ProgressOverlay.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"ProgressOverlay.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/components/ProgressOverlay.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,uBAAuB,CAAC;AAE/B,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAEvD,gBAAgB;AAChB,MAAM,UAAU,eAAe;IAC7B,OAAO,CACL,eAAK,SAAS,EAAC,+BAA+B,aAC5C,KAAC,WAAW,uBAAkB,iBAAiB,EAAE,IAAI,EAAE,QAAQ,GAAI,EACnE,KAAC,cAAc,IAAC,EAAE,EAAE,iBAAiB,YAAG,UAAU,CAAC,SAAS,CAAC,gBAAgB,CAAC,GAAkB,EAChG,cAAK,SAAS,EAAC,8BAA8B,GAAG,IAC5C,CACP,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport \"./ProgressOverlay.css\";\n\nimport { ProgressBar, VisuallyHidden } from \"@stratakit/bricks\";\nimport { TreeWidget } from \"../../../../TreeWidget.js\";\n\n/** @internal */\nexport function ProgressOverlay() {\n return (\n <div className=\"tw-progress-overlay-container\">\n <ProgressBar aria-labelledby={\"tw-progress-bar\"} tone={\"accent\"} />\n <VisuallyHidden id={\"tw-progress-bar\"}>{TreeWidget.translate(\"loading.filter\")}</VisuallyHidden>\n <div className=\"tw-progress-overlay-backdrop\" />\n </div>\n );\n}\n"]}
|
|
@@ -6,7 +6,10 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
6
6
|
import "./SkeletonTree.css";
|
|
7
7
|
import { Skeleton, VisuallyHidden } from "@stratakit/bricks";
|
|
8
8
|
import { TreeWidget } from "../../../../TreeWidget.js";
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* Represents the loaded tree content before it finishes loading.
|
|
11
|
+
* @beta
|
|
12
|
+
*/
|
|
10
13
|
export function SkeletonTree() {
|
|
11
14
|
return (_jsxs("div", { className: "tw-skeleton-container", children: [Array.from({ length: 20 }, (_, index) => (_jsx(SkeletonRow, {}, index))), _jsx(VisuallyHidden, { id: "tw-progress-bar", children: TreeWidget.translate("loading.skeleton") })] }));
|
|
12
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SkeletonTree.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/components/SkeletonTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"SkeletonTree.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/components/SkeletonTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,oBAAoB,CAAC;AAE5B,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAEvD;;;GAGG;AACH,MAAM,UAAU,YAAY;IAC1B,OAAO,CACL,eAAK,SAAS,EAAC,uBAAuB,aACnC,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,CACxC,KAAC,WAAW,MAAM,KAAK,CAAI,CAC5B,CAAC,EACF,KAAC,cAAc,IAAC,EAAE,EAAE,iBAAiB,YAAG,UAAU,CAAC,SAAS,CAAC,kBAAkB,CAAC,GAAkB,IAC9F,CACP,CAAC;AACJ,CAAC;AAED,SAAS,WAAW;IAClB,OAAO,CACL,eAAK,SAAS,EAAC,iBAAiB,aAC9B,KAAC,QAAQ,IAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,GAAI,EAC9C,KAAC,QAAQ,IAAC,OAAO,EAAE,MAAM,GAAI,IACzB,CACP,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport \"./SkeletonTree.css\";\n\nimport { Skeleton, VisuallyHidden } from \"@stratakit/bricks\";\nimport { TreeWidget } from \"../../../../TreeWidget.js\";\n\n/**\n * Represents the loaded tree content before it finishes loading.\n * @beta\n */\nexport function SkeletonTree() {\n return (\n <div className=\"tw-skeleton-container\">\n {Array.from({ length: 20 }, (_, index) => (\n <SkeletonRow key={index} />\n ))}\n <VisuallyHidden id={\"tw-progress-bar\"}>{TreeWidget.translate(\"loading.skeleton\")}</VisuallyHidden>\n </div>\n );\n}\n\nfunction SkeletonRow() {\n return (\n <div className=\"tw-skeleton-row\">\n <Skeleton variant={\"object\"} size={\"small\"} />\n <Skeleton variant={\"text\"} />\n </div>\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tree.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/components/Tree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,YAAY,CAAC;AACpB,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC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7B,OAAO,IAAI,IAAI,CAAC,CAAC,SAAS,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;IACjD,CAAC,CAAC,EACF,UAAU,CACX,EACH,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,CAAC,CAC7B,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport \"./Tree.css\";\nimport { useCallback, useState } from \"react\";\nimport { BeEvent } from \"@itwin/core-bentley\";\nimport { SchemaMetadataContextProvider } from \"@itwin/presentation-components\";\nimport { StrataKitRootErrorRenderer, useIModelUnifiedSelectionTree, useNodeHighlighting } from \"@itwin/presentation-hierarchies-react\";\nimport { TreeWidget } from \"../../../../TreeWidget.js\";\nimport { useHierarchiesLocalization } from \"../internal/UseHierarchiesLocalization.js\";\nimport { useHierarchyLevelFiltering } from \"../internal/UseHierarchyFiltering.js\";\nimport { useIModelAccess } from \"../internal/UseIModelAccess.js\";\nimport { useIModelChangeListener } from \"../internal/UseIModelChangeListener.js\";\nimport { useReportingAction, useTelemetryContext } from \"../UseTelemetryContext.js\";\nimport { LOGGING_NAMESPACE } from \"../Utils.js\";\nimport { Delayed } from \"./Delayed.js\";\nimport { EmptyTreeContent } from \"./EmptyTree.js\";\nimport { ProgressOverlay } from \"./ProgressOverlay.js\";\nimport { SkeletonTree } from \"./SkeletonTree.js\";\n\nimport type { ReactNode } from \"react\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport type {\n PresentationHierarchyNode,\n SelectionStorage,\n TreeRendererProps,\n useIModelTree,\n useSelectionHandler,\n useTree,\n} from \"@itwin/presentation-hierarchies-react\";\nimport type { FunctionProps } from \"../Utils.js\";\nimport type { BaseTreeRendererProps } from \"./BaseTreeRenderer.js\";\n\n/** @beta */\nexport type TreeProps = Pick<FunctionProps<typeof useIModelTree>, \"getFilteredPaths\" | \"getHierarchyDefinition\"> &\n Partial<Pick<FunctionProps<typeof useSelectionHandler>, \"selectionMode\">> & {\n /** iModel connection that should be used to pull data from. */\n imodel: IModelConnection;\n /** Unique tree component name that will be used as unified selection change event source when selecting node. */\n treeName: string;\n /** Unified selection storage that should be used by tree to handle tree selection changes. */\n selectionStorage: SelectionStorage;\n /**\n * An optional predicate to allow or prohibit selection of a node.\n * When not supplied, all nodes are selectable.\n */\n selectionPredicate?: (node: PresentationHierarchyNode) => boolean;\n /** Tree renderer that should be used to render tree data. */\n treeRenderer: (\n treeProps: Required<Pick<BaseTreeRendererProps, \"getLabel\" | \"onFilterClick\" | \"selectionMode\" | \"getLabel\"> & TreeRendererProps>,\n ) => ReactNode;\n /** Custom iModel access that is stored outside tree component. If not provided it new iModel access will be created using `imodel` prop. */\n imodelAccess?: FunctionProps<typeof useIModelTree>[\"imodelAccess\"];\n /** Size limit that should be applied on each hierarchy level. Default to `1000`. */\n hierarchyLevelSizeLimit?: number;\n /** Component that should be renderer if there are no tree nodes. */\n emptyTreeContent?: ReactNode;\n /** Callback that this invoked when tree reloads. */\n onReload?: () => void;\n /** Text that should be highlighted in node labels. */\n highlightText?: string;\n };\n\n/**\n * Default tree component that manages tree state and renders using supplied `treeRenderer`.\n * @beta\n */\nexport function Tree({\n hierarchyLevelSizeLimit,\n getHierarchyDefinition,\n getFilteredPaths,\n selectionStorage,\n imodelAccess: providedIModelAccess,\n treeName,\n onReload,\n ...props\n}: TreeProps) {\n const { onFeatureUsed, onPerformanceMeasured } = useTelemetryContext();\n const [imodelChanged] = useState(new BeEvent<() => void>());\n const localizedStrings = useHierarchiesLocalization();\n\n const { imodelAccess, currentHierarchyLevelSizeLimit } = useIModelAccess({\n imodel: props.imodel,\n imodelAccess: providedIModelAccess,\n treeName,\n hierarchyLevelSizeLimit,\n });\n\n const {\n getNode,\n setFormatter: _setFormatter,\n isReloading,\n ...treeProps\n } = useIModelUnifiedSelectionTree({\n imodelAccess,\n imodelChanged,\n getHierarchyDefinition,\n getFilteredPaths,\n sourceName: treeName,\n localizedStrings,\n selectionStorage,\n onPerformanceMeasured: (action, duration) => {\n if (action === \"reload\") {\n onReload?.();\n }\n onPerformanceMeasured(action, duration);\n },\n onHierarchyLimitExceeded: () => onFeatureUsed({ featureId: \"hierarchy-level-size-limit-hit\", reportInteraction: false }),\n onHierarchyLoadError: ({ type, error }) => {\n // eslint-disable-next-line no-console\n console.error(error);\n onFeatureUsed({ featureId: `error-${type}`, reportInteraction: false });\n },\n });\n useIModelChangeListener({\n imodel: props.imodel,\n action: useCallback(() => {\n TreeWidget.logger.logTrace(`${LOGGING_NAMESPACE}.${treeName}`, `iModel data changed`);\n imodelChanged.raiseEvent();\n }, [imodelChanged, treeName]),\n });\n\n if (treeProps.rootErrorRendererProps !== undefined) {\n return <StrataKitRootErrorRenderer {...treeProps.rootErrorRendererProps} />;\n }\n\n return (\n <TreeBase\n {...props}\n isReloading={isReloading}\n treeRendererProps={treeProps.treeRendererProps}\n getNode={getNode}\n currentHierarchyLevelSizeLimit={currentHierarchyLevelSizeLimit}\n />\n );\n}\n\ntype TreeBaseProps = {\n currentHierarchyLevelSizeLimit: number;\n getNode: (nodeId: string) => PresentationHierarchyNode | undefined;\n treeRendererProps?: TreeRendererProps;\n} & Omit<TreeProps, \"selectionStorage\" | \"treeName\" | \"getHierarchyDefinition\"> &\n Pick<ReturnType<typeof useTree>, \"getNode\" | \"isReloading\">;\n\n/** @internal */\nfunction TreeBase({ treeRendererProps, ...props }: TreeBaseProps) {\n const getSchemaContext = useCallback(() => props.imodel.schemaContext, [props.imodel]);\n\n if (treeRendererProps === undefined) {\n return <SkeletonTree />;\n }\n\n return (\n <SchemaMetadataContextProvider imodel={props.imodel} schemaContextProvider={getSchemaContext}>\n <TreeBaseImpl {...props} treeRendererProps={treeRendererProps} />\n </SchemaMetadataContextProvider>\n );\n}\n\nfunction TreeBaseImpl({\n imodel,\n emptyTreeContent,\n currentHierarchyLevelSizeLimit,\n selectionPredicate,\n selectionMode,\n treeRenderer,\n highlightText,\n treeRendererProps,\n isReloading,\n getNode,\n}: Omit<TreeBaseProps, \"getSchemaContext\" | \"treeRendererProps\"> & Required<Pick<TreeBaseProps, \"treeRendererProps\">>) {\n const selectNodes = useSelectionPredicate({\n action: useReportingAction({ action: treeRendererProps.selectNodes }),\n predicate: selectionPredicate,\n getNode,\n });\n const { filteringDialog, onFilterClick } = useHierarchyLevelFiltering({\n imodel,\n defaultHierarchyLevelSizeLimit: currentHierarchyLevelSizeLimit,\n });\n const reportingExpandNode = useReportingAction({ action: treeRendererProps.expandNode });\n const reportingOnFilterClicked = useReportingAction({ action: onFilterClick });\n // Don't highlight nodes if tree is reloading\n const { getLabel } = useNodeHighlighting({ highlightText: isReloading ? undefined : highlightText });\n\n if (treeRendererProps.rootNodes.length === 0 && !isReloading) {\n return <>{emptyTreeContent ? emptyTreeContent : <EmptyTreeContent />}</>;\n }\n\n const treeRenderProps: FunctionProps<TreeProps[\"treeRenderer\"]> = {\n ...treeRendererProps,\n selectNodes,\n selectionMode: selectionMode ?? \"single\",\n expandNode: reportingExpandNode,\n onFilterClick: reportingOnFilterClicked,\n getLabel,\n };\n\n return (\n <div style={{ position: \"relative\", height: \"100%\", overflow: \"hidden\" }}>\n <div className={\"tw-tree-renderer-container\"} id=\"tw-tree-renderer-container\">\n {treeRenderer(treeRenderProps)}\n {filteringDialog}\n </div>\n <Delayed show={isReloading}>\n <ProgressOverlay />\n </Delayed>\n </div>\n );\n}\n\nfunction useSelectionPredicate({\n action,\n predicate,\n getNode,\n}: {\n action: (...args: any[]) => void;\n predicate?: (node: PresentationHierarchyNode) => boolean;\n getNode: (nodeId: string) => PresentationHierarchyNode | undefined;\n}): TreeRendererProps[\"selectNodes\"] {\n return useCallback(\n (nodeIds, changeType) =>\n action(\n nodeIds.filter((nodeId) => {\n const node = getNode(nodeId);\n return node && (!predicate || predicate(node));\n }),\n changeType,\n ),\n [action, getNode, predicate],\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Tree.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/components/Tree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,YAAY,CAAC;AAEpB,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAC;AAC/E,OAAO,EAAE,0BAA0B,EAAE,6BAA6B,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AACvI,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,0BAA0B,EAAE,MAAM,2CAA2C,CAAC;AACvF,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAClF,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AACjF,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACpF,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AA6CjD;;;GAGG;AACH,MAAM,UAAU,IAAI,CAAC,EACnB,uBAAuB,EACvB,sBAAsB,EACtB,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EAAE,oBAAoB,EAClC,QAAQ,EACR,QAAQ,EACR,GAAG,KAAK,EACE;IACV,MAAM,EAAE,aAAa,EAAE,qBAAqB,EAAE,GAAG,mBAAmB,EAAE,CAAC;IACvE,MAAM,CA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,CAAC;AAED,SAAS,qBAAqB,CAAC,EAC7B,MAAM,EACN,SAAS,EACT,OAAO,GAKR;IACC,OAAO,WAAW,CAChB,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,CACtB,MAAM,CACJ,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE;QACxB,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;QAC7B,OAAO,IAAI,IAAI,CAAC,CAAC,SAAS,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;IACjD,CAAC,CAAC,EACF,UAAU,CACX,EACH,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,CAAC,CAC7B,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport \"./Tree.css\";\n\nimport { useCallback, useState } from \"react\";\nimport { BeEvent } from \"@itwin/core-bentley\";\nimport { SchemaMetadataContextProvider } from \"@itwin/presentation-components\";\nimport { StrataKitRootErrorRenderer, useIModelUnifiedSelectionTree, useNodeHighlighting } from \"@itwin/presentation-hierarchies-react\";\nimport { TreeWidget } from \"../../../../TreeWidget.js\";\nimport { useHierarchiesLocalization } from \"../internal/UseHierarchiesLocalization.js\";\nimport { useHierarchyLevelFiltering } from \"../internal/UseHierarchyFiltering.js\";\nimport { useIModelAccess } from \"../internal/UseIModelAccess.js\";\nimport { useIModelChangeListener } from \"../internal/UseIModelChangeListener.js\";\nimport { useReportingAction, useTelemetryContext } from \"../UseTelemetryContext.js\";\nimport { LOGGING_NAMESPACE } from \"../Utils.js\";\nimport { Delayed } from \"./Delayed.js\";\nimport { EmptyTreeContent } from \"./EmptyTree.js\";\nimport { ProgressOverlay } from \"./ProgressOverlay.js\";\nimport { SkeletonTree } from \"./SkeletonTree.js\";\n\nimport type { ReactNode } from \"react\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport type {\n PresentationHierarchyNode,\n SelectionStorage,\n TreeRendererProps,\n useIModelTree,\n useSelectionHandler,\n useTree,\n} from \"@itwin/presentation-hierarchies-react\";\nimport type { FunctionProps } from \"../Utils.js\";\nimport type { BaseTreeRendererProps } from \"./BaseTreeRenderer.js\";\n\n/** @beta */\nexport type TreeProps = Pick<FunctionProps<typeof useIModelTree>, \"getFilteredPaths\" | \"getHierarchyDefinition\"> &\n Partial<Pick<FunctionProps<typeof useSelectionHandler>, \"selectionMode\">> & {\n /** iModel connection that should be used to pull data from. */\n imodel: IModelConnection;\n /** Unique tree component name that will be used as unified selection change event source when selecting node. */\n treeName: string;\n /** Unified selection storage that should be used by tree to handle tree selection changes. */\n selectionStorage: SelectionStorage;\n /**\n * An optional predicate to allow or prohibit selection of a node.\n * When not supplied, all nodes are selectable.\n */\n selectionPredicate?: (node: PresentationHierarchyNode) => boolean;\n /** Tree renderer that should be used to render tree data. */\n treeRenderer: (\n treeProps: Required<Pick<BaseTreeRendererProps, \"getLabel\" | \"onFilterClick\" | \"selectionMode\" | \"getLabel\"> & TreeRendererProps>,\n ) => ReactNode;\n /** Custom iModel access that is stored outside tree component. If not provided it new iModel access will be created using `imodel` prop. */\n imodelAccess?: FunctionProps<typeof useIModelTree>[\"imodelAccess\"];\n /** Size limit that should be applied on each hierarchy level. Default to `1000`. */\n hierarchyLevelSizeLimit?: number;\n /** Component that should be renderer if there are no tree nodes. */\n emptyTreeContent?: ReactNode;\n /** Callback that this invoked when tree reloads. */\n onReload?: () => void;\n /** Text that should be highlighted in node labels. */\n highlightText?: string;\n };\n\n/**\n * Default tree component that manages tree state and renders using supplied `treeRenderer`.\n * @beta\n */\nexport function Tree({\n hierarchyLevelSizeLimit,\n getHierarchyDefinition,\n getFilteredPaths,\n selectionStorage,\n imodelAccess: providedIModelAccess,\n treeName,\n onReload,\n ...props\n}: TreeProps) {\n const { onFeatureUsed, onPerformanceMeasured } = useTelemetryContext();\n const [imodelChanged] = useState(new BeEvent<() => void>());\n const localizedStrings = useHierarchiesLocalization();\n\n const { imodelAccess, currentHierarchyLevelSizeLimit } = useIModelAccess({\n imodel: props.imodel,\n imodelAccess: providedIModelAccess,\n treeName,\n hierarchyLevelSizeLimit,\n });\n\n const {\n getNode,\n setFormatter: _setFormatter,\n isReloading,\n ...treeProps\n } = useIModelUnifiedSelectionTree({\n imodelAccess,\n imodelChanged,\n getHierarchyDefinition,\n getFilteredPaths,\n sourceName: treeName,\n localizedStrings,\n selectionStorage,\n onPerformanceMeasured: (action, duration) => {\n if (action === \"reload\") {\n onReload?.();\n }\n onPerformanceMeasured(action, duration);\n },\n onHierarchyLimitExceeded: () => onFeatureUsed({ featureId: \"hierarchy-level-size-limit-hit\", reportInteraction: false }),\n onHierarchyLoadError: ({ type, error }) => {\n // eslint-disable-next-line no-console\n console.error(error);\n onFeatureUsed({ featureId: `error-${type}`, reportInteraction: false });\n },\n });\n useIModelChangeListener({\n imodel: props.imodel,\n action: useCallback(() => {\n TreeWidget.logger.logTrace(`${LOGGING_NAMESPACE}.${treeName}`, `iModel data changed`);\n imodelChanged.raiseEvent();\n }, [imodelChanged, treeName]),\n });\n\n if (treeProps.rootErrorRendererProps !== undefined) {\n return <StrataKitRootErrorRenderer {...treeProps.rootErrorRendererProps} />;\n }\n\n return (\n <TreeBase\n {...props}\n isReloading={isReloading}\n treeRendererProps={treeProps.treeRendererProps}\n getNode={getNode}\n currentHierarchyLevelSizeLimit={currentHierarchyLevelSizeLimit}\n />\n );\n}\n\ntype TreeBaseProps = {\n currentHierarchyLevelSizeLimit: number;\n getNode: (nodeId: string) => PresentationHierarchyNode | undefined;\n treeRendererProps?: TreeRendererProps;\n} & Omit<TreeProps, \"selectionStorage\" | \"treeName\" | \"getHierarchyDefinition\"> &\n Pick<ReturnType<typeof useTree>, \"getNode\" | \"isReloading\">;\n\n/** @internal */\nfunction TreeBase({ treeRendererProps, ...props }: TreeBaseProps) {\n const getSchemaContext = useCallback(() => props.imodel.schemaContext, [props.imodel]);\n\n if (treeRendererProps === undefined) {\n return <SkeletonTree />;\n }\n\n return (\n <SchemaMetadataContextProvider imodel={props.imodel} schemaContextProvider={getSchemaContext}>\n <TreeBaseImpl {...props} treeRendererProps={treeRendererProps} />\n </SchemaMetadataContextProvider>\n );\n}\n\nfunction TreeBaseImpl({\n imodel,\n emptyTreeContent,\n currentHierarchyLevelSizeLimit,\n selectionPredicate,\n selectionMode,\n treeRenderer,\n highlightText,\n treeRendererProps,\n isReloading,\n getNode,\n}: Omit<TreeBaseProps, \"getSchemaContext\" | \"treeRendererProps\"> & Required<Pick<TreeBaseProps, \"treeRendererProps\">>) {\n const selectNodes = useSelectionPredicate({\n action: useReportingAction({ action: treeRendererProps.selectNodes }),\n predicate: selectionPredicate,\n getNode,\n });\n const { filteringDialog, onFilterClick } = useHierarchyLevelFiltering({\n imodel,\n defaultHierarchyLevelSizeLimit: currentHierarchyLevelSizeLimit,\n });\n const reportingExpandNode = useReportingAction({ action: treeRendererProps.expandNode });\n const reportingOnFilterClicked = useReportingAction({ action: onFilterClick });\n // Don't highlight nodes if tree is reloading\n const { getLabel } = useNodeHighlighting({ highlightText: isReloading ? undefined : highlightText });\n\n if (treeRendererProps.rootNodes.length === 0 && !isReloading) {\n return <>{emptyTreeContent ? emptyTreeContent : <EmptyTreeContent />}</>;\n }\n\n const treeRenderProps: FunctionProps<TreeProps[\"treeRenderer\"]> = {\n ...treeRendererProps,\n selectNodes,\n selectionMode: selectionMode ?? \"single\",\n expandNode: reportingExpandNode,\n onFilterClick: reportingOnFilterClicked,\n getLabel,\n };\n\n return (\n <div style={{ position: \"relative\", height: \"100%\", overflow: \"hidden\" }}>\n <div className={\"tw-tree-renderer-container\"} id=\"tw-tree-renderer-container\">\n {treeRenderer(treeRenderProps)}\n {filteringDialog}\n </div>\n <Delayed show={isReloading}>\n <ProgressOverlay />\n </Delayed>\n </div>\n );\n}\n\nfunction useSelectionPredicate({\n action,\n predicate,\n getNode,\n}: {\n action: (...args: any[]) => void;\n predicate?: (node: PresentationHierarchyNode) => boolean;\n getNode: (nodeId: string) => PresentationHierarchyNode | undefined;\n}): TreeRendererProps[\"selectNodes\"] {\n return useCallback(\n (nodeIds, changeType) =>\n action(\n nodeIds.filter((nodeId) => {\n const node = getNode(nodeId);\n return node && (!predicate || predicate(node));\n }),\n changeType,\n ),\n [action, getNode, predicate],\n );\n}\n"]}
|
package/lib/esm/tree-widget-react/components/trees/common/components/TreeNodeVisibilityButton.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeNodeVisibilityButton.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/components/TreeNodeVisibilityButton.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"TreeNodeVisibilityButton.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/components/TreeNodeVisibilityButton.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,gCAAgC,CAAC;AAExC,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,iBAAiB,MAAM,sCAAsC,CAAC;AACrE,OAAO,oBAAoB,MAAM,yCAAyC,CAAC;AAC3E,OAAO,iBAAiB,MAAM,sCAAsC,CAAC;AACrE,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAmCvD;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC,SAAS,gBAAgB,CAAC,EAAE,IAAI,EAAE,YAAY,EAAuE;IACxJ,MAAM,OAAO,GAAG,oBAAoB,EAAE,CAAC;IACvC,MAAM,KAAK,GAAG,OAA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AAgB;AAChB,MAAM,UAAU,yBAAyB,CAAC,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,QAAQ,EAAwC;IAC7I,OAAO,CACL,KAAC,iBAAiB,CAAC,QAAQ,IACzB,KAAK,EAAE,OAAO,CACZ,GAAG,EAAE,CAAC,CAAC;YACL,uBAAuB;YACvB,wBAAwB;SACzB,CAAC,EACF,CAAC,wBAAwB,EAAE,uBAAuB,CAAC,CACpD,YAEA,QAAQ,GACkB,CAC9B,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport \"./TreeNodeVisibilityButton.css\";\n\nimport { createContext, memo, useContext, useMemo } from \"react\";\nimport visibilityHideSvg from \"@stratakit/icons/visibility-hide.svg\";\nimport visibilityPartialSvg from \"@stratakit/icons/visibility-partial.svg\";\nimport visibilityShowSvg from \"@stratakit/icons/visibility-show.svg\";\nimport { Tree } from \"@stratakit/structures\";\nimport { TreeWidget } from \"../../../../TreeWidget.js\";\nimport { createTooltip } from \"../internal/Tooltip.js\";\n\nimport type { PropsWithChildren } from \"react\";\nimport type { PresentationHierarchyNode } from \"@itwin/presentation-hierarchies-react\";\n\n/** @beta */\ninterface LoadedTreeItemVisibilityButtonState {\n state: \"visible\" | \"hidden\" | \"partial\";\n isDisabled?: boolean;\n}\n/**\n * Data structure that describes tree node checkbox state.\n * @beta\n */\nexport type TreeItemVisibilityButtonState = (\n | LoadedTreeItemVisibilityButtonState\n | {\n isLoading: true;\n }\n) & {\n tooltip?: string;\n};\n\n/** @beta */\nexport interface TreeItemVisibilityButtonProps {\n /**\n * Indicates that space for this action button should be reserved, even when the action is not available.\n * For nodes that don't support visibility, `<VisibilityAction reserveSpace />` renders:\n *\n * - Blank space when the action is used as an inline action. It's recommended to set this prop to keep all action buttons of the same kind vertically aligned.\n * - Disabled menu item when the action is used as a menu action.\n */\n reserveSpace?: true;\n}\n\n/**\n * React component that renders a visibility action for a tree item.\n * Should be used with `VisibilityTreeRenderer`.\n * @beta\n */\nexport const VisibilityAction = memo(function VisibilityAction({ node, reserveSpace }: TreeItemVisibilityButtonProps & { node: PresentationHierarchyNode }) {\n const context = useVisibilityContext();\n const state = context?.getVisibilityButtonState(node);\n\n if (!context || !state || (\"isDisabled\" in state && state.isDisabled) || \"isLoading\" in state) {\n return reserveSpace ? (\n <Tree.ItemAction label={TreeWidget.translate(`visibilityTooltips.status.disabled`)} visible={false} icon={visibilityShowSvg} />\n ) : undefined;\n }\n\n const getIcon = () => {\n switch (state.state) {\n case \"visible\":\n return visibilityShowSvg;\n case \"hidden\":\n return visibilityHideSvg;\n case \"partial\":\n return visibilityPartialSvg;\n }\n };\n\n return (\n <Tree.ItemAction\n label={state.tooltip ?? createTooltip(state.state)}\n onClick={() => context.onVisibilityButtonClick(node, state.state)}\n visible={state.state !== \"visible\" ? true : undefined}\n icon={getIcon()}\n />\n );\n});\n\n/** @beta */\nexport interface VisibilityContext {\n /** Callback that should be invoked when checkbox is clicked. */\n onVisibilityButtonClick: (node: PresentationHierarchyNode, state: LoadedTreeItemVisibilityButtonState[\"state\"]) => void;\n /** Callback that should be used to determine current checkbox state. */\n getVisibilityButtonState: (node: PresentationHierarchyNode) => TreeItemVisibilityButtonState;\n}\n\nconst visibilityContext = createContext<VisibilityContext | undefined>(undefined);\n\n/** @internal */\nexport const useVisibilityContext = () => {\n return useContext(visibilityContext);\n};\n\n/** @internal */\nexport function VisibilityContextProvider({ onVisibilityButtonClick, getVisibilityButtonState, children }: PropsWithChildren<VisibilityContext>) {\n return (\n <visibilityContext.Provider\n value={useMemo(\n () => ({\n onVisibilityButtonClick,\n getVisibilityButtonState,\n }),\n [getVisibilityButtonState, onVisibilityButtonClick],\n )}\n >\n {children}\n </visibilityContext.Provider>\n );\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { TreeProps } from "./Tree.js";
|
|
2
|
-
import type { FunctionProps } from "../Utils.js";
|
|
3
1
|
import type { ReactNode } from "react";
|
|
4
2
|
import type { ECClassHierarchyInspector } from "@itwin/presentation-shared";
|
|
5
3
|
import type { HierarchyVisibilityHandler } from "../UseHierarchyVisibility.js";
|
|
4
|
+
import type { FunctionProps } from "../Utils.js";
|
|
5
|
+
import type { TreeProps } from "./Tree.js";
|
|
6
6
|
import type { VisibilityContext } from "./TreeNodeVisibilityButton.js";
|
|
7
7
|
/** @beta */
|
|
8
8
|
export type VisibilityTreeProps = Omit<TreeProps, "treeRenderer" | "imodelAccess"> & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VisibilityTree.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/components/VisibilityTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAmBjC;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,EAAE,wBAAwB,EAAE,YAAY,EAAE,uBAAuB,EAAE,GAAG,KAAK,EAAuB;IAC/H,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IACnC,MAAM,EAAE,YAAY,EAAE,8BAA8B,EAAE,GAAG,eAAe,CAAC;QACvE,MAAM;QACN,QAAQ;QACR,uBAAuB;KACxB,CAAC,CAAC;IAEH,MAAM,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,cAAc,EAAE,GAAG,sBAAsB,CAAC;QACnG,wBAAwB,EAAE,WAAW,CAAC,GAAG,EAAE,CAAC,wBAAwB,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC,wBAAwB,EAAE,YAAY,CAAC,CAAC;KAClI,CAAC,CAAC;IAEH,OAAO,CACL,KAAC,IAAI,OACC,KAAK,EACT,QAAQ,EAAE,cAAc,EACxB,YAAY,EAAE,YAAY,EAC1B,uBAAuB,EAAE,8BAA8B,EACvD,YAAY,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,YAAY,CAAC,EAAE,GAAG,SAAS,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,CAAC,GAC9G,CACH,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useCallback } from \"react\";\nimport { useIModelAccess } from \"../internal/UseIModelAccess.js\";\nimport { useHierarchyVisibility } from \"../UseHierarchyVisibility.js\";\nimport { Tree } from \"./Tree.js\";\n\nimport type {
|
|
1
|
+
{"version":3,"file":"VisibilityTree.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/components/VisibilityTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAmBjC;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,EAAE,wBAAwB,EAAE,YAAY,EAAE,uBAAuB,EAAE,GAAG,KAAK,EAAuB;IAC/H,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IACnC,MAAM,EAAE,YAAY,EAAE,8BAA8B,EAAE,GAAG,eAAe,CAAC;QACvE,MAAM;QACN,QAAQ;QACR,uBAAuB;KACxB,CAAC,CAAC;IAEH,MAAM,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,cAAc,EAAE,GAAG,sBAAsB,CAAC;QACnG,wBAAwB,EAAE,WAAW,CAAC,GAAG,EAAE,CAAC,wBAAwB,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC,wBAAwB,EAAE,YAAY,CAAC,CAAC;KAClI,CAAC,CAAC;IAEH,OAAO,CACL,KAAC,IAAI,OACC,KAAK,EACT,QAAQ,EAAE,cAAc,EACxB,YAAY,EAAE,YAAY,EAC1B,uBAAuB,EAAE,8BAA8B,EACvD,YAAY,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,YAAY,CAAC,EAAE,GAAG,SAAS,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,CAAC,GAC9G,CACH,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useCallback } from \"react\";\nimport { useIModelAccess } from \"../internal/UseIModelAccess.js\";\nimport { useHierarchyVisibility } from \"../UseHierarchyVisibility.js\";\nimport { Tree } from \"./Tree.js\";\n\nimport type { ReactNode } from \"react\";\nimport type { ECClassHierarchyInspector } from \"@itwin/presentation-shared\";\nimport type { HierarchyVisibilityHandler } from \"../UseHierarchyVisibility.js\";\nimport type { FunctionProps } from \"../Utils.js\";\nimport type { TreeProps } from \"./Tree.js\";\nimport type { VisibilityContext } from \"./TreeNodeVisibilityButton.js\";\n\n/** @beta */\nexport type VisibilityTreeProps = Omit<TreeProps, \"treeRenderer\" | \"imodelAccess\"> & {\n /** Callback for creating visibility handler used to control visibility of instances represented by tree nodes. */\n visibilityHandlerFactory: (props: { imodelAccess: ECClassHierarchyInspector }) => HierarchyVisibilityHandler;\n /** Tree renderer that should be used to render tree data. */\n treeRenderer: (\n treeProps: FunctionProps<TreeProps[\"treeRenderer\"]> & Pick<VisibilityContext, \"getVisibilityButtonState\" | \"onVisibilityButtonClick\">,\n ) => ReactNode;\n};\n\n/**\n * Tree component that can control visibility of instances represented by tree nodes.\n * @beta\n */\nexport function VisibilityTree({ visibilityHandlerFactory, treeRenderer, hierarchyLevelSizeLimit, ...props }: VisibilityTreeProps) {\n const { imodel, treeName } = props;\n const { imodelAccess, currentHierarchyLevelSizeLimit } = useIModelAccess({\n imodel,\n treeName,\n hierarchyLevelSizeLimit,\n });\n\n const { getVisibilityButtonState, onVisibilityButtonClick, triggerRefresh } = useHierarchyVisibility({\n visibilityHandlerFactory: useCallback(() => visibilityHandlerFactory({ imodelAccess }), [visibilityHandlerFactory, imodelAccess]),\n });\n\n return (\n <Tree\n {...props}\n onReload={triggerRefresh}\n imodelAccess={imodelAccess}\n hierarchyLevelSizeLimit={currentHierarchyLevelSizeLimit}\n treeRenderer={(treeProps) => treeRenderer({ ...treeProps, getVisibilityButtonState, onVisibilityButtonClick })}\n />\n );\n}\n"]}
|