@itwin/tree-widget-react 3.15.1 → 3.16.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 +14 -2
- package/lib/cjs/tree-widget-react/TreeWidget.d.ts +1 -2
- package/lib/cjs/tree-widget-react/TreeWidget.js +12 -12
- package/lib/cjs/tree-widget-react/TreeWidget.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.d.ts +2 -3
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.js +5 -4
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.d.ts +4 -7
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js +39 -31
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js +6 -2
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.d.ts +3 -11
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js +45 -36
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.d.ts +1 -3
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.js +30 -30
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.d.ts +2 -7
- package/lib/cjs/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.js +8 -21
- package/lib/cjs/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/common/internal/useTreeHooks/UseIdsCache.d.ts +3 -0
- package/lib/cjs/tree-widget-react/components/trees/common/internal/useTreeHooks/UseIdsCache.js +7 -7
- package/lib/cjs/tree-widget-react/components/trees/common/internal/useTreeHooks/UseIdsCache.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/common/useGuid.d.ts +2 -0
- package/lib/cjs/tree-widget-react/components/trees/common/useGuid.js +14 -0
- package/lib/cjs/tree-widget-react/components/trees/common/useGuid.js.map +1 -0
- package/lib/cjs/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.js +4 -1
- package/lib/cjs/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeDefinition.d.ts +4 -6
- package/lib/cjs/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeDefinition.js +31 -26
- package/lib/cjs/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeDefinition.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.d.ts +1 -1
- package/lib/cjs/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.js +4 -2
- package/lib/cjs/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeDefinition.d.ts +1 -5
- package/lib/cjs/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeDefinition.js +44 -44
- package/lib/cjs/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeDefinition.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/imodel-content-tree/internal/IModelContentTreeIdsCache.d.ts +3 -6
- package/lib/cjs/tree-widget-react/components/trees/imodel-content-tree/internal/IModelContentTreeIdsCache.js +20 -16
- package/lib/cjs/tree-widget-react/components/trees/imodel-content-tree/internal/IModelContentTreeIdsCache.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.js +3 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.d.ts +6 -10
- package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js +107 -64
- package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/UseModelsTree.js +18 -8
- package/lib/cjs/tree-widget-react/components/trees/models-tree/UseModelsTree.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/Utils.d.ts +24 -0
- package/lib/cjs/tree-widget-react/components/trees/models-tree/Utils.js +46 -0
- package/lib/cjs/tree-widget-react/components/trees/models-tree/Utils.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.d.ts +40 -9
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.js +68 -39
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/FilteredTree.d.ts +13 -5
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/FilteredTree.js +20 -14
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/FilteredTree.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.d.ts +4 -13
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js +62 -60
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.d.ts +6 -2
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js +155 -177
- package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js.map +1 -1
- package/lib/esm/tree-widget-react/TreeWidget.d.ts +1 -2
- package/lib/esm/tree-widget-react/TreeWidget.js +12 -12
- package/lib/esm/tree-widget-react/TreeWidget.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.d.ts +2 -3
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.js +5 -3
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.d.ts +4 -7
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js +39 -31
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js +6 -2
- package/lib/esm/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.d.ts +3 -11
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js +45 -36
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.d.ts +1 -3
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.js +30 -30
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.d.ts +2 -7
- package/lib/esm/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.js +8 -20
- package/lib/esm/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/useTreeHooks/UseIdsCache.d.ts +3 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/useTreeHooks/UseIdsCache.js +7 -7
- package/lib/esm/tree-widget-react/components/trees/common/internal/useTreeHooks/UseIdsCache.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/useGuid.d.ts +2 -0
- package/lib/esm/tree-widget-react/components/trees/common/useGuid.js +11 -0
- package/lib/esm/tree-widget-react/components/trees/common/useGuid.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.js +4 -1
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeDefinition.d.ts +4 -6
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeDefinition.js +31 -26
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeDefinition.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.d.ts +1 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.js +4 -2
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeDefinition.d.ts +1 -5
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeDefinition.js +44 -44
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeDefinition.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/internal/IModelContentTreeIdsCache.d.ts +3 -6
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/internal/IModelContentTreeIdsCache.js +21 -17
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/internal/IModelContentTreeIdsCache.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.js +3 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.d.ts +6 -10
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js +107 -64
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.js +18 -8
- package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/Utils.d.ts +24 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/Utils.js +44 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/Utils.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.d.ts +40 -9
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.js +70 -41
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/FilteredTree.d.ts +13 -5
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/FilteredTree.js +22 -16
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/FilteredTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.d.ts +4 -13
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js +63 -61
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.d.ts +6 -2
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js +157 -179
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js.map +1 -1
- package/package.json +8 -8
|
@@ -2,26 +2,9 @@
|
|
|
2
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
import { Guid } from "@itwin/core-bentley";
|
|
5
6
|
import { QueryRowFormat } from "@itwin/core-common";
|
|
6
7
|
import { PerModelCategoryVisibility } from "@itwin/core-frontend";
|
|
7
|
-
/**
|
|
8
|
-
* Toggles visibility of categories to show or hide.
|
|
9
|
-
* @internal
|
|
10
|
-
*/
|
|
11
|
-
export async function toggleAllCategories(viewport, display) {
|
|
12
|
-
const ids = await getCategories(viewport);
|
|
13
|
-
if (ids.length === 0) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
await enableCategoryDisplay(viewport, ids, display);
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Gets ids of all categories from specified imodel and viewport.
|
|
20
|
-
*/
|
|
21
|
-
async function getCategories(viewport) {
|
|
22
|
-
const categories = await loadCategoriesFromViewport(viewport);
|
|
23
|
-
return categories.map((category) => category.categoryId);
|
|
24
|
-
}
|
|
25
8
|
/**
|
|
26
9
|
* Changes category display in the viewport.
|
|
27
10
|
* @internal
|
|
@@ -51,14 +34,19 @@ export function enableSubCategoryDisplay(viewport, key, enabled) {
|
|
|
51
34
|
viewport.changeSubCategoryDisplay(key, enabled);
|
|
52
35
|
}
|
|
53
36
|
/** @internal */
|
|
54
|
-
export async function loadCategoriesFromViewport(vp) {
|
|
37
|
+
export async function loadCategoriesFromViewport(vp, componentId) {
|
|
55
38
|
// Query categories and add them to state
|
|
56
39
|
const selectUsedSpatialCategoryIds = "SELECT DISTINCT Category.Id as id from BisCore.GeometricElement3d WHERE Category.Id IN (SELECT ECInstanceId from BisCore.SpatialCategory)";
|
|
57
40
|
const selectUsedDrawingCategoryIds = "SELECT DISTINCT Category.Id as id from BisCore.GeometricElement2d WHERE Model.Id=? AND Category.Id IN (SELECT ECInstanceId from BisCore.DrawingCategory)";
|
|
58
41
|
const ecsql = vp.view.is3d() ? selectUsedSpatialCategoryIds : selectUsedDrawingCategoryIds;
|
|
59
42
|
const ecsql2 = `SELECT ECInstanceId as id FROM ${vp.view.is3d() ? "BisCore.SpatialCategory" : "BisCore.DrawingCategory"} WHERE ECInstanceId IN (${ecsql})`;
|
|
60
43
|
const categories = [];
|
|
61
|
-
const rows = await vp.iModel
|
|
44
|
+
const rows = await vp.iModel
|
|
45
|
+
.createQueryReader(ecsql2, undefined, {
|
|
46
|
+
rowFormat: QueryRowFormat.UseJsPropertyNames,
|
|
47
|
+
restartToken: `CategoriesVisibilityUtils/${componentId ?? Guid.createValue()}/categories`,
|
|
48
|
+
})
|
|
49
|
+
.toArray();
|
|
62
50
|
(await vp.iModel.categories.getCategoryInfo(rows.map((row) => row.id))).forEach((val) => {
|
|
63
51
|
categories.push({ categoryId: val.id, subCategoryIds: val.subCategories.size ? [...val.subCategories.keys()] : undefined });
|
|
64
52
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CategoriesVisibilityUtils.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"CategoriesVisibilityUtils.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAclE;;;GAGG;AACH,MAAM,C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mB,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;IAED,MAAM,qBAAqB,CAAC,QAAQ,EAAE,CAAC,GAAG,mBAAmB,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;IAE7E,MAAM,qBAAqB,CAAC,QAAQ,EAAE,CAAC,GAAG,kBAAkB,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAC7E,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 { Guid } from \"@itwin/core-bentley\";\nimport { QueryRowFormat } from \"@itwin/core-common\";\nimport { PerModelCategoryVisibility } from \"@itwin/core-frontend\";\n\nimport type { GuidString, Id64Array, Id64String } from \"@itwin/core-bentley\";\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 * Changes category display in the viewport.\n * @internal\n */\nexport async function enableCategoryDisplay(viewport: Viewport, categoryIds: Id64Array, enabled: boolean, enableAllSubCategories = true) {\n viewport.changeCategoryDisplay(categoryIds, enabled, enableAllSubCategories);\n\n // remove category overrides per model\n const modelsContainingOverrides: string[] = [];\n for (const ovr of viewport.perModelCategoryVisibility) {\n if (categoryIds.findIndex((id) => id === ovr.categoryId) !== -1) {\n modelsContainingOverrides.push(ovr.modelId);\n }\n }\n viewport.perModelCategoryVisibility.setOverride(modelsContainingOverrides, categoryIds, 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(categoryIds)).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 * @internal\n */\nexport function enableSubCategoryDisplay(viewport: Viewport, key: string, enabled: boolean) {\n viewport.changeSubCategoryDisplay(key, enabled);\n}\n\n/** @internal */\nexport async function loadCategoriesFromViewport(vp: Viewport, componentId?: GuidString) {\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\n .createQueryReader(ecsql2, undefined, {\n rowFormat: QueryRowFormat.UseJsPropertyNames,\n restartToken: `CategoriesVisibilityUtils/${componentId ?? Guid.createValue()}/categories`,\n })\n .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 * Categories are inverted like this:\n * - If category is visible, it will be hidden.\n * - If category is hidden, it will be visible.\n * - If category is partially visible, it will be fully visible.\n * @public\n */\nexport async function invertAllCategories(categories: CategoryInfo[], viewport: Viewport) {\n const categoriesToEnable = new Set<Id64String>();\n const categoriesToDisable = new Set<Id64String>();\n\n for (const category of categories) {\n if (!viewport.view.viewsCategory(category.categoryId)) {\n categoriesToEnable.add(category.categoryId);\n continue;\n }\n // Check if category is in partial state\n if (category.subCategoryIds?.some((subCategory) => !viewport.isSubCategoryVisible(subCategory))) {\n categoriesToEnable.add(category.categoryId);\n } else {\n categoriesToDisable.add(category.categoryId);\n }\n }\n\n // collect per model overrides that need to be inverted\n for (const { categoryId, visible } of viewport.perModelCategoryVisibility) {\n if (!visible && categoriesToDisable.has(categoryId)) {\n categoriesToEnable.add(categoryId);\n categoriesToDisable.delete(categoryId);\n }\n }\n\n await enableCategoryDisplay(viewport, [...categoriesToDisable], false, true);\n\n await enableCategoryDisplay(viewport, [...categoriesToEnable], true, true);\n}\n"]}
|
package/lib/esm/tree-widget-react/components/trees/common/internal/useTreeHooks/UseIdsCache.d.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
|
+
import type { GuidString } from "@itwin/core-bentley";
|
|
1
2
|
import type { IModelConnection } from "@itwin/core-frontend";
|
|
2
3
|
/** @internal */
|
|
3
4
|
export interface CreateCacheProps<TCacheSpecificProps> {
|
|
4
5
|
imodel: IModelConnection;
|
|
5
6
|
specificProps: TCacheSpecificProps;
|
|
7
|
+
componentId: GuidString;
|
|
6
8
|
}
|
|
7
9
|
/** @internal */
|
|
8
10
|
export interface UseIdsCacheProps<TCache, TCacheSpecificProps> {
|
|
9
11
|
imodel: IModelConnection;
|
|
10
12
|
createCache: (props: CreateCacheProps<TCacheSpecificProps>) => TCache;
|
|
11
13
|
cacheSpecificProps: TCacheSpecificProps;
|
|
14
|
+
componentId: GuidString;
|
|
12
15
|
}
|
|
13
16
|
/** @internal */
|
|
14
17
|
export declare function useIdsCache<TCache extends Disposable, TCacheSpecificProps extends object>(props: UseIdsCacheProps<TCache, TCacheSpecificProps>): {
|
package/lib/esm/tree-widget-react/components/trees/common/internal/useTreeHooks/UseIdsCache.js
CHANGED
|
@@ -12,32 +12,32 @@ export function useIdsCache(props) {
|
|
|
12
12
|
cacheRef.current = undefined;
|
|
13
13
|
});
|
|
14
14
|
const { imodel, createCache, cacheSpecificProps } = props;
|
|
15
|
-
const createCacheGetterRef = useRef((currImodel, specificProps) => {
|
|
15
|
+
const createCacheGetterRef = useRef((currImodel, specificProps, componentId) => {
|
|
16
16
|
return () => {
|
|
17
17
|
if (cacheRef.current === undefined) {
|
|
18
|
-
cacheRef.current = createCache({ imodel: currImodel, specificProps });
|
|
18
|
+
cacheRef.current = createCache({ imodel: currImodel, specificProps, componentId });
|
|
19
19
|
}
|
|
20
20
|
return cacheRef.current;
|
|
21
21
|
};
|
|
22
22
|
});
|
|
23
|
-
const [getCache, setCacheGetter] = useState(() => createCacheGetterRef.current(imodel, cacheSpecificProps));
|
|
23
|
+
const [getCache, setCacheGetter] = useState(() => createCacheGetterRef.current(imodel, cacheSpecificProps, props.componentId));
|
|
24
24
|
useEffect(() => {
|
|
25
25
|
// clear cache in case it was created before `useEffect` was run first time
|
|
26
26
|
clearCacheRef.current();
|
|
27
27
|
// make sure all cache users rerender
|
|
28
|
-
setCacheGetter(() => createCacheGetterRef.current(imodel, cacheSpecificProps));
|
|
28
|
+
setCacheGetter(() => createCacheGetterRef.current(imodel, cacheSpecificProps, props.componentId));
|
|
29
29
|
return () => {
|
|
30
30
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
31
31
|
clearCacheRef.current();
|
|
32
32
|
};
|
|
33
|
-
}, [imodel, cacheSpecificProps]);
|
|
33
|
+
}, [imodel, cacheSpecificProps, props.componentId]);
|
|
34
34
|
useIModelChangeListener({
|
|
35
35
|
imodel,
|
|
36
36
|
action: useCallback(() => {
|
|
37
37
|
clearCacheRef.current();
|
|
38
38
|
// make sure all cache users rerender
|
|
39
|
-
setCacheGetter(() => createCacheGetterRef.current(imodel, cacheSpecificProps));
|
|
40
|
-
}, [imodel, cacheSpecificProps]),
|
|
39
|
+
setCacheGetter(() => createCacheGetterRef.current(imodel, cacheSpecificProps, props.componentId));
|
|
40
|
+
}, [imodel, cacheSpecificProps, props.componentId]),
|
|
41
41
|
});
|
|
42
42
|
return {
|
|
43
43
|
getCache,
|
package/lib/esm/tree-widget-react/components/trees/common/internal/useTreeHooks/UseIdsCache.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UseIdsCache.js","sourceRoot":"","sources":["../../../../../../../../src/tree-widget-react/components/trees/common/internal/useTreeHooks/UseIdsCache.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"UseIdsCache.js","sourceRoot":"","sources":["../../../../../../../../src/tree-widget-react/components/trees/common/internal/useTreeHooks/UseIdsCache.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAoB3E,gBAAgB;AAChB,MAAM,UAAU,WAAW,CACzB,KAAoD;IAEpD,MAAM,QAAQ,GAAG,MAAM,CAAqB,SAAS,CAAC,CAAC;IACvD,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,EAAE;QAChC,QAAQ,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC;QACvC,QAAQ,CAAC,OAAO,GAAG,SAAS,CAAC;IAC/B,CAAC,CAAC,CAAC;IACH,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,kBAAkB,EAAE,GAAG,KAAK,CAAC;IAE1D,MAAM,oBAAoB,GAAG,MAAM,CAAC,CAAC,UAA4B,EAAE,aAAkC,EAA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;QACL,QAAQ;KACT,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, useEffect, useRef, useState } from \"react\";\nimport { useIModelChangeListener } from \"../../UseIModelChangeListener.js\";\n\nimport type { GuidString } from \"@itwin/core-bentley\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\n\n/** @internal */\nexport interface CreateCacheProps<TCacheSpecificProps> {\n imodel: IModelConnection;\n specificProps: TCacheSpecificProps;\n componentId: GuidString;\n}\n\n/** @internal */\nexport interface UseIdsCacheProps<TCache, TCacheSpecificProps> {\n imodel: IModelConnection;\n createCache: (props: CreateCacheProps<TCacheSpecificProps>) => TCache;\n cacheSpecificProps: TCacheSpecificProps;\n componentId: GuidString;\n}\n\n/** @internal */\nexport function useIdsCache<TCache extends Disposable, TCacheSpecificProps extends object>(\n props: UseIdsCacheProps<TCache, TCacheSpecificProps>,\n): { getCache: () => TCache } {\n const cacheRef = useRef<TCache | undefined>(undefined);\n const clearCacheRef = useRef(() => {\n cacheRef.current?.[Symbol.dispose]?.();\n cacheRef.current = undefined;\n });\n const { imodel, createCache, cacheSpecificProps } = props;\n\n const createCacheGetterRef = useRef((currImodel: IModelConnection, specificProps: TCacheSpecificProps, componentId: GuidString) => {\n return () => {\n if (cacheRef.current === undefined) {\n cacheRef.current = createCache({ imodel: currImodel, specificProps, componentId });\n }\n return cacheRef.current;\n };\n });\n\n const [getCache, setCacheGetter] = useState<() => TCache>(() => createCacheGetterRef.current(imodel, cacheSpecificProps, props.componentId));\n\n useEffect(() => {\n // clear cache in case it was created before `useEffect` was run first time\n clearCacheRef.current();\n\n // make sure all cache users rerender\n setCacheGetter(() => createCacheGetterRef.current(imodel, cacheSpecificProps, props.componentId));\n return () => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n clearCacheRef.current();\n };\n }, [imodel, cacheSpecificProps, props.componentId]);\n\n useIModelChangeListener({\n imodel,\n action: useCallback(() => {\n clearCacheRef.current();\n // make sure all cache users rerender\n setCacheGetter(() => createCacheGetterRef.current(imodel, cacheSpecificProps, props.componentId));\n }, [imodel, cacheSpecificProps, props.componentId]),\n });\n\n return {\n getCache,\n };\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
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 { useState } from "react";
|
|
6
|
+
import { Guid } from "@itwin/core-bentley";
|
|
7
|
+
export function useGuid() {
|
|
8
|
+
const [componentId] = useState(() => Guid.createValue());
|
|
9
|
+
return componentId;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=useGuid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGuid.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/common/useGuid.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE3C,MAAM,UAAU,OAAO;IACrB,MAAM,CAAC,WAAW,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;IACzD,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useState } from \"react\";\nimport { Guid } from \"@itwin/core-bentley\";\n\nexport function useGuid() {\n const [componentId] = useState(() => Guid.createValue());\n return componentId;\n}\n"]}
|
package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.js
CHANGED
|
@@ -3,14 +3,17 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
4
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
import { useCallback } from "react";
|
|
6
7
|
import { SvgDetails, SvgDocument, SvgItem } from "@itwin/itwinui-icons-react";
|
|
7
8
|
import { Tree } from "../common/components/Tree.js";
|
|
8
9
|
import { TreeRenderer } from "../common/components/TreeRenderer.js";
|
|
10
|
+
import { useGuid } from "../common/useGuid.js";
|
|
9
11
|
import { ExternalSourcesTreeComponent } from "./ExternalSourcesTreeComponent.js";
|
|
10
12
|
import { ExternalSourcesTreeDefinition } from "./ExternalSourcesTreeDefinition.js";
|
|
11
13
|
/** @beta */
|
|
12
14
|
export function ExternalSourcesTree(props) {
|
|
13
|
-
|
|
15
|
+
const componentId = useGuid();
|
|
16
|
+
return (_jsx(Tree, { ...props, treeName: ExternalSourcesTreeComponent.id, getHierarchyDefinition: useCallback((definitionProps) => getDefinitionsProvider({ ...definitionProps, componentId }), [componentId]), selectionMode: props.selectionMode ?? "none", treeRenderer: (treeProps) => _jsx(TreeRenderer, { ...treeProps, getIcon: getIcon }) }));
|
|
14
17
|
}
|
|
15
18
|
const getDefinitionsProvider = (props) => {
|
|
16
19
|
return new ExternalSourcesTreeDefinition(props);
|
package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExternalSourcesTree.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAC9E,OAAO,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AACjF,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"ExternalSourcesTree.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAC9E,OAAO,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AACjF,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AAenF,YAAY;AACZ,MAAM,UAAU,mBAAmB,CAAC,KAA+B;IACjE,MAAM,WAAW,GAAG,OAAO,EAAE,CAAC;IAC9B,OAAO,CACL,KAAC,IAAI,OACC,KAAK,EACT,QAAQ,EAAE,4BAA4B,CAAC,EAAE,EACzC,sBAAsB,EAAE,WAAW,CAAC,CAAC,eAAe,EAAE,EAAE,CAAC,sBAAsB,CAAC,EAAE,GAAG,eAAe,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,EACpI,aAAa,EAAE,KAAK,CAAC,aAAa,IAAI,MAAM,EAC5C,YAAY,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,KAAC,YAAY,OAAK,SAAS,EAAE,OAAO,EAAE,OAAO,GAAI,GAC9E,CACH,CAAC;AACJ,CAAC;AAED,MAAM,sBAAsB,GAAG,CAAC,KAAuF,EAAuB,EAAE;IAC9I,OAAO,IAAI,6BAA6B,CAAC,KAAK,CAAC,CAAC;AAClD,CAAC,CAAC;AAEF,SAAS,OAAO,CAAC,IAA+B;IAC9C,IAAI,IAAI,CAAC,YAAY,EAAE,OAAO,KAAK,SAAS,EAAE,CAAC;QAC7C,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,QAAQ,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;QAClC,KAAK,WAAW;YACd,OAAO,KAAC,OAAO,KAAG,CAAC;QACrB,KAAK,eAAe;YAClB,OAAO,KAAC,OAAO,KAAG,CAAC;QACrB,KAAK,eAAe;YAClB,OAAO,KAAC,WAAW,KAAG,CAAC;QACzB,KAAK,gBAAgB;YACnB,OAAO,KAAC,UAAU,KAAG,CAAC;IAC1B,CAAC;IAED,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 } from \"react\";\nimport { SvgDetails, SvgDocument, SvgItem } from \"@itwin/itwinui-icons-react\";\nimport { Tree } from \"../common/components/Tree.js\";\nimport { TreeRenderer } from \"../common/components/TreeRenderer.js\";\nimport { useGuid } from \"../common/useGuid.js\";\nimport { ExternalSourcesTreeComponent } from \"./ExternalSourcesTreeComponent.js\";\nimport { ExternalSourcesTreeDefinition } from \"./ExternalSourcesTreeDefinition.js\";\n\nimport type { ReactElement } from \"react\";\nimport type { GuidString } from \"@itwin/core-bentley\";\nimport type { HierarchyDefinition } from \"@itwin/presentation-hierarchies\";\nimport type { PresentationHierarchyNode } from \"@itwin/presentation-hierarchies-react\";\nimport type { TreeProps } from \"../common/components/Tree.js\";\n\n/** @beta */\nexport type ExternalSourcesTreeProps = Pick<TreeProps, \"imodel\" | \"getSchemaContext\" | \"selectionStorage\" | \"density\" | \"selectionMode\"> & {\n hierarchyLevelConfig?: {\n sizeLimit?: number;\n };\n};\n\n/** @beta */\nexport function ExternalSourcesTree(props: ExternalSourcesTreeProps) {\n const componentId = useGuid();\n return (\n <Tree\n {...props}\n treeName={ExternalSourcesTreeComponent.id}\n getHierarchyDefinition={useCallback((definitionProps) => getDefinitionsProvider({ ...definitionProps, componentId }), [componentId])}\n selectionMode={props.selectionMode ?? \"none\"}\n treeRenderer={(treeProps) => <TreeRenderer {...treeProps} getIcon={getIcon} />}\n />\n );\n}\n\nconst getDefinitionsProvider = (props: Parameters<TreeProps[\"getHierarchyDefinition\"]>[0] & { componentId: GuidString }): HierarchyDefinition => {\n return new ExternalSourcesTreeDefinition(props);\n};\n\nfunction getIcon(node: PresentationHierarchyNode): ReactElement | undefined {\n if (node.extendedData?.imageId === undefined) {\n return undefined;\n }\n\n switch (node.extendedData.imageId) {\n case \"icon-item\":\n return <SvgItem />;\n case \"icon-ec-class\":\n return <SvgItem />;\n case \"icon-document\":\n return <SvgDocument />;\n case \"icon-ec-schema\":\n return <SvgDetails />;\n }\n\n return undefined;\n}\n"]}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { GuidString } from "@itwin/core-bentley";
|
|
2
2
|
import type { DefineHierarchyLevelProps, HierarchyDefinition, HierarchyLevelDefinition, LimitingECSqlQueryExecutor, ProcessedHierarchyNode } from "@itwin/presentation-hierarchies";
|
|
3
|
+
import type { ECClassHierarchyInspector, ECSchemaProvider } from "@itwin/presentation-shared";
|
|
3
4
|
interface ExternalSourcesTreeDefinitionProps {
|
|
4
5
|
imodelAccess: ECSchemaProvider & ECClassHierarchyInspector & LimitingECSqlQueryExecutor;
|
|
6
|
+
componentId?: GuidString;
|
|
5
7
|
}
|
|
6
8
|
export declare class ExternalSourcesTreeDefinition implements HierarchyDefinition {
|
|
7
|
-
private
|
|
8
|
-
private _selectQueryFactory;
|
|
9
|
-
private _nodeLabelSelectClauseFactory;
|
|
10
|
-
private _queryExecutor;
|
|
11
|
-
private _isSupported?;
|
|
9
|
+
#private;
|
|
12
10
|
constructor(props: ExternalSourcesTreeDefinitionProps);
|
|
13
11
|
postProcessNode(node: ProcessedHierarchyNode): Promise<ProcessedHierarchyNode>;
|
|
14
12
|
defineHierarchyLevel(props: DefineHierarchyLevelProps): Promise<HierarchyLevelDefinition>;
|
|
@@ -2,16 +2,19 @@
|
|
|
2
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
import { Guid } from "@itwin/core-bentley";
|
|
5
6
|
import { createNodesQueryClauseFactory, createPredicateBasedHierarchyDefinition, HierarchyNode } from "@itwin/presentation-hierarchies";
|
|
6
7
|
import { createBisInstanceLabelSelectClauseFactory, ECSql } from "@itwin/presentation-shared";
|
|
7
8
|
export class ExternalSourcesTreeDefinition {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
#impl;
|
|
10
|
+
#selectQueryFactory;
|
|
11
|
+
#nodeLabelSelectClauseFactory;
|
|
12
|
+
#queryExecutor;
|
|
13
|
+
#isSupported;
|
|
14
|
+
#componentId;
|
|
15
|
+
#componentName;
|
|
13
16
|
constructor(props) {
|
|
14
|
-
this
|
|
17
|
+
this.#impl = createPredicateBasedHierarchyDefinition({
|
|
15
18
|
classHierarchyInspector: props.imodelAccess,
|
|
16
19
|
hierarchy: {
|
|
17
20
|
rootNodes: async (requestProps) => this.createRootHierarchyLevelDefinition(requestProps),
|
|
@@ -31,12 +34,14 @@ export class ExternalSourcesTreeDefinition {
|
|
|
31
34
|
],
|
|
32
35
|
},
|
|
33
36
|
});
|
|
34
|
-
this
|
|
35
|
-
this
|
|
36
|
-
this
|
|
37
|
+
this.#queryExecutor = props.imodelAccess;
|
|
38
|
+
this.#nodeLabelSelectClauseFactory = createBisInstanceLabelSelectClauseFactory({ classHierarchyInspector: props.imodelAccess });
|
|
39
|
+
this.#selectQueryFactory = createNodesQueryClauseFactory({
|
|
37
40
|
imodelAccess: props.imodelAccess,
|
|
38
|
-
instanceLabelSelectClauseFactory: this
|
|
41
|
+
instanceLabelSelectClauseFactory: this.#nodeLabelSelectClauseFactory,
|
|
39
42
|
});
|
|
43
|
+
this.#componentId = props.componentId ?? Guid.createValue();
|
|
44
|
+
this.#componentName = "ExternalSourcesTreeDefinition";
|
|
40
45
|
}
|
|
41
46
|
async postProcessNode(node) {
|
|
42
47
|
if (HierarchyNode.isClassGroupingNode(node)) {
|
|
@@ -46,16 +51,16 @@ export class ExternalSourcesTreeDefinition {
|
|
|
46
51
|
return node;
|
|
47
52
|
}
|
|
48
53
|
async defineHierarchyLevel(props) {
|
|
49
|
-
if (this
|
|
50
|
-
this
|
|
54
|
+
if (this.#isSupported === undefined) {
|
|
55
|
+
this.#isSupported = this.isSupported();
|
|
51
56
|
}
|
|
52
|
-
if ((await this
|
|
57
|
+
if ((await this.#isSupported) === false) {
|
|
53
58
|
return [];
|
|
54
59
|
}
|
|
55
|
-
return this.
|
|
60
|
+
return this.#impl.defineHierarchyLevel(props);
|
|
56
61
|
}
|
|
57
62
|
async createRootHierarchyLevelDefinition(props) {
|
|
58
|
-
const instanceFilterClauses = await this.
|
|
63
|
+
const instanceFilterClauses = await this.#selectQueryFactory.createFilterClauses({
|
|
59
64
|
filter: props.instanceFilter,
|
|
60
65
|
contentClass: { fullName: "BisCore.ExternalSource", alias: "this" },
|
|
61
66
|
});
|
|
@@ -66,7 +71,7 @@ export class ExternalSourcesTreeDefinition {
|
|
|
66
71
|
query: {
|
|
67
72
|
ecsql: `
|
|
68
73
|
SELECT
|
|
69
|
-
${await this.
|
|
74
|
+
${await this.#selectQueryFactory.createSelectClause({
|
|
70
75
|
ecClassId: { selector: ECSql.createRawPropertyValueSelector("this", "ECClassId") },
|
|
71
76
|
ecInstanceId: { selector: "this.ECInstanceId" },
|
|
72
77
|
nodeLabel: {
|
|
@@ -90,7 +95,7 @@ export class ExternalSourcesTreeDefinition {
|
|
|
90
95
|
// cspell:enable
|
|
91
96
|
}
|
|
92
97
|
async createExternalSourcesGroupChildrenQuery({ parentNodeInstanceIds: groupIds, instanceFilter, }) {
|
|
93
|
-
const instanceFilterClauses = await this.
|
|
98
|
+
const instanceFilterClauses = await this.#selectQueryFactory.createFilterClauses({
|
|
94
99
|
filter: instanceFilter,
|
|
95
100
|
contentClass: { fullName: "BisCore.ExternalSource", alias: "this" },
|
|
96
101
|
});
|
|
@@ -101,7 +106,7 @@ export class ExternalSourcesTreeDefinition {
|
|
|
101
106
|
query: {
|
|
102
107
|
ecsql: `
|
|
103
108
|
SELECT
|
|
104
|
-
${await this.
|
|
109
|
+
${await this.#selectQueryFactory.createSelectClause({
|
|
105
110
|
ecClassId: { selector: "this.ECClassId" },
|
|
106
111
|
ecInstanceId: { selector: "this.ECInstanceId" },
|
|
107
112
|
nodeLabel: {
|
|
@@ -127,7 +132,7 @@ export class ExternalSourcesTreeDefinition {
|
|
|
127
132
|
// cspell:enable
|
|
128
133
|
}
|
|
129
134
|
async createExternalSourceChildrenQuery({ parentNodeInstanceIds: sourceIds, instanceFilter, }) {
|
|
130
|
-
const instanceFilterClauses = await this.
|
|
135
|
+
const instanceFilterClauses = await this.#selectQueryFactory.createFilterClauses({
|
|
131
136
|
filter: instanceFilter,
|
|
132
137
|
contentClass: { fullName: "BisCore.ExternalSource", alias: "this" },
|
|
133
138
|
});
|
|
@@ -137,7 +142,7 @@ export class ExternalSourcesTreeDefinition {
|
|
|
137
142
|
query: {
|
|
138
143
|
ecsql: `
|
|
139
144
|
SELECT
|
|
140
|
-
${await this.
|
|
145
|
+
${await this.#selectQueryFactory.createSelectClause({
|
|
141
146
|
ecClassId: { selector: "this.ECClassId" },
|
|
142
147
|
ecInstanceId: { selector: "this.ECInstanceId" },
|
|
143
148
|
nodeLabel: {
|
|
@@ -190,7 +195,7 @@ export class ExternalSourcesTreeDefinition {
|
|
|
190
195
|
}
|
|
191
196
|
async createElementsNodeChildrenQuery({ parentNode, instanceFilter }) {
|
|
192
197
|
const sourceIds = parentNode.extendedData?.sourceIds;
|
|
193
|
-
const instanceFilterClauses = await this.
|
|
198
|
+
const instanceFilterClauses = await this.#selectQueryFactory.createFilterClauses({
|
|
194
199
|
filter: instanceFilter,
|
|
195
200
|
contentClass: { fullName: "BisCore.GeometricElement", alias: "this" },
|
|
196
201
|
});
|
|
@@ -200,11 +205,11 @@ export class ExternalSourcesTreeDefinition {
|
|
|
200
205
|
query: {
|
|
201
206
|
ecsql: `
|
|
202
207
|
SELECT
|
|
203
|
-
${await this.
|
|
208
|
+
${await this.#selectQueryFactory.createSelectClause({
|
|
204
209
|
ecClassId: { selector: "this.ECClassId" },
|
|
205
210
|
ecInstanceId: { selector: "this.ECInstanceId" },
|
|
206
211
|
nodeLabel: {
|
|
207
|
-
selector: await this.
|
|
212
|
+
selector: await this.#nodeLabelSelectClauseFactory.createSelectClause({
|
|
208
213
|
classAlias: "this",
|
|
209
214
|
className: "BisCore.GeometricElement",
|
|
210
215
|
}),
|
|
@@ -234,7 +239,7 @@ export class ExternalSourcesTreeDefinition {
|
|
|
234
239
|
${repositoryLinkAlias}.ECInstanceId IS NOT NULL,
|
|
235
240
|
${ECSql.createConcatenatedValueJsonSelector([
|
|
236
241
|
{
|
|
237
|
-
selector: await this.
|
|
242
|
+
selector: await this.#nodeLabelSelectClauseFactory.createSelectClause({
|
|
238
243
|
classAlias: repositoryLinkAlias,
|
|
239
244
|
className: "BisCore.RepositoryLink",
|
|
240
245
|
}),
|
|
@@ -248,7 +253,7 @@ export class ExternalSourcesTreeDefinition {
|
|
|
248
253
|
)`,
|
|
249
254
|
},
|
|
250
255
|
{
|
|
251
|
-
selector: await this.
|
|
256
|
+
selector: await this.#nodeLabelSelectClauseFactory.createSelectClause({
|
|
252
257
|
classAlias: externalSourceAlias,
|
|
253
258
|
className: "BisCore.ExternalSource",
|
|
254
259
|
}),
|
|
@@ -261,7 +266,7 @@ export class ExternalSourcesTreeDefinition {
|
|
|
261
266
|
FROM ECDbMeta.ECSchemaDef
|
|
262
267
|
WHERE Name = 'BisCore' AND (VersionMajor > 1 OR (VersionMajor = 1 AND VersionMinor > 12))
|
|
263
268
|
`;
|
|
264
|
-
for await (const _row of this.
|
|
269
|
+
for await (const _row of this.#queryExecutor.createQueryReader({ ecsql: query }, { restartToken: `${this.#componentName}/${this.#componentId}/is-external-source-supported` })) {
|
|
265
270
|
return true;
|
|
266
271
|
}
|
|
267
272
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExternalSourcesTreeDefinition.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeDefinition.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,6BAA6B,EAAE,uCAAuC,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AACxI,OAAO,EAAE,yCAAyC,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAmB9F,MAAM,OAAO,6BAA6B;IAChC,KAAK,CAAsB;IAC3B,mBAAmB,CAA0B;IAC7C,6BAA6B,CAAoC;IACjE,cAAc,CAA6B;IAC3C,YAAY,CAAoB;IAExC,YAAmB,KAAyC;QAC1D,IAAI,CAAC,KAAK,GAAG,uCAAuC,CAAC;YACnD,uBAAuB,EAAE,KAAK,CAAC,YAAY;YAC3C,SAAS,EAAE;gBACT,SAAS,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,CAAC,IAAI,CAAC,kCAAkC,CAAC,YAAY,CAAC;gBACxF,UAAU,EAAE;oBACV;wBACE,4BAA4B,EAAE,6BAA6B;wBAC3D,WAAW,EAAE,KAAK,EAAE,YAAwD,EAAE,EAAE,CAAC,IAAI,CAAC,uCAAuC,CAAC,YAAY,CAAC;qBAC5I;oBACD;wBACE,4BAA4B,EAAE,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EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;gBACpD,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,qBAAqB,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE;WAC5E;oBACD,QAAQ,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;iBAC7D;aACF;SACF,CAAC;IACJ,CAAC;IAEO,KAAK,CAAC,gCAAgC,CAAC,EAAE,mBAAmB,EAAE,mBAAmB,EAAgE;QACvJ,OAAO,KAAK,CAAC,mCAAmC,CAAC;YAC/C;gBACE,QAAQ,EAAE;YACN,mBAAmB;YACnB,KAAK,CAAC,mCAAmC,CAAC;oBAC1C;wBACE,QAAQ,EAAE,MAAM,IAAI,CAAC,6BAA6B,CAAC,kBAAkB,CAAC;4BACpE,UAAU,EAAE,mBAAmB;4BAC/B,SAAS,EAAE,wBAAwB;yBACpC,CAAC;qBACH;oBACD;wBACE,IAAI,EAAE,QAAQ;wBACd,KAAK,EAAE,KAAK;qBACb;iBACF,CAAC;;UAEF;aACH;YACD;gBACE,QAAQ,EAAE,MAAM,IAAI,CAAC,6BAA6B,CAAC,kBAAkB,CAAC;oBACpE,UAAU,EAAE,mBAAmB;oBAC/B,SAAS,EAAE,wBAAwB;iBACpC,CAAC;aACH;SACF,CAAC,CAAC;IACL,CAAC;IAEO,KAAK,CAAC,WAAW;QACvB,MAAM,KAAK,GAAG;;;;KAIb,CAAC;QAEF,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,IAAI,CAAC,cAAc,CAAC,iBAAiB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;YACjF,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { createNodesQueryClauseFactory, createPredicateBasedHierarchyDefinition, HierarchyNode } from \"@itwin/presentation-hierarchies\";\nimport { createBisInstanceLabelSelectClauseFactory, ECSql } from \"@itwin/presentation-shared\";\n\nimport type { ECClassHierarchyInspector, ECSchemaProvider, IInstanceLabelSelectClauseFactory } from \"@itwin/presentation-shared\";\nimport type {\n DefineGenericNodeChildHierarchyLevelProps,\n DefineHierarchyLevelProps,\n DefineInstanceNodeChildHierarchyLevelProps,\n DefineRootHierarchyLevelProps,\n HierarchyDefinition,\n HierarchyLevelDefinition,\n LimitingECSqlQueryExecutor,\n NodesQueryClauseFactory,\n ProcessedHierarchyNode,\n} from \"@itwin/presentation-hierarchies\";\n\ninterface ExternalSourcesTreeDefinitionProps {\n imodelAccess: ECSchemaProvider & ECClassHierarchyInspector & LimitingECSqlQueryExecutor;\n}\n\nexport class ExternalSourcesTreeDefinition implements HierarchyDefinition {\n private _impl: HierarchyDefinition;\n private _selectQueryFactory: NodesQueryClauseFactory;\n private _nodeLabelSelectClauseFactory: IInstanceLabelSelectClauseFactory;\n private _queryExecutor: LimitingECSqlQueryExecutor;\n private _isSupported?: Promise<boolean>;\n\n public constructor(props: ExternalSourcesTreeDefinitionProps) {\n this._impl = createPredicateBasedHierarchyDefinition({\n classHierarchyInspector: props.imodelAccess,\n hierarchy: {\n rootNodes: async (requestProps) => this.createRootHierarchyLevelDefinition(requestProps),\n childNodes: [\n {\n parentInstancesNodePredicate: \"BisCore.ExternalSourceGroup\",\n definitions: async (requestProps: DefineInstanceNodeChildHierarchyLevelProps) => this.createExternalSourcesGroupChildrenQuery(requestProps),\n },\n {\n parentInstancesNodePredicate: \"BisCore.ExternalSource\",\n definitions: async (requestProps: DefineInstanceNodeChildHierarchyLevelProps) => this.createExternalSourceChildrenQuery(requestProps),\n },\n {\n parentGenericNodePredicate: async ({ id }) => id === \"ElementsNode\",\n definitions: async (requestProps: DefineGenericNodeChildHierarchyLevelProps) => this.createElementsNodeChildrenQuery(requestProps),\n },\n ],\n },\n });\n this._queryExecutor = props.imodelAccess;\n this._nodeLabelSelectClauseFactory = createBisInstanceLabelSelectClauseFactory({ classHierarchyInspector: props.imodelAccess });\n this._selectQueryFactory = createNodesQueryClauseFactory({\n imodelAccess: props.imodelAccess,\n instanceLabelSelectClauseFactory: this._nodeLabelSelectClauseFactory,\n });\n }\n\n public async postProcessNode(node: ProcessedHierarchyNode): Promise<ProcessedHierarchyNode> {\n if (HierarchyNode.isClassGroupingNode(node)) {\n // `imageId` is assigned to instance nodes at query time, but grouping ones need to be handled during post-processing\n return { ...node, extendedData: { ...node.extendedData, imageId: \"icon-ec-class\" } };\n }\n return node;\n }\n\n public async defineHierarchyLevel(props: DefineHierarchyLevelProps) {\n if (this._isSupported === undefined) {\n this._isSupported = this.isSupported();\n }\n\n if ((await this._isSupported) === false) {\n return [];\n }\n\n return this._impl.defineHierarchyLevel(props);\n }\n\n private async createRootHierarchyLevelDefinition(props: DefineRootHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n const instanceFilterClauses = await this._selectQueryFactory.createFilterClauses({\n filter: props.instanceFilter,\n contentClass: { fullName: \"BisCore.ExternalSource\", alias: \"this\" },\n });\n\n // cspell:disable\n return [\n {\n fullClassName: \"BisCore.ExternalSource\",\n query: {\n ecsql: `\n SELECT\n ${await this._selectQueryFactory.createSelectClause({\n ecClassId: { selector: ECSql.createRawPropertyValueSelector(\"this\", \"ECClassId\") },\n ecInstanceId: { selector: \"this.ECInstanceId\" },\n nodeLabel: {\n selector: await this.createCompositeLabelSelectClause({ externalSourceAlias: \"this\", repositoryLinkAlias: \"rl\" }),\n },\n extendedData: {\n imageId: \"icon-document\",\n },\n autoExpand: true,\n supportsFiltering: { selector: this.createExternalSourceSupportsFilteringSelector(\"this\") },\n })}\n FROM ${instanceFilterClauses.from} this\n ${instanceFilterClauses.joins}\n JOIN BisCore.SynchronizationConfigSpecifiesRootSources scsrs ON scsrs.TargetECInstanceId = this.ECInstanceId\n LEFT JOIN BisCore.RepositoryLink rl ON rl.ECInstanceId = this.Repository.Id\n ${instanceFilterClauses.where ? `WHERE ${instanceFilterClauses.where}` : \"\"}\n `,\n },\n },\n ];\n // cspell:enable\n }\n\n private async createExternalSourcesGroupChildrenQuery({\n parentNodeInstanceIds: groupIds,\n instanceFilter,\n }: DefineInstanceNodeChildHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n const instanceFilterClauses = await this._selectQueryFactory.createFilterClauses({\n filter: instanceFilter,\n contentClass: { fullName: \"BisCore.ExternalSource\", alias: \"this\" },\n });\n // cspell:disable\n return [\n {\n fullClassName: \"BisCore.ExternalSource\",\n query: {\n ecsql: `\n SELECT\n ${await this._selectQueryFactory.createSelectClause({\n ecClassId: { selector: \"this.ECClassId\" },\n ecInstanceId: { selector: \"this.ECInstanceId\" },\n nodeLabel: {\n selector: await this.createCompositeLabelSelectClause({ externalSourceAlias: \"this\", repositoryLinkAlias: \"rl\" }),\n },\n extendedData: {\n imageId: \"icon-document\",\n },\n supportsFiltering: { selector: this.createExternalSourceSupportsFilteringSelector(\"this\") },\n })}\n FROM ${instanceFilterClauses.from} this\n JOIN BisCore.ExternalSourceGroupGroupsSources esggs ON esggs.TargetECInstanceId = this.ECInstanceId\n LEFT JOIN BisCore.RepositoryLink rl ON rl.ECInstanceId = this.Repository.Id\n ${instanceFilterClauses.joins}\n WHERE\n esggs.SourceECInstanceId IN (${groupIds.map(() => \"?\").join(\",\")})\n ${instanceFilterClauses.where ? `AND ${instanceFilterClauses.where}` : \"\"}\n `,\n bindings: groupIds.map((id) => ({ type: \"id\", value: id })),\n },\n },\n ];\n // cspell:enable\n }\n\n private async createExternalSourceChildrenQuery({\n parentNodeInstanceIds: sourceIds,\n instanceFilter,\n }: DefineInstanceNodeChildHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n const instanceFilterClauses = await this._selectQueryFactory.createFilterClauses({\n filter: instanceFilter,\n contentClass: { fullName: \"BisCore.ExternalSource\", alias: \"this\" },\n });\n return [\n {\n fullClassName: \"BisCore.ExternalSource\",\n query: {\n ecsql: `\n SELECT\n ${await this._selectQueryFactory.createSelectClause({\n ecClassId: { selector: \"this.ECClassId\" },\n ecInstanceId: { selector: \"this.ECInstanceId\" },\n nodeLabel: {\n selector: await this.createCompositeLabelSelectClause({ externalSourceAlias: \"this\", repositoryLinkAlias: \"rl\" }),\n },\n extendedData: {\n imageId: \"icon-document\",\n },\n supportsFiltering: { selector: this.createExternalSourceSupportsFilteringSelector(\"this\") },\n })}\n FROM ${instanceFilterClauses.from} this\n JOIN BisCore.ExternalSourceAttachment esa ON esa.Attaches.Id = this.ECInstanceId\n LEFT JOIN BisCore.RepositoryLink rl ON rl.ECInstanceId = this.Repository.Id\n ${instanceFilterClauses.joins}\n WHERE\n esa.Parent.Id IN (${sourceIds.map(() => \"?\").join(\",\")})\n ${instanceFilterClauses.where ? `AND ${instanceFilterClauses.where}` : \"\"}\n `,\n bindings: sourceIds.map((id) => ({ type: \"id\", value: id })),\n },\n },\n {\n node: {\n key: \"ElementsNode\",\n label: \"Elements\",\n extendedData: {\n sourceIds,\n imageId: \"icon-ec-schema\",\n },\n supportsFiltering: true,\n processingParams: {\n hideIfNoChildren: true,\n },\n },\n },\n ];\n }\n\n private createExternalSourceSupportsFilteringSelector(alias: string) {\n return `\n IFNULL((\n SELECT 1\n FROM (\n SELECT 1 FROM BisCore.ExternalSourceGroupGroupsSources WHERE SourceECInstanceId = ${alias}.ECInstanceId\n UNION ALL\n SELECT 1 FROM BisCore.ExternalSourceAttachment WHERE Parent.Id = ${alias}.ECInstanceId\n )\n LIMIT 1\n ), 0)\n `;\n }\n\n private async createElementsNodeChildrenQuery({ parentNode, instanceFilter }: DefineGenericNodeChildHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n const sourceIds: string[] = parentNode.extendedData?.sourceIds;\n const instanceFilterClauses = await this._selectQueryFactory.createFilterClauses({\n filter: instanceFilter,\n contentClass: { fullName: \"BisCore.GeometricElement\", alias: \"this\" },\n });\n return [\n {\n fullClassName: \"BisCore.GeometricElement\",\n query: {\n ecsql: `\n SELECT\n ${await this._selectQueryFactory.createSelectClause({\n ecClassId: { selector: \"this.ECClassId\" },\n ecInstanceId: { selector: \"this.ECInstanceId\" },\n nodeLabel: {\n selector: await this._nodeLabelSelectClauseFactory.createSelectClause({\n classAlias: \"this\",\n className: \"BisCore.GeometricElement\",\n }),\n },\n extendedData: {\n imageId: \"icon-item\",\n },\n grouping: { byClass: true },\n hasChildren: false,\n })}\n FROM ${instanceFilterClauses.from} this\n JOIN BisCore.ExternalSourceAspect esa ON esa.Element.Id = this.ECInstanceId\n ${instanceFilterClauses.joins}\n WHERE\n esa.Source.Id IN (${sourceIds.map(() => \"?\").join(\",\")})\n ${instanceFilterClauses.where ? `AND ${instanceFilterClauses.where}` : \"\"}\n `,\n bindings: sourceIds.map((id) => ({ type: \"id\", value: id })),\n },\n },\n ];\n }\n\n private async createCompositeLabelSelectClause({ externalSourceAlias, repositoryLinkAlias }: { externalSourceAlias: string; repositoryLinkAlias: string }) {\n return ECSql.createConcatenatedValueJsonSelector([\n {\n selector: `IIF(\n ${repositoryLinkAlias}.ECInstanceId IS NOT NULL,\n ${ECSql.createConcatenatedValueJsonSelector([\n {\n selector: await this._nodeLabelSelectClauseFactory.createSelectClause({\n classAlias: repositoryLinkAlias,\n className: \"BisCore.RepositoryLink\",\n }),\n },\n {\n type: \"String\",\n value: \" - \",\n },\n ])},\n ''\n )`,\n },\n {\n selector: await this._nodeLabelSelectClauseFactory.createSelectClause({\n classAlias: externalSourceAlias,\n className: \"BisCore.ExternalSource\",\n }),\n },\n ]);\n }\n\n private async isSupported() {\n const query = `\n SELECT 1\n FROM ECDbMeta.ECSchemaDef\n WHERE Name = 'BisCore' AND (VersionMajor > 1 OR (VersionMajor = 1 AND VersionMinor > 12))\n `;\n\n for await (const _row of this._queryExecutor.createQueryReader({ ecsql: query })) {\n return true;\n }\n return false;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ExternalSourcesTreeDefinition.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeDefinition.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,6BAA6B,EAAE,uCAAuC,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AACxI,OAAO,EAAE,yCAAyC,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAqB9F,MAAM,OAAO,6BAA6B;IACxC,KAAK,CAAsB;IAC3B,mBAAmB,CAA0B;IAC7C,6BAA6B,CAAoC;IACjE,cAAc,CAA6B;IAC3C,YAAY,CAAoB;IAChC,YAAY,CAAa;IACzB,cAAc,CAAS;IAEvB,YAAmB,KAAyC;QAC1D,IAAI,CAAC,KAAK,GAAG,uCAAuC,CAAC;YACnD,uBAAuB,EAAE,KAAK,CAAC,YAAY;YAC3C,SAAS,EAAE;gBACT,SAAS,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,CAAC,IAAI,CAAC,kCAAkC,CAAC,YAAY,CAAC;gBACxF,UAAU,EAAE;oBACV;wBACE,4BAA4B,EAAE,6BAA6B;wBAC3D,WAAW,EAAE,KAAK,EAAE,YAAwD,EAAE,EAAE,CAAC,IAAI,CAAC,uCAAuC,CAAC,YAAY,CAAC;qBAC5I;oBACD;wBACE,4BAA4B,EAAE,wBAAwB;wBACtD,WAAW,EAAE,KAAK,EAAE,YAAwD,EAAE,EAAE,CAAC,IAAI,CAAC,iCAAiC,CAAC,YAAY,CAAC;qBACtI;oBACD;wBACE,0BAA0B,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,cAAc;wBACnE,WAAW,EAAE,KAAK,EAAE,YAAuD,EAAE,E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,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE;WAC5E;oBACD,QAAQ,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;iBAC7D;aACF;SACF,CAAC;IACJ,CAAC;IAEO,KAAK,CAAC,gCAAgC,CAAC,EAAE,mBAAmB,EAAE,mBAAmB,EAAgE;QACvJ,OAAO,KAAK,CAAC,mCAAmC,CAAC;YAC/C;gBACE,QAAQ,EAAE;YACN,mBAAmB;YACnB,KAAK,CAAC,mCAAmC,CAAC;oBAC1C;wBACE,QAAQ,EAAE,MAAM,IAAI,CAAC,6BAA6B,CAAC,kBAAkB,CAAC;4BACpE,UAAU,EAAE,mBAAmB;4BAC/B,SAAS,EAAE,wBAAwB;yBACpC,CAAC;qBACH;oBACD;wBACE,IAAI,EAAE,QAAQ;wBACd,KAAK,EAAE,KAAK;qBACb;iBACF,CAAC;;UAEF;aACH;YACD;gBACE,QAAQ,EAAE,MAAM,IAAI,CAAC,6BAA6B,CAAC,kBAAkB,CAAC;oBACpE,UAAU,EAAE,mBAAmB;oBAC/B,SAAS,EAAE,wBAAwB;iBACpC,CAAC;aACH;SACF,CAAC,CAAC;IACL,CAAC;IAEO,KAAK,CAAC,WAAW;QACvB,MAAM,KAAK,GAAG;;;;KAIb,CAAC;QAEF,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,IAAI,CAAC,cAAc,CAAC,iBAAiB,CAC5D,EAAE,KAAK,EAAE,KAAK,EAAE,EAChB,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,YAAY,+BAA+B,EAAE,CAC7F,EAAE,CAAC;YACF,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { Guid } from \"@itwin/core-bentley\";\nimport { createNodesQueryClauseFactory, createPredicateBasedHierarchyDefinition, HierarchyNode } from \"@itwin/presentation-hierarchies\";\nimport { createBisInstanceLabelSelectClauseFactory, ECSql } from \"@itwin/presentation-shared\";\n\nimport type { GuidString } from \"@itwin/core-bentley\";\nimport type {\n DefineGenericNodeChildHierarchyLevelProps,\n DefineHierarchyLevelProps,\n DefineInstanceNodeChildHierarchyLevelProps,\n DefineRootHierarchyLevelProps,\n HierarchyDefinition,\n HierarchyLevelDefinition,\n LimitingECSqlQueryExecutor,\n NodesQueryClauseFactory,\n ProcessedHierarchyNode,\n} from \"@itwin/presentation-hierarchies\";\nimport type { ECClassHierarchyInspector, ECSchemaProvider, IInstanceLabelSelectClauseFactory } from \"@itwin/presentation-shared\";\n\ninterface ExternalSourcesTreeDefinitionProps {\n imodelAccess: ECSchemaProvider & ECClassHierarchyInspector & LimitingECSqlQueryExecutor;\n componentId?: GuidString;\n}\n\nexport class ExternalSourcesTreeDefinition implements HierarchyDefinition {\n #impl: HierarchyDefinition;\n #selectQueryFactory: NodesQueryClauseFactory;\n #nodeLabelSelectClauseFactory: IInstanceLabelSelectClauseFactory;\n #queryExecutor: LimitingECSqlQueryExecutor;\n #isSupported?: Promise<boolean>;\n #componentId: GuidString;\n #componentName: string;\n\n public constructor(props: ExternalSourcesTreeDefinitionProps) {\n this.#impl = createPredicateBasedHierarchyDefinition({\n classHierarchyInspector: props.imodelAccess,\n hierarchy: {\n rootNodes: async (requestProps) => this.createRootHierarchyLevelDefinition(requestProps),\n childNodes: [\n {\n parentInstancesNodePredicate: \"BisCore.ExternalSourceGroup\",\n definitions: async (requestProps: DefineInstanceNodeChildHierarchyLevelProps) => this.createExternalSourcesGroupChildrenQuery(requestProps),\n },\n {\n parentInstancesNodePredicate: \"BisCore.ExternalSource\",\n definitions: async (requestProps: DefineInstanceNodeChildHierarchyLevelProps) => this.createExternalSourceChildrenQuery(requestProps),\n },\n {\n parentGenericNodePredicate: async ({ id }) => id === \"ElementsNode\",\n definitions: async (requestProps: DefineGenericNodeChildHierarchyLevelProps) => this.createElementsNodeChildrenQuery(requestProps),\n },\n ],\n },\n });\n this.#queryExecutor = props.imodelAccess;\n this.#nodeLabelSelectClauseFactory = createBisInstanceLabelSelectClauseFactory({ classHierarchyInspector: props.imodelAccess });\n this.#selectQueryFactory = createNodesQueryClauseFactory({\n imodelAccess: props.imodelAccess,\n instanceLabelSelectClauseFactory: this.#nodeLabelSelectClauseFactory,\n });\n this.#componentId = props.componentId ?? Guid.createValue();\n this.#componentName = \"ExternalSourcesTreeDefinition\";\n }\n\n public async postProcessNode(node: ProcessedHierarchyNode): Promise<ProcessedHierarchyNode> {\n if (HierarchyNode.isClassGroupingNode(node)) {\n // `imageId` is assigned to instance nodes at query time, but grouping ones need to be handled during post-processing\n return { ...node, extendedData: { ...node.extendedData, imageId: \"icon-ec-class\" } };\n }\n return node;\n }\n\n public async defineHierarchyLevel(props: DefineHierarchyLevelProps) {\n if (this.#isSupported === undefined) {\n this.#isSupported = this.isSupported();\n }\n\n if ((await this.#isSupported) === false) {\n return [];\n }\n\n return this.#impl.defineHierarchyLevel(props);\n }\n\n private async createRootHierarchyLevelDefinition(props: DefineRootHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n const instanceFilterClauses = await this.#selectQueryFactory.createFilterClauses({\n filter: props.instanceFilter,\n contentClass: { fullName: \"BisCore.ExternalSource\", alias: \"this\" },\n });\n\n // cspell:disable\n return [\n {\n fullClassName: \"BisCore.ExternalSource\",\n query: {\n ecsql: `\n SELECT\n ${await this.#selectQueryFactory.createSelectClause({\n ecClassId: { selector: ECSql.createRawPropertyValueSelector(\"this\", \"ECClassId\") },\n ecInstanceId: { selector: \"this.ECInstanceId\" },\n nodeLabel: {\n selector: await this.createCompositeLabelSelectClause({ externalSourceAlias: \"this\", repositoryLinkAlias: \"rl\" }),\n },\n extendedData: {\n imageId: \"icon-document\",\n },\n autoExpand: true,\n supportsFiltering: { selector: this.createExternalSourceSupportsFilteringSelector(\"this\") },\n })}\n FROM ${instanceFilterClauses.from} this\n ${instanceFilterClauses.joins}\n JOIN BisCore.SynchronizationConfigSpecifiesRootSources scsrs ON scsrs.TargetECInstanceId = this.ECInstanceId\n LEFT JOIN BisCore.RepositoryLink rl ON rl.ECInstanceId = this.Repository.Id\n ${instanceFilterClauses.where ? `WHERE ${instanceFilterClauses.where}` : \"\"}\n `,\n },\n },\n ];\n // cspell:enable\n }\n\n private async createExternalSourcesGroupChildrenQuery({\n parentNodeInstanceIds: groupIds,\n instanceFilter,\n }: DefineInstanceNodeChildHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n const instanceFilterClauses = await this.#selectQueryFactory.createFilterClauses({\n filter: instanceFilter,\n contentClass: { fullName: \"BisCore.ExternalSource\", alias: \"this\" },\n });\n // cspell:disable\n return [\n {\n fullClassName: \"BisCore.ExternalSource\",\n query: {\n ecsql: `\n SELECT\n ${await this.#selectQueryFactory.createSelectClause({\n ecClassId: { selector: \"this.ECClassId\" },\n ecInstanceId: { selector: \"this.ECInstanceId\" },\n nodeLabel: {\n selector: await this.createCompositeLabelSelectClause({ externalSourceAlias: \"this\", repositoryLinkAlias: \"rl\" }),\n },\n extendedData: {\n imageId: \"icon-document\",\n },\n supportsFiltering: { selector: this.createExternalSourceSupportsFilteringSelector(\"this\") },\n })}\n FROM ${instanceFilterClauses.from} this\n JOIN BisCore.ExternalSourceGroupGroupsSources esggs ON esggs.TargetECInstanceId = this.ECInstanceId\n LEFT JOIN BisCore.RepositoryLink rl ON rl.ECInstanceId = this.Repository.Id\n ${instanceFilterClauses.joins}\n WHERE\n esggs.SourceECInstanceId IN (${groupIds.map(() => \"?\").join(\",\")})\n ${instanceFilterClauses.where ? `AND ${instanceFilterClauses.where}` : \"\"}\n `,\n bindings: groupIds.map((id) => ({ type: \"id\", value: id })),\n },\n },\n ];\n // cspell:enable\n }\n\n private async createExternalSourceChildrenQuery({\n parentNodeInstanceIds: sourceIds,\n instanceFilter,\n }: DefineInstanceNodeChildHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n const instanceFilterClauses = await this.#selectQueryFactory.createFilterClauses({\n filter: instanceFilter,\n contentClass: { fullName: \"BisCore.ExternalSource\", alias: \"this\" },\n });\n return [\n {\n fullClassName: \"BisCore.ExternalSource\",\n query: {\n ecsql: `\n SELECT\n ${await this.#selectQueryFactory.createSelectClause({\n ecClassId: { selector: \"this.ECClassId\" },\n ecInstanceId: { selector: \"this.ECInstanceId\" },\n nodeLabel: {\n selector: await this.createCompositeLabelSelectClause({ externalSourceAlias: \"this\", repositoryLinkAlias: \"rl\" }),\n },\n extendedData: {\n imageId: \"icon-document\",\n },\n supportsFiltering: { selector: this.createExternalSourceSupportsFilteringSelector(\"this\") },\n })}\n FROM ${instanceFilterClauses.from} this\n JOIN BisCore.ExternalSourceAttachment esa ON esa.Attaches.Id = this.ECInstanceId\n LEFT JOIN BisCore.RepositoryLink rl ON rl.ECInstanceId = this.Repository.Id\n ${instanceFilterClauses.joins}\n WHERE\n esa.Parent.Id IN (${sourceIds.map(() => \"?\").join(\",\")})\n ${instanceFilterClauses.where ? `AND ${instanceFilterClauses.where}` : \"\"}\n `,\n bindings: sourceIds.map((id) => ({ type: \"id\", value: id })),\n },\n },\n {\n node: {\n key: \"ElementsNode\",\n label: \"Elements\",\n extendedData: {\n sourceIds,\n imageId: \"icon-ec-schema\",\n },\n supportsFiltering: true,\n processingParams: {\n hideIfNoChildren: true,\n },\n },\n },\n ];\n }\n\n private createExternalSourceSupportsFilteringSelector(alias: string) {\n return `\n IFNULL((\n SELECT 1\n FROM (\n SELECT 1 FROM BisCore.ExternalSourceGroupGroupsSources WHERE SourceECInstanceId = ${alias}.ECInstanceId\n UNION ALL\n SELECT 1 FROM BisCore.ExternalSourceAttachment WHERE Parent.Id = ${alias}.ECInstanceId\n )\n LIMIT 1\n ), 0)\n `;\n }\n\n private async createElementsNodeChildrenQuery({ parentNode, instanceFilter }: DefineGenericNodeChildHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n const sourceIds: string[] = parentNode.extendedData?.sourceIds;\n const instanceFilterClauses = await this.#selectQueryFactory.createFilterClauses({\n filter: instanceFilter,\n contentClass: { fullName: \"BisCore.GeometricElement\", alias: \"this\" },\n });\n return [\n {\n fullClassName: \"BisCore.GeometricElement\",\n query: {\n ecsql: `\n SELECT\n ${await this.#selectQueryFactory.createSelectClause({\n ecClassId: { selector: \"this.ECClassId\" },\n ecInstanceId: { selector: \"this.ECInstanceId\" },\n nodeLabel: {\n selector: await this.#nodeLabelSelectClauseFactory.createSelectClause({\n classAlias: \"this\",\n className: \"BisCore.GeometricElement\",\n }),\n },\n extendedData: {\n imageId: \"icon-item\",\n },\n grouping: { byClass: true },\n hasChildren: false,\n })}\n FROM ${instanceFilterClauses.from} this\n JOIN BisCore.ExternalSourceAspect esa ON esa.Element.Id = this.ECInstanceId\n ${instanceFilterClauses.joins}\n WHERE\n esa.Source.Id IN (${sourceIds.map(() => \"?\").join(\",\")})\n ${instanceFilterClauses.where ? `AND ${instanceFilterClauses.where}` : \"\"}\n `,\n bindings: sourceIds.map((id) => ({ type: \"id\", value: id })),\n },\n },\n ];\n }\n\n private async createCompositeLabelSelectClause({ externalSourceAlias, repositoryLinkAlias }: { externalSourceAlias: string; repositoryLinkAlias: string }) {\n return ECSql.createConcatenatedValueJsonSelector([\n {\n selector: `IIF(\n ${repositoryLinkAlias}.ECInstanceId IS NOT NULL,\n ${ECSql.createConcatenatedValueJsonSelector([\n {\n selector: await this.#nodeLabelSelectClauseFactory.createSelectClause({\n classAlias: repositoryLinkAlias,\n className: \"BisCore.RepositoryLink\",\n }),\n },\n {\n type: \"String\",\n value: \" - \",\n },\n ])},\n ''\n )`,\n },\n {\n selector: await this.#nodeLabelSelectClauseFactory.createSelectClause({\n classAlias: externalSourceAlias,\n className: \"BisCore.ExternalSource\",\n }),\n },\n ]);\n }\n\n private async isSupported() {\n const query = `\n SELECT 1\n FROM ECDbMeta.ECSchemaDef\n WHERE Name = 'BisCore' AND (VersionMajor > 1 OR (VersionMajor = 1 AND VersionMinor > 12))\n `;\n\n for await (const _row of this.#queryExecutor.createQueryReader(\n { ecsql: query },\n { restartToken: `${this.#componentName}/${this.#componentId}/is-external-source-supported` },\n )) {\n return true;\n }\n return false;\n }\n}\n"]}
|
package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { IModelContentTreeHierarchyConfiguration } from "./IModelContentTreeDefinition.js";
|
|
2
1
|
import type { TreeProps } from "../common/components/Tree.js";
|
|
2
|
+
import type { IModelContentTreeHierarchyConfiguration } from "./IModelContentTreeDefinition.js";
|
|
3
3
|
/** @beta */
|
|
4
4
|
export type IModelContentTreeProps = Pick<TreeProps, "imodel" | "getSchemaContext" | "selectionStorage" | "density" | "selectionMode"> & {
|
|
5
5
|
hierarchyLevelConfig?: {
|
|
@@ -7,20 +7,22 @@ import { useCallback } from "react";
|
|
|
7
7
|
import { SvgFolder, SvgGroup, SvgHierarchyTree, SvgImodelHollow, SvgItem, SvgLayers, SvgModel } from "@itwin/itwinui-icons-react";
|
|
8
8
|
import { Tree } from "../common/components/Tree.js";
|
|
9
9
|
import { TreeRenderer } from "../common/components/TreeRenderer.js";
|
|
10
|
+
import { useGuid } from "../common/useGuid.js";
|
|
10
11
|
import { IModelContentTreeComponent } from "./IModelContentTreeComponent.js";
|
|
11
12
|
import { defaultHierarchyConfiguration, IModelContentTreeDefinition } from "./IModelContentTreeDefinition.js";
|
|
12
13
|
import { IModelContentTreeIdsCache } from "./internal/IModelContentTreeIdsCache.js";
|
|
13
14
|
/** @beta */
|
|
14
15
|
export function IModelContentTree({ hierarchyConfig: hierarchyConfigProp, ...props }) {
|
|
16
|
+
const componentId = useGuid();
|
|
15
17
|
const getHierarchyDefinition = useCallback(({ imodelAccess }) => {
|
|
16
18
|
const hierarchyConfig = {
|
|
17
19
|
...defaultHierarchyConfiguration,
|
|
18
20
|
...hierarchyConfigProp,
|
|
19
21
|
};
|
|
20
|
-
return new IModelContentTreeDefinition({ imodelAccess, idsCache: new IModelContentTreeIdsCache(imodelAccess), hierarchyConfig });
|
|
22
|
+
return new IModelContentTreeDefinition({ imodelAccess, idsCache: new IModelContentTreeIdsCache(imodelAccess, componentId), hierarchyConfig });
|
|
21
23
|
},
|
|
22
24
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
23
|
-
Object.values(hierarchyConfigProp ?? {}));
|
|
25
|
+
Object.values({ ...(hierarchyConfigProp ?? {}), componentId }));
|
|
24
26
|
return (_jsx(Tree, { ...props, treeName: IModelContentTreeComponent.id, getHierarchyDefinition: getHierarchyDefinition, selectionMode: props.selectionMode ?? "extended", treeRenderer: (treeProps) => _jsx(TreeRenderer, { ...treeProps, getIcon: getIcon }) }));
|
|
25
27
|
}
|
|
26
28
|
function getIcon(node) {
|
package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelContentTree.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,gBAAgB,EAAE,eAAe,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAClI,OAAO,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,6BAA6B,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC9G,OAAO,EAAE,yBAAyB,EAAE,MAAM,yCAAyC,CAAC;AAepF,YAAY;AACZ,MAAM,UAAU,iBAAiB,CAAC,EAAE,eAAe,EAAE,mBAAmB,EAAE,GAAG,KAAK,EAA0B;IAC1G,MAAM,sBAAsB,GAAG,WAAW,CACxC,CAAC,EAAE,YAAY,EAAE,EAAE,EAAE;QACnB,MAAM,eAAe,GAAG;YACtB,GAAG,6BAA6B;YAChC,GAAG,mBAAmB;SACvB,CAAC;QACF,OAAO,IAAI,2BAA2B,CAAC,EAAE,YAAY,EAAE,QAAQ,EAAE,IAAI,yBAAyB,CAAC,YAAY,CAAC,EAAE,eAAe,EAAE,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"IModelContentTree.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,gBAAgB,EAAE,eAAe,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAClI,OAAO,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,6BAA6B,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC9G,OAAO,EAAE,yBAAyB,EAAE,MAAM,yCAAyC,CAAC;AAepF,YAAY;AACZ,MAAM,UAAU,iBAAiB,CAAC,EAAE,eAAe,EAAE,mBAAmB,EAAE,GAAG,KAAK,EAA0B;IAC1G,MAAM,WAAW,GAAG,OAAO,EAAE,CAAC;IAC9B,MAAM,s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BAAqB;YACxB,OAAO,KAAC,gBAAgB,KAAG,CAAC;QAC9B,KAAK,YAAY;YACf,OAAO,KAAC,QAAQ,KAAG,CAAC;IACxB,CAAC;IAED,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 } from \"react\";\nimport { SvgFolder, SvgGroup, SvgHierarchyTree, SvgImodelHollow, SvgItem, SvgLayers, SvgModel } from \"@itwin/itwinui-icons-react\";\nimport { Tree } from \"../common/components/Tree.js\";\nimport { TreeRenderer } from \"../common/components/TreeRenderer.js\";\nimport { useGuid } from \"../common/useGuid.js\";\nimport { IModelContentTreeComponent } from \"./IModelContentTreeComponent.js\";\nimport { defaultHierarchyConfiguration, IModelContentTreeDefinition } from \"./IModelContentTreeDefinition.js\";\nimport { IModelContentTreeIdsCache } from \"./internal/IModelContentTreeIdsCache.js\";\n\nimport type { ReactElement } from \"react\";\nimport type { PresentationHierarchyNode } from \"@itwin/presentation-hierarchies-react\";\nimport type { TreeProps } from \"../common/components/Tree.js\";\nimport type { IModelContentTreeHierarchyConfiguration } from \"./IModelContentTreeDefinition.js\";\n\n/** @beta */\nexport type IModelContentTreeProps = Pick<TreeProps, \"imodel\" | \"getSchemaContext\" | \"selectionStorage\" | \"density\" | \"selectionMode\"> & {\n hierarchyLevelConfig?: {\n sizeLimit?: number;\n };\n hierarchyConfig?: Partial<IModelContentTreeHierarchyConfiguration>;\n};\n\n/** @beta */\nexport function IModelContentTree({ hierarchyConfig: hierarchyConfigProp, ...props }: IModelContentTreeProps) {\n const componentId = useGuid();\n const getHierarchyDefinition = useCallback<TreeProps[\"getHierarchyDefinition\"]>(\n ({ imodelAccess }) => {\n const hierarchyConfig = {\n ...defaultHierarchyConfiguration,\n ...hierarchyConfigProp,\n };\n return new IModelContentTreeDefinition({ imodelAccess, idsCache: new IModelContentTreeIdsCache(imodelAccess, componentId), hierarchyConfig });\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n Object.values({ ...(hierarchyConfigProp ?? {}), componentId }),\n );\n\n return (\n <Tree\n {...props}\n treeName={IModelContentTreeComponent.id}\n getHierarchyDefinition={getHierarchyDefinition}\n selectionMode={props.selectionMode ?? \"extended\"}\n treeRenderer={(treeProps) => <TreeRenderer {...treeProps} getIcon={getIcon} />}\n />\n );\n}\n\nfunction getIcon(node: PresentationHierarchyNode): ReactElement | undefined {\n if (node.extendedData?.imageId === undefined) {\n return undefined;\n }\n\n switch (node.extendedData.imageId) {\n case \"icon-layers\":\n return <SvgLayers />;\n case \"icon-item\":\n return <SvgItem />;\n case \"icon-ec-class\":\n return <SvgItem />;\n case \"icon-imodel-hollow-2\":\n return <SvgImodelHollow />;\n case \"icon-folder\":\n return <SvgFolder />;\n case \"icon-model\":\n return <SvgModel />;\n case \"icon-hierarchy-tree\":\n return <SvgHierarchyTree />;\n case \"icon-group\":\n return <SvgGroup />;\n }\n\n return undefined;\n}\n"]}
|
|
@@ -18,11 +18,7 @@ interface IModelContentTreeDefinitionProps {
|
|
|
18
18
|
hierarchyConfig: IModelContentTreeHierarchyConfiguration;
|
|
19
19
|
}
|
|
20
20
|
export declare class IModelContentTreeDefinition implements HierarchyDefinition {
|
|
21
|
-
private
|
|
22
|
-
private _idsCache;
|
|
23
|
-
private _hierarchyConfig;
|
|
24
|
-
private _selectQueryFactory;
|
|
25
|
-
private _nodeLabelSelectClauseFactory;
|
|
21
|
+
#private;
|
|
26
22
|
constructor(props: IModelContentTreeDefinitionProps);
|
|
27
23
|
postProcessNode(node: ProcessedHierarchyNode): Promise<ProcessedHierarchyNode>;
|
|
28
24
|
defineHierarchyLevel(props: DefineHierarchyLevelProps): Promise<HierarchyLevelDefinition>;
|