@itwin/tree-widget-react 1.2.1 → 2.0.0-dev.0
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 +11 -2
- package/README.md +1 -1
- package/lib/cjs/TreeWidget.d.ts +0 -1
- package/lib/cjs/TreeWidget.js +9 -10
- package/lib/cjs/TreeWidget.js.map +1 -1
- package/lib/cjs/components/SelectableTree.js +24 -13
- package/lib/cjs/components/SelectableTree.js.map +1 -1
- package/lib/cjs/components/TreeFilteringState.js +3 -3
- package/lib/cjs/components/TreeFilteringState.js.map +1 -1
- package/lib/cjs/components/TreeWidgetUiItemsProvider.js +7 -5
- package/lib/cjs/components/TreeWidgetUiItemsProvider.js.map +1 -1
- package/lib/cjs/components/TreeWidgetUiItemsProvider.scss +1 -1
- package/lib/cjs/components/tree-header/TreeHeader.js +15 -12
- package/lib/cjs/components/tree-header/TreeHeader.js.map +1 -1
- package/lib/cjs/components/tree-header/TreeHeader.scss +1 -1
- package/lib/cjs/components/trees/CategoriesVisibilityUtils.js +13 -8
- package/lib/cjs/components/trees/CategoriesVisibilityUtils.js.map +1 -1
- package/lib/cjs/components/trees/VisibilityTreeBase.scss +1 -1
- package/lib/cjs/components/trees/VisibilityTreeEventHandler.d.ts +1 -1
- package/lib/cjs/components/trees/VisibilityTreeEventHandler.js +25 -28
- package/lib/cjs/components/trees/VisibilityTreeEventHandler.js.map +1 -1
- package/lib/cjs/components/trees/VisibilityTreeRenderer.d.ts +20 -4
- package/lib/cjs/components/trees/VisibilityTreeRenderer.js +28 -10
- package/lib/cjs/components/trees/VisibilityTreeRenderer.js.map +1 -1
- package/lib/cjs/components/trees/category-tree/CategoriesTree.d.ts +7 -2
- package/lib/cjs/components/trees/category-tree/CategoriesTree.js +47 -30
- package/lib/cjs/components/trees/category-tree/CategoriesTree.js.map +1 -1
- package/lib/cjs/components/trees/category-tree/CategoriesTreeComponent.js +14 -10
- package/lib/cjs/components/trees/category-tree/CategoriesTreeComponent.js.map +1 -1
- package/lib/cjs/components/trees/category-tree/CategoryVisibilityHandler.js +18 -13
- package/lib/cjs/components/trees/category-tree/CategoryVisibilityHandler.js.map +1 -1
- package/lib/cjs/components/trees/common/ContextMenu.js +4 -4
- package/lib/cjs/components/trees/common/ContextMenu.js.map +1 -1
- package/lib/cjs/components/trees/common/TreeNodeRenderer.d.ts +1 -1
- package/lib/cjs/components/trees/common/TreeNodeRenderer.js +4 -4
- package/lib/cjs/components/trees/common/TreeNodeRenderer.js.map +1 -1
- package/lib/cjs/components/trees/common/TreeRenderer.d.ts +15 -1
- package/lib/cjs/components/trees/common/TreeRenderer.js +17 -7
- package/lib/cjs/components/trees/common/TreeRenderer.js.map +1 -1
- package/lib/cjs/components/trees/common/TreeRenderer.scss +7 -2
- package/lib/cjs/components/trees/common/Types.d.ts +8 -0
- package/lib/cjs/components/trees/common/Types.js +3 -3
- package/lib/cjs/components/trees/common/Types.js.map +1 -1
- package/lib/cjs/components/trees/common/UseVisibilityTreeState.d.ts +36 -0
- package/lib/cjs/components/trees/common/UseVisibilityTreeState.js +47 -0
- package/lib/cjs/components/trees/common/UseVisibilityTreeState.js.map +1 -0
- package/lib/cjs/components/trees/common/Utils.js +7 -5
- package/lib/cjs/components/trees/common/Utils.js.map +1 -1
- package/lib/cjs/components/trees/external-sources-tree/ExternalSources.json +1 -3
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.d.ts +9 -3
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.js +19 -7
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js +4 -4
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js.map +1 -1
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.d.ts +9 -3
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.js +16 -12
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTreeComponent.js +6 -5
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTreeComponent.js.map +1 -1
- package/lib/cjs/components/trees/index.js +3 -3
- package/lib/cjs/components/trees/index.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsTree.d.ts +7 -2
- package/lib/cjs/components/trees/models-tree/ModelsTree.js +76 -62
- package/lib/cjs/components/trees/models-tree/ModelsTree.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.js +11 -18
- package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsTreeEventHandler.d.ts +9 -0
- package/lib/cjs/components/trees/models-tree/ModelsTreeEventHandler.js +31 -0
- package/lib/cjs/components/trees/models-tree/ModelsTreeEventHandler.js.map +1 -0
- package/lib/cjs/components/trees/models-tree/ModelsVisibilityHandler.js +125 -66
- package/lib/cjs/components/trees/models-tree/ModelsVisibilityHandler.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/Utils.d.ts +4 -0
- package/lib/cjs/components/trees/models-tree/Utils.js +52 -58
- package/lib/cjs/components/trees/models-tree/Utils.js.map +1 -1
- package/lib/cjs/components/utils/AutoSizer.js +7 -5
- package/lib/cjs/components/utils/AutoSizer.js.map +1 -1
- package/lib/cjs/components/utils/IsPromiseLike.js +4 -4
- package/lib/cjs/components/utils/IsPromiseLike.js.map +1 -1
- package/lib/cjs/components/utils/UseTreeTransientState.js +3 -3
- package/lib/cjs/components/utils/UseTreeTransientState.js.map +1 -1
- package/lib/cjs/e2e-tests/TreeWidget.test.js +55 -1
- package/lib/cjs/e2e-tests/TreeWidget.test.js.map +1 -1
- package/lib/cjs/e2e-tests/utils.d.ts +1 -0
- package/lib/cjs/e2e-tests/utils.js +4 -5
- package/lib/cjs/e2e-tests/utils.js.map +1 -1
- package/lib/cjs/tree-widget-react.js +3 -3
- package/lib/cjs/tree-widget-react.js.map +1 -1
- package/lib/esm/TreeWidget.d.ts +0 -1
- package/lib/esm/TreeWidget.js +9 -10
- package/lib/esm/TreeWidget.js.map +1 -1
- package/lib/esm/components/SelectableTree.js +24 -13
- package/lib/esm/components/SelectableTree.js.map +1 -1
- package/lib/esm/components/TreeFilteringState.js +3 -3
- package/lib/esm/components/TreeFilteringState.js.map +1 -1
- package/lib/esm/components/TreeWidgetUiItemsProvider.js +7 -5
- package/lib/esm/components/TreeWidgetUiItemsProvider.js.map +1 -1
- package/lib/esm/components/TreeWidgetUiItemsProvider.scss +1 -1
- package/lib/esm/components/tree-header/TreeHeader.js +15 -12
- package/lib/esm/components/tree-header/TreeHeader.js.map +1 -1
- package/lib/esm/components/tree-header/TreeHeader.scss +1 -1
- package/lib/esm/components/trees/CategoriesVisibilityUtils.js +13 -8
- package/lib/esm/components/trees/CategoriesVisibilityUtils.js.map +1 -1
- package/lib/esm/components/trees/VisibilityTreeBase.scss +1 -1
- package/lib/esm/components/trees/VisibilityTreeEventHandler.d.ts +1 -1
- package/lib/esm/components/trees/VisibilityTreeEventHandler.js +22 -25
- package/lib/esm/components/trees/VisibilityTreeEventHandler.js.map +1 -1
- package/lib/esm/components/trees/VisibilityTreeRenderer.d.ts +20 -4
- package/lib/esm/components/trees/VisibilityTreeRenderer.js +27 -10
- package/lib/esm/components/trees/VisibilityTreeRenderer.js.map +1 -1
- package/lib/esm/components/trees/category-tree/CategoriesTree.d.ts +7 -2
- package/lib/esm/components/trees/category-tree/CategoriesTree.js +51 -34
- package/lib/esm/components/trees/category-tree/CategoriesTree.js.map +1 -1
- package/lib/esm/components/trees/category-tree/CategoriesTreeComponent.js +14 -10
- package/lib/esm/components/trees/category-tree/CategoriesTreeComponent.js.map +1 -1
- package/lib/esm/components/trees/category-tree/CategoryVisibilityHandler.js +18 -13
- package/lib/esm/components/trees/category-tree/CategoryVisibilityHandler.js.map +1 -1
- package/lib/esm/components/trees/common/ContextMenu.js +4 -4
- package/lib/esm/components/trees/common/ContextMenu.js.map +1 -1
- package/lib/esm/components/trees/common/TreeNodeRenderer.d.ts +1 -1
- package/lib/esm/components/trees/common/TreeNodeRenderer.js +4 -4
- package/lib/esm/components/trees/common/TreeNodeRenderer.js.map +1 -1
- package/lib/esm/components/trees/common/TreeRenderer.d.ts +15 -1
- package/lib/esm/components/trees/common/TreeRenderer.js +15 -6
- package/lib/esm/components/trees/common/TreeRenderer.js.map +1 -1
- package/lib/esm/components/trees/common/TreeRenderer.scss +7 -2
- package/lib/esm/components/trees/common/Types.d.ts +8 -0
- package/lib/esm/components/trees/common/Types.js +3 -3
- package/lib/esm/components/trees/common/Types.js.map +1 -1
- package/lib/esm/components/trees/common/UseVisibilityTreeState.d.ts +36 -0
- package/lib/esm/components/trees/common/UseVisibilityTreeState.js +43 -0
- package/lib/esm/components/trees/common/UseVisibilityTreeState.js.map +1 -0
- package/lib/esm/components/trees/common/Utils.js +7 -5
- package/lib/esm/components/trees/common/Utils.js.map +1 -1
- package/lib/esm/components/trees/external-sources-tree/ExternalSources.json +1 -3
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.d.ts +9 -3
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.js +22 -10
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js +4 -4
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js.map +1 -1
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.d.ts +9 -3
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.js +19 -15
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTreeComponent.js +6 -5
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTreeComponent.js.map +1 -1
- package/lib/esm/components/trees/index.js +3 -3
- package/lib/esm/components/trees/index.js.map +1 -1
- package/lib/esm/components/trees/models-tree/ModelsTree.d.ts +7 -2
- package/lib/esm/components/trees/models-tree/ModelsTree.js +80 -66
- package/lib/esm/components/trees/models-tree/ModelsTree.js.map +1 -1
- package/lib/esm/components/trees/models-tree/ModelsTreeComponent.js +12 -19
- package/lib/esm/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
- package/lib/esm/components/trees/models-tree/ModelsTreeEventHandler.d.ts +9 -0
- package/lib/esm/components/trees/models-tree/ModelsTreeEventHandler.js +27 -0
- package/lib/esm/components/trees/models-tree/ModelsTreeEventHandler.js.map +1 -0
- package/lib/esm/components/trees/models-tree/ModelsVisibilityHandler.js +125 -66
- package/lib/esm/components/trees/models-tree/ModelsVisibilityHandler.js.map +1 -1
- package/lib/esm/components/trees/models-tree/Utils.d.ts +4 -0
- package/lib/esm/components/trees/models-tree/Utils.js +50 -57
- package/lib/esm/components/trees/models-tree/Utils.js.map +1 -1
- package/lib/esm/components/utils/AutoSizer.js +7 -5
- package/lib/esm/components/utils/AutoSizer.js.map +1 -1
- package/lib/esm/components/utils/IsPromiseLike.js +4 -4
- package/lib/esm/components/utils/IsPromiseLike.js.map +1 -1
- package/lib/esm/components/utils/UseTreeTransientState.js +3 -3
- package/lib/esm/components/utils/UseTreeTransientState.js.map +1 -1
- package/lib/esm/e2e-tests/TreeWidget.test.js +56 -2
- package/lib/esm/e2e-tests/TreeWidget.test.js.map +1 -1
- package/lib/esm/e2e-tests/utils.d.ts +1 -0
- package/lib/esm/e2e-tests/utils.js +2 -4
- package/lib/esm/e2e-tests/utils.js.map +1 -1
- package/lib/esm/tree-widget-react.js +3 -3
- package/lib/esm/tree-widget-react.js.map +1 -1
- package/package.json +88 -87
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*---------------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
-
*--------------------------------------------------------------------------------------------*/
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import { useMemo } from "react";
|
|
6
6
|
import { useAsyncValue } from "@itwin/components-react";
|
|
7
7
|
import { BeEvent } from "@itwin/core-bentley";
|
|
@@ -51,23 +51,26 @@ export class CategoryVisibilityHandler {
|
|
|
51
51
|
}
|
|
52
52
|
getVisibilityStatus(node) {
|
|
53
53
|
const nodeKey = isPresentationTreeNodeItem(node) ? node.key : undefined;
|
|
54
|
-
if (!nodeKey)
|
|
54
|
+
if (!nodeKey) {
|
|
55
55
|
return { state: "hidden", isDisabled: true };
|
|
56
|
+
}
|
|
56
57
|
const instanceId = CategoryVisibilityHandler.getInstanceIdFromTreeNodeKey(nodeKey);
|
|
57
58
|
return { state: node.parentId ? this.getSubCategoryVisibility(instanceId) : this.getCategoryVisibility(instanceId) };
|
|
58
59
|
}
|
|
59
60
|
async changeVisibility(node, shouldDisplay) {
|
|
60
61
|
const nodeKey = isPresentationTreeNodeItem(node) ? node.key : undefined;
|
|
61
|
-
if (!nodeKey)
|
|
62
|
+
if (!nodeKey) {
|
|
62
63
|
return;
|
|
64
|
+
}
|
|
63
65
|
// handle subcategory visibility change
|
|
64
66
|
if (node.parentId) {
|
|
65
67
|
const childId = CategoryVisibilityHandler.getInstanceIdFromTreeNodeKey(nodeKey);
|
|
66
68
|
// istanbul ignore next
|
|
67
69
|
const parentId = this.getParent(childId)?.categoryId;
|
|
68
70
|
// make sure parent category is enabled
|
|
69
|
-
if (shouldDisplay && parentId)
|
|
71
|
+
if (shouldDisplay && parentId) {
|
|
70
72
|
await this.enableCategory([parentId], true, false);
|
|
73
|
+
}
|
|
71
74
|
this.enableSubCategory(childId, shouldDisplay);
|
|
72
75
|
return;
|
|
73
76
|
}
|
|
@@ -76,8 +79,9 @@ export class CategoryVisibilityHandler {
|
|
|
76
79
|
}
|
|
77
80
|
getSubCategoryVisibility(id) {
|
|
78
81
|
const parentItem = this.getParent(id);
|
|
79
|
-
if (!parentItem)
|
|
82
|
+
if (!parentItem) {
|
|
80
83
|
return "hidden";
|
|
84
|
+
}
|
|
81
85
|
const isVisible = this._activeView.view.viewsCategory(parentItem.categoryId) && this._activeView.isSubCategoryVisible(id);
|
|
82
86
|
return isVisible ? "visible" : "hidden";
|
|
83
87
|
}
|
|
@@ -87,23 +91,23 @@ export class CategoryVisibilityHandler {
|
|
|
87
91
|
getParent(key) {
|
|
88
92
|
for (const category of this._categories) {
|
|
89
93
|
// istanbul ignore else
|
|
90
|
-
if (category.subCategoryIds) {
|
|
91
|
-
|
|
92
|
-
return category;
|
|
94
|
+
if (category.subCategoryIds && category.subCategoryIds.indexOf(key) !== -1) {
|
|
95
|
+
return category;
|
|
93
96
|
}
|
|
94
97
|
}
|
|
95
98
|
return undefined;
|
|
96
99
|
}
|
|
97
100
|
onVisibilityChangeInternal() {
|
|
98
|
-
if (this._pendingVisibilityChange)
|
|
101
|
+
if (this._pendingVisibilityChange) {
|
|
99
102
|
return;
|
|
103
|
+
}
|
|
100
104
|
this._pendingVisibilityChange = setTimeout(() => {
|
|
101
105
|
this.onVisibilityChange.raiseEvent();
|
|
102
106
|
this._pendingVisibilityChange = undefined;
|
|
103
107
|
}, 0);
|
|
104
108
|
}
|
|
105
109
|
static getInstanceIdFromTreeNodeKey(nodeKey) {
|
|
106
|
-
return
|
|
110
|
+
return NodeKey.isInstancesNodeKey(nodeKey) && nodeKey.instanceKeys.length > 0 ? nodeKey.instanceKeys[0].id : /* istanbul ignore next */ "";
|
|
107
111
|
}
|
|
108
112
|
async enableCategory(ids, enabled, enableAllSubCategories = true) {
|
|
109
113
|
await enableCategory(this._viewManager, this._imodel, ids, enabled, this._useAllViewports, enableAllSubCategories);
|
|
@@ -142,8 +146,9 @@ export async function invertAllCategories(categories, viewport) {
|
|
|
142
146
|
}
|
|
143
147
|
// First, we need to check if at least one subcategory is disabled. If it is true, then only subcategories should change display, not categories.
|
|
144
148
|
if (category.subCategoryIds?.some((subCategory) => !viewport.isSubCategoryVisible(subCategory))) {
|
|
145
|
-
for (const subCategory of category.subCategoryIds)
|
|
149
|
+
for (const subCategory of category.subCategoryIds) {
|
|
146
150
|
viewport.isSubCategoryVisible(subCategory) ? enabledSubCategories.push(subCategory) : disabledSubCategories.push(subCategory);
|
|
151
|
+
}
|
|
147
152
|
}
|
|
148
153
|
else {
|
|
149
154
|
enabled.push(category.categoryId);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CategoryVisibilityHandler.js","sourceRoot":"","sources":["../../../../../src/components/trees/category-tree/CategoryVisibilityHandler.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAM7G,MAAM,sBAAsB,GAAmB,EAAE,CAAC;AAElD;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,WAAwB,EAAE,MAAwB,EAAE,IAAe;IAC/F,MAAM,WAAW,GAAG,IAAI,IAAI,WAAW,CAAC,gBAAgB,EAAE,CAAC;IAC3D,MAAM,iBAAiB,GAAG,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,0BAA0B,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC;IACtH,OAAO,aAAa,CAAC,iBAAiB,CAAC,IAAI,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AAC,EAAE;YACrD,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;YACnC,SAAS;SACV;QACD,iJAAiJ;QACjJ,IAAI,QAAQ,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC,EAAE;YAC/F,KAAK,MAAM,WAAW,IAAI,QAAQ,CAAC,cAAc;gBAC/C,QAAQ,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,oBAAoB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,qBAAqB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;SACjI;aAAM;YACL,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;SACnC;KACF;IAED,kBAAkB;IAClB,oBAAoB,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,iBAAiB,CAC7D,SAAS,CAAC,WAAW,EACrB,WAAW,EACX,KAAK,EACL,IAAI,CACL,CAAC,CAAC;IAEH,MAAM,cAAc,CAClB,SAAS,CAAC,WAAW,EACrB,QAAQ,CAAC,MAAM,EACf,OAAO,EACP,KAAK,EACL,IAAI,CACL,CAAC;IAEF,kBAAkB;IAClB,qBAAqB,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,iBAAiB,CAC9D,SAAS,CAAC,WAAW,EACrB,WAAW,EACX,IAAI,EACJ,IAAI,CACL,CAAC,CAAC;IAEH,MAAM,cAAc,CAClB,SAAS,CAAC,WAAW,EACrB,QAAQ,CAAC,MAAM,EACf,QAAQ,EACR,IAAI,EACJ,IAAI,CACL,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 { useMemo } from \"react\";\nimport { useAsyncValue } from \"@itwin/components-react\";\nimport { BeEvent } from \"@itwin/core-bentley\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { NodeKey } from \"@itwin/presentation-common\";\nimport { isPresentationTreeNodeItem } from \"@itwin/presentation-components\";\nimport { enableCategory, enableSubCategory, loadCategoriesFromViewport } from \"../CategoriesVisibilityUtils\";\n\nimport type { TreeNodeItem } from \"@itwin/components-react\";\nimport type { IModelConnection, ViewManager, Viewport } from \"@itwin/core-frontend\";\nimport type { IVisibilityHandler, VisibilityChangeListener, VisibilityStatus } from \"../VisibilityTreeEventHandler\";\n\nconst EMPTY_CATEGORIES_ARRAY: CategoryInfo[] = [];\n\n/**\n * Loads categories from viewport or uses provided list of categories.\n * @internal\n */\nexport function useCategories(viewManager: ViewManager, imodel: IModelConnection, view?: Viewport) {\n const currentView = view || viewManager.getFirstOpenView();\n const categoriesPromise = useMemo(async () => loadCategoriesFromViewport(imodel, currentView), [imodel, currentView]);\n return useAsyncValue(categoriesPromise) ?? EMPTY_CATEGORIES_ARRAY;\n}\n\n/**\n * Data structure that describes category.\n * @public\n */\nexport interface CategoryInfo {\n categoryId: string;\n subCategoryIds?: string[];\n}\n\n/**\n * Params for creating a [[CategoryVisibilityHandler]].\n * @public\n */\nexport interface CategoryVisibilityHandlerParams {\n viewManager: ViewManager;\n imodel: IModelConnection;\n categories: CategoryInfo[];\n activeView: Viewport;\n allViewports?: boolean;\n}\n\n/**\n * An [[IVisibilityHandler]] implementation that knows how to determine and change visibility of categories\n * and subcategories.\n * @public\n */\nexport class CategoryVisibilityHandler implements IVisibilityHandler {\n private _viewManager: ViewManager;\n private _imodel: IModelConnection;\n private _pendingVisibilityChange: any | undefined;\n private _activeView: Viewport;\n private _useAllViewports: boolean;\n private _categories: CategoryInfo[];\n\n constructor(params: CategoryVisibilityHandlerParams) {\n this._viewManager = params.viewManager;\n this._imodel = params.imodel;\n this._activeView = params.activeView;\n // istanbul ignore next\n this._useAllViewports = params.allViewports ?? false;\n this._categories = params.categories;\n this._activeView.onDisplayStyleChanged.addListener(this.onDisplayStyleChanged);\n this._activeView.onViewedCategoriesChanged.addListener(this.onViewedCategoriesChanged);\n }\n\n public dispose() {\n this._activeView.onDisplayStyleChanged.removeListener(this.onDisplayStyleChanged);\n this._activeView.onViewedCategoriesChanged.removeListener(this.onViewedCategoriesChanged);\n clearTimeout(this._pendingVisibilityChange);\n }\n\n public onVisibilityChange = new BeEvent<VisibilityChangeListener>();\n\n public getVisibilityStatus(node: TreeNodeItem,): VisibilityStatus {\n const nodeKey = isPresentationTreeNodeItem(node) ? node.key : undefined;\n if (!nodeKey)\n return { state: \"hidden\", isDisabled: true };\n\n const instanceId = CategoryVisibilityHandler.getInstanceIdFromTreeNodeKey(nodeKey);\n return { state: node.parentId ? this.getSubCategoryVisibility(instanceId) : this.getCategoryVisibility(instanceId) };\n }\n\n public async changeVisibility(node: TreeNodeItem, shouldDisplay: boolean): Promise<void> {\n const nodeKey = isPresentationTreeNodeItem(node) ? node.key : undefined;\n if (!nodeKey)\n return;\n\n // handle subcategory visibility change\n if (node.parentId) {\n const childId = CategoryVisibilityHandler.getInstanceIdFromTreeNodeKey(nodeKey);\n // istanbul ignore next\n const parentId = this.getParent(childId)?.categoryId;\n\n // make sure parent category is enabled\n if (shouldDisplay && parentId)\n await this.enableCategory([parentId], true, false);\n\n this.enableSubCategory(childId, shouldDisplay);\n return;\n }\n\n const instanceId = CategoryVisibilityHandler.getInstanceIdFromTreeNodeKey(nodeKey);\n await this.enableCategory([instanceId], shouldDisplay, true);\n }\n\n public getSubCategoryVisibility(id: string) {\n const parentItem = this.getParent(id);\n if (!parentItem)\n return \"hidden\";\n\n const isVisible = this._activeView.view.viewsCategory(parentItem.categoryId) && this._activeView.isSubCategoryVisible(id);\n return isVisible ? \"visible\" : \"hidden\";\n }\n\n public getCategoryVisibility(id: string) {\n return this._activeView.view.viewsCategory(id) ? \"visible\" : \"hidden\";\n }\n\n public getParent(key: string): CategoryInfo | undefined {\n for (const category of this._categories) {\n // istanbul ignore else\n if (category.subCategoryIds) {\n if (category.subCategoryIds.indexOf(key) !== -1)\n return category;\n }\n }\n\n return undefined;\n }\n\n // eslint-disable-next-line @typescript-eslint/naming-convention\n private onDisplayStyleChanged = () => {\n this.onVisibilityChangeInternal();\n };\n\n // eslint-disable-next-line @typescript-eslint/naming-convention\n private onViewedCategoriesChanged = () => {\n this.onVisibilityChangeInternal();\n };\n\n private onVisibilityChangeInternal() {\n if (this._pendingVisibilityChange)\n return;\n\n this._pendingVisibilityChange = setTimeout(() => {\n this.onVisibilityChange.raiseEvent();\n this._pendingVisibilityChange = undefined;\n }, 0);\n }\n\n public static getInstanceIdFromTreeNodeKey(nodeKey: NodeKey) {\n return (NodeKey.isInstancesNodeKey(nodeKey) && nodeKey.instanceKeys.length > 0) ? nodeKey.instanceKeys[0].id : /* istanbul ignore next */ \"\";\n }\n\n public async enableCategory(ids: string[], enabled: boolean, enableAllSubCategories = true) {\n await enableCategory(this._viewManager, this._imodel, ids, enabled, this._useAllViewports, enableAllSubCategories);\n }\n\n public enableSubCategory(key: string, enabled: boolean) {\n enableSubCategory(this._viewManager, key, enabled, this._useAllViewports);\n }\n}\n\n/**\n * Enable display of all given categories.\n * @public\n */\nexport async function showAllCategories(categories: string[], viewport: Viewport) {\n await enableCategory(\n IModelApp.viewManager,\n viewport.iModel,\n categories,\n true,\n true\n );\n}\n\n/**\n * Disable display of all given categories.\n * @public\n */\nexport async function hideAllCategories(categories: string[], viewport: Viewport) {\n await enableCategory(\n IModelApp.viewManager,\n viewport.iModel,\n categories,\n false,\n true\n );\n}\n\n/**\n * Invert display of all given categories.\n * @public\n */\nexport async function invertAllCategories(categories: CategoryInfo[], viewport: Viewport) {\n const enabled: string[] = [];\n const disabled: string[] = [];\n const enabledSubCategories: string[] = [];\n const disabledSubCategories: string[] = [];\n\n for (const category of categories) {\n if (!viewport.view.viewsCategory(category.categoryId)) {\n disabled.push(category.categoryId);\n continue;\n }\n // First, we need to check if at least one subcategory is disabled. If it is true, then only subcategories should change display, not categories.\n if (category.subCategoryIds?.some((subCategory) => !viewport.isSubCategoryVisible(subCategory))) {\n for (const subCategory of category.subCategoryIds)\n viewport.isSubCategoryVisible(subCategory) ? enabledSubCategories.push(subCategory) : disabledSubCategories.push(subCategory);\n } else {\n enabled.push(category.categoryId);\n }\n }\n\n // Disable enabled\n enabledSubCategories.forEach((subCategory) => enableSubCategory(\n IModelApp.viewManager,\n subCategory,\n false,\n true\n ));\n\n await enableCategory(\n IModelApp.viewManager,\n viewport.iModel,\n enabled,\n false,\n true\n );\n\n // Enable disabled\n disabledSubCategories.forEach((subCategory) => enableSubCategory(\n IModelApp.viewManager,\n subCategory,\n true,\n true\n ));\n\n await enableCategory(\n IModelApp.viewManager,\n viewport.iModel,\n disabled,\n true,\n true\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CategoryVisibilityHandler.js","sourceRoot":"","sources":["../../../../../src/components/trees/category-tree/CategoryVisibilityHandler.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAM7G,MAAM,sBAAsB,GAAmB,EAAE,CAAC;AAElD;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,WAAwB,EAAE,MAAwB,EAAE,IAAe;IAC/F,MAAM,WAAW,GAAG,IAAI,IAAI,WAAW,CAAC,gBAAgB,EAAE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AAC,CAAC;IAElH,MAAM,cAAc,CAAC,SAAS,CAAC,WAAW,EAAE,QAAQ,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AACrF,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 { useMemo } from \"react\";\nimport { useAsyncValue } from \"@itwin/components-react\";\nimport { BeEvent } from \"@itwin/core-bentley\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { NodeKey } from \"@itwin/presentation-common\";\nimport { isPresentationTreeNodeItem } from \"@itwin/presentation-components\";\nimport { enableCategory, enableSubCategory, loadCategoriesFromViewport } from \"../CategoriesVisibilityUtils\";\n\nimport type { TreeNodeItem } from \"@itwin/components-react\";\nimport type { IModelConnection, ViewManager, Viewport } from \"@itwin/core-frontend\";\nimport type { IVisibilityHandler, VisibilityChangeListener, VisibilityStatus } from \"../VisibilityTreeEventHandler\";\n\nconst EMPTY_CATEGORIES_ARRAY: CategoryInfo[] = [];\n\n/**\n * Loads categories from viewport or uses provided list of categories.\n * @internal\n */\nexport function useCategories(viewManager: ViewManager, imodel: IModelConnection, view?: Viewport) {\n const currentView = view || viewManager.getFirstOpenView();\n const categoriesPromise = useMemo(async () => loadCategoriesFromViewport(imodel, currentView), [imodel, currentView]);\n return useAsyncValue(categoriesPromise) ?? EMPTY_CATEGORIES_ARRAY;\n}\n\n/**\n * Data structure that describes category.\n * @public\n */\nexport interface CategoryInfo {\n categoryId: string;\n subCategoryIds?: string[];\n}\n\n/**\n * Params for creating a [[CategoryVisibilityHandler]].\n * @public\n */\nexport interface CategoryVisibilityHandlerParams {\n viewManager: ViewManager;\n imodel: IModelConnection;\n categories: CategoryInfo[];\n activeView: Viewport;\n allViewports?: boolean;\n}\n\n/**\n * An [[IVisibilityHandler]] implementation that knows how to determine and change visibility of categories\n * and subcategories.\n * @public\n */\nexport class CategoryVisibilityHandler implements IVisibilityHandler {\n private _viewManager: ViewManager;\n private _imodel: IModelConnection;\n private _pendingVisibilityChange: any | undefined;\n private _activeView: Viewport;\n private _useAllViewports: boolean;\n private _categories: CategoryInfo[];\n\n constructor(params: CategoryVisibilityHandlerParams) {\n this._viewManager = params.viewManager;\n this._imodel = params.imodel;\n this._activeView = params.activeView;\n // istanbul ignore next\n this._useAllViewports = params.allViewports ?? false;\n this._categories = params.categories;\n this._activeView.onDisplayStyleChanged.addListener(this.onDisplayStyleChanged);\n this._activeView.onViewedCategoriesChanged.addListener(this.onViewedCategoriesChanged);\n }\n\n public dispose() {\n this._activeView.onDisplayStyleChanged.removeListener(this.onDisplayStyleChanged);\n this._activeView.onViewedCategoriesChanged.removeListener(this.onViewedCategoriesChanged);\n clearTimeout(this._pendingVisibilityChange);\n }\n\n public onVisibilityChange = new BeEvent<VisibilityChangeListener>();\n\n public getVisibilityStatus(node: TreeNodeItem): VisibilityStatus {\n const nodeKey = isPresentationTreeNodeItem(node) ? node.key : undefined;\n if (!nodeKey) {\n return { state: \"hidden\", isDisabled: true };\n }\n\n const instanceId = CategoryVisibilityHandler.getInstanceIdFromTreeNodeKey(nodeKey);\n return { state: node.parentId ? this.getSubCategoryVisibility(instanceId) : this.getCategoryVisibility(instanceId) };\n }\n\n public async changeVisibility(node: TreeNodeItem, shouldDisplay: boolean): Promise<void> {\n const nodeKey = isPresentationTreeNodeItem(node) ? node.key : undefined;\n if (!nodeKey) {\n return;\n }\n\n // handle subcategory visibility change\n if (node.parentId) {\n const childId = CategoryVisibilityHandler.getInstanceIdFromTreeNodeKey(nodeKey);\n // istanbul ignore next\n const parentId = this.getParent(childId)?.categoryId;\n\n // make sure parent category is enabled\n if (shouldDisplay && parentId) {\n await this.enableCategory([parentId], true, false);\n }\n\n this.enableSubCategory(childId, shouldDisplay);\n return;\n }\n\n const instanceId = CategoryVisibilityHandler.getInstanceIdFromTreeNodeKey(nodeKey);\n await this.enableCategory([instanceId], shouldDisplay, true);\n }\n\n public getSubCategoryVisibility(id: string) {\n const parentItem = this.getParent(id);\n if (!parentItem) {\n return \"hidden\";\n }\n\n const isVisible = this._activeView.view.viewsCategory(parentItem.categoryId) && this._activeView.isSubCategoryVisible(id);\n return isVisible ? \"visible\" : \"hidden\";\n }\n\n public getCategoryVisibility(id: string) {\n return this._activeView.view.viewsCategory(id) ? \"visible\" : \"hidden\";\n }\n\n public getParent(key: string): CategoryInfo | undefined {\n for (const category of this._categories) {\n // istanbul ignore else\n if (category.subCategoryIds && category.subCategoryIds.indexOf(key) !== -1) {\n return category;\n }\n }\n\n return undefined;\n }\n\n // eslint-disable-next-line @typescript-eslint/naming-convention\n private onDisplayStyleChanged = () => {\n this.onVisibilityChangeInternal();\n };\n\n // eslint-disable-next-line @typescript-eslint/naming-convention\n private onViewedCategoriesChanged = () => {\n this.onVisibilityChangeInternal();\n };\n\n private onVisibilityChangeInternal() {\n if (this._pendingVisibilityChange) {\n return;\n }\n\n this._pendingVisibilityChange = setTimeout(() => {\n this.onVisibilityChange.raiseEvent();\n this._pendingVisibilityChange = undefined;\n }, 0);\n }\n\n public static getInstanceIdFromTreeNodeKey(nodeKey: NodeKey) {\n return NodeKey.isInstancesNodeKey(nodeKey) && nodeKey.instanceKeys.length > 0 ? nodeKey.instanceKeys[0].id : /* istanbul ignore next */ \"\";\n }\n\n public async enableCategory(ids: string[], enabled: boolean, enableAllSubCategories = true) {\n await enableCategory(this._viewManager, this._imodel, ids, enabled, this._useAllViewports, enableAllSubCategories);\n }\n\n public enableSubCategory(key: string, enabled: boolean) {\n enableSubCategory(this._viewManager, key, enabled, this._useAllViewports);\n }\n}\n\n/**\n * Enable display of all given categories.\n * @public\n */\nexport async function showAllCategories(categories: string[], viewport: Viewport) {\n await enableCategory(IModelApp.viewManager, viewport.iModel, categories, true, true);\n}\n\n/**\n * Disable display of all given categories.\n * @public\n */\nexport async function hideAllCategories(categories: string[], viewport: Viewport) {\n await enableCategory(IModelApp.viewManager, viewport.iModel, categories, false, true);\n}\n\n/**\n * Invert display of all given categories.\n * @public\n */\nexport async function invertAllCategories(categories: CategoryInfo[], viewport: Viewport) {\n const enabled: string[] = [];\n const disabled: string[] = [];\n const enabledSubCategories: string[] = [];\n const disabledSubCategories: string[] = [];\n\n for (const category of categories) {\n if (!viewport.view.viewsCategory(category.categoryId)) {\n disabled.push(category.categoryId);\n continue;\n }\n // First, we need to check if at least one subcategory is disabled. If it is true, then only subcategories should change display, not categories.\n if (category.subCategoryIds?.some((subCategory) => !viewport.isSubCategoryVisible(subCategory))) {\n for (const subCategory of category.subCategoryIds) {\n viewport.isSubCategoryVisible(subCategory) ? enabledSubCategories.push(subCategory) : disabledSubCategories.push(subCategory);\n }\n } else {\n enabled.push(category.categoryId);\n }\n }\n\n // Disable enabled\n enabledSubCategories.forEach((subCategory) => enableSubCategory(IModelApp.viewManager, subCategory, false, true));\n\n await enableCategory(IModelApp.viewManager, viewport.iModel, enabled, false, true);\n\n // Enable disabled\n disabledSubCategories.forEach((subCategory) => enableSubCategory(IModelApp.viewManager, subCategory, true, true));\n\n await enableCategory(IModelApp.viewManager, viewport.iModel, disabled, true, true);\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
/*---------------------------------------------------------------------------------------------
|
|
3
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
-
*--------------------------------------------------------------------------------------------*/
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
6
|
import { Fragment, useState } from "react";
|
|
7
7
|
import { ContextMenuItem, GlobalContextMenu } from "@itwin/core-react";
|
|
8
8
|
/**
|
|
@@ -10,7 +10,7 @@ import { ContextMenuItem, GlobalContextMenu } from "@itwin/core-react";
|
|
|
10
10
|
* @public
|
|
11
11
|
*/
|
|
12
12
|
export function TreeContextMenuItem({ id, children, title, onSelect }) {
|
|
13
|
-
return _jsx(ContextMenuItem, { onSelect: onSelect, title: title, children: children }, id);
|
|
13
|
+
return (_jsx(ContextMenuItem, { onSelect: onSelect, title: title, children: children }, id));
|
|
14
14
|
}
|
|
15
15
|
/** @internal */
|
|
16
16
|
export function useContextMenu({ contextMenuItems }) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextMenu.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/ContextMenu.tsx"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"ContextMenu.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/ContextMenu.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAkCvE;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAA+C;IAChH,OAAO,CACL,KAAC,eAAe,IAAU,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,YACvD,QAAQ,IADW,EAAE,CAEN,CACnB,CAAC;AACJ,CAAC;AAOD,gBAAgB;AAChB,MAAM,UAAU,cAAc,CAAC,EAAE,gBAAgB,EAAwB;IACvE,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,EAAe,CAAC;IAC9D,MAAM,KAAK,GAAG,GAAG,EAAE,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;IAE9C,MAAM,aAAa,GAAG,CAAC,CAAa,EAAE,IAAmB,EAAE,EAAE;QAC3D,IAAI,CAAC,gBAAgB,EAAE;YACrB,OAAO;SACR;QAED,cAAc,CAAC;YACb,KAAK,EAAE,gBAAgB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,KAAC,QAAQ,cAAc,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,IAAtB,KAAK,CAA6B,CAAC;YAC/F,QAAQ,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE;SACzC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,MAAM,iBAAiB,GAAG,GAAG,EAAE;QAC7B,IAAI,CAAC,WAAW,EAAE;YAChB,OAAO,IAAI,CAAC;SACb;QAED,OAAO,CACL,KAAC,iBAAiB,IAChB,UAAU,EAAC,0BAA0B,EACrC,CAAC,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC,EACzB,CAAC,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC,EACzB,MAAM,EAAE,IAAI,EACZ,cAAc,EAAE,KAAK,EACrB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,KAAK,YAEd,WAAW,CAAC,KAAK,GACA,CACrB,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO;QACL,aAAa;QACb,iBAAiB;KAClB,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 { Fragment, useState } from \"react\";\nimport { ContextMenuItem, GlobalContextMenu } from \"@itwin/core-react\";\n\nimport type { MouseEvent, PropsWithChildren, ReactNode } from \"react\";\nimport type { TreeModelNode } from \"@itwin/components-react\";\n\n/**\n * Props for single context menu item.\n * @public\n */\nexport interface ContextMenuItemProps {\n node: TreeModelNode;\n}\n\n/**\n * Props for configuring tree context menu.\n * @public\n */\nexport interface TreeContextMenuProps {\n contextMenuItems?: Array<(props: ContextMenuItemProps) => ReactNode>;\n}\n\n/**\n * Props for [[TreeContextMenuItem]] component.\n * @public\n */\nexport interface TreeContextMenuItemProps {\n /** Unique id of the context menu item. */\n id: string;\n /** Description of the context menu item. */\n title?: string;\n /** Callback that is invoked when context menu item is clicked. */\n onSelect: () => void;\n}\n\n/**\n * Base component for rendering single context menu item.\n * @public\n */\nexport function TreeContextMenuItem({ id, children, title, onSelect }: PropsWithChildren<TreeContextMenuItemProps>) {\n return (\n <ContextMenuItem key={id} onSelect={onSelect} title={title}>\n {children}\n </ContextMenuItem>\n );\n}\n\ninterface ContextMenu {\n items: ReactNode[];\n position: { x: number; y: number };\n}\n\n/** @internal */\nexport function useContextMenu({ contextMenuItems }: TreeContextMenuProps) {\n const [contextMenu, setContextMenu] = useState<ContextMenu>();\n const close = () => setContextMenu(undefined);\n\n const onContextMenu = (e: MouseEvent, node: TreeModelNode) => {\n if (!contextMenuItems) {\n return;\n }\n\n setContextMenu({\n items: contextMenuItems.map((item, index) => <Fragment key={index}>{item({ node })}</Fragment>),\n position: { x: e.clientX, y: e.clientY },\n });\n };\n\n const renderContextMenu = () => {\n if (!contextMenu) {\n return null;\n }\n\n return (\n <GlobalContextMenu\n identifier=\"tree-widget-context-menu\"\n x={contextMenu.position.x}\n y={contextMenu.position.y}\n opened={true}\n onOutsideClick={close}\n onEsc={close}\n onSelect={close}\n >\n {contextMenu.items}\n </GlobalContextMenu>\n );\n };\n\n return {\n onContextMenu,\n renderContextMenu,\n };\n}\n"]}
|
|
@@ -43,7 +43,7 @@ export interface DefaultLabelRendererProps {
|
|
|
43
43
|
* Renders label for tree node.
|
|
44
44
|
* @public
|
|
45
45
|
*/
|
|
46
|
-
export declare function DefaultLabelRenderer({ label, context }: DefaultLabelRendererProps): JSX.Element;
|
|
46
|
+
export declare function DefaultLabelRenderer({ label, context }: DefaultLabelRendererProps): React.JSX.Element;
|
|
47
47
|
/** @internal */
|
|
48
48
|
export interface TreeNodeRendererContextProviderProps extends TreeNodeRendererProps {
|
|
49
49
|
node: TreeModelNode;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
/*---------------------------------------------------------------------------------------------
|
|
3
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
-
*--------------------------------------------------------------------------------------------*/
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
6
|
import { createContext, useContext } from "react";
|
|
7
7
|
import { PrimitivePropertyValueRenderer } from "@itwin/components-react";
|
|
8
8
|
/**
|
|
@@ -15,7 +15,7 @@ export function DefaultLabelRenderer({ label, context }) {
|
|
|
15
15
|
}
|
|
16
16
|
/** @internal */
|
|
17
17
|
export function TreeNodeRendererContextProvider({ nodeLabelRenderer, node, children }) {
|
|
18
|
-
return
|
|
18
|
+
return _jsx(treeNodeLabelRendererContext.Provider, { value: { renderer: nodeLabelRenderer, node }, children: children });
|
|
19
19
|
}
|
|
20
20
|
/** @internal */
|
|
21
21
|
export const TREE_NODE_LABEL_RENDERER = "visibility-tree-node-label";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeNodeRenderer.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/TreeNodeRenderer.tsx"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"TreeNodeRenderer.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/TreeNodeRenderer.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,EAAE,8BAA8B,EAAE,MAAM,yBAAyB,CAAC;AAgDzE;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,EAAE,KAAK,EAAE,OAAO,EAA6B;IACh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CAAC;IACzC,OAAO,4BAAG,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,GAAI,CAAC;AAC5C,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 { createContext, useContext } from \"react\";\nimport { PrimitivePropertyValueRenderer } from \"@itwin/components-react\";\n\nimport type { ReactNode } from \"react\";\nimport type { PropertyRecord } from \"@itwin/appui-abstract\";\nimport type { IPropertyValueRenderer, PropertyValueRendererContext, TreeModelNode } from \"@itwin/components-react\";\n\n/**\n * Context for rendering label value.\n * @public\n */\nexport interface LabelRendererContext {\n /** Style that should be applied to the rendered element. */\n style?: React.CSSProperties;\n /** Callback to highlight text. */\n textHighlighter?: (text: string) => React.ReactNode;\n}\n\n/**\n * Props for custom node renderer.\n * @public\n */\nexport interface TreeNodeLabelRendererProps {\n /** Tree node to rendered label for. */\n node: TreeModelNode;\n /** Context for rendering node's label value. */\n context?: LabelRendererContext;\n}\n\n/**\n * Props for customizing node rendering.\n * @public\n */\nexport interface TreeNodeRendererProps {\n /** Custom renderer for node's label. */\n nodeLabelRenderer?: (props: TreeNodeLabelRendererProps) => ReactNode;\n}\n\n/**\n * Props for [[DefaultLabelRenderer]] component.\n * @public\n */\nexport interface DefaultLabelRendererProps {\n /** Label that should be rendered. */\n label: PropertyRecord;\n /** Context for rendering label value. */\n context?: LabelRendererContext;\n}\n\n/**\n * Renders label for tree node.\n * @public\n */\nexport function DefaultLabelRenderer({ label, context }: DefaultLabelRendererProps) {\n const renderer = new PrimitivePropertyValueRenderer();\n return renderer.render(label, context);\n}\n\n/** @internal */\nexport interface TreeNodeRendererContextProviderProps extends TreeNodeRendererProps {\n node: TreeModelNode;\n children: ReactNode;\n}\n\n/** @internal */\nexport function TreeNodeRendererContextProvider({ nodeLabelRenderer, node, children }: TreeNodeRendererContextProviderProps) {\n return <treeNodeLabelRendererContext.Provider value={{ renderer: nodeLabelRenderer, node }}>{children}</treeNodeLabelRendererContext.Provider>;\n}\n\n/** @internal */\nexport const TREE_NODE_LABEL_RENDERER = \"visibility-tree-node-label\";\n\n/** @internal */\nexport class TreeNodeLabelRenderer implements IPropertyValueRenderer {\n public canRender(record: PropertyRecord, _context?: PropertyValueRendererContext | undefined): boolean {\n return record.property.renderer?.name === TREE_NODE_LABEL_RENDERER;\n }\n\n public render(record: PropertyRecord, context?: PropertyValueRendererContext | undefined): ReactNode {\n const labelContext: LabelRendererContext = {\n style: context?.style,\n textHighlighter: context?.textHighlighter,\n };\n return <LabelRenderer record={record} context={labelContext} />;\n }\n}\n\ninterface TreeNodeLabelRendererContext {\n renderer?: (props: TreeNodeLabelRendererProps) => ReactNode;\n node: TreeModelNode;\n}\n\nconst treeNodeLabelRendererContext = createContext<TreeNodeLabelRendererContext | undefined>(undefined);\n\ninterface LabelRendererProps {\n record: PropertyRecord;\n context?: LabelRendererContext;\n}\n\nfunction LabelRenderer({ record, context }: LabelRendererProps) {\n const renderContext = useContext(treeNodeLabelRendererContext);\n\n if (!renderContext || !renderContext.renderer) {\n return <DefaultLabelRenderer label={record} context={context} />;\n }\n\n const { renderer, node } = renderContext;\n return <>{renderer({ node, context })}</>;\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import "./TreeRenderer.scss";
|
|
3
|
-
import type {
|
|
3
|
+
import type { IPresentationTreeDataProvider, PresentationTreeNodeRendererProps } from "@itwin/presentation-components";
|
|
4
|
+
import type { AbstractTreeNodeLoaderWithProvider, TreeRendererProps as ComponentsTreeRendererProps } from "@itwin/components-react";
|
|
4
5
|
import type { TreeNodeRendererProps } from "./TreeNodeRenderer";
|
|
5
6
|
import type { TreeContextMenuProps } from "./ContextMenu";
|
|
6
7
|
/**
|
|
@@ -23,4 +24,17 @@ export type TreeRendererProps = ComponentsTreeRendererProps & TreeRendererBasePr
|
|
|
23
24
|
* @public
|
|
24
25
|
*/
|
|
25
26
|
export declare function TreeRenderer({ contextMenuItems, nodeRenderer, nodeLabelRenderer, density, ...restProps }: TreeRendererProps): JSX.Element;
|
|
27
|
+
/**
|
|
28
|
+
* Props for [[FilterableTreeRenderer]] component.
|
|
29
|
+
* @beta
|
|
30
|
+
*/
|
|
31
|
+
export interface FilterableTreeRendererProps extends Omit<TreeRendererProps, "nodeLoader" | "nodeRenderer"> {
|
|
32
|
+
nodeLoader: AbstractTreeNodeLoaderWithProvider<IPresentationTreeDataProvider>;
|
|
33
|
+
nodeRenderer: (props: PresentationTreeNodeRendererProps) => React.ReactNode;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Base tree renderer for trees with enabled hierarchy level filtering.
|
|
37
|
+
* @beta
|
|
38
|
+
*/
|
|
39
|
+
export declare function FilterableTreeRenderer({ nodeRenderer, nodeLoader, ...restProps }: FilterableTreeRendererProps): JSX.Element;
|
|
26
40
|
//# sourceMappingURL=TreeRenderer.d.ts.map
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
/*---------------------------------------------------------------------------------------------
|
|
3
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
-
*--------------------------------------------------------------------------------------------*/
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
6
|
import "./TreeRenderer.scss";
|
|
7
7
|
import classNames from "classnames";
|
|
8
8
|
import { TreeRenderer as ComponentsTreeRenderer, TreeNodeRenderer } from "@itwin/components-react";
|
|
9
|
+
import { useFilterablePresentationTree } from "@itwin/presentation-components";
|
|
9
10
|
import { useContextMenu } from "./ContextMenu";
|
|
10
11
|
import { TreeNodeRendererContextProvider } from "./TreeNodeRenderer";
|
|
11
12
|
/**
|
|
@@ -18,11 +19,19 @@ export function TreeRenderer({ contextMenuItems, nodeRenderer, nodeLabelRenderer
|
|
|
18
19
|
const className = classNames("tree-widget-tree-nodes-list", { ["enlarge"]: density === "enlarged" });
|
|
19
20
|
return (_jsxs("div", { className: className, children: [_jsx(ComponentsTreeRenderer, { ...restProps, nodeRenderer: (nodeProps) => {
|
|
20
21
|
const nodeClassName = nodeProps.node.numChildren === 0 ? "without-expander" : undefined;
|
|
21
|
-
return (_jsx(TreeNodeRendererContextProvider, { node: nodeProps.node, nodeLabelRenderer: nodeLabelRenderer, children: nodeRenderer
|
|
22
|
-
? nodeRenderer({ ...nodeProps, onContextMenu, className: nodeClassName })
|
|
23
|
-
: _jsx(TreeNodeRenderer, { ...nodeProps, onContextMenu: onContextMenu, className: nodeClassName }) }));
|
|
22
|
+
return (_jsx(TreeNodeRendererContextProvider, { node: nodeProps.node, nodeLabelRenderer: nodeLabelRenderer, children: nodeRenderer ? (nodeRenderer({ ...nodeProps, onContextMenu, className: nodeClassName })) : (_jsx(TreeNodeRenderer, { ...nodeProps, onContextMenu: onContextMenu, className: nodeClassName })) }));
|
|
24
23
|
}, nodeHeight: nodeHeight }), renderContextMenu()] }));
|
|
25
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Base tree renderer for trees with enabled hierarchy level filtering.
|
|
27
|
+
* @beta
|
|
28
|
+
*/
|
|
29
|
+
export function FilterableTreeRenderer({ nodeRenderer, nodeLoader, ...restProps }) {
|
|
30
|
+
const { onClearFilterClick, onFilterClick, filterDialog } = useFilterablePresentationTree({ nodeLoader });
|
|
31
|
+
return (_jsxs("div", { children: [_jsx(TreeRenderer, { ...restProps, nodeLoader: nodeLoader, nodeRenderer: (props) => {
|
|
32
|
+
return nodeRenderer({ ...props, onClearFilterClick, onFilterClick });
|
|
33
|
+
} }), filterDialog] }));
|
|
34
|
+
}
|
|
26
35
|
function getNodeHeight(density, defaultHeight) {
|
|
27
36
|
switch (density) {
|
|
28
37
|
case "default":
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeRenderer.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/TreeRenderer.tsx"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"TreeRenderer.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/TreeRenderer.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,qBAAqB,CAAC;AAC7B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,YAAY,IAAI,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AACnG,OAAO,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,+BAA+B,EAAE,MAAM,oBAAoB,CAAC;AAuBrE;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,EAAE,gBAAgB,EAAE,YAAY,EAAE,iBAAiB,EAAE,OAAO,EAAE,GAAG,SAAS,EAAqB;IAC1H,MAAM,EAAE,aAAa,EAAE,iBAAiB,EAAE,GAAG,cAAc,CAAC,EAAE,gBAAgB,EAAE,CAAC,CAAC;IAElF,MAAM,UAAU,GAAG,aAAa,CAAC,OAAO,IAAI,SAAS,EAAE,SAAS,CAAC,UAAU,CAAC,CAAC;IAC7E,MAAM,SAAS,GAAG,UAAU,CAAC,6BAA6B,EAAE,EAAE,CAAC,SAAS,CAAC,EAAE,OAAO,KAAK,UAAU,EAAE,CAAC,CAAC;IAErG,OAAO,CACL,eAAK,SAAS,EAAE,SAAS,aACvB,KAAC,sBAAsB,OACjB,SAAS,EACb,YAAY,EAAE,CAAC,SAAS,EAAE,EAAE;oBAC1B,MAAM,aAAa,GAAG,SAAS,CAAC,IAAI,CAAC,WAAW,KAAK,CAAC,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,SAAS,CAAC;oBACxF,OAAO,CACL,KAAC,+BAA+B,IAAC,IAAI,EAAE,SAAS,CAAC,IAAI,EAAE,iBAAiB,EAAE,iBAAiB,YACxF,YAAY,CAAC,CAAC,CAAC,CACd,YAAY,CAAC,EAAE,GAAG,SAAS,EAAE,aAAa,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC,CACxE,CAAC,CAAC,CAAC,CACF,KAAC,gBAAgB,OAAK,SAAS,EAAE,aAAa,EAAE,aAAa,EAAE,SAAS,EAAE,aAAa,GAAI,CAC5F,GAC+B,CACnC,CAAC;gBACJ,CAAC,EACD,UAAU,EAAE,UAAU,GACtB,EACD,iBAAiB,EAAE,IAChB,CACP,CAAC;AACJ,CAAC;AAUD;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAC,EAAE,YAAY,EAAE,UAAU,EAAE,GAAG,SAAS,EAA+B;IAC5G,MAAM,EAAE,kBAAkB,EAAE,aAAa,EAAE,YAAY,EAAE,GAAG,6BAA6B,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC;IAE1G,OAAO,CACL,0BACE,KAAC,YAAY,OACP,SAAS,EACb,UAAU,EAAE,UAAU,EACtB,YAAY,EAAE,CAAC,KAAK,EAAE,EAAE;oBACtB,OAAO,YAAY,CAAC,EAAE,GAAG,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,CAAC,CAAC;gBACvE,CAAC,GACD,EACD,YAAY,IACT,CACP,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CAAC,OAA+B,EAAE,aAAwD;IAC9G,QAAQ,OAAO,EAAE;QACf,KAAK,SAAS;YACZ,OAAO,aAAa,CAAC;QACvB,KAAK,UAAU;YACb,OAAO,GAAG,EAAE,CAAC,EAAE,CAAC;KACnB;AACH,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 \"./TreeRenderer.scss\";\nimport classNames from \"classnames\";\nimport { TreeRenderer as ComponentsTreeRenderer, TreeNodeRenderer } from \"@itwin/components-react\";\nimport { useFilterablePresentationTree } from \"@itwin/presentation-components\";\nimport { useContextMenu } from \"./ContextMenu\";\nimport { TreeNodeRendererContextProvider } from \"./TreeNodeRenderer\";\n\nimport type { IPresentationTreeDataProvider, PresentationTreeNodeRendererProps } from \"@itwin/presentation-components\";\nimport type { AbstractTreeNodeLoaderWithProvider, TreeRendererProps as ComponentsTreeRendererProps } from \"@itwin/components-react\";\nimport type { TreeNodeRendererProps } from \"./TreeNodeRenderer\";\nimport type { TreeContextMenuProps } from \"./ContextMenu\";\n/**\n * Base props for [[TreeRenderer]] component.\n * @public\n */\nexport interface TreeRendererBaseProps extends TreeContextMenuProps, TreeNodeRendererProps {\n /**\n * Modifies the density of tree nodes. `enlarged` tree nodes have bigger height and bigger button hit boxes.\n */\n density?: \"default\" | \"enlarged\";\n}\n\n/**\n * Props for [[TreeRenderer]] component.\n * @public\n */\nexport type TreeRendererProps = ComponentsTreeRendererProps & TreeRendererBaseProps;\n\n/**\n * Base tree renderer for visibility trees.\n * @public\n */\nexport function TreeRenderer({ contextMenuItems, nodeRenderer, nodeLabelRenderer, density, ...restProps }: TreeRendererProps) {\n const { onContextMenu, renderContextMenu } = useContextMenu({ contextMenuItems });\n\n const nodeHeight = getNodeHeight(density ?? \"default\", restProps.nodeHeight);\n const className = classNames(\"tree-widget-tree-nodes-list\", { [\"enlarge\"]: density === \"enlarged\" });\n\n return (\n <div className={className}>\n <ComponentsTreeRenderer\n {...restProps}\n nodeRenderer={(nodeProps) => {\n const nodeClassName = nodeProps.node.numChildren === 0 ? \"without-expander\" : undefined;\n return (\n <TreeNodeRendererContextProvider node={nodeProps.node} nodeLabelRenderer={nodeLabelRenderer}>\n {nodeRenderer ? (\n nodeRenderer({ ...nodeProps, onContextMenu, className: nodeClassName })\n ) : (\n <TreeNodeRenderer {...nodeProps} onContextMenu={onContextMenu} className={nodeClassName} />\n )}\n </TreeNodeRendererContextProvider>\n );\n }}\n nodeHeight={nodeHeight}\n />\n {renderContextMenu()}\n </div>\n );\n}\n\n/**\n * Props for [[FilterableTreeRenderer]] component.\n * @beta\n */\nexport interface FilterableTreeRendererProps extends Omit<TreeRendererProps, \"nodeLoader\" | \"nodeRenderer\"> {\n nodeLoader: AbstractTreeNodeLoaderWithProvider<IPresentationTreeDataProvider>;\n nodeRenderer: (props: PresentationTreeNodeRendererProps) => React.ReactNode;\n}\n/**\n * Base tree renderer for trees with enabled hierarchy level filtering.\n * @beta\n */\nexport function FilterableTreeRenderer({ nodeRenderer, nodeLoader, ...restProps }: FilterableTreeRendererProps) {\n const { onClearFilterClick, onFilterClick, filterDialog } = useFilterablePresentationTree({ nodeLoader });\n\n return (\n <div>\n <TreeRenderer\n {...restProps}\n nodeLoader={nodeLoader}\n nodeRenderer={(props) => {\n return nodeRenderer({ ...props, onClearFilterClick, onFilterClick });\n }}\n />\n {filterDialog}\n </div>\n );\n}\n\nfunction getNodeHeight(density: \"default\" | \"enlarged\", defaultHeight: ComponentsTreeRendererProps[\"nodeHeight\"]) {\n switch (density) {\n case \"default\":\n return defaultHeight;\n case \"enlarged\":\n return () => 43;\n }\n}\n"]}
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
|
|
30
30
|
.core-tree-node {
|
|
31
31
|
&.without-expander {
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
> .contents {
|
|
33
|
+
> .core-tree-node-icon {
|
|
34
34
|
margin-left: 5px;
|
|
35
35
|
}
|
|
36
36
|
}
|
|
@@ -40,10 +40,15 @@
|
|
|
40
40
|
&.enlarge {
|
|
41
41
|
--enlarged-node-height: calc(var(--iui-size-l) + var(--iui-size-m) + var(--iui-size-3xs));
|
|
42
42
|
--enlarged-node-icon-size: var(--iui-size-m);
|
|
43
|
+
--enlarged-node-without-expander-margin: var(--iui-size-m);
|
|
43
44
|
--enlarged-node-icon-padding: calc(var(--enlarged-node-height) - var(--enlarged-node-icon-size));
|
|
44
45
|
--enlarged-node-expander-additional-padding: calc(var(--iui-size-l) - var(--iui-size-3xs) / 2);
|
|
45
46
|
|
|
46
47
|
.core-tree-node {
|
|
48
|
+
&.without-expander {
|
|
49
|
+
margin-left: var(--enlarged-node-without-expander-margin);
|
|
50
|
+
}
|
|
51
|
+
|
|
47
52
|
> .contents {
|
|
48
53
|
height: var(--enlarged-node-height);
|
|
49
54
|
font-size: var(--iui-font-size-2);
|
|
@@ -22,6 +22,14 @@ export interface VisibilityTreeFilterInfo {
|
|
|
22
22
|
filter: string;
|
|
23
23
|
activeMatchIndex?: number;
|
|
24
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Configuration for hierarchy levels. Setting it implies that hierarchy level filtering will be enabled.
|
|
27
|
+
* @beta
|
|
28
|
+
*/
|
|
29
|
+
export interface HierarchyLevelConfig {
|
|
30
|
+
isFilteringEnabled: true;
|
|
31
|
+
sizeLimit?: number;
|
|
32
|
+
}
|
|
25
33
|
/**
|
|
26
34
|
* Base props for tree components.
|
|
27
35
|
* @public
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*---------------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
-
*--------------------------------------------------------------------------------------------*/
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
/**
|
|
6
6
|
* An option of how class grouping should work in a component.
|
|
7
7
|
* @public
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Types.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/Types.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"Types.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/Types.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAOhG;;;GAGG;AACH,MAAM,CAAN,IAAY,mBAOX;AAPD,WAAY,mBAAmB;IAC7B,iCAAiC;IACjC,yDAAE,CAAA;IACF,gCAAgC;IAChC,2DAAG,CAAA;IACH,4EAA4E;IAC5E,+EAAa,CAAA;AACf,CAAC,EAPW,mBAAmB,KAAnB,mBAAmB,QAO9B","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 type { IModelConnection } from \"@itwin/core-frontend\";\nimport type { SelectionMode } from \"@itwin/components-react\";\nimport type { IPresentationTreeDataProvider } from \"@itwin/presentation-components\";\nimport type { TreeRendererBaseProps } from \"./TreeRenderer\";\n\n/**\n * An option of how class grouping should work in a component.\n * @public\n */\nexport enum ClassGroupingOption {\n /** Class grouping is disabled */\n No,\n /** Class grouping is enabled */\n Yes,\n /** Class grouping is enabled and grouping node shows grouped items count */\n YesWithCounts,\n}\n\n/**\n * Data structure that describes info used to filter visibility tree.\n * @public\n */\nexport interface VisibilityTreeFilterInfo {\n filter: string;\n activeMatchIndex?: number;\n}\n\n/**\n * Configuration for hierarchy levels. Setting it implies that hierarchy level filtering will be enabled.\n * @beta\n */\nexport interface HierarchyLevelConfig {\n isFilteringEnabled: true;\n sizeLimit?: number;\n}\n\n/**\n * Base props for tree components.\n * @public\n */\nexport interface BaseTreeProps extends TreeRendererBaseProps {\n /** An iModel to pull data from. */\n iModel: IModelConnection;\n /** Width of the component. */\n width: number;\n /** Height of the component. */\n height: number;\n /** Selection mode in the tree. */\n selectionMode?: SelectionMode;\n}\n\n/**\n * Base props for filterable tree components.\n * @public\n */\nexport interface BaseFilterableTreeProps extends BaseTreeProps {\n /** Information for tree filtering. */\n filterInfo?: VisibilityTreeFilterInfo;\n /** Callback invoked when tree is filtered. */\n onFilterApplied?: (filteredDataProvider: IPresentationTreeDataProvider, matchesCount: number) => void;\n}\n"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { VisibilityTreeEventHandler } from "../VisibilityTreeEventHandler";
|
|
2
|
+
import type { IModelConnection } from "@itwin/core-frontend";
|
|
3
|
+
import type { Ruleset } from "@itwin/presentation-common";
|
|
4
|
+
import type { IFilteredPresentationTreeDataProvider, UsePresentationTreeStateProps } from "@itwin/presentation-components";
|
|
5
|
+
import type { IVisibilityHandler, VisibilityTreeEventHandlerParams, VisibilityTreeSelectionPredicate } from "../VisibilityTreeEventHandler";
|
|
6
|
+
import type { VisibilityTreeFilterInfo } from "./Types";
|
|
7
|
+
/**
|
|
8
|
+
* Props for [[useVisibilityTreeState]] hook.
|
|
9
|
+
* @beta
|
|
10
|
+
*/
|
|
11
|
+
export interface UseVisibilityTreeStateProps extends Omit<UsePresentationTreeStateProps<VisibilityTreeEventHandler>, "rulesetOrId"> {
|
|
12
|
+
/** iModel to pull data from. */
|
|
13
|
+
imodel: IModelConnection;
|
|
14
|
+
/** Presentation rules to use when pulling data from iModel. */
|
|
15
|
+
ruleset: Ruleset;
|
|
16
|
+
/** Visibility handler that will be used to determine tree node visibility or change it. */
|
|
17
|
+
visibilityHandler?: IVisibilityHandler;
|
|
18
|
+
/** Info about filter that should be applied on tree. */
|
|
19
|
+
filterInfo?: VisibilityTreeFilterInfo;
|
|
20
|
+
/** Callback that is invoked when filter is applied, changed or removed. */
|
|
21
|
+
onFilterChange?: (filteredDataProvider?: IFilteredPresentationTreeDataProvider, matchesCount?: number) => void;
|
|
22
|
+
/** Callback that is used to determine if node can be selected. If not provided all nodes are selectable. */
|
|
23
|
+
selectionPredicate?: VisibilityTreeSelectionPredicate;
|
|
24
|
+
/** Factory for custom `VisibilityTreeEventHandler`. Defaults to `VisibilityTreeEventHandler`. */
|
|
25
|
+
eventHandler?: (props: VisibilityTreeEventHandlerParams) => VisibilityTreeEventHandler;
|
|
26
|
+
/** The limit for how many items should be loaded for a single hierarchy level. */
|
|
27
|
+
hierarchyLevelSizeLimit?: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Custom hook for creating visibility tree component state.
|
|
31
|
+
*
|
|
32
|
+
* @returns `undefined` on first render cycle. On all other render cycles state is initialized and valid object is returned.
|
|
33
|
+
* @beta
|
|
34
|
+
*/
|
|
35
|
+
export declare function useVisibilityTreeState({ imodel, ruleset, filterInfo, onFilterChange, visibilityHandler, selectionPredicate, eventHandler, ...props }: UseVisibilityTreeStateProps): import("@itwin/presentation-components").UsePresentationTreeStateResult<VisibilityTreeEventHandler> | undefined;
|
|
36
|
+
//# sourceMappingURL=UseVisibilityTreeState.d.ts.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
import { useCallback, useEffect } from "react";
|
|
6
|
+
import { usePresentationTreeState } from "@itwin/presentation-components";
|
|
7
|
+
import { VisibilityTreeEventHandler } from "../VisibilityTreeEventHandler";
|
|
8
|
+
/**
|
|
9
|
+
* Custom hook for creating visibility tree component state.
|
|
10
|
+
*
|
|
11
|
+
* @returns `undefined` on first render cycle. On all other render cycles state is initialized and valid object is returned.
|
|
12
|
+
* @beta
|
|
13
|
+
*/
|
|
14
|
+
export function useVisibilityTreeState({ imodel, ruleset, filterInfo, onFilterChange, visibilityHandler, selectionPredicate, eventHandler, ...props }) {
|
|
15
|
+
const eventHandlerFactory = useCallback((params) => {
|
|
16
|
+
if (!visibilityHandler) {
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
const eventHandlerProps = {
|
|
20
|
+
nodeLoader: params.nodeLoader,
|
|
21
|
+
visibilityHandler,
|
|
22
|
+
selectionPredicate,
|
|
23
|
+
};
|
|
24
|
+
return eventHandler ? eventHandler(eventHandlerProps) : new VisibilityTreeEventHandler(eventHandlerProps);
|
|
25
|
+
}, [visibilityHandler, selectionPredicate, eventHandler]);
|
|
26
|
+
const treeState = usePresentationTreeState({
|
|
27
|
+
...props,
|
|
28
|
+
imodel,
|
|
29
|
+
ruleset,
|
|
30
|
+
eventHandlerFactory,
|
|
31
|
+
filteringParams: filterInfo?.filter
|
|
32
|
+
? {
|
|
33
|
+
filter: filterInfo.filter,
|
|
34
|
+
activeMatchIndex: filterInfo?.activeMatchIndex,
|
|
35
|
+
}
|
|
36
|
+
: undefined,
|
|
37
|
+
});
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
onFilterChange && onFilterChange(treeState?.filteringResult?.filteredProvider, treeState?.filteringResult?.matchesCount);
|
|
40
|
+
}, [treeState?.filteringResult?.matchesCount, treeState?.filteringResult?.filteredProvider, onFilterChange]);
|
|
41
|
+
return treeState;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=UseVisibilityTreeState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UseVisibilityTreeState.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/UseVisibilityTreeState.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AA+B3E;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAAC,EACrC,MAAM,EACN,OAAO,EACP,UAAU,EACV,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,EACZ,GAAG,KAAK,EACoB;IAC5B,MAAM,mBAAmB,GAAG,WAAW,CACrC,CAAC,MAAyC,EAAE,EAAE;QAC5C,IAAI,CAAC,iBAAiB,EAAE;YACtB,OAAO,SAAS,CAAC;SAClB;QAED,MAAM,iBAAiB,GAAqC;YAC1D,UAAU,EAAE,MAAM,CAAC,UAAU;YAC7B,iBAAiB;YACjB,kBAAkB;SACnB,CAAC;QAEF,OAAO,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,IAAI,0BAA0B,CAAC,iBAAiB,CAAC,CAAC;IAC5G,CAAC,EACD,CAAC,iBAAiB,EAAE,kBAAkB,EAAE,YAAY,CAAC,CACtD,CAAC;IAEF,MAAM,SAAS,GAAG,wBAAwB,CAAC;QACzC,GAAG,KAAK;QACR,MAAM;QACN,OAAO;QACP,mBAAmB;QACnB,eAAe,EAAE,UAAU,EAAE,MAAM;YACjC,CAAC,CAAC;gBACE,MAAM,EAAE,UAAU,CAAC,MAAM;gBACzB,gBAAgB,EAAE,UAAU,EAAE,gBAAgB;aAC/C;YACH,CAAC,CAAC,SAAS;KACd,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,cAAc,IAAI,cAAc,CAAC,SAAS,EAAE,eAAe,EAAE,gBAAgB,EAAE,SAAS,EAAE,eAAe,EAAE,YAAY,CAAC,CAAC;IAC3H,CAAC,EAAE,CAAC,SAAS,EAAE,eAAe,EAAE,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,gBAAgB,EAAE,cAAc,CAAC,CAAC,CAAC;IAE7G,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useCallback, useEffect } from \"react\";\nimport { usePresentationTreeState } from \"@itwin/presentation-components\";\nimport { VisibilityTreeEventHandler } from \"../VisibilityTreeEventHandler\";\n\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport type { Ruleset } from \"@itwin/presentation-common\";\nimport type { IFilteredPresentationTreeDataProvider, PresentationTreeEventHandlerProps, UsePresentationTreeStateProps } from \"@itwin/presentation-components\";\nimport type { IVisibilityHandler, VisibilityTreeEventHandlerParams, VisibilityTreeSelectionPredicate } from \"../VisibilityTreeEventHandler\";\nimport type { VisibilityTreeFilterInfo } from \"./Types\";\n\n/**\n * Props for [[useVisibilityTreeState]] hook.\n * @beta\n */\nexport interface UseVisibilityTreeStateProps extends Omit<UsePresentationTreeStateProps<VisibilityTreeEventHandler>, \"rulesetOrId\"> {\n /** iModel to pull data from. */\n imodel: IModelConnection;\n /** Presentation rules to use when pulling data from iModel. */\n ruleset: Ruleset;\n /** Visibility handler that will be used to determine tree node visibility or change it. */\n visibilityHandler?: IVisibilityHandler;\n /** Info about filter that should be applied on tree. */\n filterInfo?: VisibilityTreeFilterInfo;\n /** Callback that is invoked when filter is applied, changed or removed. */\n onFilterChange?: (filteredDataProvider?: IFilteredPresentationTreeDataProvider, matchesCount?: number) => void;\n /** Callback that is used to determine if node can be selected. If not provided all nodes are selectable. */\n selectionPredicate?: VisibilityTreeSelectionPredicate;\n /** Factory for custom `VisibilityTreeEventHandler`. Defaults to `VisibilityTreeEventHandler`. */\n eventHandler?: (props: VisibilityTreeEventHandlerParams) => VisibilityTreeEventHandler;\n /** The limit for how many items should be loaded for a single hierarchy level. */\n hierarchyLevelSizeLimit?: number;\n}\n\n/**\n * Custom hook for creating visibility tree component state.\n *\n * @returns `undefined` on first render cycle. On all other render cycles state is initialized and valid object is returned.\n * @beta\n */\nexport function useVisibilityTreeState({\n imodel,\n ruleset,\n filterInfo,\n onFilterChange,\n visibilityHandler,\n selectionPredicate,\n eventHandler,\n ...props\n}: UseVisibilityTreeStateProps) {\n const eventHandlerFactory = useCallback(\n (params: PresentationTreeEventHandlerProps) => {\n if (!visibilityHandler) {\n return undefined;\n }\n\n const eventHandlerProps: VisibilityTreeEventHandlerParams = {\n nodeLoader: params.nodeLoader,\n visibilityHandler,\n selectionPredicate,\n };\n\n return eventHandler ? eventHandler(eventHandlerProps) : new VisibilityTreeEventHandler(eventHandlerProps);\n },\n [visibilityHandler, selectionPredicate, eventHandler],\n );\n\n const treeState = usePresentationTreeState({\n ...props,\n imodel,\n ruleset,\n eventHandlerFactory,\n filteringParams: filterInfo?.filter\n ? {\n filter: filterInfo.filter,\n activeMatchIndex: filterInfo?.activeMatchIndex,\n }\n : undefined,\n });\n\n useEffect(() => {\n onFilterChange && onFilterChange(treeState?.filteringResult?.filteredProvider, treeState?.filteringResult?.matchesCount);\n }, [treeState?.filteringResult?.matchesCount, treeState?.filteringResult?.filteredProvider, onFilterChange]);\n\n return treeState;\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*---------------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
-
*--------------------------------------------------------------------------------------------*/
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import { PropertyValueRendererManager } from "@itwin/components-react";
|
|
6
6
|
import { CheckBoxState } from "@itwin/core-react";
|
|
7
7
|
import { TREE_NODE_LABEL_RENDERER, TreeNodeLabelRenderer } from "./TreeNodeRenderer";
|
|
@@ -26,10 +26,12 @@ export function addTreeNodeItemCheckbox(item) {
|
|
|
26
26
|
}
|
|
27
27
|
/** @internal */
|
|
28
28
|
export function registerRenderers() {
|
|
29
|
-
const renderers = [
|
|
29
|
+
const renderers = [
|
|
30
|
+
{
|
|
30
31
|
name: TREE_NODE_LABEL_RENDERER,
|
|
31
32
|
renderer: new TreeNodeLabelRenderer(),
|
|
32
|
-
}
|
|
33
|
+
},
|
|
34
|
+
];
|
|
33
35
|
for (const { name, renderer } of renderers) {
|
|
34
36
|
PropertyValueRendererManager.defaultManager.registerRenderer(name, renderer);
|
|
35
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/Utils.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/Utils.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAKrF,gBAAgB;AAChB,MAAM,UAAU,iCAAiC,CAAC,cAA4F;IAC5I,OAAO,CAAC,IAAsC,EAAE,IAAmB,EAAE,EAAE;QACrE,cAAc,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IAC/D,CAAC,CAAC;AACJ,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,kCAAkC,CAAC,IAAsC;IACvF,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;QACf,OAAO;KACR;IAED,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,GAAG,EAAE,IAAI,EAAE,wBAAwB,EAAE,CAAC;AACpE,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,uBAAuB,CAAC,IAAsC;IAC5E,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;IAC9B,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC;IAC/B,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC,GAAG,CAAC;AACzC,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,iBAAiB;IAC/B,MAAM,SAAS,GAA8D;QAC3E;YACE,IAAI,EAAE,wBAAwB;YAC9B,QAAQ,EAAE,IAAI,qBAAqB,EAAE;SACtC;KACF,CAAC;IAEF,KAAK,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,SAAS,EAAE;QAC1C,4BAA4B,CAAC,cAAc,CAAC,gBAAgB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;KAC9E;IAED,OAAO,GAAG,EAAE;QACV,KAAK,MAAM,EAAE,IAAI,EAAE,IAAI,SAAS,EAAE;YAChC,4BAA4B,CAAC,cAAc,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;SACtE;IACH,CAAC,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 { PropertyValueRendererManager } from \"@itwin/components-react\";\nimport { CheckBoxState } from \"@itwin/core-react\";\nimport { TREE_NODE_LABEL_RENDERER, TreeNodeLabelRenderer } from \"./TreeNodeRenderer\";\n\nimport type { DelayLoadedTreeNodeItem, IPropertyValueRenderer } from \"@itwin/components-react\";\nimport type { Node } from \"@itwin/presentation-common\";\n\n/** @internal */\nexport function combineTreeNodeItemCustomizations(customizations: Array<(item: Partial<DelayLoadedTreeNodeItem>, node: Partial<Node>) => void>) {\n return (item: Partial<DelayLoadedTreeNodeItem>, node: Partial<Node>) => {\n customizations.forEach((customize) => customize(item, node));\n };\n}\n\n/** @internal */\nexport function addCustomTreeNodeItemLabelRenderer(item: Partial<DelayLoadedTreeNodeItem>) {\n if (!item.label) {\n return;\n }\n\n item.label.property.renderer = { name: TREE_NODE_LABEL_RENDERER };\n}\n\n/** @internal */\nexport function addTreeNodeItemCheckbox(item: Partial<DelayLoadedTreeNodeItem>) {\n item.isCheckboxVisible = true;\n item.isCheckboxDisabled = true;\n item.checkBoxState = CheckBoxState.Off;\n}\n\n/** @internal */\nexport function registerRenderers() {\n const renderers: Array<{ name: string; renderer: IPropertyValueRenderer }> = [\n {\n name: TREE_NODE_LABEL_RENDERER,\n renderer: new TreeNodeLabelRenderer(),\n },\n ];\n\n for (const { name, renderer } of renderers) {\n PropertyValueRendererManager.defaultManager.registerRenderer(name, renderer);\n }\n\n return () => {\n for (const { name } of renderers) {\n PropertyValueRendererManager.defaultManager.unregisterRenderer(name);\n }\n };\n}\n"]}
|