@itwin/tree-widget-react 3.0.0-dev.3 → 3.0.0-dev.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +122 -6
- package/lib/cjs/components/SelectableTree.js +1 -2
- package/lib/cjs/components/SelectableTree.js.map +1 -1
- package/lib/cjs/components/SelectableTree.scss +5 -0
- package/lib/cjs/components/tree-header/TreeHeader.d.ts +12 -9
- package/lib/cjs/components/tree-header/TreeHeader.js +4 -6
- package/lib/cjs/components/tree-header/TreeHeader.js.map +1 -1
- package/lib/cjs/components/tree-header/TreeWithHeader.d.ts +13 -0
- package/lib/cjs/components/tree-header/TreeWithHeader.js +20 -0
- package/lib/cjs/components/tree-header/TreeWithHeader.js.map +1 -0
- package/lib/cjs/components/trees/categories-tree/CategoriesTree.d.ts +3 -7
- package/lib/cjs/components/trees/categories-tree/CategoriesTree.js +7 -63
- package/lib/cjs/components/trees/categories-tree/CategoriesTree.js.map +1 -1
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeButtons.d.ts +9 -2
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeButtons.js +24 -4
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeButtons.js.map +1 -1
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeComponent.d.ts +0 -1
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeComponent.js +17 -19
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeComponent.js.map +1 -1
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeDefinition.d.ts +2 -2
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeDefinition.js +5 -4
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeDefinition.js.map +1 -1
- package/lib/cjs/components/trees/categories-tree/CategoriesVisibilityHandler.d.ts +1 -9
- package/lib/cjs/components/trees/categories-tree/CategoriesVisibilityHandler.js +2 -6
- package/lib/cjs/components/trees/categories-tree/CategoriesVisibilityHandler.js.map +1 -1
- package/lib/cjs/components/trees/categories-tree/UseCategoriesTree.d.ts +25 -0
- package/lib/cjs/components/trees/categories-tree/UseCategoriesTree.js +90 -0
- package/lib/cjs/components/trees/categories-tree/UseCategoriesTree.js.map +1 -0
- package/lib/cjs/components/trees/common/CategoriesVisibilityUtils.d.ts +6 -6
- package/lib/cjs/components/trees/common/CategoriesVisibilityUtils.js +32 -78
- package/lib/cjs/components/trees/common/CategoriesVisibilityUtils.js.map +1 -1
- package/lib/cjs/components/trees/common/FocusedInstancesContext.d.ts +1 -1
- package/lib/cjs/components/trees/common/FocusedInstancesContext.js.map +1 -1
- package/lib/cjs/components/trees/common/FocusedInstancesContextProvider.js +4 -4
- package/lib/cjs/components/trees/common/FocusedInstancesContextProvider.js.map +1 -1
- package/lib/cjs/components/trees/common/TreeErrors.d.ts +9 -0
- package/lib/cjs/components/trees/common/TreeErrors.js +19 -0
- package/lib/cjs/components/trees/common/TreeErrors.js.map +1 -0
- package/lib/cjs/components/trees/common/UseActiveViewport.d.ts +7 -0
- package/lib/cjs/components/trees/common/UseActiveViewport.js +25 -0
- package/lib/cjs/components/trees/common/UseActiveViewport.js.map +1 -0
- package/lib/cjs/components/trees/common/UseTelemetryContext.d.ts +1 -1
- package/lib/cjs/components/trees/common/UseTelemetryContext.js.map +1 -1
- package/lib/cjs/components/trees/common/components/Tree.d.ts +0 -2
- package/lib/cjs/components/trees/common/components/Tree.js +5 -4
- package/lib/cjs/components/trees/common/components/Tree.js.map +1 -1
- package/lib/cjs/components/trees/common/components/VisibilityTree.d.ts +2 -3
- package/lib/cjs/components/trees/common/components/VisibilityTree.js.map +1 -1
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.d.ts +1 -1
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js +1 -2
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js.map +1 -1
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.d.ts +1 -1
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTreeComponent.js +1 -2
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTreeComponent.js.map +1 -1
- package/lib/cjs/components/trees/index.d.ts +5 -0
- package/lib/cjs/components/trees/index.js +11 -1
- package/lib/cjs/components/trees/index.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsTree.d.ts +6 -11
- package/lib/cjs/components/trees/models-tree/ModelsTree.js +4 -203
- package/lib/cjs/components/trees/models-tree/ModelsTree.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsTreeButtons.d.ts +9 -3
- package/lib/cjs/components/trees/models-tree/ModelsTreeButtons.js +13 -3
- package/lib/cjs/components/trees/models-tree/ModelsTreeButtons.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.d.ts +1 -2
- package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.js +29 -21
- package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsTreeDefinition.d.ts +10 -6
- package/lib/cjs/components/trees/models-tree/ModelsTreeDefinition.js +63 -43
- package/lib/cjs/components/trees/models-tree/ModelsTreeDefinition.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/UseModelsTree.d.ts +38 -0
- package/lib/cjs/components/trees/models-tree/UseModelsTree.js +253 -0
- package/lib/cjs/components/trees/models-tree/UseModelsTree.js.map +1 -0
- package/lib/cjs/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js +5 -4
- package/lib/cjs/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js.map +1 -1
- package/lib/cjs/tree-widget-react.d.ts +1 -0
- package/lib/cjs/tree-widget-react.js +3 -1
- package/lib/cjs/tree-widget-react.js.map +1 -1
- package/lib/esm/components/SelectableTree.js +2 -3
- package/lib/esm/components/SelectableTree.js.map +1 -1
- package/lib/esm/components/SelectableTree.scss +5 -0
- package/lib/esm/components/tree-header/TreeHeader.d.ts +12 -9
- package/lib/esm/components/tree-header/TreeHeader.js +4 -6
- package/lib/esm/components/tree-header/TreeHeader.js.map +1 -1
- package/lib/esm/components/tree-header/TreeWithHeader.d.ts +13 -0
- package/lib/esm/components/tree-header/TreeWithHeader.js +13 -0
- package/lib/esm/components/tree-header/TreeWithHeader.js.map +1 -0
- package/lib/esm/components/trees/categories-tree/CategoriesTree.d.ts +3 -7
- package/lib/esm/components/trees/categories-tree/CategoriesTree.js +7 -63
- package/lib/esm/components/trees/categories-tree/CategoriesTree.js.map +1 -1
- package/lib/esm/components/trees/categories-tree/CategoriesTreeButtons.d.ts +9 -2
- package/lib/esm/components/trees/categories-tree/CategoriesTreeButtons.js +22 -4
- package/lib/esm/components/trees/categories-tree/CategoriesTreeButtons.js.map +1 -1
- package/lib/esm/components/trees/categories-tree/CategoriesTreeComponent.d.ts +0 -1
- package/lib/esm/components/trees/categories-tree/CategoriesTreeComponent.js +18 -17
- package/lib/esm/components/trees/categories-tree/CategoriesTreeComponent.js.map +1 -1
- package/lib/esm/components/trees/categories-tree/CategoriesTreeDefinition.d.ts +2 -2
- package/lib/esm/components/trees/categories-tree/CategoriesTreeDefinition.js +5 -4
- package/lib/esm/components/trees/categories-tree/CategoriesTreeDefinition.js.map +1 -1
- package/lib/esm/components/trees/categories-tree/CategoriesVisibilityHandler.d.ts +1 -9
- package/lib/esm/components/trees/categories-tree/CategoriesVisibilityHandler.js +2 -6
- package/lib/esm/components/trees/categories-tree/CategoriesVisibilityHandler.js.map +1 -1
- package/lib/esm/components/trees/categories-tree/UseCategoriesTree.d.ts +25 -0
- package/lib/esm/components/trees/categories-tree/UseCategoriesTree.js +86 -0
- package/lib/esm/components/trees/categories-tree/UseCategoriesTree.js.map +1 -0
- package/lib/esm/components/trees/common/CategoriesVisibilityUtils.d.ts +6 -6
- package/lib/esm/components/trees/common/CategoriesVisibilityUtils.js +33 -79
- package/lib/esm/components/trees/common/CategoriesVisibilityUtils.js.map +1 -1
- package/lib/esm/components/trees/common/FocusedInstancesContext.d.ts +1 -1
- package/lib/esm/components/trees/common/FocusedInstancesContext.js.map +1 -1
- package/lib/esm/components/trees/common/FocusedInstancesContextProvider.js +4 -4
- package/lib/esm/components/trees/common/FocusedInstancesContextProvider.js.map +1 -1
- package/lib/esm/components/trees/common/TreeErrors.d.ts +9 -0
- package/lib/esm/components/trees/common/TreeErrors.js +15 -0
- package/lib/esm/components/trees/common/TreeErrors.js.map +1 -0
- package/lib/esm/components/trees/common/UseActiveViewport.d.ts +7 -0
- package/lib/esm/components/trees/common/UseActiveViewport.js +21 -0
- package/lib/esm/components/trees/common/UseActiveViewport.js.map +1 -0
- package/lib/esm/components/trees/common/UseTelemetryContext.d.ts +1 -1
- package/lib/esm/components/trees/common/UseTelemetryContext.js.map +1 -1
- package/lib/esm/components/trees/common/components/Tree.d.ts +0 -2
- package/lib/esm/components/trees/common/components/Tree.js +5 -4
- package/lib/esm/components/trees/common/components/Tree.js.map +1 -1
- package/lib/esm/components/trees/common/components/VisibilityTree.d.ts +2 -3
- package/lib/esm/components/trees/common/components/VisibilityTree.js.map +1 -1
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.d.ts +1 -1
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js +1 -2
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js.map +1 -1
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.d.ts +1 -1
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTreeComponent.js +1 -2
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTreeComponent.js.map +1 -1
- package/lib/esm/components/trees/index.d.ts +5 -0
- package/lib/esm/components/trees/index.js +5 -0
- package/lib/esm/components/trees/index.js.map +1 -1
- package/lib/esm/components/trees/models-tree/ModelsTree.d.ts +6 -11
- package/lib/esm/components/trees/models-tree/ModelsTree.js +5 -204
- package/lib/esm/components/trees/models-tree/ModelsTree.js.map +1 -1
- package/lib/esm/components/trees/models-tree/ModelsTreeButtons.d.ts +9 -3
- package/lib/esm/components/trees/models-tree/ModelsTreeButtons.js +12 -2
- package/lib/esm/components/trees/models-tree/ModelsTreeButtons.js.map +1 -1
- package/lib/esm/components/trees/models-tree/ModelsTreeComponent.d.ts +1 -2
- package/lib/esm/components/trees/models-tree/ModelsTreeComponent.js +31 -20
- package/lib/esm/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
- package/lib/esm/components/trees/models-tree/ModelsTreeDefinition.d.ts +10 -6
- package/lib/esm/components/trees/models-tree/ModelsTreeDefinition.js +63 -43
- package/lib/esm/components/trees/models-tree/ModelsTreeDefinition.js.map +1 -1
- package/lib/esm/components/trees/models-tree/UseModelsTree.d.ts +38 -0
- package/lib/esm/components/trees/models-tree/UseModelsTree.js +249 -0
- package/lib/esm/components/trees/models-tree/UseModelsTree.js.map +1 -0
- package/lib/esm/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js +6 -5
- package/lib/esm/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js.map +1 -1
- package/lib/esm/tree-widget-react.d.ts +1 -0
- package/lib/esm/tree-widget-react.js +1 -0
- package/lib/esm/tree-widget-react.js.map +1 -1
- package/package.json +37 -41
- package/lib/cjs/components/trees/categories-tree/UseCategories.d.ts +0 -8
- package/lib/cjs/components/trees/categories-tree/UseCategories.js +0 -22
- package/lib/cjs/components/trees/categories-tree/UseCategories.js.map +0 -1
- package/lib/cjs/components/utils/AutoSizer.d.ts +0 -13
- package/lib/cjs/components/utils/AutoSizer.js +0 -21
- package/lib/cjs/components/utils/AutoSizer.js.map +0 -1
- package/lib/esm/components/trees/categories-tree/UseCategories.d.ts +0 -8
- package/lib/esm/components/trees/categories-tree/UseCategories.js +0 -18
- package/lib/esm/components/trees/categories-tree/UseCategories.js.map +0 -1
- package/lib/esm/components/utils/AutoSizer.d.ts +0 -13
- package/lib/esm/components/utils/AutoSizer.js +0 -17
- package/lib/esm/components/utils/AutoSizer.js.map +0 -1
- /package/lib/cjs/components/{trees/Tree.scss → tree-header/TreeWithHeader.scss} +0 -0
- /package/lib/esm/components/{trees/Tree.scss → tree-header/TreeWithHeader.scss} +0 -0
|
@@ -10,117 +10,71 @@ const core_frontend_1 = require("@itwin/core-frontend");
|
|
|
10
10
|
/**
|
|
11
11
|
* Toggles visibility of categories to show or hide.
|
|
12
12
|
*/
|
|
13
|
-
async function toggleAllCategories(
|
|
14
|
-
|
|
15
|
-
const activeView = viewport ?? viewManager.getFirstOpenView();
|
|
16
|
-
const ids = await getCategories(imodel, activeView);
|
|
17
|
-
// istanbul ignore if
|
|
13
|
+
async function toggleAllCategories(viewport, display) {
|
|
14
|
+
const ids = await getCategories(viewport);
|
|
18
15
|
if (ids.length === 0) {
|
|
19
16
|
return;
|
|
20
17
|
}
|
|
21
|
-
await enableCategoryDisplay(
|
|
18
|
+
await enableCategoryDisplay(viewport, ids, display);
|
|
22
19
|
}
|
|
23
20
|
exports.toggleAllCategories = toggleAllCategories;
|
|
24
21
|
/**
|
|
25
22
|
* Gets ids of all categories from specified imodel and viewport.
|
|
26
23
|
*/
|
|
27
|
-
async function getCategories(
|
|
28
|
-
const categories = await loadCategoriesFromViewport(
|
|
24
|
+
async function getCategories(viewport) {
|
|
25
|
+
const categories = await loadCategoriesFromViewport(viewport);
|
|
29
26
|
return categories.map((category) => category.categoryId);
|
|
30
27
|
}
|
|
31
28
|
exports.getCategories = getCategories;
|
|
32
29
|
/**
|
|
33
30
|
* Changes category display in the viewport.
|
|
34
31
|
*/
|
|
35
|
-
async function enableCategoryDisplay(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
//
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
vp.changeCategoryDisplay(ids, enabled, enableAllSubCategories);
|
|
44
|
-
// remove category overrides per model
|
|
45
|
-
const modelsContainingOverrides = [];
|
|
46
|
-
for (const ovr of vp.perModelCategoryVisibility) {
|
|
47
|
-
// istanbul ignore else
|
|
48
|
-
if (ids.findIndex((id) => id === ovr.categoryId) !== -1) {
|
|
49
|
-
modelsContainingOverrides.push(ovr.modelId);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
vp.perModelCategoryVisibility.setOverride(modelsContainingOverrides, ids, core_frontend_1.PerModelCategoryVisibility.Override.None);
|
|
53
|
-
// changeCategoryDisplay only enables subcategories, it does not disabled them. So we must do that ourselves.
|
|
54
|
-
if (false === enabled) {
|
|
55
|
-
(await imodel.categories.getCategoryInfo(ids)).forEach((categoryInfo) => {
|
|
56
|
-
categoryInfo.subCategories.forEach((value) => enableSubCategoryDisplay(viewManager, value.id, false, forAllViewports));
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
// This property let us act on all viewports or just on the selected one, configurable by the app
|
|
62
|
-
if (forAllViewports) {
|
|
63
|
-
for (const viewport of viewManager) {
|
|
64
|
-
await updateViewport(viewport);
|
|
32
|
+
async function enableCategoryDisplay(viewport, ids, enabled, enableAllSubCategories = true) {
|
|
33
|
+
viewport.changeCategoryDisplay(ids, enabled, enableAllSubCategories);
|
|
34
|
+
// remove category overrides per model
|
|
35
|
+
const modelsContainingOverrides = [];
|
|
36
|
+
for (const ovr of viewport.perModelCategoryVisibility) {
|
|
37
|
+
// istanbul ignore else
|
|
38
|
+
if (ids.findIndex((id) => id === ovr.categoryId) !== -1) {
|
|
39
|
+
modelsContainingOverrides.push(ovr.modelId);
|
|
65
40
|
}
|
|
66
41
|
}
|
|
67
|
-
|
|
68
|
-
|
|
42
|
+
viewport.perModelCategoryVisibility.setOverride(modelsContainingOverrides, ids, core_frontend_1.PerModelCategoryVisibility.Override.None);
|
|
43
|
+
// changeCategoryDisplay only enables subcategories, it does not disabled them. So we must do that ourselves.
|
|
44
|
+
if (false === enabled) {
|
|
45
|
+
(await viewport.iModel.categories.getCategoryInfo(ids)).forEach((categoryInfo) => {
|
|
46
|
+
categoryInfo.subCategories.forEach((value) => enableSubCategoryDisplay(viewport, value.id, false));
|
|
47
|
+
});
|
|
69
48
|
}
|
|
70
49
|
}
|
|
71
50
|
exports.enableCategoryDisplay = enableCategoryDisplay;
|
|
72
51
|
/**
|
|
73
52
|
* Changes subcategory display in the viewport
|
|
74
53
|
*/
|
|
75
|
-
function enableSubCategoryDisplay(
|
|
76
|
-
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
const updateViewport = (vp) => {
|
|
80
|
-
// Only act on viewports that are both 3D or both 2D. Important if we have multiple viewports opened and we
|
|
81
|
-
// are using 'allViewports' property
|
|
82
|
-
if (viewManager.selectedView && viewManager.selectedView.view.is3d() === vp.view.is3d()) {
|
|
83
|
-
vp.changeSubCategoryDisplay(key, enabled);
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
// This property let us act on all viewports or just on the selected one, configurable by the app
|
|
87
|
-
if (forAllViewports) {
|
|
88
|
-
for (const viewport of viewManager) {
|
|
89
|
-
updateViewport(viewport);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
updateViewport(viewManager.selectedView);
|
|
94
|
-
}
|
|
54
|
+
function enableSubCategoryDisplay(viewport, key, enabled) {
|
|
55
|
+
viewport.changeSubCategoryDisplay(key, enabled);
|
|
95
56
|
}
|
|
96
57
|
exports.enableSubCategoryDisplay = enableSubCategoryDisplay;
|
|
97
|
-
async function loadCategoriesFromViewport(
|
|
98
|
-
if (!vp) {
|
|
99
|
-
return EMPTY_CATEGORIES_ARRAY;
|
|
100
|
-
}
|
|
58
|
+
async function loadCategoriesFromViewport(vp) {
|
|
101
59
|
// Query categories and add them to state
|
|
102
60
|
const selectUsedSpatialCategoryIds = "SELECT DISTINCT Category.Id as id from BisCore.GeometricElement3d WHERE Category.Id IN (SELECT ECInstanceId from BisCore.SpatialCategory)";
|
|
103
61
|
const selectUsedDrawingCategoryIds = "SELECT DISTINCT Category.Id as id from BisCore.GeometricElement2d WHERE Model.Id=? AND Category.Id IN (SELECT ECInstanceId from BisCore.DrawingCategory)";
|
|
104
62
|
const ecsql = vp.view.is3d() ? selectUsedSpatialCategoryIds : selectUsedDrawingCategoryIds;
|
|
105
63
|
const ecsql2 = `SELECT ECInstanceId as id FROM ${vp.view.is3d() ? "BisCore.SpatialCategory" : "BisCore.DrawingCategory"} WHERE ECInstanceId IN (${ecsql})`;
|
|
106
64
|
const categories = [];
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
categories.push({ categoryId: val.id, subCategoryIds: val.subCategories.size ? [...val.subCategories.keys()] : undefined });
|
|
112
|
-
});
|
|
113
|
-
}
|
|
65
|
+
const rows = await vp.iModel.createQueryReader(ecsql2, undefined, { rowFormat: core_common_1.QueryRowFormat.UseJsPropertyNames }).toArray();
|
|
66
|
+
(await vp.iModel.categories.getCategoryInfo(rows.map((row) => row.id))).forEach((val) => {
|
|
67
|
+
categories.push({ categoryId: val.id, subCategoryIds: val.subCategories.size ? [...val.subCategories.keys()] : undefined });
|
|
68
|
+
});
|
|
114
69
|
return categories;
|
|
115
70
|
}
|
|
116
71
|
exports.loadCategoriesFromViewport = loadCategoriesFromViewport;
|
|
117
|
-
const EMPTY_CATEGORIES_ARRAY = [];
|
|
118
72
|
/**
|
|
119
73
|
* Enable display of all given categories.
|
|
120
74
|
* @public
|
|
121
75
|
*/
|
|
122
76
|
async function showAllCategories(categories, viewport) {
|
|
123
|
-
await enableCategoryDisplay(
|
|
77
|
+
await enableCategoryDisplay(viewport, categories, true, true);
|
|
124
78
|
}
|
|
125
79
|
exports.showAllCategories = showAllCategories;
|
|
126
80
|
/**
|
|
@@ -128,7 +82,7 @@ exports.showAllCategories = showAllCategories;
|
|
|
128
82
|
* @public
|
|
129
83
|
*/
|
|
130
84
|
async function hideAllCategories(categories, viewport) {
|
|
131
|
-
await enableCategoryDisplay(
|
|
85
|
+
await enableCategoryDisplay(viewport, categories, false, true);
|
|
132
86
|
}
|
|
133
87
|
exports.hideAllCategories = hideAllCategories;
|
|
134
88
|
/**
|
|
@@ -156,11 +110,11 @@ async function invertAllCategories(categories, viewport) {
|
|
|
156
110
|
}
|
|
157
111
|
}
|
|
158
112
|
// Disable enabled
|
|
159
|
-
enabledSubCategories.forEach((subCategory) => enableSubCategoryDisplay(
|
|
160
|
-
await enableCategoryDisplay(
|
|
113
|
+
enabledSubCategories.forEach((subCategory) => enableSubCategoryDisplay(viewport, subCategory, false));
|
|
114
|
+
await enableCategoryDisplay(viewport, enabled, false, true);
|
|
161
115
|
// Enable disabled
|
|
162
|
-
disabledSubCategories.forEach((subCategory) => enableSubCategoryDisplay(
|
|
163
|
-
await enableCategoryDisplay(
|
|
116
|
+
disabledSubCategories.forEach((subCategory) => enableSubCategoryDisplay(viewport, subCategory, true));
|
|
117
|
+
await enableCategoryDisplay(viewport, disabled, true, true);
|
|
164
118
|
}
|
|
165
119
|
exports.invertAllCategories = invertAllCategories;
|
|
166
120
|
//# sourceMappingURL=CategoriesVisibilityUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CategoriesVisibilityUtils.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/CategoriesVisibilityUtils.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,oDAAoD;AACpD,wDAA6E;AAa7E;;GAEG;AACI,KAAK,UAAU,mBAAmB,CACvC,WAAwB,EACxB,MAAwB,EACxB,OAAgB,EAChB,QAAmB,EACnB,eAAyB;IAEzB,uBAAuB;IACvB,MAAM,UAAU,GAAG,QAAQ,IAAI,WAAW,CAAC,gBAAgB,EAAE,CAAC;IAC9D,MAAM,GAAG,GAAG,MAAM,aAAa,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAEpD,qBAAqB;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MAAM,WAAW,IAAI,QAAQ,CAAC,cAAc,EAAE;gBACjD,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;aAC/H;SACF;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,wBAAwB,CAAC,yBAAS,CAAC,WAAW,EAAE,WAAW,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;IAEzH,MAAM,qBAAqB,CAAC,yBAAS,CAAC,WAAW,EAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;IAE1F,kBAAkB;IAClB,qBAAqB,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,wBAAwB,CAAC,yBAAS,CAAC,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IAEzH,MAAM,qBAAqB,CAAC,yBAAS,CAAC,WAAW,EAAE,QAAQ,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAC5F,CAAC;AA9BD,kDA8BC","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 { QueryRowFormat } from \"@itwin/core-common\";\nimport { IModelApp, PerModelCategoryVisibility } from \"@itwin/core-frontend\";\n\nimport type { IModelConnection, ViewManager, Viewport } from \"@itwin/core-frontend\";\n\n/**\n * Data structure that describes category.\n * @beta\n */\nexport interface CategoryInfo {\n categoryId: string;\n subCategoryIds?: string[];\n}\n\n/**\n * Toggles visibility of categories to show or hide.\n */\nexport async function toggleAllCategories(\n viewManager: ViewManager,\n imodel: IModelConnection,\n display: boolean,\n viewport?: Viewport,\n forAllViewports?: boolean,\n) {\n // istanbul ignore next\n const activeView = viewport ?? viewManager.getFirstOpenView();\n const ids = await getCategories(imodel, activeView);\n\n // istanbul ignore if\n if (ids.length === 0) {\n return;\n }\n\n await enableCategoryDisplay(viewManager, imodel, ids, display, forAllViewports ?? false);\n}\n\n/**\n * Gets ids of all categories from specified imodel and viewport.\n */\nexport async function getCategories(imodel: IModelConnection, viewport?: Viewport) {\n const categories = await loadCategoriesFromViewport(imodel, viewport);\n return categories.map((category) => category.categoryId);\n}\n\n/**\n * Changes category display in the viewport.\n */\nexport async function enableCategoryDisplay(\n viewManager: ViewManager,\n imodel: IModelConnection,\n ids: string[],\n enabled: boolean,\n forAllViewports: boolean,\n enableAllSubCategories = true,\n) {\n if (!viewManager.selectedView) {\n return;\n }\n\n const updateViewport = async (vp: Viewport) => {\n // Only act on viewports that are both 3D or both 2D. Important if we have multiple viewports opened and we\n // are using 'allViewports' property\n if (viewManager.selectedView && viewManager.selectedView.view.is3d() === vp.view.is3d()) {\n vp.changeCategoryDisplay(ids, enabled, enableAllSubCategories);\n\n // remove category overrides per model\n const modelsContainingOverrides: string[] = [];\n for (const ovr of vp.perModelCategoryVisibility) {\n // istanbul ignore else\n if (ids.findIndex((id) => id === ovr.categoryId) !== -1) {\n modelsContainingOverrides.push(ovr.modelId);\n }\n }\n vp.perModelCategoryVisibility.setOverride(modelsContainingOverrides, ids, PerModelCategoryVisibility.Override.None);\n\n // changeCategoryDisplay only enables subcategories, it does not disabled them. So we must do that ourselves.\n if (false === enabled) {\n (await imodel.categories.getCategoryInfo(ids)).forEach((categoryInfo) => {\n categoryInfo.subCategories.forEach((value) => enableSubCategoryDisplay(viewManager, value.id, false, forAllViewports));\n });\n }\n }\n };\n\n // This property let us act on all viewports or just on the selected one, configurable by the app\n if (forAllViewports) {\n for (const viewport of viewManager) {\n await updateViewport(viewport);\n }\n } else {\n await updateViewport(viewManager.selectedView);\n }\n}\n\n/**\n * Changes subcategory display in the viewport\n */\nexport function enableSubCategoryDisplay(viewManager: ViewManager, key: string, enabled: boolean, forAllViewports?: boolean) {\n if (!viewManager.selectedView) {\n return;\n }\n\n const updateViewport = (vp: Viewport) => {\n // Only act on viewports that are both 3D or both 2D. Important if we have multiple viewports opened and we\n // are using 'allViewports' property\n if (viewManager.selectedView && viewManager.selectedView.view.is3d() === vp.view.is3d()) {\n vp.changeSubCategoryDisplay(key, enabled);\n }\n };\n\n // This property let us act on all viewports or just on the selected one, configurable by the app\n if (forAllViewports) {\n for (const viewport of viewManager) {\n updateViewport(viewport);\n }\n } else {\n updateViewport(viewManager.selectedView);\n }\n}\n\nexport async function loadCategoriesFromViewport(iModel?: IModelConnection, vp?: Viewport) {\n if (!vp) {\n return EMPTY_CATEGORIES_ARRAY;\n }\n\n // Query categories and add them to state\n const selectUsedSpatialCategoryIds =\n \"SELECT DISTINCT Category.Id as id from BisCore.GeometricElement3d WHERE Category.Id IN (SELECT ECInstanceId from BisCore.SpatialCategory)\";\n const selectUsedDrawingCategoryIds =\n \"SELECT DISTINCT Category.Id as id from BisCore.GeometricElement2d WHERE Model.Id=? AND Category.Id IN (SELECT ECInstanceId from BisCore.DrawingCategory)\";\n const ecsql = vp.view.is3d() ? selectUsedSpatialCategoryIds : selectUsedDrawingCategoryIds;\n const ecsql2 = `SELECT ECInstanceId as id FROM ${vp.view.is3d() ? \"BisCore.SpatialCategory\" : \"BisCore.DrawingCategory\"} WHERE ECInstanceId IN (${ecsql})`;\n\n const categories: CategoryInfo[] = [];\n\n // istanbul ignore else\n if (iModel) {\n const rows = await iModel.createQueryReader(ecsql2, undefined, { rowFormat: QueryRowFormat.UseJsPropertyNames }).toArray();\n (await iModel.categories.getCategoryInfo(rows.map((row) => row.id))).forEach((val) => {\n categories.push({ categoryId: val.id, subCategoryIds: val.subCategories.size ? [...val.subCategories.keys()] : undefined });\n });\n }\n return categories;\n}\nconst EMPTY_CATEGORIES_ARRAY: CategoryInfo[] = [];\n\n/**\n * Enable display of all given categories.\n * @public\n */\nexport async function showAllCategories(categories: string[], viewport: Viewport) {\n await enableCategoryDisplay(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 enableCategoryDisplay(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) => enableSubCategoryDisplay(IModelApp.viewManager, subCategory, false, true));\n\n await enableCategoryDisplay(IModelApp.viewManager, viewport.iModel, enabled, false, true);\n\n // Enable disabled\n disabledSubCategories.forEach((subCategory) => enableSubCategoryDisplay(IModelApp.viewManager, subCategory, true, true));\n\n await enableCategoryDisplay(IModelApp.viewManager, viewport.iModel, disabled, true, true);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CategoriesVisibilityUtils.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/CategoriesVisibilityUtils.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,oDAAoD;AACpD,wDAAkE;AAalE;;GAEG;AACI,KAAK,U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WAAW,CAAC,CAAC,EAAE;YAC/F,KAAK,MAAM,WAAW,IAAI,QAAQ,CAAC,cAAc,EAAE;gBACjD,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;aAC/H;SACF;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,wBAAwB,CAAC,QAAQ,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC;IAEtG,MAAM,qBAAqB,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;IAE5D,kBAAkB;IAClB,qBAAqB,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,wBAAwB,CAAC,QAAQ,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC;IAEtG,MAAM,qBAAqB,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAC9D,CAAC;AA9BD,kDA8BC","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 { QueryRowFormat } from \"@itwin/core-common\";\nimport { PerModelCategoryVisibility } from \"@itwin/core-frontend\";\n\nimport type { Viewport } from \"@itwin/core-frontend\";\n\n/**\n * Data structure that describes category.\n * @beta\n */\nexport interface CategoryInfo {\n categoryId: string;\n subCategoryIds?: string[];\n}\n\n/**\n * Toggles visibility of categories to show or hide.\n */\nexport async function toggleAllCategories(viewport: Viewport, display: boolean) {\n const ids = await getCategories(viewport);\n if (ids.length === 0) {\n return;\n }\n\n await enableCategoryDisplay(viewport, ids, display);\n}\n\n/**\n * Gets ids of all categories from specified imodel and viewport.\n */\nexport async function getCategories(viewport: Viewport) {\n const categories = await loadCategoriesFromViewport(viewport);\n return categories.map((category) => category.categoryId);\n}\n\n/**\n * Changes category display in the viewport.\n */\nexport async function enableCategoryDisplay(viewport: Viewport, ids: string[], enabled: boolean, enableAllSubCategories = true) {\n viewport.changeCategoryDisplay(ids, enabled, enableAllSubCategories);\n\n // remove category overrides per model\n const modelsContainingOverrides: string[] = [];\n for (const ovr of viewport.perModelCategoryVisibility) {\n // istanbul ignore else\n if (ids.findIndex((id) => id === ovr.categoryId) !== -1) {\n modelsContainingOverrides.push(ovr.modelId);\n }\n }\n viewport.perModelCategoryVisibility.setOverride(modelsContainingOverrides, ids, PerModelCategoryVisibility.Override.None);\n\n // changeCategoryDisplay only enables subcategories, it does not disabled them. So we must do that ourselves.\n if (false === enabled) {\n (await viewport.iModel.categories.getCategoryInfo(ids)).forEach((categoryInfo) => {\n categoryInfo.subCategories.forEach((value) => enableSubCategoryDisplay(viewport, value.id, false));\n });\n }\n}\n\n/**\n * Changes subcategory display in the viewport\n */\nexport function enableSubCategoryDisplay(viewport: Viewport, key: string, enabled: boolean) {\n viewport.changeSubCategoryDisplay(key, enabled);\n}\n\nexport async function loadCategoriesFromViewport(vp: Viewport) {\n // Query categories and add them to state\n const selectUsedSpatialCategoryIds =\n \"SELECT DISTINCT Category.Id as id from BisCore.GeometricElement3d WHERE Category.Id IN (SELECT ECInstanceId from BisCore.SpatialCategory)\";\n const selectUsedDrawingCategoryIds =\n \"SELECT DISTINCT Category.Id as id from BisCore.GeometricElement2d WHERE Model.Id=? AND Category.Id IN (SELECT ECInstanceId from BisCore.DrawingCategory)\";\n const ecsql = vp.view.is3d() ? selectUsedSpatialCategoryIds : selectUsedDrawingCategoryIds;\n const ecsql2 = `SELECT ECInstanceId as id FROM ${vp.view.is3d() ? \"BisCore.SpatialCategory\" : \"BisCore.DrawingCategory\"} WHERE ECInstanceId IN (${ecsql})`;\n\n const categories: CategoryInfo[] = [];\n\n const rows = await vp.iModel.createQueryReader(ecsql2, undefined, { rowFormat: QueryRowFormat.UseJsPropertyNames }).toArray();\n (await vp.iModel.categories.getCategoryInfo(rows.map((row) => row.id))).forEach((val) => {\n categories.push({ categoryId: val.id, subCategoryIds: val.subCategories.size ? [...val.subCategories.keys()] : undefined });\n });\n return categories;\n}\n\n/**\n * Enable display of all given categories.\n * @public\n */\nexport async function showAllCategories(categories: string[], viewport: Viewport) {\n await enableCategoryDisplay(viewport, 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 enableCategoryDisplay(viewport, 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) => enableSubCategoryDisplay(viewport, subCategory, false));\n\n await enableCategoryDisplay(viewport, enabled, false, true);\n\n // Enable disabled\n disabledSubCategories.forEach((subCategory) => enableSubCategoryDisplay(viewport, subCategory, true));\n\n await enableCategoryDisplay(viewport, disabled, true, true);\n}\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import type { InstanceKey } from "@itwin/presentation-shared";
|
|
3
3
|
import type { GroupingHierarchyNode } from "@itwin/presentation-hierarchies";
|
|
4
4
|
export interface FocusedInstancesContext {
|
|
5
|
-
|
|
5
|
+
loadFocusedItems?: () => AsyncIterableIterator<InstanceKey | GroupingHierarchyNode>;
|
|
6
6
|
enabled: boolean;
|
|
7
7
|
toggle: () => void;
|
|
8
8
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FocusedInstancesContext.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/FocusedInstancesContext.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,iCAAkD;AAWrC,QAAA,uBAAuB,GAAG,IAAA,qBAAa,EAA0B,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,CAAC,CAAC;AAEpH,SAAgB,0BAA0B;IACxC,OAAO,IAAA,kBAAU,EAAC,+BAAuB,CAAC,CAAC;AAC7C,CAAC;AAFD,gEAEC","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\";\n\nimport type { InstanceKey } from \"@itwin/presentation-shared\";\nimport type { GroupingHierarchyNode } from \"@itwin/presentation-hierarchies\";\n\nexport interface FocusedInstancesContext {\n
|
|
1
|
+
{"version":3,"file":"FocusedInstancesContext.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/FocusedInstancesContext.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,iCAAkD;AAWrC,QAAA,uBAAuB,GAAG,IAAA,qBAAa,EAA0B,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,CAAC,CAAC;AAEpH,SAAgB,0BAA0B;IACxC,OAAO,IAAA,kBAAU,EAAC,+BAAuB,CAAC,CAAC;AAC7C,CAAC;AAFD,gEAEC","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\";\n\nimport type { InstanceKey } from \"@itwin/presentation-shared\";\nimport type { GroupingHierarchyNode } from \"@itwin/presentation-hierarchies\";\n\nexport interface FocusedInstancesContext {\n loadFocusedItems?: () => AsyncIterableIterator<InstanceKey | GroupingHierarchyNode>;\n enabled: boolean;\n toggle: () => void;\n}\n\nexport const focusedInstancesContext = createContext<FocusedInstancesContext>({ enabled: false, toggle: () => {} });\n\nexport function useFocusedInstancesContext() {\n return useContext(focusedInstancesContext);\n}\n"]}
|
|
@@ -20,13 +20,13 @@ function FocusedInstancesContextProvider({ selectionStorage, imodelKey, children
|
|
|
20
20
|
const enabled = state.enabled;
|
|
21
21
|
(0, react_1.useEffect)(() => {
|
|
22
22
|
if (!enabled) {
|
|
23
|
-
setState((prev) => ({ ...prev,
|
|
23
|
+
setState((prev) => ({ ...prev, loadFocusedItems: undefined }));
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
26
|
const onSelectionChanged = () => {
|
|
27
27
|
const selection = selectionStorage.getSelection({ imodelKey, level: 0 });
|
|
28
28
|
if (unified_selection_1.Selectables.isEmpty(selection)) {
|
|
29
|
-
setState((prev) => ({ ...prev,
|
|
29
|
+
setState((prev) => ({ ...prev, loadFocusedItems: undefined }));
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
32
|
const selected = [];
|
|
@@ -41,7 +41,7 @@ function FocusedInstancesContextProvider({ selectionStorage, imodelKey, children
|
|
|
41
41
|
}
|
|
42
42
|
selected.push(selectable.loadInstanceKeys);
|
|
43
43
|
});
|
|
44
|
-
const
|
|
44
|
+
const loadFocusedItems = async function* () {
|
|
45
45
|
for (const item of selected) {
|
|
46
46
|
if (typeof item === "function") {
|
|
47
47
|
yield* item();
|
|
@@ -51,7 +51,7 @@ function FocusedInstancesContextProvider({ selectionStorage, imodelKey, children
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
};
|
|
54
|
-
setState((prev) => ({ ...prev,
|
|
54
|
+
setState((prev) => ({ ...prev, loadFocusedItems }));
|
|
55
55
|
};
|
|
56
56
|
onSelectionChanged();
|
|
57
57
|
return selectionStorage.selectionChangeEvent.addListener(({ imodelKey: changeImodelKey, level }) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FocusedInstancesContextProvider.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/FocusedInstancesContextProvider.tsx"],"names":[],"mappings":";;;;AAAA;;;gGAGgG;AAEhG,iCAA4C;AAC5C,0FAAsE;AACtE,gEAAmE;AACnE,uEAAoE;AAQpE,SAAgB,+BAA+B,CAAC,EAC9C,gBAAgB,EAChB,SAAS,EACT,QAAQ,GACqE;IAC7E,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EAA0B;QAC1D,OAAO,EAAE,KAAK;QACd,MAAM,EAAE,GAAG,EAAE;YACX,QAAQ,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QAC5D,CAAC;KACF,CAAC,CAAC;IACH,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;IAE9B,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,CAAC,OAAO,EAAE;YACZ,QAAQ,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,gBAAgB,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;YAC/D,OAAO;SACR;QAED,MAAM,kBAAkB,GAAG,GAAG,EAAE;YAC9B,MAAM,SAAS,GAAG,gBAAgB,CAAC,YAAY,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC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;YACjG,IAAI,eAAe,KAAK,SAAS,IAAI,KAAK,KAAK,CAAC,EAAE;gBAChD,OAAO;aACR;YACD,kBAAkB,EAAE,CAAC;QACvB,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,OAAO,EAAE,SAAS,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAE3C,OAAO,uBAAC,iDAAuB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAAoC,CAAC;AACvG,CAAC;AAhED,0EAgEC;AAED,SAAS,eAAe,CAAC,IAAa;IACpC,OAAO,CAAC,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,KAAK,IAAI,IAAI,CAAC;AAC7D,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useEffect, useState } from \"react\";\nimport { HierarchyNode } from \"@itwin/presentation-hierarchies-react\";\nimport { Selectable, Selectables } from \"@itwin/unified-selection\";\nimport { focusedInstancesContext } from \"./FocusedInstancesContext\";\n\nimport type { SelectionStorage } from \"@itwin/presentation-hierarchies-react\";\nimport type { PropsWithChildren } from \"react\";\nimport type { InstanceKey } from \"@itwin/presentation-common\";\nimport type { FocusedInstancesContext } from \"./FocusedInstancesContext\";\nimport type { GroupingHierarchyNode } from \"@itwin/presentation-hierarchies\";\n\nexport function FocusedInstancesContextProvider({\n selectionStorage,\n imodelKey,\n children,\n}: PropsWithChildren<{ selectionStorage: SelectionStorage; imodelKey: string }>) {\n const [state, setState] = useState<FocusedInstancesContext>({\n enabled: false,\n toggle: () => {\n setState((prev) => ({ ...prev, enabled: !prev.enabled }));\n },\n });\n const enabled = state.enabled;\n\n useEffect(() => {\n if (!enabled) {\n setState((prev) => ({ ...prev,
|
|
1
|
+
{"version":3,"file":"FocusedInstancesContextProvider.js","sourceRoot":"","sources":["../../../../../src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CAAC,IAAa;IACpC,OAAO,CAAC,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,KAAK,IAAI,IAAI,CAAC;AAC7D,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useEffect, useState } from \"react\";\nimport { HierarchyNode } from \"@itwin/presentation-hierarchies-react\";\nimport { Selectable, Selectables } from \"@itwin/unified-selection\";\nimport { focusedInstancesContext } from \"./FocusedInstancesContext\";\n\nimport type { SelectionStorage } from \"@itwin/presentation-hierarchies-react\";\nimport type { PropsWithChildren } from \"react\";\nimport type { InstanceKey } from \"@itwin/presentation-common\";\nimport type { FocusedInstancesContext } from \"./FocusedInstancesContext\";\nimport type { GroupingHierarchyNode } from \"@itwin/presentation-hierarchies\";\n\nexport function FocusedInstancesContextProvider({\n selectionStorage,\n imodelKey,\n children,\n}: PropsWithChildren<{ selectionStorage: SelectionStorage; imodelKey: string }>) {\n const [state, setState] = useState<FocusedInstancesContext>({\n enabled: false,\n toggle: () => {\n setState((prev) => ({ ...prev, enabled: !prev.enabled }));\n },\n });\n const enabled = state.enabled;\n\n useEffect(() => {\n if (!enabled) {\n setState((prev) => ({ ...prev, loadFocusedItems: undefined }));\n return;\n }\n\n const onSelectionChanged = () => {\n const selection = selectionStorage.getSelection({ imodelKey, level: 0 });\n if (Selectables.isEmpty(selection)) {\n setState((prev) => ({ ...prev, loadFocusedItems: undefined }));\n return;\n }\n\n const selected: Array<InstanceKey | GroupingHierarchyNode | (() => AsyncIterableIterator<InstanceKey>)> = [];\n Selectables.forEach(selection, (selectable) => {\n if (Selectable.isInstanceKey(selectable)) {\n selected.push(selectable);\n return;\n }\n\n if (isHierarchyNode(selectable.data) && HierarchyNode.isGroupingNode(selectable.data)) {\n selected.push(selectable.data);\n return;\n }\n\n selected.push(selectable.loadInstanceKeys);\n });\n\n const loadFocusedItems: () => AsyncIterableIterator<InstanceKey | GroupingHierarchyNode> = async function* () {\n for (const item of selected) {\n if (typeof item === \"function\") {\n yield* item();\n } else {\n yield item;\n }\n }\n };\n\n setState((prev) => ({ ...prev, loadFocusedItems }));\n };\n\n onSelectionChanged();\n return selectionStorage.selectionChangeEvent.addListener(({ imodelKey: changeImodelKey, level }) => {\n if (changeImodelKey !== imodelKey || level !== 0) {\n return;\n }\n onSelectionChanged();\n });\n }, [enabled, imodelKey, selectionStorage]);\n\n return <focusedInstancesContext.Provider value={state}>{children}</focusedInstancesContext.Provider>;\n}\n\nfunction isHierarchyNode(data: unknown): data is HierarchyNode {\n return !!data && typeof data === \"object\" && \"key\" in data;\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error that is thrown when too many matches are found while filtering the tree.
|
|
3
|
+
* @beta
|
|
4
|
+
*/
|
|
5
|
+
export declare class FilterLimitExceededError extends Error {
|
|
6
|
+
readonly limit: number;
|
|
7
|
+
constructor(limit: number);
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=TreeErrors.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
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
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.FilterLimitExceededError = void 0;
|
|
8
|
+
/**
|
|
9
|
+
* Error that is thrown when too many matches are found while filtering the tree.
|
|
10
|
+
* @beta
|
|
11
|
+
*/
|
|
12
|
+
class FilterLimitExceededError extends Error {
|
|
13
|
+
constructor(limit) {
|
|
14
|
+
super("Too many filter matches");
|
|
15
|
+
this.limit = limit;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.FilterLimitExceededError = FilterLimitExceededError;
|
|
19
|
+
//# sourceMappingURL=TreeErrors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TreeErrors.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/TreeErrors.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG;;;GAGG;AACH,MAAa,wBAAyB,SAAQ,KAAK;IACjD,YAAmC,KAAa;QAC9C,KAAK,CAAC,yBAAyB,CAAC,CAAC;QADA,UAAK,GAAL,KAAK,CAAQ;IAEhD,CAAC;CACF;AAJD,4DAIC","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\n/**\n * Error that is thrown when too many matches are found while filtering the tree.\n * @beta\n */\nexport class FilterLimitExceededError extends Error {\n public constructor(public readonly limit: number) {\n super(\"Too many filter matches\");\n }\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ScreenViewport } from "@itwin/core-frontend";
|
|
2
|
+
/**
|
|
3
|
+
* A copy of `useActiveViewport` from `@itwin/appui-react` package until X is fixed.
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export declare function useActiveViewport(): ScreenViewport | undefined;
|
|
7
|
+
//# sourceMappingURL=UseActiveViewport.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
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
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.useActiveViewport = void 0;
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const core_frontend_1 = require("@itwin/core-frontend");
|
|
10
|
+
/**
|
|
11
|
+
* A copy of `useActiveViewport` from `@itwin/appui-react` package until X is fixed.
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
function useActiveViewport() {
|
|
15
|
+
const [activeViewport, setActiveViewport] = (0, react_1.useState)(core_frontend_1.IModelApp.viewManager.selectedView);
|
|
16
|
+
(0, react_1.useEffect)(() => {
|
|
17
|
+
setActiveViewport(core_frontend_1.IModelApp.viewManager.selectedView);
|
|
18
|
+
return core_frontend_1.IModelApp.viewManager.onSelectedViewportChanged.addListener((args) => {
|
|
19
|
+
setActiveViewport(args.current);
|
|
20
|
+
});
|
|
21
|
+
}, []);
|
|
22
|
+
return activeViewport;
|
|
23
|
+
}
|
|
24
|
+
exports.useActiveViewport = useActiveViewport;
|
|
25
|
+
//# sourceMappingURL=UseActiveViewport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UseActiveViewport.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/UseActiveViewport.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,iCAA4C;AAE5C,wDAAiD;AAEjD;;;GAGG;AACH,SAAgB,iBAAiB;IAC/B,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,IAAA,gBAAQ,EAClD,yBAAS,CAAC,WAAW,CAAC,YAAY,CACnC,CAAC;IACF,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,iBAAiB,CAAC,yBAAS,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;QACtD,OAAO,yBAAS,CAAC,WAAW,CAAC,yBAAyB,CAAC,WAAW,CAChE,CAAC,IAAI,EAAE,EAAE;YACP,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAClC,CAAC,CACF,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,cAAc,CAAC;AACxB,CAAC;AAdD,8CAcC","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, useState } from \"react\";\nimport type { ScreenViewport } from \"@itwin/core-frontend\";\nimport { IModelApp } from \"@itwin/core-frontend\";\n\n/** \n * A copy of `useActiveViewport` from `@itwin/appui-react` package until X is fixed.\n * @internal\n */\nexport function useActiveViewport(): ScreenViewport | undefined {\n const [activeViewport, setActiveViewport] = useState(\n IModelApp.viewManager.selectedView\n );\n useEffect(() => {\n setActiveViewport(IModelApp.viewManager.selectedView);\n return IModelApp.viewManager.onSelectedViewportChanged.addListener(\n (args) => {\n setActiveViewport(args.current);\n }\n );\n }, []);\n\n return activeViewport;\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PropsWithChildren } from "react";
|
|
2
|
-
type TrackedFeatures = "visibility-change" | "hierarchy-level-filtering" | "filtering" | "hierarchy-level-size-limit-hit" | "zoom-to-node";
|
|
2
|
+
type TrackedFeatures = "visibility-change" | "hierarchy-level-filtering" | "filtering" | "hierarchy-level-size-limit-hit" | "zoom-to-node" | "error-timeout" | "error-unknown";
|
|
3
3
|
interface TelemetryContext {
|
|
4
4
|
onPerformanceMeasured: (featureId: string, duration: number) => void;
|
|
5
5
|
onFeatureUsed: (props: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UseTelemetryContext.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/UseTelemetryContext.tsx"],"names":[],"mappings":";;;;AAAA;;;gGAGgG;AAEhG,iCAAwE;AACxE,mCAAoC;
|
|
1
|
+
{"version":3,"file":"UseTelemetryContext.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/UseTelemetryContext.tsx"],"names":[],"mappings":";;;;AAAA;;;gGAGgG;AAEhG,iCAAwE;AACxE,mCAAoC;AAkBpC,MAAM,gBAAgB,GAAG,IAAA,qBAAa,EAA+B,SAAS,CAAC,CAAC;AAYhF,YAAY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kB,CAA2C,EAAE,MAAM,EAAE,SAAS,EAAoC;IAClI,MAAM,EAAE,aAAa,EAAE,GAAG,mBAAmB,EAAE,CAAC;IAChD,OAAO,IAAA,mBAAW,EAChB,CAAC,GAAG,IAAI,EAAE,EAAE;QACV,aAAa,CAAC,EAAE,SAAS,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC;QACtD,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;IAClB,CAAC,EACD,CAAC,MAAM,EAAE,SAAS,EAAE,aAAa,CAAC,CACnC,CAAC;AACJ,CAAC;AATD,gDASC","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, useCallback, useContext, useMemo } from \"react\";\nimport { useLatest } from \"./Utils\";\n\nimport type { PropsWithChildren } from \"react\";\n\ntype TrackedFeatures =\n | \"visibility-change\"\n | \"hierarchy-level-filtering\"\n | \"filtering\"\n | \"hierarchy-level-size-limit-hit\"\n | \"zoom-to-node\"\n | \"error-timeout\"\n | \"error-unknown\";\n\ninterface TelemetryContext {\n onPerformanceMeasured: (featureId: string, duration: number) => void;\n onFeatureUsed: (props: { featureId?: TrackedFeatures; reportInteraction: boolean }) => void;\n}\n\nconst telemetryContext = createContext<TelemetryContext | undefined>(undefined);\n\n/** @beta */\nexport interface TelemetryContextProviderProps {\n /** Callback that is invoked when performance of tracked feature is measured. */\n onPerformanceMeasured?: (featureId: string, duration: number) => void;\n /** Callback that is invoked when a tracked feature is used. */\n onFeatureUsed?: (featureId: string) => void;\n /** Unique identifier that is appended to feature id to help track which component used that feature. */\n componentIdentifier: string;\n}\n\n/** @beta */\nexport function TelemetryContextProvider({\n children,\n onPerformanceMeasured,\n onFeatureUsed,\n componentIdentifier,\n}: PropsWithChildren<TelemetryContextProviderProps>) {\n const onPerformanceMeasuredRef = useLatest(onPerformanceMeasured);\n const onFeatureUsedRef = useLatest(onFeatureUsed);\n\n const contextValue = useMemo<TelemetryContext>(() => {\n return {\n onPerformanceMeasured: (featureId, duration) => onPerformanceMeasuredRef.current?.(`${componentIdentifier}-${featureId}`, duration),\n onFeatureUsed: ({ featureId, reportInteraction }) => {\n if (reportInteraction !== false) {\n onFeatureUsedRef.current?.(`use-${componentIdentifier}`);\n }\n if (featureId) {\n onFeatureUsedRef.current?.(`${componentIdentifier}-${featureId}`);\n }\n },\n };\n }, [componentIdentifier, onPerformanceMeasuredRef, onFeatureUsedRef]);\n\n return <telemetryContext.Provider value={contextValue}>{children}</telemetryContext.Provider>;\n}\n\nconst defaultContextValue: TelemetryContext = {\n onPerformanceMeasured: () => {},\n onFeatureUsed: () => {},\n};\n\nexport function useTelemetryContext() {\n return useContext(telemetryContext) ?? defaultContextValue;\n}\n\ninterface UseReportingActionProps<TAction> {\n action: TAction;\n featureId?: TrackedFeatures;\n}\n\n/** @internal */\nexport function useReportingAction<TAction extends (...args: any[]) => void>({ action, featureId }: UseReportingActionProps<TAction>) {\n const { onFeatureUsed } = useTelemetryContext();\n return useCallback<(...args: Parameters<TAction>) => void>(\n (...args) => {\n onFeatureUsed({ featureId, reportInteraction: true });\n action(...args);\n },\n [action, featureId, onFeatureUsed],\n );\n}\n"]}
|
|
@@ -12,8 +12,6 @@ import type { TreeRenderer } from "./TreeRenderer";
|
|
|
12
12
|
export type TreeRendererProps = Required<Pick<ComponentPropsWithoutRef<typeof TreeRenderer>, "rootNodes" | "expandNode" | "onNodeClick" | "onNodeKeyDown" | "onFilterClick" | "isNodeSelected" | "getHierarchyLevelDetails" | "size" | "getLabel">>;
|
|
13
13
|
/** @beta */
|
|
14
14
|
interface TreeOwnProps {
|
|
15
|
-
height: number;
|
|
16
|
-
width: number;
|
|
17
15
|
/** iModel connection that should be used to pull data from. */
|
|
18
16
|
imodel: IModelConnection;
|
|
19
17
|
/** Callback for getting `SchemaContext` for specific iModel. */
|
|
@@ -31,7 +31,7 @@ function Tree({ getSchemaContext, hierarchyLevelSizeLimit, selectionStorage, imo
|
|
|
31
31
|
return ((0, jsx_runtime_1.jsx)(presentation_components_1.SchemaMetadataContextProvider, { imodel: props.imodel, schemaContextProvider: getSchemaContext, children: (0, jsx_runtime_1.jsx)(presentation_hierarchies_react_1.UnifiedSelectionProvider, { storage: selectionStorage, children: (0, jsx_runtime_1.jsx)(TreeImpl, { ...props, imodelAccess: imodelAccess, defaultHierarchyLevelSizeLimit: defaultHierarchyLevelSizeLimit }) }) }));
|
|
32
32
|
}
|
|
33
33
|
exports.Tree = Tree;
|
|
34
|
-
function TreeImpl({ imodel, imodelAccess,
|
|
34
|
+
function TreeImpl({ imodel, imodelAccess, treeName, noDataMessage, getFilteredPaths, defaultHierarchyLevelSizeLimit, getHierarchyDefinition, selectionMode, onReload, treeRenderer, density, highlight, }) {
|
|
35
35
|
const localizedStrings = (0, UseHierarchiesLocalization_1.useHierarchiesLocalization)();
|
|
36
36
|
const { onFeatureUsed, onPerformanceMeasured } = (0, UseTelemetryContext_1.useTelemetryContext)();
|
|
37
37
|
const { rootNodes, isLoading, selectNodes, setFormatter: _setFormatter, expandNode, ...treeProps } = (0, presentation_hierarchies_react_1.useUnifiedSelectionTree)({
|
|
@@ -48,6 +48,7 @@ function TreeImpl({ imodel, imodelAccess, height, width, treeName, noDataMessage
|
|
|
48
48
|
onPerformanceMeasured(action, duration);
|
|
49
49
|
},
|
|
50
50
|
onHierarchyLimitExceeded: () => onFeatureUsed({ featureId: "hierarchy-level-size-limit-hit", reportInteraction: false }),
|
|
51
|
+
onHierarchyLoadError: ({ type }) => onFeatureUsed({ featureId: `error-${type}`, reportInteraction: false }),
|
|
51
52
|
});
|
|
52
53
|
const reloadTree = treeProps.reloadTree;
|
|
53
54
|
(0, UseIModelChangeListener_1.useIModelChangeListener)({ imodel, action: (0, react_1.useCallback)(() => reloadTree({ dataSourceChanged: true }), [reloadTree]) });
|
|
@@ -61,10 +62,10 @@ function TreeImpl({ imodel, imodelAccess, height, width, treeName, noDataMessage
|
|
|
61
62
|
const reportingOnFilterClicked = (0, UseTelemetryContext_1.useReportingAction)({ action: onFilterClick });
|
|
62
63
|
const { getLabel } = (0, UseNodeHighlighting_1.useNodeHighlighting)({ rootNodes, highlight });
|
|
63
64
|
if (rootNodes === undefined) {
|
|
64
|
-
return ((0, jsx_runtime_1.jsx)(itwinui_react_1.Flex, { alignItems: "center", justifyContent: "center", flexDirection: "column", style: { width, height }, children: (0, jsx_runtime_1.jsx)(Delayed_1.Delayed, { show: true, children: (0, jsx_runtime_1.jsx)(itwinui_react_1.ProgressRadial, { size: "large" }) }) }));
|
|
65
|
+
return ((0, jsx_runtime_1.jsx)(itwinui_react_1.Flex, { alignItems: "center", justifyContent: "center", flexDirection: "column", style: { width: "100%", height: "100%" }, children: (0, jsx_runtime_1.jsx)(Delayed_1.Delayed, { show: true, children: (0, jsx_runtime_1.jsx)(itwinui_react_1.ProgressRadial, { size: "large" }) }) }));
|
|
65
66
|
}
|
|
66
67
|
if (rootNodes.length === 0 && !isLoading) {
|
|
67
|
-
return ((0, jsx_runtime_1.jsx)(itwinui_react_1.Flex, { alignItems: "center", justifyContent: "center", flexDirection: "column", style: { width, height }, children: noDataMessage ? noDataMessage : (0, jsx_runtime_1.jsx)(itwinui_react_1.Text, { children: TreeWidget_1.TreeWidget.translate("baseTree.dataIsNotAvailable") }) }));
|
|
68
|
+
return ((0, jsx_runtime_1.jsx)(itwinui_react_1.Flex, { alignItems: "center", justifyContent: "center", flexDirection: "column", style: { width: "100%", height: "100%" }, children: noDataMessage ? noDataMessage : (0, jsx_runtime_1.jsx)(itwinui_react_1.Text, { children: TreeWidget_1.TreeWidget.translate("baseTree.dataIsNotAvailable") }) }));
|
|
68
69
|
}
|
|
69
70
|
const treeRendererProps = {
|
|
70
71
|
...treeProps,
|
|
@@ -76,6 +77,6 @@ function TreeImpl({ imodel, imodelAccess, height, width, treeName, noDataMessage
|
|
|
76
77
|
getLabel,
|
|
77
78
|
size: density === "enlarged" ? "default" : "small",
|
|
78
79
|
};
|
|
79
|
-
return ((0, jsx_runtime_1.jsxs)("div", { style: { position: "relative", height, overflow: "hidden" }, children: [(0, jsx_runtime_1.jsxs)("div", { id: "tw-tree-renderer-container", style: { overflow: "auto", height: "100%" }, children: [treeRenderer(treeRendererProps), filteringDialog] }), (0, jsx_runtime_1.jsx)(Delayed_1.Delayed, { show: isLoading, children: (0, jsx_runtime_1.jsx)(ProgressOverlay_1.ProgressOverlay, {}) })] }));
|
|
80
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: { position: "relative", height: "100%", overflow: "hidden" }, children: [(0, jsx_runtime_1.jsxs)("div", { id: "tw-tree-renderer-container", style: { overflow: "auto", height: "100%" }, children: [treeRenderer(treeRendererProps), filteringDialog] }), (0, jsx_runtime_1.jsx)(Delayed_1.Delayed, { show: isLoading, children: (0, jsx_runtime_1.jsx)(ProgressOverlay_1.ProgressOverlay, {}) })] }));
|
|
80
81
|
}
|
|
81
82
|
//# sourceMappingURL=Tree.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tree.js","sourceRoot":"","sources":["../../../../../../src/components/trees/common/components/Tree.tsx"],"names":[],"mappings":";;;;AAAA;;;gGAGgG;AAEhG,iCAA6C;AAC7C,wDAAkE;AAClE,4EAA+E;AAC/E,0FAA+H;AAC/H,uDAAoD;AACpD,8EAA2E;AAC3E,oEAAsE;AACtE,wEAAqE;AACrE,gEAA6D;AAC7D,gEAAiF;AACjF,oCAA8C;AAC9C,uCAAoC;AACpC,uDAAoD;AA6DpD;;;GAGG;AACH,SAAgB,IAAI,CAAC,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,YAAY,EAAE,oBAAoB,EAAE,GAAG,KAAK,EAAa;IAC3I,MAAM,8BAA8B,GAAG,uBAAuB,IAAI,IAAI,CAAC;IAEvE,MAAM,YAAY,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE;QAChC,OAAO,oBAAoB,I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,uBAAC,iBAAO,IAAC,IAAI,EAAE,IAAI,YACjB,uBAAC,8BAAc,IAAC,IAAI,EAAC,OAAO,GAAG,GACvB,GACL,CACR,CAAC;KACH;IAED,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE;QACxC,OAAO,CACL,uBAAC,oBAAI,IAAC,UAAU,EAAC,QAAQ,EAAC,cAAc,EAAC,QAAQ,EAAC,aAAa,EAAC,QAAQ,EAAC,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,YAC9F,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,uBAAC,oBAAI,cAAE,uBAAU,CAAC,SAAS,CAAC,6BAA6B,CAAC,GAAQ,GAC9F,CACR,CAAC;KACH;IAED,MAAM,iBAAiB,GAAsB;QAC3C,GAAG,SAAS;QACZ,SAAS;QACT,WAAW;QACX,aAAa;QACb,UAAU,EAAE,mBAAmB;QAC/B,aAAa,EAAE,wBAAwB;QACvC,QAAQ;QACR,IAAI,EAAE,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO;KACnD,CAAC;IAEF,OAAO,CACL,iCAAK,KAAK,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAC9D,iCAAK,EAAE,EAAC,4BAA4B,EAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,aAC7E,YAAY,CAAC,iBAAiB,CAAC,EAC/B,eAAe,IACZ,EACN,uBAAC,iBAAO,IAAC,IAAI,EAAE,SAAS,YACtB,uBAAC,iCAAe,KAAG,GACX,IACN,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 { useCallback, useMemo } from \"react\";\nimport { Flex, ProgressRadial, Text } from \"@itwin/itwinui-react\";\nimport { SchemaMetadataContextProvider } from \"@itwin/presentation-components\";\nimport { UnifiedSelectionProvider, useSelectionHandler, useUnifiedSelectionTree } from \"@itwin/presentation-hierarchies-react\";\nimport { TreeWidget } from \"../../../../TreeWidget\";\nimport { useHierarchiesLocalization } from \"../UseHierarchiesLocalization\";\nimport { useHierarchyLevelFiltering } from \"../UseHierarchyFiltering\";\nimport { useIModelChangeListener } from \"../UseIModelChangeListener\";\nimport { useNodeHighlighting } from \"../UseNodeHighlighting\";\nimport { useReportingAction, useTelemetryContext } from \"../UseTelemetryContext\";\nimport { createIModelAccess } from \"../Utils\";\nimport { Delayed } from \"./Delayed\";\nimport { ProgressOverlay } from \"./ProgressOverlay\";\n\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\";\nimport type { MarkRequired } from \"@itwin/core-bentley\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport type { SchemaContext } from \"@itwin/ecschema-metadata\";\nimport type { SelectionStorage, useTree } from \"@itwin/presentation-hierarchies-react\";\nimport type { HighlightInfo } from \"../UseNodeHighlighting\";\nimport type { TreeRenderer } from \"./TreeRenderer\";\n\n/**\n * Properties that are passed to `treeRenderer` from `Tree` component.\n * @beta\n */\nexport type TreeRendererProps = Required<\n Pick<\n ComponentPropsWithoutRef<typeof TreeRenderer>,\n \"rootNodes\" | \"expandNode\" | \"onNodeClick\" | \"onNodeKeyDown\" | \"onFilterClick\" | \"isNodeSelected\" | \"getHierarchyLevelDetails\" | \"size\" | \"getLabel\"\n >\n>;\n\n/** @beta */\ninterface TreeOwnProps {\n height: number;\n width: number;\n /** iModel connection that should be used to pull data from. */\n imodel: IModelConnection;\n /** Callback for getting `SchemaContext` for specific iModel. */\n getSchemaContext: (imodel: IModelConnection) => SchemaContext;\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 /** Tree renderer that should be used to render tree data. */\n treeRenderer: (treeProps: TreeRendererProps) => 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?: IModelAccess;\n /** Size limit that should be applied on each hierarchy level. Default to `1000`. */\n hierarchyLevelSizeLimit?: number;\n /** Modifies the density of tree nodes. `enlarged` tree nodes have bigger button hit boxes. */\n density?: \"default\" | \"enlarged\";\n /** Message that should be renderer if there are no tree nodes. */\n noDataMessage?: ReactNode;\n /** Callback that this invoked when tree reloads. */\n onReload?: () => void;\n /** Options for highlighting node labels. */\n highlight?: HighlightInfo;\n}\n\n/** @beta */\ntype UseTreeProps = Parameters<typeof useTree>[0];\n\n/** @beta */\ntype UseSelectionHandlerProps = Parameters<typeof useSelectionHandler>[0];\n\n/** @beta */\ntype IModelAccess = UseTreeProps[\"imodelAccess\"];\n\n/** @beta */\ntype TreeProps = TreeOwnProps & Pick<UseTreeProps, \"getFilteredPaths\" | \"getHierarchyDefinition\"> & Pick<Partial<UseSelectionHandlerProps>, \"selectionMode\">;\n\n/**\n * Default tree component that manages tree state and renders using supplied `treeRenderer`.\n * @Beta\n */\nexport function Tree({ getSchemaContext, hierarchyLevelSizeLimit, selectionStorage, imodelAccess: providedIModelAccess, ...props }: TreeProps) {\n const defaultHierarchyLevelSizeLimit = hierarchyLevelSizeLimit ?? 1000;\n\n const imodelAccess = useMemo(() => {\n return providedIModelAccess ?? createIModelAccess({ getSchemaContext, imodel: props.imodel });\n }, [providedIModelAccess, getSchemaContext, props.imodel]);\n\n return (\n <SchemaMetadataContextProvider imodel={props.imodel} schemaContextProvider={getSchemaContext}>\n <UnifiedSelectionProvider storage={selectionStorage}>\n <TreeImpl {...props} imodelAccess={imodelAccess} defaultHierarchyLevelSizeLimit={defaultHierarchyLevelSizeLimit} />\n </UnifiedSelectionProvider>\n </SchemaMetadataContextProvider>\n );\n}\n\nfunction TreeImpl({\n imodel,\n imodelAccess,\n height,\n width,\n treeName,\n noDataMessage,\n getFilteredPaths,\n defaultHierarchyLevelSizeLimit,\n getHierarchyDefinition,\n selectionMode,\n onReload,\n treeRenderer,\n density,\n highlight,\n}: MarkRequired<Omit<TreeProps, \"getSchemaContext\" | \"selectionStorage\">, \"imodelAccess\"> & { defaultHierarchyLevelSizeLimit: number }) {\n const localizedStrings = useHierarchiesLocalization();\n const { onFeatureUsed, onPerformanceMeasured } = useTelemetryContext();\n const {\n rootNodes,\n isLoading,\n selectNodes,\n setFormatter: _setFormatter,\n expandNode,\n ...treeProps\n } = useUnifiedSelectionTree({\n imodelAccess,\n getHierarchyDefinition,\n getFilteredPaths,\n imodelKey: imodel.key,\n sourceName: treeName,\n localizedStrings,\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 });\n\n const reloadTree = treeProps.reloadTree;\n useIModelChangeListener({ imodel, action: useCallback(() => reloadTree({ dataSourceChanged: true }), [reloadTree]) });\n const reportingSelectNodes = useReportingAction({ action: selectNodes });\n const { onNodeClick, onNodeKeyDown } = useSelectionHandler({ rootNodes, selectNodes: reportingSelectNodes, selectionMode: selectionMode ?? \"single\" });\n const { filteringDialog, onFilterClick } = useHierarchyLevelFiltering({\n imodel,\n defaultHierarchyLevelSizeLimit,\n });\n const reportingExpandNode = useReportingAction({ action: expandNode });\n const reportingOnFilterClicked = useReportingAction({ action: onFilterClick });\n const { getLabel } = useNodeHighlighting({ rootNodes, highlight });\n\n if (rootNodes === undefined) {\n return (\n <Flex alignItems=\"center\" justifyContent=\"center\" flexDirection=\"column\" style={{ width, height }}>\n <Delayed show={true}>\n <ProgressRadial size=\"large\" />\n </Delayed>\n </Flex>\n );\n }\n\n if (rootNodes.length === 0 && !isLoading) {\n return (\n <Flex alignItems=\"center\" justifyContent=\"center\" flexDirection=\"column\" style={{ width, height }}>\n {noDataMessage ? noDataMessage : <Text>{TreeWidget.translate(\"baseTree.dataIsNotAvailable\")}</Text>}\n </Flex>\n );\n }\n\n const treeRendererProps: TreeRendererProps = {\n ...treeProps,\n rootNodes,\n onNodeClick,\n onNodeKeyDown,\n expandNode: reportingExpandNode,\n onFilterClick: reportingOnFilterClicked,\n getLabel,\n size: density === \"enlarged\" ? \"default\" : \"small\",\n };\n\n return (\n <div style={{ position: \"relative\", height, overflow: \"hidden\" }}>\n <div id=\"tw-tree-renderer-container\" style={{ overflow: \"auto\", height: \"100%\" }}>\n {treeRenderer(treeRendererProps)}\n {filteringDialog}\n </div>\n <Delayed show={isLoading}>\n <ProgressOverlay />\n </Delayed>\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Tree.js","sourceRoot":"","sources":["../../../../../../src/components/trees/common/components/Tree.tsx"],"names":[],"mappings":";;;;AAAA;;;gGAGgG;AAEhG,iCAA6C;AAC7C,wDAAkE;AAClE,4EAA+E;AAC/E,0FAA+H;AAC/H,uDAAoD;AACpD,8EAA2E;AAC3E,oEAAsE;AACtE,wEAAqE;AACrE,gEAA6D;AAC7D,gEAAiF;AACjF,oCAA8C;AAC9C,uCAAoC;AACpC,uDAAoD;AA2DpD;;;GAGG;AACH,SAAgB,IAAI,CAAC,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,YAAY,EAAE,oBAAoB,EAAE,GAAG,KAAK,EAAa;IAC3I,MAAM,8BAA8B,GAAG,uBAAuB,IAAI,IAAI,CAAC;IAEvE,MAAM,YAAY,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE;QAChC,OAAO,oBAAoB,IAAI,IAAA,0BAAkB,EAAC,EAAE,gBAAgB,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;IAChG,CAAC,EAAE,CAAC,oBAAoB,EAAE,gBAAgB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IAE3D,OAAO,CACL,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AAC,8BAAc,IAAC,IAAI,EAAC,OAAO,GAAG,GACvB,GACL,CACR,CAAC;KACH;IAED,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE;QACxC,OAAO,CACL,uBAAC,oBAAI,IAAC,UAAU,EAAC,QAAQ,EAAC,cAAc,EAAC,QAAQ,EAAC,aAAa,EAAC,QAAQ,EAAC,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,YAC9G,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,uBAAC,oBAAI,cAAE,uBAAU,CAAC,SAAS,CAAC,6BAA6B,CAAC,GAAQ,GAC9F,CACR,CAAC;KACH;IAED,MAAM,iBAAiB,GAAsB;QAC3C,GAAG,SAAS;QACZ,SAAS;QACT,WAAW;QACX,aAAa;QACb,UAAU,EAAE,mBAAmB;QAC/B,aAAa,EAAE,wBAAwB;QACvC,QAAQ;QACR,IAAI,EAAE,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO;KACnD,CAAC;IAEF,OAAO,CACL,iCAAK,KAAK,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,aACtE,iCAAK,EAAE,EAAC,4BAA4B,EAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,aAC7E,YAAY,CAAC,iBAAiB,CAAC,EAC/B,eAAe,IACZ,EACN,uBAAC,iBAAO,IAAC,IAAI,EAAE,SAAS,YACtB,uBAAC,iCAAe,KAAG,GACX,IACN,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 { useCallback, useMemo } from \"react\";\nimport { Flex, ProgressRadial, Text } from \"@itwin/itwinui-react\";\nimport { SchemaMetadataContextProvider } from \"@itwin/presentation-components\";\nimport { UnifiedSelectionProvider, useSelectionHandler, useUnifiedSelectionTree } from \"@itwin/presentation-hierarchies-react\";\nimport { TreeWidget } from \"../../../../TreeWidget\";\nimport { useHierarchiesLocalization } from \"../UseHierarchiesLocalization\";\nimport { useHierarchyLevelFiltering } from \"../UseHierarchyFiltering\";\nimport { useIModelChangeListener } from \"../UseIModelChangeListener\";\nimport { useNodeHighlighting } from \"../UseNodeHighlighting\";\nimport { useReportingAction, useTelemetryContext } from \"../UseTelemetryContext\";\nimport { createIModelAccess } from \"../Utils\";\nimport { Delayed } from \"./Delayed\";\nimport { ProgressOverlay } from \"./ProgressOverlay\";\n\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\";\nimport type { MarkRequired } from \"@itwin/core-bentley\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport type { SchemaContext } from \"@itwin/ecschema-metadata\";\nimport type { SelectionStorage, useTree } from \"@itwin/presentation-hierarchies-react\";\nimport type { HighlightInfo } from \"../UseNodeHighlighting\";\nimport type { TreeRenderer } from \"./TreeRenderer\";\n\n/**\n * Properties that are passed to `treeRenderer` from `Tree` component.\n * @beta\n */\nexport type TreeRendererProps = Required<\n Pick<\n ComponentPropsWithoutRef<typeof TreeRenderer>,\n \"rootNodes\" | \"expandNode\" | \"onNodeClick\" | \"onNodeKeyDown\" | \"onFilterClick\" | \"isNodeSelected\" | \"getHierarchyLevelDetails\" | \"size\" | \"getLabel\"\n >\n>;\n\n/** @beta */\ninterface TreeOwnProps {\n /** iModel connection that should be used to pull data from. */\n imodel: IModelConnection;\n /** Callback for getting `SchemaContext` for specific iModel. */\n getSchemaContext: (imodel: IModelConnection) => SchemaContext;\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 /** Tree renderer that should be used to render tree data. */\n treeRenderer: (treeProps: TreeRendererProps) => 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?: IModelAccess;\n /** Size limit that should be applied on each hierarchy level. Default to `1000`. */\n hierarchyLevelSizeLimit?: number;\n /** Modifies the density of tree nodes. `enlarged` tree nodes have bigger button hit boxes. */\n density?: \"default\" | \"enlarged\";\n /** Message that should be renderer if there are no tree nodes. */\n noDataMessage?: ReactNode;\n /** Callback that this invoked when tree reloads. */\n onReload?: () => void;\n /** Options for highlighting node labels. */\n highlight?: HighlightInfo;\n}\n\n/** @beta */\ntype UseTreeProps = Parameters<typeof useTree>[0];\n\n/** @beta */\ntype UseSelectionHandlerProps = Parameters<typeof useSelectionHandler>[0];\n\n/** @beta */\ntype IModelAccess = UseTreeProps[\"imodelAccess\"];\n\n/** @beta */\ntype TreeProps = TreeOwnProps & Pick<UseTreeProps, \"getFilteredPaths\" | \"getHierarchyDefinition\"> & Pick<Partial<UseSelectionHandlerProps>, \"selectionMode\">;\n\n/**\n * Default tree component that manages tree state and renders using supplied `treeRenderer`.\n * @Beta\n */\nexport function Tree({ getSchemaContext, hierarchyLevelSizeLimit, selectionStorage, imodelAccess: providedIModelAccess, ...props }: TreeProps) {\n const defaultHierarchyLevelSizeLimit = hierarchyLevelSizeLimit ?? 1000;\n\n const imodelAccess = useMemo(() => {\n return providedIModelAccess ?? createIModelAccess({ getSchemaContext, imodel: props.imodel });\n }, [providedIModelAccess, getSchemaContext, props.imodel]);\n\n return (\n <SchemaMetadataContextProvider imodel={props.imodel} schemaContextProvider={getSchemaContext}>\n <UnifiedSelectionProvider storage={selectionStorage}>\n <TreeImpl {...props} imodelAccess={imodelAccess} defaultHierarchyLevelSizeLimit={defaultHierarchyLevelSizeLimit} />\n </UnifiedSelectionProvider>\n </SchemaMetadataContextProvider>\n );\n}\n\nfunction TreeImpl({\n imodel,\n imodelAccess,\n treeName,\n noDataMessage,\n getFilteredPaths,\n defaultHierarchyLevelSizeLimit,\n getHierarchyDefinition,\n selectionMode,\n onReload,\n treeRenderer,\n density,\n highlight,\n}: MarkRequired<Omit<TreeProps, \"getSchemaContext\" | \"selectionStorage\">, \"imodelAccess\"> & { defaultHierarchyLevelSizeLimit: number }) {\n const localizedStrings = useHierarchiesLocalization();\n const { onFeatureUsed, onPerformanceMeasured } = useTelemetryContext();\n const {\n rootNodes,\n isLoading,\n selectNodes,\n setFormatter: _setFormatter,\n expandNode,\n ...treeProps\n } = useUnifiedSelectionTree({\n imodelAccess,\n getHierarchyDefinition,\n getFilteredPaths,\n imodelKey: imodel.key,\n sourceName: treeName,\n localizedStrings,\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 }) => onFeatureUsed({ featureId: `error-${type}`, reportInteraction: false }),\n });\n\n const reloadTree = treeProps.reloadTree;\n useIModelChangeListener({ imodel, action: useCallback(() => reloadTree({ dataSourceChanged: true }), [reloadTree]) });\n const reportingSelectNodes = useReportingAction({ action: selectNodes });\n const { onNodeClick, onNodeKeyDown } = useSelectionHandler({ rootNodes, selectNodes: reportingSelectNodes, selectionMode: selectionMode ?? \"single\" });\n const { filteringDialog, onFilterClick } = useHierarchyLevelFiltering({\n imodel,\n defaultHierarchyLevelSizeLimit,\n });\n const reportingExpandNode = useReportingAction({ action: expandNode });\n const reportingOnFilterClicked = useReportingAction({ action: onFilterClick });\n const { getLabel } = useNodeHighlighting({ rootNodes, highlight });\n\n if (rootNodes === undefined) {\n return (\n <Flex alignItems=\"center\" justifyContent=\"center\" flexDirection=\"column\" style={{ width: \"100%\", height: \"100%\" }}>\n <Delayed show={true}>\n <ProgressRadial size=\"large\" />\n </Delayed>\n </Flex>\n );\n }\n\n if (rootNodes.length === 0 && !isLoading) {\n return (\n <Flex alignItems=\"center\" justifyContent=\"center\" flexDirection=\"column\" style={{ width: \"100%\", height: \"100%\" }}>\n {noDataMessage ? noDataMessage : <Text>{TreeWidget.translate(\"baseTree.dataIsNotAvailable\")}</Text>}\n </Flex>\n );\n }\n\n const treeRendererProps: TreeRendererProps = {\n ...treeProps,\n rootNodes,\n onNodeClick,\n onNodeKeyDown,\n expandNode: reportingExpandNode,\n onFilterClick: reportingOnFilterClicked,\n getLabel,\n size: density === \"enlarged\" ? \"default\" : \"small\",\n };\n\n return (\n <div style={{ position: \"relative\", height: \"100%\", overflow: \"hidden\" }}>\n <div id=\"tw-tree-renderer-container\" style={{ overflow: \"auto\", height: \"100%\" }}>\n {treeRenderer(treeRendererProps)}\n {filteringDialog}\n </div>\n <Delayed show={isLoading}>\n <ProgressOverlay />\n </Delayed>\n </div>\n );\n}\n"]}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { Tree } from "./Tree";
|
|
2
|
-
import type
|
|
2
|
+
import type { ComponentPropsWithoutRef, ReactNode } from "react";
|
|
3
3
|
import type { VisibilityTreeRenderer } from "./VisibilityTreeRenderer";
|
|
4
4
|
import type { TreeRendererProps } from "./Tree";
|
|
5
5
|
import type { ECClassHierarchyInspector } from "@itwin/presentation-shared";
|
|
6
6
|
import type { HierarchyVisibilityHandler } from "../UseHierarchyVisibility";
|
|
7
|
-
import type { ComponentPropsWithoutRef } from "react";
|
|
8
7
|
/** @beta */
|
|
9
8
|
type TreeProps = ComponentPropsWithoutRef<typeof Tree>;
|
|
10
9
|
/**
|
|
@@ -19,7 +18,7 @@ interface VisibilityTreeOwnProps {
|
|
|
19
18
|
imodelAccess: ECClassHierarchyInspector;
|
|
20
19
|
}) => HierarchyVisibilityHandler;
|
|
21
20
|
/** Tree renderer that should be used to render tree data. */
|
|
22
|
-
treeRenderer: (treeProps: VisibilityTreeRendererProps) =>
|
|
21
|
+
treeRenderer: (treeProps: VisibilityTreeRendererProps) => ReactNode;
|
|
23
22
|
}
|
|
24
23
|
/** @beta */
|
|
25
24
|
type VisibilityTreeProps = VisibilityTreeOwnProps & Omit<TreeProps, "treeRenderer" | "imodelAccess">;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VisibilityTree.js","sourceRoot":"","sources":["../../../../../../src/components/trees/common/components/VisibilityTree.tsx"],"names":[],"mappings":";;;;AAAA;;;gGAGgG;AAEhG,iCAA6C;AAC7C,sEAAmE;AACnE,oCAA8C;AAC9C,iCAA8B;
|
|
1
|
+
{"version":3,"file":"VisibilityTree.js","sourceRoot":"","sources":["../../../../../../src/components/trees/common/components/VisibilityTree.tsx"],"names":[],"mappings":";;;;AAAA;;;gGAGgG;AAEhG,iCAA6C;AAC7C,sEAAmE;AACnE,oCAA8C;AAC9C,iCAA8B;AA6B9B;;;GAGG;AACH,SAAgB,cAAc,CAAC,EAAE,wBAAwB,EAAE,YAAY,EAAE,GAAG,KAAK,EAAuB;IACtG,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,GAAG,KAAK,CAAC;IAC3C,MAAM,YAAY,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,IAAA,0BAAkB,EAAC,EAAE,MAAM,EAAE,gBAAgB,EAAE,CAAC,EAAE,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC;IACjH,MAAM,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,cAAc,EAAE,GAAG,IAAA,+CAAsB,EAAC;QACrF,wBAAwB,EAAE,IAAA,mBAAW,EAAC,GAAG,EAAE,CAAC,wBAAwB,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC,wBAAwB,EAAE,YAAY,CAAC,CAAC;KAClI,CAAC,CAAC;IAEH,OAAO,CACL,uBAAC,WAAI,OACC,KAAK,EACT,QAAQ,EAAE,cAAc,EACxB,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,YAAY,CAAC,EAAE,GAAG,SAAS,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,CAAC,GAChG,CACH,CAAC;AACJ,CAAC;AAfD,wCAeC","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, useMemo } from \"react\";\nimport { useHierarchyVisibility } from \"../UseHierarchyVisibility\";\nimport { createIModelAccess } from \"../Utils\";\nimport { Tree } from \"./Tree\";\n\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\";\nimport type { VisibilityTreeRenderer } from \"./VisibilityTreeRenderer\";\nimport type { TreeRendererProps } from \"./Tree\";\nimport type { ECClassHierarchyInspector } from \"@itwin/presentation-shared\";\nimport type { HierarchyVisibilityHandler } from \"../UseHierarchyVisibility\";\n\n/** @beta */\ntype TreeProps = ComponentPropsWithoutRef<typeof Tree>;\n\n/**\n * Properties that are passed to `treeRenderer` from `VisibilityTree` component.\n * @beta\n */\nexport type VisibilityTreeRendererProps = TreeRendererProps &\n Pick<ComponentPropsWithoutRef<typeof VisibilityTreeRenderer>, \"getCheckboxState\" | \"onCheckboxClicked\">;\n\n/** @beta */\ninterface VisibilityTreeOwnProps {\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: (treeProps: VisibilityTreeRendererProps) => ReactNode;\n}\n\n/** @beta */\ntype VisibilityTreeProps = VisibilityTreeOwnProps & Omit<TreeProps, \"treeRenderer\" | \"imodelAccess\">;\n\n/**\n * Tree component that can control visibility of instances represented by tree nodes.\n * @beta\n */\nexport function VisibilityTree({ visibilityHandlerFactory, treeRenderer, ...props }: VisibilityTreeProps) {\n const { imodel, getSchemaContext } = props;\n const imodelAccess = useMemo(() => createIModelAccess({ imodel, getSchemaContext }), [imodel, getSchemaContext]);\n const { getCheckboxState, onCheckboxClicked, triggerRefresh } = useHierarchyVisibility({\n visibilityHandlerFactory: useCallback(() => visibilityHandlerFactory({ imodelAccess }), [visibilityHandlerFactory, imodelAccess]),\n });\n\n return (\n <Tree\n {...props}\n onReload={triggerRefresh}\n imodelAccess={imodelAccess}\n treeRenderer={(treeProps) => treeRenderer({ ...treeProps, getCheckboxState, onCheckboxClicked })}\n />\n );\n}\n"]}
|
|
@@ -9,7 +9,7 @@ interface ExternalSourcesTreeOwnProps {
|
|
|
9
9
|
/** @beta */
|
|
10
10
|
type TreeProps = Parameters<typeof Tree>[0];
|
|
11
11
|
/** @beta */
|
|
12
|
-
type ExternalSourcesTreeProps = ExternalSourcesTreeOwnProps & Pick<TreeProps, "imodel" | "getSchemaContext" | "selectionStorage" | "
|
|
12
|
+
type ExternalSourcesTreeProps = ExternalSourcesTreeOwnProps & Pick<TreeProps, "imodel" | "getSchemaContext" | "selectionStorage" | "density" | "selectionMode">;
|
|
13
13
|
/** @beta */
|
|
14
14
|
export declare function ExternalSourcesTree(props: ExternalSourcesTreeProps): JSX.Element;
|
|
15
15
|
export {};
|