@itwin/tree-widget-react 3.10.3 → 3.12.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 +22 -2
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.d.ts +1 -0
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js +18 -12
- 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 +2 -2
- package/lib/cjs/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.d.ts +10 -1
- package/lib/cjs/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.js +28 -21
- package/lib/cjs/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/common/UseIModelAccess.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/common/Utils.d.ts +4 -0
- package/lib/cjs/tree-widget-react/components/trees/common/Utils.js +50 -0
- package/lib/cjs/tree-widget-react/components/trees/common/Utils.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTree.d.ts +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTree.js +2 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTree.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.d.ts +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
- package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.d.ts +8 -9
- package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js +32 -27
- 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.d.ts +20 -2
- package/lib/cjs/tree-widget-react/components/trees/models-tree/UseModelsTree.js +95 -37
- package/lib/cjs/tree-widget-react/components/trees/models-tree/UseModelsTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.d.ts +1 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js +19 -13
- 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 +2 -2
- package/lib/esm/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.d.ts +10 -1
- package/lib/esm/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.js +28 -21
- package/lib/esm/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/UseIModelAccess.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/Utils.d.ts +4 -0
- package/lib/esm/tree-widget-react/components/trees/common/Utils.js +49 -0
- package/lib/esm/tree-widget-react/components/trees/common/Utils.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTree.d.ts +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTree.js +2 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.d.ts +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.d.ts +8 -9
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js +33 -28
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.d.ts +20 -2
- package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.js +96 -38
- package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.js.map +1 -1
- package/lib/public/locales/en/TreeWidget.json +3 -0
- package/package.json +3 -3
|
@@ -6,6 +6,7 @@ import { QueryRowFormat } from "@itwin/core-common";
|
|
|
6
6
|
import { PerModelCategoryVisibility } from "@itwin/core-frontend";
|
|
7
7
|
/**
|
|
8
8
|
* Toggles visibility of categories to show or hide.
|
|
9
|
+
* @internal
|
|
9
10
|
*/
|
|
10
11
|
export async function toggleAllCategories(viewport, display) {
|
|
11
12
|
const ids = await getCategories(viewport);
|
|
@@ -23,30 +24,33 @@ async function getCategories(viewport) {
|
|
|
23
24
|
}
|
|
24
25
|
/**
|
|
25
26
|
* Changes category display in the viewport.
|
|
27
|
+
* @internal
|
|
26
28
|
*/
|
|
27
|
-
export async function enableCategoryDisplay(viewport,
|
|
28
|
-
viewport.changeCategoryDisplay(
|
|
29
|
+
export async function enableCategoryDisplay(viewport, categoryIds, enabled, enableAllSubCategories = true) {
|
|
30
|
+
viewport.changeCategoryDisplay(categoryIds, enabled, enableAllSubCategories);
|
|
29
31
|
// remove category overrides per model
|
|
30
32
|
const modelsContainingOverrides = [];
|
|
31
33
|
for (const ovr of viewport.perModelCategoryVisibility) {
|
|
32
|
-
if (
|
|
34
|
+
if (categoryIds.findIndex((id) => id === ovr.categoryId) !== -1) {
|
|
33
35
|
modelsContainingOverrides.push(ovr.modelId);
|
|
34
36
|
}
|
|
35
37
|
}
|
|
36
|
-
viewport.perModelCategoryVisibility.setOverride(modelsContainingOverrides,
|
|
38
|
+
viewport.perModelCategoryVisibility.setOverride(modelsContainingOverrides, categoryIds, PerModelCategoryVisibility.Override.None);
|
|
37
39
|
// changeCategoryDisplay only enables subcategories, it does not disabled them. So we must do that ourselves.
|
|
38
40
|
if (false === enabled) {
|
|
39
|
-
(await viewport.iModel.categories.getCategoryInfo(
|
|
41
|
+
(await viewport.iModel.categories.getCategoryInfo(categoryIds)).forEach((categoryInfo) => {
|
|
40
42
|
categoryInfo.subCategories.forEach((value) => enableSubCategoryDisplay(viewport, value.id, false));
|
|
41
43
|
});
|
|
42
44
|
}
|
|
43
45
|
}
|
|
44
46
|
/**
|
|
45
47
|
* Changes subcategory display in the viewport
|
|
48
|
+
* @internal
|
|
46
49
|
*/
|
|
47
50
|
export function enableSubCategoryDisplay(viewport, key, enabled) {
|
|
48
51
|
viewport.changeSubCategoryDisplay(key, enabled);
|
|
49
52
|
}
|
|
53
|
+
/** @internal */
|
|
50
54
|
export async function loadCategoriesFromViewport(vp) {
|
|
51
55
|
// Query categories and add them to state
|
|
52
56
|
const selectUsedSpatialCategoryIds = "SELECT DISTINCT Category.Id as id from BisCore.GeometricElement3d WHERE Category.Id IN (SELECT ECInstanceId from BisCore.SpatialCategory)";
|
|
@@ -76,33 +80,36 @@ export async function hideAllCategories(categories, viewport) {
|
|
|
76
80
|
}
|
|
77
81
|
/**
|
|
78
82
|
* Invert display of all given categories.
|
|
83
|
+
* Categories are inverted like this:
|
|
84
|
+
* - If category is visible, it will be hidden.
|
|
85
|
+
* - If category is hidden, it will be visible.
|
|
86
|
+
* - If category is partially visible, it will be fully visible.
|
|
79
87
|
* @public
|
|
80
88
|
*/
|
|
81
89
|
export async function invertAllCategories(categories, viewport) {
|
|
82
|
-
const
|
|
83
|
-
const
|
|
84
|
-
const enabledSubCategories = [];
|
|
85
|
-
const disabledSubCategories = [];
|
|
90
|
+
const categoriesToEnable = new Set();
|
|
91
|
+
const categoriesToDisable = new Set();
|
|
86
92
|
for (const category of categories) {
|
|
87
93
|
if (!viewport.view.viewsCategory(category.categoryId)) {
|
|
88
|
-
|
|
94
|
+
categoriesToEnable.add(category.categoryId);
|
|
89
95
|
continue;
|
|
90
96
|
}
|
|
91
|
-
//
|
|
97
|
+
// Check if category is in partial state
|
|
92
98
|
if (category.subCategoryIds?.some((subCategory) => !viewport.isSubCategoryVisible(subCategory))) {
|
|
93
|
-
|
|
94
|
-
viewport.isSubCategoryVisible(subCategory) ? enabledSubCategories.push(subCategory) : disabledSubCategories.push(subCategory);
|
|
95
|
-
}
|
|
99
|
+
categoriesToEnable.add(category.categoryId);
|
|
96
100
|
}
|
|
97
101
|
else {
|
|
98
|
-
|
|
102
|
+
categoriesToDisable.add(category.categoryId);
|
|
99
103
|
}
|
|
100
104
|
}
|
|
101
|
-
//
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
105
|
+
// collect per model overrides that need to be inverted
|
|
106
|
+
for (const { categoryId, visible } of viewport.perModelCategoryVisibility) {
|
|
107
|
+
if (!visible && categoriesToDisable.has(categoryId)) {
|
|
108
|
+
categoriesToEnable.add(categoryId);
|
|
109
|
+
categoriesToDisable.delete(categoryId);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
await enableCategoryDisplay(viewport, [...categoriesToDisable], false, true);
|
|
113
|
+
await enableCategoryDisplay(viewport, [...categoriesToEnable], true, true);
|
|
107
114
|
}
|
|
108
115
|
//# sourceMappingURL=CategoriesVisibilityUtils.js.map
|
|
@@ -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,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"CategoriesVisibilityUtils.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EA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C,WAAW,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC;YAChG,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QAC9C,CAAC;aAAM,CAAC;YACN,mBAAmB,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;IAED,uDAAuD;IACvD,KAAK,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,QAAQ,CAAC,0BAA0B,EAAE,CAAC;QAC1E,IAAI,CAAC,OAAO,IAAI,mBAAmB,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;YACpD,kBAAkB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YACnC,mBAAmB,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 { QueryRowFormat } from \"@itwin/core-common\";\nimport { PerModelCategoryVisibility } from \"@itwin/core-frontend\";\n\nimport type { 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 * Toggles visibility of categories to show or hide.\n * @internal\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 */\nasync 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 * @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) {\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 * 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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UseIModelAccess.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/common/UseIModelAccess.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AACpG,OAAO,EAAE,gCAAgC,EAAE,MAAM,iCAAiC,CAAC;AACnF,OAAO,EAAE,sCAAsC,EAAE,MAAM,4BAA4B,CAAC;AAgBpF,gBAAgB;AAChB,MAAM,UAAU,eAAe,CAAC,
|
|
1
|
+
{"version":3,"file":"UseIModelAccess.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/common/UseIModelAccess.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AACpG,OAAO,EAAE,gCAAgC,EAAE,MAAM,iCAAiC,CAAC;AACnF,OAAO,EAAE,sCAAsC,EAAE,MAAM,4BAA4B,CAAC;AAgBpF,gBAAgB;AAChB,MAAM,UAAU,eAAe,CAAC,EAAE,MAAM,EAAE,gBAAgB,EAAE,YAAY,EAAE,oBAAoB,EAAE,uBAAuB,EAAwB;IAI7I,MAAM,8BAA8B,GAAG,uBAAuB,IAAI,IAAI,CAAC;IACvE,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,EAAE;QAChC,OAAO,oBAAoB,IAAI,kBAAkB,CAAC,EAAE,gBAAgB,EAAE,MAAM,EAAE,uBAAuB,EAAE,8BAA8B,EAAE,CAAC,CAAC;IAC3I,CAAC,EAAE,CAAC,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,EAAE,8BAA8B,CAAC,CAAC,CAAC;IAErF,OAAO;QACL,YAAY;QACZ,8BAA8B,EAAE,8BAA8B;KAC/D,CAAC;AACJ,CAAC;AAED,SAAS,kBAAkB,CAAC,EAC1B,MAAM,EACN,gBAAgB,EAChB,uBAAuB,GAKxB;IACC,MAAM,OAAO,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACzC,MAAM,cAAc,GAAG,sBAAsB,CAAC,OAAO,CAAC,CAAC;IACvD,OAAO;QACL,SAAS,EAAE,MAAM,CAAC,GAAG;QACrB,GAAG,cAAc;QACjB,GAAG,sCAAsC,CAAC,EAAE,cAAc,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC;QAC7E,GAAG,gCAAgC,CAAC,wBAAwB,CAAC,MAAM,CAAC,EAAE,uBAAuB,CAAC;KAC/F,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useMemo } from \"react\";\nimport { createECSchemaProvider, createECSqlQueryExecutor } from \"@itwin/presentation-core-interop\";\nimport { createLimitingECSqlQueryExecutor } from \"@itwin/presentation-hierarchies\";\nimport { createCachingECClassHierarchyInspector } from \"@itwin/presentation-shared\";\n\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport type { SchemaContext } from \"@itwin/ecschema-metadata\";\nimport type { useIModelTree } from \"@itwin/presentation-hierarchies-react\";\nimport type { FunctionProps } from \"./Utils.js\";\n\ntype IModelAccess = FunctionProps<typeof useIModelTree>[\"imodelAccess\"];\n\nexport interface UseIModelAccessProps {\n imodel: IModelConnection;\n getSchemaContext: (imodel: IModelConnection) => SchemaContext;\n imodelAccess?: IModelAccess;\n hierarchyLevelSizeLimit?: number;\n}\n\n/** @internal */\nexport function useIModelAccess({ imodel, getSchemaContext, imodelAccess: providedIModelAccess, hierarchyLevelSizeLimit }: UseIModelAccessProps): {\n imodelAccess: IModelAccess;\n currentHierarchyLevelSizeLimit: number;\n} {\n const defaultHierarchyLevelSizeLimit = hierarchyLevelSizeLimit ?? 1000;\n const imodelAccess = useMemo(() => {\n return providedIModelAccess ?? createIModelAccess({ getSchemaContext, imodel, hierarchyLevelSizeLimit: defaultHierarchyLevelSizeLimit });\n }, [providedIModelAccess, getSchemaContext, imodel, defaultHierarchyLevelSizeLimit]);\n\n return {\n imodelAccess,\n currentHierarchyLevelSizeLimit: defaultHierarchyLevelSizeLimit,\n };\n}\n\nfunction createIModelAccess({\n imodel,\n getSchemaContext,\n hierarchyLevelSizeLimit,\n}: {\n imodel: IModelConnection;\n getSchemaContext: (imodel: IModelConnection) => SchemaContext;\n hierarchyLevelSizeLimit: number;\n}) {\n const schemas = getSchemaContext(imodel);\n const schemaProvider = createECSchemaProvider(schemas);\n return {\n imodelKey: imodel.key,\n ...schemaProvider,\n ...createCachingECClassHierarchyInspector({ schemaProvider, cacheSize: 100 }),\n ...createLimitingECSqlQueryExecutor(createECSqlQueryExecutor(imodel), hierarchyLevelSizeLimit),\n };\n}\n"]}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { HierarchyFilteringPath } from "@itwin/presentation-hierarchies";
|
|
1
2
|
import type { Id64Array } from "@itwin/core-bentley";
|
|
3
|
+
import type { HierarchyNodeIdentifiersPath } from "@itwin/presentation-hierarchies";
|
|
2
4
|
/** @beta */
|
|
3
5
|
export type FunctionProps<THook extends (props: any) => any> = Parameters<THook>[0];
|
|
4
6
|
/** @internal */
|
|
@@ -9,4 +11,6 @@ export declare function parseIdsSelectorResult(selectorResult: any): Id64Array;
|
|
|
9
11
|
export declare function pushToMap<TKey, TValue>(targetMap: Map<TKey, Set<TValue>>, key: TKey, value: TValue): void;
|
|
10
12
|
/** @internal */
|
|
11
13
|
export declare function useLatest<T>(value: T): import("react").MutableRefObject<T>;
|
|
14
|
+
/** @internal */
|
|
15
|
+
export declare function joinHierarchyFilteringPaths(subTreePaths: HierarchyNodeIdentifiersPath[], filteringPaths: HierarchyFilteringPath[]): HierarchyFilteringPath[];
|
|
12
16
|
//# sourceMappingURL=Utils.d.ts.map
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import { useEffect, useRef } from "react";
|
|
6
|
+
import { HierarchyFilteringPath, HierarchyNodeIdentifier } from "@itwin/presentation-hierarchies";
|
|
6
7
|
/** @internal */
|
|
7
8
|
export function createIdsSelector(ids) {
|
|
8
9
|
// Note: `json_array` function only accepts up to 127 arguments and we may have more `ids` than that. As a workaround,
|
|
@@ -41,4 +42,52 @@ export function useLatest(value) {
|
|
|
41
42
|
}, [value]);
|
|
42
43
|
return ref;
|
|
43
44
|
}
|
|
45
|
+
/** @internal */
|
|
46
|
+
export function joinHierarchyFilteringPaths(subTreePaths, filteringPaths) {
|
|
47
|
+
const normalizedFilteringPaths = filteringPaths.map((filteringPath) => HierarchyFilteringPath.normalize(filteringPath));
|
|
48
|
+
const result = new Array();
|
|
49
|
+
const filteringPathsToIncludeIndexes = new Set();
|
|
50
|
+
subTreePaths.forEach((subTreePath) => {
|
|
51
|
+
let options;
|
|
52
|
+
let addSubTreePathToResult = false;
|
|
53
|
+
for (let i = 0; i < normalizedFilteringPaths.length; ++i) {
|
|
54
|
+
const normalizedFilteringPath = normalizedFilteringPaths[i];
|
|
55
|
+
if (normalizedFilteringPath.path.length === 0) {
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
for (let j = 0; j < subTreePath.length; ++j) {
|
|
59
|
+
const identifier = subTreePath[j];
|
|
60
|
+
if (normalizedFilteringPath.path.length <= j || !HierarchyNodeIdentifier.equal(normalizedFilteringPath.path[j], identifier)) {
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
// filtering paths that are shorter or equal than subTree paths length don't need to be added to the result
|
|
64
|
+
if (normalizedFilteringPath.path.length === j + 1) {
|
|
65
|
+
addSubTreePathToResult = true;
|
|
66
|
+
// If filtering path has autoExpand set to true, it means that we should expand only to the targeted filtered node
|
|
67
|
+
// This is done by setting depthInPath
|
|
68
|
+
options =
|
|
69
|
+
normalizedFilteringPath.options?.autoExpand !== true
|
|
70
|
+
? HierarchyFilteringPath.mergeOptions(options, normalizedFilteringPath.options)
|
|
71
|
+
: { autoExpand: { depthInPath: normalizedFilteringPath.path.length - 1 } };
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
// filtering paths that are longer than subTree paths need to be added to the result
|
|
75
|
+
if (subTreePath.length === j + 1) {
|
|
76
|
+
addSubTreePathToResult = true;
|
|
77
|
+
filteringPathsToIncludeIndexes.add(i);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (addSubTreePathToResult) {
|
|
82
|
+
result.push({
|
|
83
|
+
path: subTreePath,
|
|
84
|
+
options,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
for (const index of filteringPathsToIncludeIndexes) {
|
|
89
|
+
result.push(normalizedFilteringPaths[index]);
|
|
90
|
+
}
|
|
91
|
+
return result;
|
|
92
|
+
}
|
|
44
93
|
//# sourceMappingURL=Utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/common/Utils.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/common/Utils.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAQlG,gBAAgB;AAChB,MAAM,UAAU,iBAAiB,CAAC,GAAc;IAC9C,sHAAsH;IACtH,oCAAoC;IACpC,MAAM,MAAM,GAAG,I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------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useEffect, useRef } from \"react\";\nimport { HierarchyFilteringPath, HierarchyNodeIdentifier } from \"@itwin/presentation-hierarchies\";\n\nimport type { Id64Array, Id64String } from \"@itwin/core-bentley\";\nimport type { HierarchyFilteringPathOptions, HierarchyNodeIdentifiersPath } from \"@itwin/presentation-hierarchies\";\n\n/** @beta */\nexport type FunctionProps<THook extends (props: any) => any> = Parameters<THook>[0];\n\n/** @internal */\nexport function createIdsSelector(ids: Id64Array): string {\n // Note: `json_array` function only accepts up to 127 arguments and we may have more `ids` than that. As a workaround,\n // we're creating an array of arrays\n const slices = new Array<Id64String[]>();\n for (let sliceStartIndex = 0; sliceStartIndex < ids.length; sliceStartIndex += 127) {\n let sliceEndIndex: number | undefined = sliceStartIndex + 127;\n if (sliceEndIndex > ids.length) {\n sliceEndIndex = undefined;\n }\n slices.push(ids.slice(sliceStartIndex, sliceEndIndex));\n }\n return `json_array(${slices.map((sliceIds) => `json_array(${sliceIds.map((id) => `'${id}'`).join(\",\")})`).join(\",\")})`;\n}\n\n/** @internal */\nexport function parseIdsSelectorResult(selectorResult: any): Id64Array {\n if (!Array.isArray(selectorResult)) {\n return [];\n }\n return selectorResult.reduce((arr, ids: Id64String | Id64String[]) => [...arr, ...(Array.isArray(ids) ? ids : [ids])], new Array<Id64String>());\n}\n\n/** @internal */\nexport function pushToMap<TKey, TValue>(targetMap: Map<TKey, Set<TValue>>, key: TKey, value: TValue) {\n let set = targetMap.get(key);\n if (!set) {\n set = new Set();\n targetMap.set(key, set);\n }\n set.add(value);\n}\n\n/** @internal */\nexport function useLatest<T>(value: T) {\n const ref = useRef(value);\n useEffect(() => {\n ref.current = value;\n }, [value]);\n return ref;\n}\n\n/** @internal */\nexport function joinHierarchyFilteringPaths(subTreePaths: HierarchyNodeIdentifiersPath[], filteringPaths: HierarchyFilteringPath[]): HierarchyFilteringPath[] {\n const normalizedFilteringPaths = filteringPaths.map((filteringPath) => HierarchyFilteringPath.normalize(filteringPath));\n\n const result = new Array<HierarchyFilteringPath>();\n const filteringPathsToIncludeIndexes = new Set<number>();\n\n subTreePaths.forEach((subTreePath) => {\n let options: HierarchyFilteringPathOptions | undefined;\n let addSubTreePathToResult = false;\n\n for (let i = 0; i < normalizedFilteringPaths.length; ++i) {\n const normalizedFilteringPath = normalizedFilteringPaths[i];\n if (normalizedFilteringPath.path.length === 0) {\n continue;\n }\n\n for (let j = 0; j < subTreePath.length; ++j) {\n const identifier = subTreePath[j];\n if (normalizedFilteringPath.path.length <= j || !HierarchyNodeIdentifier.equal(normalizedFilteringPath.path[j], identifier)) {\n break;\n }\n\n // filtering paths that are shorter or equal than subTree paths length don't need to be added to the result\n if (normalizedFilteringPath.path.length === j + 1) {\n addSubTreePathToResult = true;\n // If filtering path has autoExpand set to true, it means that we should expand only to the targeted filtered node\n // This is done by setting depthInPath\n options =\n normalizedFilteringPath.options?.autoExpand !== true\n ? HierarchyFilteringPath.mergeOptions(options, normalizedFilteringPath.options)\n : { autoExpand: { depthInPath: normalizedFilteringPath.path.length - 1 } };\n break;\n }\n\n // filtering paths that are longer than subTree paths need to be added to the result\n if (subTreePath.length === j + 1) {\n addSubTreePathToResult = true;\n filteringPathsToIncludeIndexes.add(i);\n }\n }\n }\n\n if (addSubTreePathToResult) {\n result.push({\n path: subTreePath,\n options,\n });\n }\n });\n for (const index of filteringPathsToIncludeIndexes) {\n result.push(normalizedFilteringPaths[index]);\n }\n return result;\n}\n"]}
|
|
@@ -7,5 +7,5 @@ export type ModelsTreeProps = Pick<VisibilityTreeProps, "imodel" | "getSchemaCon
|
|
|
7
7
|
};
|
|
8
8
|
};
|
|
9
9
|
/** @beta */
|
|
10
|
-
export declare function ModelsTree({ imodel, getSchemaContext, selectionStorage, activeView, filter, density, hierarchyLevelConfig, hierarchyConfig, selectionMode, selectionPredicate, visibilityHandlerOverrides, getFilteredPaths, onModelsFiltered, }: ModelsTreeProps): JSX.Element;
|
|
10
|
+
export declare function ModelsTree({ imodel, getSchemaContext, selectionStorage, activeView, filter, density, hierarchyLevelConfig, hierarchyConfig, selectionMode, selectionPredicate, visibilityHandlerOverrides, getFilteredPaths, onModelsFiltered, getSubTreePaths, }: ModelsTreeProps): JSX.Element;
|
|
11
11
|
//# sourceMappingURL=ModelsTree.d.ts.map
|
|
@@ -7,7 +7,7 @@ import { VisibilityTree } from "../common/components/VisibilityTree.js";
|
|
|
7
7
|
import { VisibilityTreeRenderer } from "../common/components/VisibilityTreeRenderer.js";
|
|
8
8
|
import { useModelsTree } from "./UseModelsTree.js";
|
|
9
9
|
/** @beta */
|
|
10
|
-
export function ModelsTree({ imodel, getSchemaContext, selectionStorage, activeView, filter, density, hierarchyLevelConfig, hierarchyConfig, selectionMode, selectionPredicate, visibilityHandlerOverrides, getFilteredPaths, onModelsFiltered, }) {
|
|
10
|
+
export function ModelsTree({ imodel, getSchemaContext, selectionStorage, activeView, filter, density, hierarchyLevelConfig, hierarchyConfig, selectionMode, selectionPredicate, visibilityHandlerOverrides, getFilteredPaths, onModelsFiltered, getSubTreePaths, }) {
|
|
11
11
|
const { modelsTreeProps, rendererProps } = useModelsTree({
|
|
12
12
|
activeView,
|
|
13
13
|
filter,
|
|
@@ -16,6 +16,7 @@ export function ModelsTree({ imodel, getSchemaContext, selectionStorage, activeV
|
|
|
16
16
|
getFilteredPaths,
|
|
17
17
|
onModelsFiltered,
|
|
18
18
|
selectionPredicate,
|
|
19
|
+
getSubTreePaths,
|
|
19
20
|
});
|
|
20
21
|
return (_jsx(VisibilityTree, { ...modelsTreeProps, imodel: imodel, selectionStorage: selectionStorage, getSchemaContext: getSchemaContext, hierarchyLevelSizeLimit: hierarchyLevelConfig?.sizeLimit, density: density, selectionMode: selectionMode, treeRenderer: (treeProps) => _jsx(VisibilityTreeRenderer, { ...treeProps, ...rendererProps }) }));
|
|
21
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelsTree.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/models-tree/ModelsTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AACxF,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAanD,YAAY;AACZ,MAAM,UAAU,UAAU,CAAC,EACzB,MAAM,EACN,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACV,MAAM,EACN,OAAO,EACP,oBAAoB,EACpB,eAAe,EACf,aAAa,EACb,kBAAkB,EAClB,0BAA0B,EAC1B,gBAAgB,EAChB,gBAAgB,
|
|
1
|
+
{"version":3,"file":"ModelsTree.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/models-tree/ModelsTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AACxF,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAanD,YAAY;AACZ,MAAM,UAAU,UAAU,CAAC,EACzB,MAAM,EACN,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACV,MAAM,EACN,OAAO,EACP,oBAAoB,EACpB,eAAe,EACf,aAAa,EACb,kBAAkB,EAClB,0BAA0B,EAC1B,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,GACC;IAChB,MAAM,EAAE,eAAe,EAAE,aAAa,EAAE,GAAG,aAAa,CAAC;QACvD,UAAU;QACV,MAAM;QACN,eAAe;QACf,0BAA0B;QAC1B,gBAAgB;QAChB,gBAAgB;QAChB,kBAAkB;QAClB,eAAe;KAChB,CAAC,CAAC;IAEH,OAAO,CACL,KAAC,cAAc,OACT,eAAe,EACnB,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,gBAAgB,EAClC,gBAAgB,EAAE,gBAAgB,EAClC,uBAAuB,EAAE,oBAAoB,EAAE,SAAS,EACxD,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,KAAC,sBAAsB,OAAK,SAAS,KAAM,aAAa,GAAI,GACzF,CACH,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { VisibilityTree } from \"../common/components/VisibilityTree.js\";\nimport { VisibilityTreeRenderer } from \"../common/components/VisibilityTreeRenderer.js\";\nimport { useModelsTree } from \"./UseModelsTree.js\";\n\nimport type { UseModelsTreeProps } from \"./UseModelsTree.js\";\nimport type { VisibilityTreeProps } from \"../common/components/VisibilityTree.js\";\n\n/** @beta */\nexport type ModelsTreeProps = Pick<VisibilityTreeProps, \"imodel\" | \"getSchemaContext\" | \"selectionStorage\" | \"density\" | \"selectionMode\"> &\n UseModelsTreeProps & {\n hierarchyLevelConfig?: {\n sizeLimit?: number;\n };\n };\n\n/** @beta */\nexport function ModelsTree({\n imodel,\n getSchemaContext,\n selectionStorage,\n activeView,\n filter,\n density,\n hierarchyLevelConfig,\n hierarchyConfig,\n selectionMode,\n selectionPredicate,\n visibilityHandlerOverrides,\n getFilteredPaths,\n onModelsFiltered,\n getSubTreePaths,\n}: ModelsTreeProps) {\n const { modelsTreeProps, rendererProps } = useModelsTree({\n activeView,\n filter,\n hierarchyConfig,\n visibilityHandlerOverrides,\n getFilteredPaths,\n onModelsFiltered,\n selectionPredicate,\n getSubTreePaths,\n });\n\n return (\n <VisibilityTree\n {...modelsTreeProps}\n imodel={imodel}\n selectionStorage={selectionStorage}\n getSchemaContext={getSchemaContext}\n hierarchyLevelSizeLimit={hierarchyLevelConfig?.sizeLimit}\n density={density}\n selectionMode={selectionMode}\n treeRenderer={(treeProps) => <VisibilityTreeRenderer {...treeProps} {...rendererProps} />}\n />\n );\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ModelsTreeProps } from "./ModelsTree.js";
|
|
2
2
|
import type { ModelsTreeHeaderButtonProps, ModelsTreeHeaderButtonType } from "./ModelsTreeButtons.js";
|
|
3
3
|
/** @public */
|
|
4
|
-
interface ModelsTreeComponentProps extends Pick<ModelsTreeProps, "getSchemaContext" | "selectionStorage" | "density" | "hierarchyLevelConfig" | "selectionMode" | "selectionPredicate" | "hierarchyConfig" | "visibilityHandlerOverrides" | "getFilteredPaths"> {
|
|
4
|
+
interface ModelsTreeComponentProps extends Pick<ModelsTreeProps, "getSchemaContext" | "selectionStorage" | "density" | "hierarchyLevelConfig" | "selectionMode" | "selectionPredicate" | "hierarchyConfig" | "visibilityHandlerOverrides" | "getFilteredPaths" | "getSubTreePaths"> {
|
|
5
5
|
/**
|
|
6
6
|
* Renderers of header buttons. Defaults to:
|
|
7
7
|
* ```ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelsTreeComponent.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.tsx"],"names":[],"mappings":";;AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,+BAA+B,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AACnH,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B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EAAE,aAAa,GAAI;YACnG,KAAC,0BAA0B,IAAkC,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,IAA3E,4BAA4B,CAAmD;SAChH,CAAC;IAEN,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,oBAAoB,EAAE,CAAC;YACzB,WAAW,EAAE,CAAC;QAChB,CAAC;IACH,CAAC,EAAE,CAAC,oBAAoB,EAAE,WAAW,CAAC,CAAC,CAAC;IAExC,OAAO,CACL,KAAC,wBAAwB,IAAC,mBAAmB,EAAE,mBAAmB,CAAC,EAAE,EAAE,aAAa,EAAE,aAAa,EAAE,qBAAqB,EAAE,qBAAqB,YAC/I,KAAC,cAAc,IACb,cAAc,EAAE;gBACd,aAAa,EAAE,WAAW;gBAC1B,aAAa,EAAE,WAAW;gBAC1B,UAAU,EAAE,oBAAoB,IAAI,CAAC,CAAC,SAAS,CAAC,gBAAgB;aACjE,EACD,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,YAEhB,KAAC,UAAU,OAAK,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,GAAI,GACxG,GACQ,CAC5B,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { Fragment, useEffect } from \"react\";\nimport { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport { TreeWidget } from \"../../../TreeWidget.js\";\nimport { TreeWithHeader } from \"../../tree-header/TreeWithHeader.js\";\nimport { FocusedInstancesContextProvider, useFocusedInstancesContext } from \"../common/FocusedInstancesContext.js\";\nimport { useActiveViewport } from \"../common/UseActiveViewport.js\";\nimport { useFiltering } from \"../common/UseFiltering.js\";\nimport { TelemetryContextProvider } from \"../common/UseTelemetryContext.js\";\nimport { ModelsTree } from \"./ModelsTree.js\";\nimport {\n HideAllButton,\n InvertButton,\n ShowAllButton,\n ToggleInstancesFocusButton,\n useModelsTreeButtonProps,\n View2DButton,\n View3DButton,\n} from \"./ModelsTreeButtons.js\";\n\nimport type { ModelsTreeProps } from \"./ModelsTree.js\";\nimport type { ReactNode } from \"react\";\nimport type { IModelConnection, ScreenViewport } from \"@itwin/core-frontend\";\nimport type { ModelsTreeHeaderButtonProps, ModelsTreeHeaderButtonType } from \"./ModelsTreeButtons.js\";\n\n/** @public */\ninterface ModelsTreeComponentProps\n extends Pick<\n ModelsTreeProps,\n | \"getSchemaContext\"\n | \"selectionStorage\"\n | \"density\"\n | \"hierarchyLevelConfig\"\n | \"selectionMode\"\n | \"selectionPredicate\"\n | \"hierarchyConfig\"\n | \"visibilityHandlerOverrides\"\n | \"getFilteredPaths\"\n > {\n /**\n * Renderers of header buttons. Defaults to:\n * ```ts\n * [\n * ModelsTreeComponent.ShowAllButton,\n * ModelsTreeComponent.HideAllButton,\n * ModelsTreeComponent.InvertButton,\n * ModelsTreeComponent.View2DButton,\n * ModelsTreeComponent.View3DButton,\n * ModelsTreeComponent.ToggleInstancesFocusButton,\n * ]\n * ```\n */\n headerButtons?: Array<(props: ModelsTreeHeaderButtonProps) => React.ReactNode>;\n onPerformanceMeasured?: (featureId: string, duration: number) => void;\n onFeatureUsed?: (feature: string) => void;\n}\n\n/**\n * A component that renders `ModelsTree` and a header with filtering capabilities\n * and header buttons.\n *\n * @public\n */\nexport const ModelsTreeComponent = (props: ModelsTreeComponentProps) => {\n const iModel = useActiveIModelConnection();\n const viewport = useActiveViewport();\n\n if (!iModel || !viewport) {\n return null;\n }\n\n return (\n <FocusedInstancesContextProvider selectionStorage={props.selectionStorage} imodelKey={iModel.key}>\n <ModelsTreeComponentImpl {...props} iModel={iModel} viewport={viewport} />\n </FocusedInstancesContextProvider>\n );\n};\n\n/**\n * Renders a \"Show all\" button that enables display of all models.\n * @public\n */\nModelsTreeComponent.ShowAllButton = ShowAllButton as ModelsTreeHeaderButtonType;\n\n/**\n * Renders a \"Hide all\" button that disables display of all models.\n * @public\n */\nModelsTreeComponent.HideAllButton = HideAllButton as ModelsTreeHeaderButtonType;\n\n/**\n * Renders an \"Invert all\" button that inverts display of all models.\n * @public\n */\nModelsTreeComponent.InvertButton = InvertButton as ModelsTreeHeaderButtonType;\n\n/**\n * Renders a \"View 2D\" button that enables display of all plan projection models and disables all others.\n * @public\n */\nModelsTreeComponent.View2DButton = View2DButton as ModelsTreeHeaderButtonType;\n\n/**\n * Renders a \"View 3D\" button that enables display of all non-plan projection models and disables all plan projection ones.\n * @public\n */\nModelsTreeComponent.View3DButton = View3DButton as ModelsTreeHeaderButtonType;\n\n/**\n * Renders an \"Instance focus\" toggle button that enables/disables instances focusing mode.\n *\n * Requires instances focus context to be provided using `FocusedInstancesContextProvider`. The context\n * is provided automatically, when using `ModelsTreeComponent`, but needs to be provided by consumers\n * when rendering `ToggleInstancesFocusButton` outside of `ModelsTreeComponent`.\n *\n * @public\n */\nModelsTreeComponent.ToggleInstancesFocusButton = ToggleInstancesFocusButton as ModelsTreeHeaderButtonType;\n\n/**\n * Id of the component. May be used when a creating a `TreeDefinition` for `SelectableTree`.\n * @public\n */\nModelsTreeComponent.id = \"models-tree-v2\";\n\n/**\n * Label of the component. May be used when a creating a `TreeDefinition` for `SelectableTree`.\n * @public\n */\nModelsTreeComponent.getLabel = () => TreeWidget.translate(\"modelsTree.label\");\n\nfunction ModelsTreeComponentImpl({\n iModel,\n viewport,\n headerButtons,\n onFeatureUsed,\n onPerformanceMeasured,\n ...treeProps\n}: ModelsTreeComponentProps & { iModel: IModelConnection; viewport: ScreenViewport }) {\n const { buttonProps, onModelsFiltered } = useModelsTreeButtonProps({ imodel: iModel, viewport });\n const { filter, applyFilter, clearFilter } = useFiltering();\n const { enabled: instanceFocusEnabled } = useFocusedInstancesContext();\n const density = treeProps.density;\n\n const buttons: ReactNode = headerButtons\n ? headerButtons.map((btn, index) => <Fragment key={index}>{btn({ ...buttonProps, onFeatureUsed })}</Fragment>)\n : [\n <ShowAllButton {...buttonProps} key=\"show-all-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n <HideAllButton {...buttonProps} key=\"hide-all-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n <InvertButton {...buttonProps} key=\"invert-all-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n <View2DButton {...buttonProps} key=\"view-2d-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n <View3DButton {...buttonProps} key=\"view-3d-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n <ToggleInstancesFocusButton key=\"toggle-instances-focus-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n ];\n\n useEffect(() => {\n if (instanceFocusEnabled) {\n clearFilter();\n }\n }, [instanceFocusEnabled, clearFilter]);\n\n return (\n <TelemetryContextProvider componentIdentifier={ModelsTreeComponent.id} onFeatureUsed={onFeatureUsed} onPerformanceMeasured={onPerformanceMeasured}>\n <TreeWithHeader\n filteringProps={{\n onFilterStart: applyFilter,\n onFilterClear: clearFilter,\n isDisabled: instanceFocusEnabled || !!treeProps.getFilteredPaths,\n }}\n buttons={buttons}\n density={density}\n >\n <ModelsTree {...treeProps} imodel={iModel} activeView={viewport} filter={filter} onModelsFiltered={onModelsFiltered} />\n </TreeWithHeader>\n </TelemetryContextProvider>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ModelsTreeComponent.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.tsx"],"names":[],"mappings":";;AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAA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AC,aAAa,EAAC,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,GAAI;YACnG,eAAC,YAAY,OAAK,WAAW,EAAE,GAAG,EAAC,aAAa,EAAC,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,GAAI;YACnG,KAAC,0BAA0B,IAAkC,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,IAA3E,4BAA4B,CAAmD;SAChH,CAAC;IAEN,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,oBAAoB,EAAE,CAAC;YACzB,WAAW,EAAE,CAAC;QAChB,CAAC;IACH,CAAC,EAAE,CAAC,oBAAoB,EAAE,WAAW,CAAC,CAAC,CAAC;IAExC,OAAO,CACL,KAAC,wBAAwB,IAAC,mBAAmB,EAAE,mBAAmB,CAAC,EAAE,EAAE,aAAa,EAAE,aAAa,EAAE,qBAAqB,EAAE,qBAAqB,YAC/I,KAAC,cAAc,IACb,cAAc,EAAE;gBACd,aAAa,EAAE,WAAW;gBAC1B,aAAa,EAAE,WAAW;gBAC1B,UAAU,EAAE,oBAAoB,IAAI,CAAC,CAAC,SAAS,CAAC,gBAAgB;aACjE,EACD,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,YAEhB,KAAC,UAAU,OAAK,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,GAAI,GACxG,GACQ,CAC5B,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { Fragment, useEffect } from \"react\";\nimport { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport { TreeWidget } from \"../../../TreeWidget.js\";\nimport { TreeWithHeader } from \"../../tree-header/TreeWithHeader.js\";\nimport { FocusedInstancesContextProvider, useFocusedInstancesContext } from \"../common/FocusedInstancesContext.js\";\nimport { useActiveViewport } from \"../common/UseActiveViewport.js\";\nimport { useFiltering } from \"../common/UseFiltering.js\";\nimport { TelemetryContextProvider } from \"../common/UseTelemetryContext.js\";\nimport { ModelsTree } from \"./ModelsTree.js\";\nimport {\n HideAllButton,\n InvertButton,\n ShowAllButton,\n ToggleInstancesFocusButton,\n useModelsTreeButtonProps,\n View2DButton,\n View3DButton,\n} from \"./ModelsTreeButtons.js\";\n\nimport type { ModelsTreeProps } from \"./ModelsTree.js\";\nimport type { ReactNode } from \"react\";\nimport type { IModelConnection, ScreenViewport } from \"@itwin/core-frontend\";\nimport type { ModelsTreeHeaderButtonProps, ModelsTreeHeaderButtonType } from \"./ModelsTreeButtons.js\";\n\n/** @public */\ninterface ModelsTreeComponentProps\n extends Pick<\n ModelsTreeProps,\n | \"getSchemaContext\"\n | \"selectionStorage\"\n | \"density\"\n | \"hierarchyLevelConfig\"\n | \"selectionMode\"\n | \"selectionPredicate\"\n | \"hierarchyConfig\"\n | \"visibilityHandlerOverrides\"\n | \"getFilteredPaths\"\n | \"getSubTreePaths\"\n > {\n /**\n * Renderers of header buttons. Defaults to:\n * ```ts\n * [\n * ModelsTreeComponent.ShowAllButton,\n * ModelsTreeComponent.HideAllButton,\n * ModelsTreeComponent.InvertButton,\n * ModelsTreeComponent.View2DButton,\n * ModelsTreeComponent.View3DButton,\n * ModelsTreeComponent.ToggleInstancesFocusButton,\n * ]\n * ```\n */\n headerButtons?: Array<(props: ModelsTreeHeaderButtonProps) => React.ReactNode>;\n onPerformanceMeasured?: (featureId: string, duration: number) => void;\n onFeatureUsed?: (feature: string) => void;\n}\n\n/**\n * A component that renders `ModelsTree` and a header with filtering capabilities\n * and header buttons.\n *\n * @public\n */\nexport const ModelsTreeComponent = (props: ModelsTreeComponentProps) => {\n const iModel = useActiveIModelConnection();\n const viewport = useActiveViewport();\n\n if (!iModel || !viewport) {\n return null;\n }\n\n return (\n <FocusedInstancesContextProvider selectionStorage={props.selectionStorage} imodelKey={iModel.key}>\n <ModelsTreeComponentImpl {...props} iModel={iModel} viewport={viewport} />\n </FocusedInstancesContextProvider>\n );\n};\n\n/**\n * Renders a \"Show all\" button that enables display of all models.\n * @public\n */\nModelsTreeComponent.ShowAllButton = ShowAllButton as ModelsTreeHeaderButtonType;\n\n/**\n * Renders a \"Hide all\" button that disables display of all models.\n * @public\n */\nModelsTreeComponent.HideAllButton = HideAllButton as ModelsTreeHeaderButtonType;\n\n/**\n * Renders an \"Invert all\" button that inverts display of all models.\n * @public\n */\nModelsTreeComponent.InvertButton = InvertButton as ModelsTreeHeaderButtonType;\n\n/**\n * Renders a \"View 2D\" button that enables display of all plan projection models and disables all others.\n * @public\n */\nModelsTreeComponent.View2DButton = View2DButton as ModelsTreeHeaderButtonType;\n\n/**\n * Renders a \"View 3D\" button that enables display of all non-plan projection models and disables all plan projection ones.\n * @public\n */\nModelsTreeComponent.View3DButton = View3DButton as ModelsTreeHeaderButtonType;\n\n/**\n * Renders an \"Instance focus\" toggle button that enables/disables instances focusing mode.\n *\n * Requires instances focus context to be provided using `FocusedInstancesContextProvider`. The context\n * is provided automatically, when using `ModelsTreeComponent`, but needs to be provided by consumers\n * when rendering `ToggleInstancesFocusButton` outside of `ModelsTreeComponent`.\n *\n * @public\n */\nModelsTreeComponent.ToggleInstancesFocusButton = ToggleInstancesFocusButton as ModelsTreeHeaderButtonType;\n\n/**\n * Id of the component. May be used when a creating a `TreeDefinition` for `SelectableTree`.\n * @public\n */\nModelsTreeComponent.id = \"models-tree-v2\";\n\n/**\n * Label of the component. May be used when a creating a `TreeDefinition` for `SelectableTree`.\n * @public\n */\nModelsTreeComponent.getLabel = () => TreeWidget.translate(\"modelsTree.label\");\n\nfunction ModelsTreeComponentImpl({\n iModel,\n viewport,\n headerButtons,\n onFeatureUsed,\n onPerformanceMeasured,\n ...treeProps\n}: ModelsTreeComponentProps & { iModel: IModelConnection; viewport: ScreenViewport }) {\n const { buttonProps, onModelsFiltered } = useModelsTreeButtonProps({ imodel: iModel, viewport });\n const { filter, applyFilter, clearFilter } = useFiltering();\n const { enabled: instanceFocusEnabled } = useFocusedInstancesContext();\n const density = treeProps.density;\n\n const buttons: ReactNode = headerButtons\n ? headerButtons.map((btn, index) => <Fragment key={index}>{btn({ ...buttonProps, onFeatureUsed })}</Fragment>)\n : [\n <ShowAllButton {...buttonProps} key=\"show-all-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n <HideAllButton {...buttonProps} key=\"hide-all-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n <InvertButton {...buttonProps} key=\"invert-all-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n <View2DButton {...buttonProps} key=\"view-2d-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n <View3DButton {...buttonProps} key=\"view-3d-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n <ToggleInstancesFocusButton key=\"toggle-instances-focus-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n ];\n\n useEffect(() => {\n if (instanceFocusEnabled) {\n clearFilter();\n }\n }, [instanceFocusEnabled, clearFilter]);\n\n return (\n <TelemetryContextProvider componentIdentifier={ModelsTreeComponent.id} onFeatureUsed={onFeatureUsed} onPerformanceMeasured={onPerformanceMeasured}>\n <TreeWithHeader\n filteringProps={{\n onFilterStart: applyFilter,\n onFilterClear: clearFilter,\n isDisabled: instanceFocusEnabled || !!treeProps.getFilteredPaths,\n }}\n buttons={buttons}\n density={density}\n >\n <ModelsTree {...treeProps} imodel={iModel} activeView={viewport} filter={filter} onModelsFiltered={onModelsFiltered} />\n </TreeWithHeader>\n </TelemetryContextProvider>\n );\n}\n"]}
|
|
@@ -42,20 +42,19 @@ export interface ElementsGroupInfo {
|
|
|
42
42
|
};
|
|
43
43
|
groupingNode: ClassGroupingHierarchyNode;
|
|
44
44
|
}
|
|
45
|
-
interface
|
|
45
|
+
interface ModelsTreeInstanceKeyPathsBaseProps {
|
|
46
46
|
imodelAccess: ECClassHierarchyInspector & LimitingECSqlQueryExecutor;
|
|
47
47
|
idsCache: ModelsTreeIdsCache;
|
|
48
|
-
targetItems: Array<InstanceKey | ElementsGroupInfo>;
|
|
49
48
|
hierarchyConfig: ModelsTreeHierarchyConfiguration;
|
|
50
49
|
limit?: number | "unbounded";
|
|
50
|
+
abortSignal?: AbortSignal;
|
|
51
51
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
type ModelsTreeInstanceKeyPathsFromTargetItemsProps = {
|
|
53
|
+
targetItems: Array<InstanceKey | ElementsGroupInfo>;
|
|
54
|
+
} & ModelsTreeInstanceKeyPathsBaseProps;
|
|
55
|
+
type ModelsTreeInstanceKeyPathsFromInstanceLabelProps = {
|
|
55
56
|
label: string;
|
|
56
|
-
|
|
57
|
-
limit?: number | "unbounded";
|
|
58
|
-
}
|
|
57
|
+
} & ModelsTreeInstanceKeyPathsBaseProps;
|
|
59
58
|
export type ModelsTreeInstanceKeyPathsProps = ModelsTreeInstanceKeyPathsFromTargetItemsProps | ModelsTreeInstanceKeyPathsFromInstanceLabelProps;
|
|
60
59
|
export declare namespace ModelsTreeInstanceKeyPathsProps {
|
|
61
60
|
function isLabelProps(props: ModelsTreeInstanceKeyPathsProps): props is ModelsTreeInstanceKeyPathsFromInstanceLabelProps;
|
|
@@ -76,7 +75,7 @@ export declare class ModelsTreeDefinition implements HierarchyDefinition {
|
|
|
76
75
|
private createGeometricModel3dChildrenQuery;
|
|
77
76
|
private createSpatialCategoryChildrenQuery;
|
|
78
77
|
private createGeometricElement3dChildrenQuery;
|
|
79
|
-
static createInstanceKeyPaths(props: ModelsTreeInstanceKeyPathsProps): Promise<import("@itwin/presentation-hierarchies").HierarchyFilteringPath[]>;
|
|
78
|
+
static createInstanceKeyPaths(props: ModelsTreeInstanceKeyPathsProps): Promise<never[] | import("@itwin/presentation-hierarchies").HierarchyFilteringPath[]>;
|
|
80
79
|
private supportsFiltering;
|
|
81
80
|
private isSupported;
|
|
82
81
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
import { bufferCount, defer, firstValueFrom, from, lastValueFrom, map, merge, mergeAll, mergeMap, reduce, switchMap } from "rxjs";
|
|
5
|
+
import { bufferCount, defaultIfEmpty, defer, firstValueFrom, from, fromEvent, identity, lastValueFrom, map, merge, mergeAll, mergeMap, reduce, switchMap, takeUntil, toArray, } from "rxjs";
|
|
6
6
|
import { IModel } from "@itwin/core-common";
|
|
7
7
|
import { createNodesQueryClauseFactory, createPredicateBasedHierarchyDefinition, NodeSelectClauseColumnNames, ProcessedHierarchyNode, } from "@itwin/presentation-hierarchies";
|
|
8
8
|
import { createBisInstanceLabelSelectClauseFactory, ECSql } from "@itwin/presentation-shared";
|
|
@@ -401,11 +401,13 @@ export class ModelsTreeDefinition {
|
|
|
401
401
|
];
|
|
402
402
|
}
|
|
403
403
|
static async createInstanceKeyPaths(props) {
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
404
|
+
return lastValueFrom(defer(() => {
|
|
405
|
+
if (ModelsTreeInstanceKeyPathsProps.isLabelProps(props)) {
|
|
406
|
+
const labelsFactory = createBisInstanceLabelSelectClauseFactory({ classHierarchyInspector: props.imodelAccess });
|
|
407
|
+
return createInstanceKeyPathsFromInstanceLabelObs({ ...props, labelsFactory });
|
|
408
|
+
}
|
|
409
|
+
return createInstanceKeyPathsFromTargetItemsObs(props);
|
|
410
|
+
}).pipe(props.abortSignal ? takeUntil(fromEvent(props.abortSignal, "abort")) : identity, defaultIfEmpty([])));
|
|
409
411
|
}
|
|
410
412
|
supportsFiltering() {
|
|
411
413
|
return this._hierarchyConfig.hierarchyLevelFiltering === "enable";
|
|
@@ -535,11 +537,11 @@ function parseQueryRow(row, groupInfos, separator, elementClassName) {
|
|
|
535
537
|
groupingNode: row[2] === -1 ? undefined : groupInfos[row[2]].groupingNode,
|
|
536
538
|
};
|
|
537
539
|
}
|
|
538
|
-
|
|
540
|
+
function createInstanceKeyPathsFromTargetItemsObs({ targetItems, imodelAccess, hierarchyConfig, idsCache, limit, }) {
|
|
539
541
|
if (limit !== "unbounded" && targetItems.length > (limit ?? MAX_FILTERING_INSTANCE_KEY_COUNT)) {
|
|
540
542
|
throw new FilterLimitExceededError(limit ?? MAX_FILTERING_INSTANCE_KEY_COUNT);
|
|
541
543
|
}
|
|
542
|
-
return
|
|
544
|
+
return from(targetItems).pipe(releaseMainThreadOnItemsCount(2000), mergeMap(async (key) => {
|
|
543
545
|
if ("parent" in key) {
|
|
544
546
|
return { key, type: 0 };
|
|
545
547
|
}
|
|
@@ -576,17 +578,18 @@ async function createInstanceKeyPathsFromTargetItems({ targetItems, imodelAccess
|
|
|
576
578
|
}), switchMap(async (ids) => {
|
|
577
579
|
const elementsLength = ids.elements.length;
|
|
578
580
|
return collect(merge(from(ids.subjects).pipe(mergeMap((id) => from(idsCache.createSubjectInstanceKeysPath(id)))), from(ids.models).pipe(mergeMap((id) => from(idsCache.createModelInstanceKeyPaths(id)).pipe(mergeAll()))), from(ids.categories).pipe(mergeMap((id) => from(idsCache.createCategoryInstanceKeyPaths(id)).pipe(mergeAll()))), from(ids.elements).pipe(bufferCount(Math.ceil(elementsLength / Math.ceil(elementsLength / 5000))), releaseMainThreadOnItemsCount(1), mergeMap((block) => createGeometricElementInstanceKeyPaths(imodelAccess, idsCache, hierarchyConfig, block), 10))));
|
|
579
|
-
}))
|
|
581
|
+
}));
|
|
580
582
|
}
|
|
581
|
-
|
|
582
|
-
const
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
583
|
+
function createInstanceKeyPathsFromInstanceLabelObs(props) {
|
|
584
|
+
const { labelsFactory, hierarchyConfig, label, imodelAccess, limit } = props;
|
|
585
|
+
return defer(async () => {
|
|
586
|
+
const elementLabelSelectClause = await labelsFactory.createSelectClause({
|
|
587
|
+
classAlias: "e",
|
|
588
|
+
className: "BisCore.Element",
|
|
589
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
590
|
+
selectorsConcatenator: ECSql.createConcatenatedValueStringSelector,
|
|
591
|
+
});
|
|
592
|
+
const ecsql = `
|
|
590
593
|
SELECT *
|
|
591
594
|
FROM (
|
|
592
595
|
SELECT
|
|
@@ -594,7 +597,7 @@ async function createInstanceKeyPathsFromInstanceLabel(props) {
|
|
|
594
597
|
e.ECInstanceId,
|
|
595
598
|
${elementLabelSelectClause} Label
|
|
596
599
|
FROM BisCore.Element e
|
|
597
|
-
WHERE e.ECClassId IS (BisCore.Subject, BisCore.SpatialCategory, ${
|
|
600
|
+
WHERE e.ECClassId IS (BisCore.Subject, BisCore.SpatialCategory, ${hierarchyConfig.elementClassSpecification})
|
|
598
601
|
|
|
599
602
|
UNION ALL
|
|
600
603
|
|
|
@@ -605,19 +608,21 @@ async function createInstanceKeyPathsFromInstanceLabel(props) {
|
|
|
605
608
|
FROM BisCore.GeometricModel3d m
|
|
606
609
|
JOIN BisCore.Element e ON e.ECInstanceId = m.ModeledElement.Id
|
|
607
610
|
WHERE NOT m.IsPrivate
|
|
608
|
-
${
|
|
611
|
+
${hierarchyConfig.showEmptyModels ? "" : `AND EXISTS (SELECT 1 FROM ${hierarchyConfig.elementClassSpecification} WHERE Model.Id = m.ECInstanceId)`}
|
|
609
612
|
AND json_extract(e.JsonProperties, '$.PhysicalPartition.Model.Content') IS NULL
|
|
610
613
|
AND json_extract(e.JsonProperties, '$.GraphicalPartition3d.Model.Content') IS NULL
|
|
611
614
|
)
|
|
612
615
|
WHERE Label LIKE '%' || ? || '%' ESCAPE '\\'
|
|
613
616
|
LIMIT ${MAX_FILTERING_INSTANCE_KEY_COUNT + 1}
|
|
614
|
-
|
|
615
|
-
bindings
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
617
|
+
`;
|
|
618
|
+
const bindings = [{ type: "string", value: label.replace(/[%_\\]/g, "\\$&") }];
|
|
619
|
+
return { ecsql, bindings };
|
|
620
|
+
}).pipe(mergeMap((queryProps) => {
|
|
621
|
+
return imodelAccess.createQueryReader(queryProps, {
|
|
622
|
+
rowFormat: "Indexes",
|
|
623
|
+
restartToken: "tree-widget/models-tree/filter-by-label-query",
|
|
624
|
+
limit,
|
|
625
|
+
});
|
|
626
|
+
}), map((row) => ({ className: row[0], id: row[1] })), toArray(), mergeMap((targetKeys) => createInstanceKeyPathsFromTargetItemsObs({ ...props, targetItems: targetKeys })));
|
|
622
627
|
}
|
|
623
628
|
//# sourceMappingURL=ModelsTreeDefinition.js.map
|