@itwin/tree-widget-react 4.0.0-alpha.22 → 4.0.0-alpha.23
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/lib/esm/tree-widget-react/components/TreeWidgetComponentImpl.d.ts +1 -1
- package/lib/esm/tree-widget-react/components/TreeWidgetComponentImpl.js +1 -1
- package/lib/esm/tree-widget-react/components/TreeWidgetComponentImpl.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTree.d.ts +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTree.js +2 -2
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeComponent.d.ts +2 -2
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeComponent.js +3 -3
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeComponent.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.d.ts +2 -2
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js +11 -11
- 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.d.ts +3 -3
- package/lib/esm/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js +25 -25
- 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 +2 -2
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js +23 -39
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/{UseFilteredPaths.d.ts → UseSearchPaths.d.ts} +8 -8
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/{UseFilteredPaths.js → UseSearchPaths.js} +21 -21
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/UseSearchPaths.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/CategoriesTreeVisibilityHandler.d.ts +7 -7
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/CategoriesTreeVisibilityHandler.js +11 -11
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/CategoriesTreeVisibilityHandler.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/CategoriesTreeVisibilityHelper.js +2 -2
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/CategoriesTreeVisibilityHelper.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/{FilteredTree.d.ts → SearchResultsTree.d.ts} +8 -8
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/{FilteredTree.js → SearchResultsTree.js} +62 -62
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/SearchResultsTree.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTree.d.ts +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTree.js +2 -2
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeComponent.d.ts +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeComponent.js +2 -2
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeComponent.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeDefinition.d.ts +2 -2
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeDefinition.js +7 -7
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeDefinition.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTree.d.ts +3 -3
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTree.js +25 -25
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTreeDefinition.d.ts +4 -4
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTreeDefinition.js +2 -2
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTreeDefinition.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeIdsCache.d.ts +4 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeIdsCache.js +36 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeIdsCache.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/UseSearchPaths.d.ts +20 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/{UseFilteredPaths.js → UseSearchPaths.js} +19 -19
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/UseSearchPaths.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/ClassificationsTreeVisibilityHandler.d.ts +4 -4
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/ClassificationsTreeVisibilityHandler.js +8 -8
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/ClassificationsTreeVisibilityHandler.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/{FilteredTree.d.ts → SearchResultsTree.d.ts} +9 -9
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/SearchResultsTree.js +168 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/SearchResultsTree.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/TreeErrors.d.ts +2 -2
- package/lib/esm/tree-widget-react/components/trees/common/TreeErrors.js +3 -3
- package/lib/esm/tree-widget-react/components/trees/common/TreeErrors.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/UseTelemetryContext.d.ts +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/UseTelemetryContext.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/Utils.d.ts +3 -3
- package/lib/esm/tree-widget-react/components/trees/common/Utils.js +17 -17
- package/lib/esm/tree-widget-react/components/trees/common/Utils.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/EmptyTree.css +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/EmptyTree.d.ts +6 -6
- package/lib/esm/tree-widget-react/components/trees/common/components/EmptyTree.js +11 -11
- package/lib/esm/tree-widget-react/components/trees/common/components/EmptyTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/ProgressOverlay.js +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/ProgressOverlay.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/Tree.d.ts +2 -2
- package/lib/esm/tree-widget-react/components/trees/common/components/Tree.js +2 -2
- package/lib/esm/tree-widget-react/components/trees/common/components/Tree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/Utils.d.ts +21 -5
- package/lib/esm/tree-widget-react/components/trees/common/internal/Utils.js +24 -8
- package/lib/esm/tree-widget-react/components/trees/common/internal/Utils.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/VisibilityUtils.d.ts +1 -6
- package/lib/esm/tree-widget-react/components/trees/common/internal/VisibilityUtils.js +4 -11
- package/lib/esm/tree-widget-react/components/trees/common/internal/VisibilityUtils.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/useTreeHooks/UseCachedVisibility.d.ts +18 -18
- package/lib/esm/tree-widget-react/components/trees/common/internal/useTreeHooks/UseCachedVisibility.js +32 -32
- package/lib/esm/tree-widget-react/components/trees/common/internal/useTreeHooks/UseCachedVisibility.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/visibility/BaseSearchResultsTree.d.ts +91 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/visibility/BaseSearchResultsTree.js +112 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/visibility/BaseSearchResultsTree.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/visibility/BaseVisibilityHelper.d.ts +6 -10
- package/lib/esm/tree-widget-react/components/trees/common/internal/visibility/BaseVisibilityHelper.js +27 -15
- package/lib/esm/tree-widget-react/components/trees/common/internal/visibility/BaseVisibilityHelper.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/index.d.ts +1 -1
- package/lib/esm/tree-widget-react/components/trees/index.js +1 -1
- package/lib/esm/tree-widget-react/components/trees/index.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTree.d.ts +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTree.js +3 -3
- 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 +5 -5
- 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 +2 -2
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js +12 -12
- 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 +29 -29
- package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.js +26 -26
- package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.d.ts +4 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js +36 -1
- 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/UseSearchPaths.d.ts +41 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/{UseFilteredPaths.js → UseSearchPaths.js} +47 -47
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/UseSearchPaths.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/ModelsTreeVisibilityHandler.d.ts +7 -7
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/ModelsTreeVisibilityHandler.js +11 -11
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/ModelsTreeVisibilityHandler.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/{FilteredTree.d.ts → SearchResultsTree.d.ts} +8 -8
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/{FilteredTree.js → SearchResultsTree.js} +43 -43
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/SearchResultsTree.js.map +1 -0
- package/lib/public/locales/en/TreeWidget.json +13 -13
- package/package.json +7 -7
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/UseFilteredPaths.js.map +0 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/FilteredTree.js.map +0 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/UseFilteredPaths.d.ts +0 -20
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/UseFilteredPaths.js.map +0 -1
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/FilteredTree.js +0 -168
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/FilteredTree.js.map +0 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/visibility/BaseFilteredTree.d.ts +0 -91
- package/lib/esm/tree-widget-react/components/trees/common/internal/visibility/BaseFilteredTree.js +0 -112
- package/lib/esm/tree-widget-react/components/trees/common/internal/visibility/BaseFilteredTree.js.map +0 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/UseFilteredPaths.d.ts +0 -41
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/UseFilteredPaths.js.map +0 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/FilteredTree.js.map +0 -1
|
@@ -186,17 +186,16 @@ export class CategoriesTreeIdsCache {
|
|
|
186
186
|
return { id: row.id, modelId: row.modelId, hasElements: !!row.hasElements };
|
|
187
187
|
}));
|
|
188
188
|
}
|
|
189
|
-
|
|
189
|
+
querySubCategories() {
|
|
190
190
|
return defer(() => {
|
|
191
191
|
const definitionsQuery = `
|
|
192
|
-
|
|
192
|
+
SELECT
|
|
193
193
|
sc.ECInstanceId id,
|
|
194
194
|
sc.Parent.Id categoryId
|
|
195
195
|
FROM
|
|
196
196
|
${CLASS_NAME_SubCategory} sc
|
|
197
197
|
WHERE
|
|
198
198
|
NOT sc.IsPrivate
|
|
199
|
-
AND sc.Parent.Id IN (${categoryIds.join(",")})
|
|
200
199
|
`;
|
|
201
200
|
return this.#queryExecutor.createQueryReader({ ecsql: definitionsQuery }, { rowFormat: "ECSqlPropertyNames", limit: "unbounded", restartToken: `${this.#componentName}/${this.#componentId}/visible-sub-categories` });
|
|
202
201
|
}).pipe(map((row) => {
|
|
@@ -292,20 +291,18 @@ export class CategoriesTreeIdsCache {
|
|
|
292
291
|
}));
|
|
293
292
|
}
|
|
294
293
|
getSubCategoriesInfo() {
|
|
295
|
-
this.#subCategoriesInfo ??= this.
|
|
296
|
-
.pipe(
|
|
297
|
-
acc.
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
if (categoriesWithMoreThanOneSubCategory.length === 0) {
|
|
302
|
-
return of(allSubCategories);
|
|
294
|
+
this.#subCategoriesInfo ??= this.querySubCategories()
|
|
295
|
+
.pipe(reduce((acc, queriedSubCategory) => {
|
|
296
|
+
acc.subCategoryCategories.set(queriedSubCategory.id, queriedSubCategory.parentId);
|
|
297
|
+
const entry = acc.categorySubCategories.get(queriedSubCategory.parentId);
|
|
298
|
+
if (entry) {
|
|
299
|
+
entry.push(queriedSubCategory.id);
|
|
303
300
|
}
|
|
304
|
-
|
|
305
|
-
acc.set(queriedSubCategory.
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
}))
|
|
301
|
+
else {
|
|
302
|
+
acc.categorySubCategories.set(queriedSubCategory.parentId, [queriedSubCategory.id]);
|
|
303
|
+
}
|
|
304
|
+
return acc;
|
|
305
|
+
}, { subCategoryCategories: new Map(), categorySubCategories: new Map() }))
|
|
309
306
|
.pipe(shareReplay());
|
|
310
307
|
return this.#subCategoriesInfo;
|
|
311
308
|
}
|
|
@@ -405,12 +402,16 @@ export class CategoriesTreeIdsCache {
|
|
|
405
402
|
}
|
|
406
403
|
getInstanceKeyPaths(props) {
|
|
407
404
|
if ("subCategoryId" in props) {
|
|
408
|
-
return this.getSubCategoriesInfo().pipe(mergeMap((
|
|
409
|
-
const
|
|
410
|
-
if (
|
|
405
|
+
return this.getSubCategoriesInfo().pipe(mergeMap(({ subCategoryCategories, categorySubCategories }) => {
|
|
406
|
+
const categoryOfSubCategory = subCategoryCategories.get(props.subCategoryId);
|
|
407
|
+
if (categoryOfSubCategory === undefined) {
|
|
408
|
+
return of([]);
|
|
409
|
+
}
|
|
410
|
+
const subCategories = categorySubCategories.get(categoryOfSubCategory);
|
|
411
|
+
if (!subCategories || subCategories.length <= 1) {
|
|
411
412
|
return of([]);
|
|
412
413
|
}
|
|
413
|
-
return this.getInstanceKeyPaths({ categoryId:
|
|
414
|
+
return this.getInstanceKeyPaths({ categoryId: categoryOfSubCategory }).pipe(map((pathToCategory) => [...pathToCategory, { id: props.subCategoryId, className: CLASS_NAME_SubCategory }]));
|
|
414
415
|
}));
|
|
415
416
|
}
|
|
416
417
|
if ("categoryId" in props) {
|
|
@@ -472,25 +473,8 @@ export class CategoriesTreeIdsCache {
|
|
|
472
473
|
}, new Array())),
|
|
473
474
|
});
|
|
474
475
|
}
|
|
475
|
-
getSubCategories(
|
|
476
|
-
return this.getSubCategoriesInfo().pipe(
|
|
477
|
-
let entry = acc.get(subCategoryInfo.categoryId);
|
|
478
|
-
if (!entry) {
|
|
479
|
-
entry = [];
|
|
480
|
-
acc.set(subCategoryInfo.categoryId, entry);
|
|
481
|
-
}
|
|
482
|
-
entry.push(subCategoryId);
|
|
483
|
-
return acc;
|
|
484
|
-
}, new Map()), map((subCategoriesMap) => {
|
|
485
|
-
const result = new Map();
|
|
486
|
-
for (const categoryId of Id64.iterable(categoryIds)) {
|
|
487
|
-
const entry = subCategoriesMap.get(categoryId);
|
|
488
|
-
if (entry) {
|
|
489
|
-
result.set(categoryId, entry);
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
return result;
|
|
493
|
-
}));
|
|
476
|
+
getSubCategories(categoryId) {
|
|
477
|
+
return this.getSubCategoriesInfo().pipe(map(({ categorySubCategories }) => categorySubCategories.get(categoryId) ?? []));
|
|
494
478
|
}
|
|
495
479
|
getIsDefinitionContainerSupported() {
|
|
496
480
|
this.#isDefinitionContainerSupported ??= this.queryIsDefinitionContainersSupported().pipe(shareReplay());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CategoriesTreeIdsCache.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACrG,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MA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CAAC,CAAC;AAC/E,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 { defer, EMPTY, forkJoin, from, map, mergeMap, of, reduce, shareReplay, toArray } from \"rxjs\";\nimport { Guid, Id64 } from \"@itwin/core-bentley\";\nimport { CLASS_NAME_DefinitionContainer, CLASS_NAME_Model, CLASS_NAME_SubCategory } from \"../../common/internal/ClassNameDefinitions.js\";\nimport { ModelCategoryElementsCountCache } from \"../../common/internal/ModelCategoryElementsCountCache.js\";\nimport { getClassesByView, joinId64Arg } from \"../../common/internal/Utils.js\";\n\nimport type { Observable } from \"rxjs\";\nimport type { GuidString, Id64Arg, Id64Array, Id64Set, Id64String } from \"@itwin/core-bentley\";\nimport type { LimitingECSqlQueryExecutor } from \"@itwin/presentation-hierarchies\";\nimport type { InstanceKey } from \"@itwin/presentation-shared\";\nimport type { CategoryId, DefinitionContainerId, ElementId, ModelId, SubCategoryId } from \"../../common/internal/Types.js\";\n\ninterface DefinitionContainerInfo {\n modelId: Id64String;\n parentDefinitionContainerExists: boolean;\n childCategories: CategoryInfo[];\n childDefinitionContainers: Array<{ id: Id64String; hasElements: boolean }>;\n hasElements: boolean;\n}\n\ninterface CategoriesInfo {\n childCategories: CategoryInfo[];\n parentDefinitionContainerExists: boolean;\n}\n\n/** @internal */\nexport interface CategoryInfo {\n id: CategoryId;\n subCategoryChildCount: number;\n hasElements: boolean;\n}\n\ninterface SubCategoryInfo {\n categoryId: Id64String;\n}\n\n/** @internal */\nexport class CategoriesTreeIdsCache implements Disposable {\n #definitionContainersInfo: Observable<Map<DefinitionContainerId, DefinitionContainerInfo>> | undefined;\n #modelsCategoriesInfo: Observable<Map<ModelId, CategoriesInfo>> | undefined;\n #elementModelsCategories: Observable<Map<ModelId, { categoryIds: Id64Set; isSubModel: boolean }>> | undefined;\n #subCategoriesInfo: Observable<Map<SubCategoryId, SubCategoryInfo>> | undefined;\n readonly #categoryElementCounts: ModelCategoryElementsCountCache;\n #modelWithCategoryModeledElements: Observable<Map<ModelId, Map<CategoryId, Set<ElementId>>>> | undefined;\n #categoryClass: string;\n #categoryElementClass: string;\n #categoryModelClass: string;\n #isDefinitionContainerSupported: Observable<boolean> | undefined;\n #filteredElementsModels: Observable<Map<ElementId, ModelId>> | undefined;\n #queryExecutor: LimitingECSqlQueryExecutor;\n #componentId: GuidString;\n #componentName: string;\n\n constructor(queryExecutor: LimitingECSqlQueryExecutor, viewType: \"3d\" | \"2d\", componentId?: GuidString) {\n this.#queryExecutor = queryExecutor;\n const { categoryClass, elementClass, modelClass } = getClassesByView(viewType);\n this.#categoryClass = categoryClass;\n this.#categoryElementClass = elementClass;\n this.#categoryModelClass = modelClass;\n this.#componentId = componentId ?? Guid.createValue();\n this.#componentName = \"CategoriesTreeIdsCache\";\n this.#categoryElementCounts = new ModelCategoryElementsCountCache(this.#queryExecutor, [elementClass], this.#componentId);\n }\n\n public [Symbol.dispose]() {\n this.#categoryElementCounts[Symbol.dispose]();\n }\n\n private queryFilteredElementsModels(filteredElementIds: Id64Arg): Observable<{\n modelId: Id64String;\n id: ElementId;\n }> {\n return defer(() => {\n const query = `\n SELECT Model.Id modelId, ECInstanceId id\n FROM ${this.#categoryElementClass}\n WHERE ECInstanceId IN (${joinId64Arg(filteredElementIds, \",\")})\n `;\n return this.#queryExecutor.createQueryReader(\n { ecsql: query },\n {\n rowFormat: \"ECSqlPropertyNames\",\n limit: \"unbounded\",\n restartToken: `${this.#componentName}/${this.#componentId}/filtered-element-models/${Guid.createValue()}`,\n },\n );\n }).pipe(\n map((row) => {\n return { modelId: row.modelId, id: row.id };\n }),\n );\n }\n\n public getFilteredElementsModels(filteredElementIds: Id64Arg) {\n if (Id64.sizeOf(filteredElementIds) === 0) {\n return of(new Map<ElementId, ModelId>());\n }\n\n this.#filteredElementsModels ??= this.queryFilteredElementsModels(filteredElementIds).pipe(\n reduce((acc, { modelId, id }) => {\n acc.set(id, modelId);\n return acc;\n }, new Map<ElementId, ModelId>()),\n shareReplay(),\n );\n return this.#filteredElementsModels;\n }\n\n public clearFilteredElementsModels() {\n this.#filteredElementsModels = undefined;\n }\n\n private queryElementModelCategories(): Observable<{\n modelId: Id64String;\n categoryId: Id64String;\n }> {\n return defer(() => {\n const query = `\n SELECT this.Model.Id modelId, this.Category.Id categoryId\n FROM ${this.#categoryModelClass} m\n JOIN ${this.#categoryElementClass} this ON m.ECInstanceId = this.Model.Id\n WHERE this.Parent.Id IS NULL AND m.IsPrivate = false\n GROUP BY modelId, categoryId\n `;\n return this.#queryExecutor.createQueryReader(\n { ecsql: query },\n { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\", restartToken: `${this.#componentName}/${this.#componentId}/element-models-and-categories` },\n );\n }).pipe(\n map((row) => {\n return { modelId: row.modelId, categoryId: row.categoryId };\n }),\n );\n }\n\n private queryCategories(): Observable<{\n id: CategoryId;\n modelId: Id64String;\n parentDefinitionContainerExists: boolean;\n subCategoryChildCount: number;\n hasElements: boolean;\n }> {\n return this.getIsDefinitionContainerSupported().pipe(\n mergeMap((isDefinitionContainerSupported) =>\n defer(() => {\n const categoriesQuery = `\n SELECT\n this.ECInstanceId id,\n COUNT(sc.ECInstanceId) subCategoryChildCount,\n this.Model.Id modelId,\n ${\n isDefinitionContainerSupported\n ? `\n IIF(this.Model.Id IN (SELECT dc.ECInstanceId FROM ${CLASS_NAME_DefinitionContainer} dc),\n true,\n false\n )`\n : \"false\"\n } parentDefinitionContainerExists,\n IFNULL(\n (SELECT 1 FROM ${this.#categoryElementClass} e WHERE e.Category.Id = this.ECInstanceId LIMIT 1),\n 0\n ) hasElements\n FROM\n ${this.#categoryClass} this\n JOIN ${CLASS_NAME_SubCategory} sc ON sc.Parent.Id = this.ECInstanceId\n JOIN ${CLASS_NAME_Model} m ON m.ECInstanceId = this.Model.Id\n WHERE\n NOT this.IsPrivate\n AND (NOT m.IsPrivate OR m.ECClassId IS (BisCore.DictionaryModel))\n GROUP BY this.ECInstanceId\n `;\n return this.#queryExecutor.createQueryReader(\n { ecsql: categoriesQuery },\n { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\", restartToken: `${this.#componentName}/${this.#componentId}/categories` },\n );\n }).pipe(\n map((row) => {\n return {\n id: row.id,\n modelId: row.modelId,\n parentDefinitionContainerExists: row.parentDefinitionContainerExists,\n subCategoryChildCount: row.subCategoryChildCount,\n hasElements: !!row.hasElements,\n };\n }),\n ),\n ),\n );\n }\n\n private queryIsDefinitionContainersSupported(): Observable<boolean> {\n return defer(() => {\n const query = `\n SELECT\n 1\n FROM\n ECDbMeta.ECSchemaDef s\n JOIN ECDbMeta.ECClassDef c ON c.Schema.Id = s.ECInstanceId\n WHERE\n s.Name = 'BisCore'\n AND c.Name = 'DefinitionContainer'\n `;\n\n return this.#queryExecutor.createQueryReader(\n { ecsql: query },\n { restartToken: `${this.#componentName}/${this.#componentId}/is-definition-container-supported` },\n );\n }).pipe(\n toArray(),\n map((rows) => rows.length > 0),\n );\n }\n\n private queryDefinitionContainers(): Observable<{ id: DefinitionContainerId; modelId: Id64String; hasElements: boolean }> {\n return defer(() => {\n // DefinitionModel ECInstanceId will always be the same as modeled DefinitionContainer ECInstanceId, if this wasn't the case, we would need to do something like:\n // JOIN BisCore.DefinitionModel dm ON dm.ECInstanceId = ${modelIdAccessor}\n // JOIN BisCore.DefinitionModelBreaksDownDefinitionContainer dr ON dr.SourceECInstanceId = dm.ECInstanceId\n // JOIN BisCore.DefinitionContainer dc ON dc.ECInstanceId = dr.TargetECInstanceId\n const DEFINITION_CONTAINERS_CTE = \"DefinitionContainers\";\n const CATEGORIES_MODELS_CTE = \"CategoriesModels\";\n const ctes = [\n `${CATEGORIES_MODELS_CTE}(ModelId, HasElements) AS (\n SELECT\n c.Model.Id,\n IFNULL((\n SELECT 1\n FROM ${this.#categoryElementClass} e\n WHERE e.Category.Id = c.ECInstanceId\n LIMIT 1\n ), 0)\n FROM\n ${this.#categoryClass} c\n WHERE\n NOT c.IsPrivate\n )`,\n `\n ${DEFINITION_CONTAINERS_CTE}(ECInstanceId, ModelId, HasElements) AS (\n SELECT\n dc.ECInstanceId,\n dc.Model.Id,\n c.HasElements\n FROM ${CLASS_NAME_DefinitionContainer} dc\n JOIN ${CATEGORIES_MODELS_CTE} c ON dc.ECInstanceId = c.ModelId\n WHERE NOT dc.IsPrivate\n\n UNION ALL\n\n SELECT\n pdc.ECInstanceId,\n pdc.Model.Id,\n cdc.HasElements\n FROM\n ${DEFINITION_CONTAINERS_CTE} cdc\n JOIN ${CLASS_NAME_DefinitionContainer} pdc ON pdc.ECInstanceId = cdc.ModelId\n WHERE NOT pdc.IsPrivate\n )\n `,\n ];\n const definitionsQuery = `\n SELECT dc.ECInstanceId id, dc.ModelId modelId, MAX(dc.HasElements) hasElements FROM ${DEFINITION_CONTAINERS_CTE} dc GROUP BY dc.ECInstanceId\n `;\n return this.#queryExecutor.createQueryReader(\n { ctes, ecsql: definitionsQuery },\n { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\", restartToken: `${this.#componentName}/${this.#componentId}/definition-containers` },\n );\n }).pipe(\n map((row) => {\n return { id: row.id, modelId: row.modelId, hasElements: !!row.hasElements };\n }),\n );\n }\n\n private queryVisibleSubCategories(categoryIds: Id64Array): Observable<{ id: SubCategoryId; parentId: CategoryId }> {\n return defer(() => {\n const definitionsQuery = `\n SELECT\n sc.ECInstanceId id,\n sc.Parent.Id categoryId\n FROM\n ${CLASS_NAME_SubCategory} sc\n WHERE\n NOT sc.IsPrivate\n AND sc.Parent.Id IN (${categoryIds.join(\",\")})\n `;\n return this.#queryExecutor.createQueryReader(\n { ecsql: definitionsQuery },\n { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\", restartToken: `${this.#componentName}/${this.#componentId}/visible-sub-categories` },\n );\n }).pipe(\n map((row) => {\n return { id: row.id, parentId: row.categoryId };\n }),\n );\n }\n\n private getModelsCategoriesInfo() {\n this.#modelsCategoriesInfo ??= this.queryCategories()\n .pipe(\n reduce((acc, queriedCategory) => {\n let modelCategories = acc.get(queriedCategory.modelId);\n if (modelCategories === undefined) {\n modelCategories = { parentDefinitionContainerExists: queriedCategory.parentDefinitionContainerExists, childCategories: [] };\n acc.set(queriedCategory.modelId, modelCategories);\n }\n modelCategories.childCategories.push({\n id: queriedCategory.id,\n subCategoryChildCount: queriedCategory.subCategoryChildCount,\n hasElements: queriedCategory.hasElements,\n });\n return acc;\n }, new Map<ModelId, CategoriesInfo>()),\n )\n .pipe(shareReplay());\n return this.#modelsCategoriesInfo;\n }\n\n private getElementModelsCategories() {\n this.#elementModelsCategories ??= forkJoin({\n modelCategories: this.queryElementModelCategories().pipe(\n reduce((acc, queriedCategory) => {\n let modelEntry = acc.get(queriedCategory.modelId);\n if (modelEntry === undefined) {\n modelEntry = { categoryIds: new Set() };\n acc.set(queriedCategory.modelId, modelEntry);\n }\n modelEntry.categoryIds.add(queriedCategory.categoryId);\n return acc;\n }, new Map<ModelId, { categoryIds: Id64Set }>()),\n ),\n modelWithCategoryModeledElements: this.getModelWithCategoryModeledElements(),\n }).pipe(\n map(({ modelCategories, modelWithCategoryModeledElements }) => {\n const result = new Map<ModelId, { categoryIds: Set<CategoryId>; isSubModel: boolean }>();\n const subModels = new Set<Id64String>();\n modelWithCategoryModeledElements.forEach((categoryMap) =>\n categoryMap.forEach((categorySubModels) => categorySubModels.forEach((subModelId) => subModels.add(subModelId))),\n );\n for (const [modelId, modelEntry] of modelCategories) {\n const isSubModel = subModels.has(modelId);\n result.set(modelId, { categoryIds: modelEntry.categoryIds, isSubModel });\n }\n return result;\n }),\n shareReplay(),\n );\n return this.#elementModelsCategories;\n }\n\n private queryModeledElements(): Observable<{\n modelId: Id64String;\n modeledElementId: Id64String;\n categoryId: Id64String;\n rootCategoryId: Id64String;\n }> {\n return defer(() => {\n const query = `\n SELECT\n pe.ECInstanceId modeledElementId,\n pe.Category.Id categoryId,\n pe.Model.Id modelId\n FROM ${this.#categoryModelClass} m\n JOIN ${this.#categoryElementClass} pe ON pe.ECInstanceId = m.ModeledElement.Id\n WHERE\n m.IsPrivate = false\n AND m.ECInstanceId IN (SELECT Model.Id FROM ${this.#categoryElementClass})\n `;\n return this.#queryExecutor.createQueryReader(\n { ecsql: query },\n { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\", restartToken: `${this.#componentName}/${this.#componentId}/modeled-elements` },\n );\n }).pipe(\n map((row) => {\n return { modelId: row.modelId, categoryId: row.categoryId, modeledElementId: row.modeledElementId, rootCategoryId: row.rootCategoryId };\n }),\n );\n }\n\n private getModelWithCategoryModeledElements() {\n this.#modelWithCategoryModeledElements ??= this.queryModeledElements().pipe(\n reduce((acc, { modelId, categoryId, modeledElementId }) => {\n let modelEntry = acc.get(modelId);\n if (!modelEntry) {\n modelEntry = new Map();\n acc.set(modelId, modelEntry);\n }\n const categoryEntry = modelEntry.get(categoryId);\n if (!categoryEntry) {\n modelEntry.set(categoryId, new Set([modeledElementId]));\n } else {\n categoryEntry.add(modeledElementId);\n }\n return acc;\n }, new Map<ModelId, Map<CategoryId, Set<ElementId>>>()),\n shareReplay(),\n );\n return this.#modelWithCategoryModeledElements;\n }\n\n public getCategoriesModeledElements(modelId: Id64String, categoryIds: Id64Arg): Observable<Id64Array> {\n return this.getModelWithCategoryModeledElements().pipe(\n mergeMap((modelWithCategoryModeledElements) => {\n const result = new Array<ElementId>();\n const categoryMap = modelWithCategoryModeledElements.get(modelId);\n if (!categoryMap) {\n return of(result);\n }\n return from(Id64.iterable(categoryIds)).pipe(\n map((categoryId) => categoryMap.get(categoryId)),\n mergeMap((elementsSet) => (elementsSet ? from(elementsSet) : EMPTY)),\n toArray(),\n );\n }),\n );\n }\n\n private getSubCategoriesInfo() {\n this.#subCategoriesInfo ??= this.getModelsCategoriesInfo()\n .pipe(\n mergeMap((modelsCategoriesInfo) => from(modelsCategoriesInfo.values())),\n reduce((acc, modelCategoriesInfo) => {\n acc.push(\n ...modelCategoriesInfo.childCategories.filter((categoryInfo) => categoryInfo.subCategoryChildCount > 1).map((categoryInfo) => categoryInfo.id),\n );\n return acc;\n }, new Array<CategoryId>()),\n mergeMap((categoriesWithMoreThanOneSubCategory) => {\n const allSubCategories = new Map<Id64String, SubCategoryInfo>();\n if (categoriesWithMoreThanOneSubCategory.length === 0) {\n return of(allSubCategories);\n }\n return this.queryVisibleSubCategories(categoriesWithMoreThanOneSubCategory).pipe(\n reduce((acc, queriedSubCategory) => {\n acc.set(queriedSubCategory.id, { categoryId: queriedSubCategory.parentId });\n return acc;\n }, allSubCategories),\n );\n }),\n )\n .pipe(shareReplay());\n return this.#subCategoriesInfo;\n }\n\n private getDefinitionContainersInfo() {\n this.#definitionContainersInfo ??= forkJoin({\n isDefinitionContainerSupported: this.getIsDefinitionContainerSupported(),\n modelsCategoriesInfo: this.getModelsCategoriesInfo(),\n })\n .pipe(\n mergeMap(({ isDefinitionContainerSupported, modelsCategoriesInfo }) => {\n const definitionContainersInfo = new Map<DefinitionContainerId, DefinitionContainerInfo>();\n if (!isDefinitionContainerSupported || modelsCategoriesInfo.size === 0) {\n return of(definitionContainersInfo);\n }\n return this.queryDefinitionContainers().pipe(\n reduce((acc, queriedDefinitionContainer) => {\n const modelCategoriesInfo = modelsCategoriesInfo.get(queriedDefinitionContainer.id);\n acc.set(queriedDefinitionContainer.id, {\n childCategories: modelCategoriesInfo?.childCategories ?? [],\n modelId: queriedDefinitionContainer.modelId,\n childDefinitionContainers: [],\n parentDefinitionContainerExists: false,\n hasElements: queriedDefinitionContainer.hasElements,\n });\n return acc;\n }, definitionContainersInfo),\n map((result) => {\n for (const [definitionContainerId, definitionContainerInfo] of result) {\n const parentDefinitionContainer = result.get(definitionContainerInfo.modelId);\n if (parentDefinitionContainer !== undefined) {\n parentDefinitionContainer.childDefinitionContainers.push({ id: definitionContainerId, hasElements: definitionContainerInfo.hasElements });\n definitionContainerInfo.parentDefinitionContainerExists = true;\n parentDefinitionContainer.hasElements = parentDefinitionContainer.hasElements || definitionContainerInfo.hasElements;\n }\n }\n\n return result;\n }),\n );\n }),\n )\n .pipe(shareReplay());\n return this.#definitionContainersInfo;\n }\n\n public getDirectChildDefinitionContainersAndCategories({\n parentDefinitionContainerIds,\n includeEmpty,\n }: {\n parentDefinitionContainerIds: Id64Arg;\n includeEmpty?: boolean;\n }): Observable<{ categories: CategoryInfo[]; definitionContainers: Array<DefinitionContainerId> }> {\n return this.getDefinitionContainersInfo().pipe(\n mergeMap((definitionContainersInfo) =>\n from(Id64.iterable(parentDefinitionContainerIds)).pipe(\n reduce(\n (acc, parentDefinitionContainerId) => {\n const parentDefinitionContainerInfo = definitionContainersInfo.get(parentDefinitionContainerId);\n if (parentDefinitionContainerInfo !== undefined) {\n acc.definitionContainers.push(...applyElementsFilter(parentDefinitionContainerInfo.childDefinitionContainers, includeEmpty).map((dc) => dc.id));\n acc.categories.push(...applyElementsFilter(parentDefinitionContainerInfo.childCategories, includeEmpty));\n }\n return acc;\n },\n { definitionContainers: new Array<Id64String>(), categories: new Array<CategoryInfo>() },\n ),\n ),\n ),\n );\n }\n\n public getCategoriesElementModels(categoryIds: Id64Arg, includeSubModels?: boolean): Observable<{ id: CategoryId; models: Array<ModelId> | undefined }> {\n return this.getElementModelsCategories().pipe(\n mergeMap((elementModelsCategories) =>\n from(Id64.iterable(categoryIds)).pipe(\n map((categoryId) => {\n const categoryModels = new Array<ModelId>();\n elementModelsCategories.forEach(({ categoryIds: categories, isSubModel }, modelId) => {\n if ((includeSubModels || !isSubModel) && categories.has(categoryId)) {\n categoryModels.push(modelId);\n }\n });\n return { id: categoryId, models: categoryModels.length > 0 ? categoryModels : undefined };\n }),\n ),\n ),\n );\n }\n\n public getModelCategoryIds(modelId: Id64String): Observable<Id64Array> {\n return this.getElementModelsCategories().pipe(\n map((elementModelsCategories) => {\n return [...(elementModelsCategories.get(modelId)?.categoryIds ?? [])];\n }),\n );\n }\n\n public getAllCategories(): Observable<Id64Set> {\n return this.getModelsCategoriesInfo().pipe(\n mergeMap((modelsCategoriesInfo) => modelsCategoriesInfo.values()),\n reduce((acc, { childCategories }) => {\n childCategories.forEach(({ id }) => acc.add(id));\n return acc;\n }, new Set<Id64String>()),\n );\n }\n\n public hasSubModel(elementId: Id64String): Observable<boolean> {\n return this.getElementModelsCategories().pipe(map((elementModelsCategories) => elementModelsCategories.has(elementId)));\n }\n\n public getAllContainedCategories({\n definitionContainerIds,\n includeEmptyCategories,\n }: {\n definitionContainerIds: Id64Arg;\n includeEmptyCategories?: boolean;\n }): Observable<Id64Set> {\n return this.getDefinitionContainersInfo().pipe(\n mergeMap((definitionContainersInfo) =>\n from(Id64.iterable(definitionContainerIds)).pipe(\n mergeMap((definitionContainerId) => {\n const definitionContainerInfo = definitionContainersInfo.get(definitionContainerId);\n if (definitionContainerInfo === undefined) {\n return of({ directCategories: undefined, indirectCategories: undefined });\n }\n const childDefinitionContainerIds = definitionContainerInfo.childDefinitionContainers.map(({ id }) => id);\n return (\n childDefinitionContainerIds.length > 0\n ? this.getAllContainedCategories({\n definitionContainerIds: childDefinitionContainerIds,\n includeEmptyCategories,\n })\n : of(new Set<CategoryId>())\n ).pipe(\n map((indirectCategories) => {\n return {\n directCategories: applyElementsFilter(definitionContainerInfo.childCategories, includeEmptyCategories).map((category) => category.id),\n indirectCategories,\n };\n }),\n );\n }),\n reduce((acc, { directCategories, indirectCategories }) => {\n directCategories?.forEach((categoryId) => acc.add(categoryId));\n indirectCategories?.forEach((categoryId) => acc.add(categoryId));\n return acc;\n }, new Set<CategoryId>()),\n ),\n ),\n );\n }\n\n public getInstanceKeyPaths(\n props: { categoryId: Id64String } | { definitionContainerId: Id64String } | { subCategoryId: Id64String },\n ): Observable<InstanceKey[]> {\n if (\"subCategoryId\" in props) {\n return this.getSubCategoriesInfo().pipe(\n mergeMap((subCategoriesInfo) => {\n const subCategoryInfo = subCategoriesInfo.get(props.subCategoryId);\n if (subCategoryInfo === undefined) {\n return of([]);\n }\n return this.getInstanceKeyPaths({ categoryId: subCategoryInfo.categoryId }).pipe(\n map((pathToCategory) => [...pathToCategory, { id: props.subCategoryId, className: CLASS_NAME_SubCategory }]),\n );\n }),\n );\n }\n\n if (\"categoryId\" in props) {\n return this.getModelsCategoriesInfo().pipe(\n mergeMap((modelsCategoriesInfo) => {\n for (const [modelId, modelCategoriesInfo] of modelsCategoriesInfo) {\n if (modelCategoriesInfo.childCategories.find((childCategory) => childCategory.id === props.categoryId)) {\n const instanceKey = { id: props.categoryId, className: this.#categoryClass };\n if (!modelCategoriesInfo.parentDefinitionContainerExists) {\n return of([instanceKey]);\n }\n\n return this.getInstanceKeyPaths({ definitionContainerId: modelId }).pipe(\n map((pathToDefinitionContainer) => [...pathToDefinitionContainer, instanceKey]),\n );\n }\n }\n return of([]);\n }),\n );\n }\n return this.getDefinitionContainersInfo().pipe(\n mergeMap((definitionContainersInfo) => {\n const definitionContainerInfo = definitionContainersInfo.get(props.definitionContainerId);\n if (definitionContainerInfo === undefined) {\n return of([]);\n }\n const instanceKey = { id: props.definitionContainerId, className: CLASS_NAME_DefinitionContainer };\n if (!definitionContainerInfo.parentDefinitionContainerExists) {\n return of([instanceKey]);\n }\n return this.getInstanceKeyPaths({ definitionContainerId: definitionContainerInfo.modelId }).pipe(\n map((pathToParentDefinitionContainer) => [...pathToParentDefinitionContainer, instanceKey]),\n );\n }),\n );\n }\n\n public getCategoryElementsCount(modelId: Id64String, categoryId: Id64String): Observable<number> {\n return this.#categoryElementCounts.getCategoryElementsCount(modelId, categoryId);\n }\n\n public getAllDefinitionContainersAndCategories(props?: {\n includeEmpty?: boolean;\n }): Observable<{ categories: Array<CategoryId>; definitionContainers: Array<DefinitionContainerId> }> {\n return forkJoin({\n categories: this.getModelsCategoriesInfo().pipe(\n mergeMap((modelsCategoriesInfo) => modelsCategoriesInfo.values()),\n reduce((acc, modelCategoriesInfo) => {\n applyElementsFilter(modelCategoriesInfo.childCategories, props?.includeEmpty).forEach((categoryInfo) => acc.push(categoryInfo.id));\n return acc;\n }, new Array<Id64String>()),\n ),\n definitionContainers: this.getDefinitionContainersInfo().pipe(\n mergeMap((definitionContainersInfo) => definitionContainersInfo.entries()),\n reduce((acc, [definitionContainerId, definitionContainerInfo]) => {\n if (definitionContainerInfo.hasElements || !!props?.includeEmpty) {\n acc.push(definitionContainerId);\n }\n return acc;\n }, new Array<Id64String>()),\n ),\n });\n }\n\n public getRootDefinitionContainersAndCategories(props?: {\n includeEmpty?: boolean;\n }): Observable<{ categories: CategoryInfo[]; definitionContainers: Array<DefinitionContainerId> }> {\n return forkJoin({\n categories: this.getModelsCategoriesInfo().pipe(\n mergeMap((modelsCategoriesInfo) => modelsCategoriesInfo.values()),\n reduce((acc, modelCategoriesInfo) => {\n if (!modelCategoriesInfo.parentDefinitionContainerExists) {\n applyElementsFilter(modelCategoriesInfo.childCategories, props?.includeEmpty).forEach((categoryInfo) => acc.push(categoryInfo));\n }\n return acc;\n }, new Array<CategoryInfo>()),\n ),\n definitionContainers: this.getDefinitionContainersInfo().pipe(\n mergeMap((definitionContainersInfo) => definitionContainersInfo.entries()),\n reduce((acc, [definitionContainerId, definitionContainerInfo]) => {\n if (!definitionContainerInfo.parentDefinitionContainerExists && (definitionContainerInfo.hasElements || !!props?.includeEmpty)) {\n acc.push(definitionContainerId);\n }\n return acc;\n }, new Array<Id64String>()),\n ),\n });\n }\n\n public getSubCategories(categoryIds: Id64Arg): Observable<Map<CategoryId, Array<SubCategoryId>>> {\n return this.getSubCategoriesInfo().pipe(\n mergeMap((subCategoriesInfo) => subCategoriesInfo.entries()),\n reduce((acc, [subCategoryId, subCategoryInfo]) => {\n let entry = acc.get(subCategoryInfo.categoryId);\n if (!entry) {\n entry = [];\n acc.set(subCategoryInfo.categoryId, entry);\n }\n entry.push(subCategoryId);\n return acc;\n }, new Map<CategoryId, Array<Id64String>>()),\n map((subCategoriesMap) => {\n const result = new Map<CategoryId, Array<Id64String>>();\n for (const categoryId of Id64.iterable(categoryIds)) {\n const entry = subCategoriesMap.get(categoryId);\n if (entry) {\n result.set(categoryId, entry);\n }\n }\n return result;\n }),\n );\n }\n\n public getIsDefinitionContainerSupported(): Observable<boolean> {\n this.#isDefinitionContainerSupported ??= this.queryIsDefinitionContainersSupported().pipe(shareReplay());\n return this.#isDefinitionContainerSupported;\n }\n}\n\nfunction applyElementsFilter<T extends { hasElements?: boolean }>(list: T[], includeEmpty: boolean | undefined): T[] {\n return includeEmpty ? list : list.filter(({ hasElements }) => !!hasElements);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CategoriesTreeIdsCache.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACrG,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,8BAA8B,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,+CAA+C,CAAC;AACzI,OAAO,EAAE,+BAA+B,EAAE,MAAM,0DAA0D,CAAC;AAC3G,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AA4B/E,gBAAgB;AAChB,MAAM,OAAO,sBAAsB;IACjC,yBAAyB,CAA8E;IACvG,qBAAqB,CAAuD;IAC5E,wBAAwB,CAAsF;IAC9G,kBAAkB,CAEJ;IACL,sBAAsB,CAAkC;IACjE,iCAAiC,CAAwE;IACzG,cAAc,CAAS;IACvB,qBAAqB,CAAS;IAC9B,mBAAmB,CAAS;IAC5B,+BAA+B,CAAkC;IACjE,uBAAuB,CAAkD;IACzE,cAAc,CAA6B;IAC3C,YAAY,CAAa;IACzB,cAAc,CAAS;IAEvB,YAAY,aAAy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AE,uBAAuB,CAAC,EAAE,EAAE;gBAC/D,IAAI,CAAC,uBAAuB,CAAC,+BAA+B,IAAI,CAAC,uBAAuB,CAAC,WAAW,IAAI,CAAC,CAAC,KAAK,EAAE,YAAY,CAAC,EAAE,CAAC;oBAC/H,GAAG,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;gBAClC,CAAC;gBACD,OAAO,GAAG,CAAC;YACb,CAAC,EAAE,IAAI,KAAK,EAAc,CAAC,CAC5B;SACF,CAAC,CAAC;IACL,CAAC;IAEM,gBAAgB,CAAC,UAAsB;QAC5C,OAAO,IAAI,CAAC,oBAAoB,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,qBAAqB,EAAE,EAAE,EAAE,CAAC,qBAAqB,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAC3H,CAAC;IAEM,iCAAiC;QACtC,IAAI,CAAC,+BAA+B,KAAK,IAAI,CAAC,oCAAoC,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;QACzG,OAAO,IAAI,CAAC,+BAA+B,CAAC;IAC9C,CAAC;CACF;AAED,SAAS,mBAAmB,CAAsC,IAAS,EAAE,YAAiC;IAC5G,OAAO,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;AAC/E,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 { defer, EMPTY, forkJoin, from, map, mergeMap, of, reduce, shareReplay, toArray } from \"rxjs\";\nimport { Guid, Id64 } from \"@itwin/core-bentley\";\nimport { CLASS_NAME_DefinitionContainer, CLASS_NAME_Model, CLASS_NAME_SubCategory } from \"../../common/internal/ClassNameDefinitions.js\";\nimport { ModelCategoryElementsCountCache } from \"../../common/internal/ModelCategoryElementsCountCache.js\";\nimport { getClassesByView, joinId64Arg } from \"../../common/internal/Utils.js\";\n\nimport type { Observable } from \"rxjs\";\nimport type { GuidString, Id64Arg, Id64Array, Id64Set, Id64String } from \"@itwin/core-bentley\";\nimport type { LimitingECSqlQueryExecutor } from \"@itwin/presentation-hierarchies\";\nimport type { InstanceKey } from \"@itwin/presentation-shared\";\nimport type { CategoryId, DefinitionContainerId, ElementId, ModelId, SubCategoryId } from \"../../common/internal/Types.js\";\n\ninterface DefinitionContainerInfo {\n modelId: Id64String;\n parentDefinitionContainerExists: boolean;\n childCategories: CategoryInfo[];\n childDefinitionContainers: Array<{ id: Id64String; hasElements: boolean }>;\n hasElements: boolean;\n}\n\ninterface CategoriesInfo {\n childCategories: CategoryInfo[];\n parentDefinitionContainerExists: boolean;\n}\n\n/** @internal */\nexport interface CategoryInfo {\n id: CategoryId;\n subCategoryChildCount: number;\n hasElements: boolean;\n}\n\n/** @internal */\nexport class CategoriesTreeIdsCache implements Disposable {\n #definitionContainersInfo: Observable<Map<DefinitionContainerId, DefinitionContainerInfo>> | undefined;\n #modelsCategoriesInfo: Observable<Map<ModelId, CategoriesInfo>> | undefined;\n #elementModelsCategories: Observable<Map<ModelId, { categoryIds: Id64Set; isSubModel: boolean }>> | undefined;\n #subCategoriesInfo:\n | Observable<{ subCategoryCategories: Map<SubCategoryId, CategoryId>; categorySubCategories: Map<CategoryId, Array<SubCategoryId>> }>\n | undefined;\n readonly #categoryElementCounts: ModelCategoryElementsCountCache;\n #modelWithCategoryModeledElements: Observable<Map<ModelId, Map<CategoryId, Set<ElementId>>>> | undefined;\n #categoryClass: string;\n #categoryElementClass: string;\n #categoryModelClass: string;\n #isDefinitionContainerSupported: Observable<boolean> | undefined;\n #filteredElementsModels: Observable<Map<ElementId, ModelId>> | undefined;\n #queryExecutor: LimitingECSqlQueryExecutor;\n #componentId: GuidString;\n #componentName: string;\n\n constructor(queryExecutor: LimitingECSqlQueryExecutor, viewType: \"3d\" | \"2d\", componentId?: GuidString) {\n this.#queryExecutor = queryExecutor;\n const { categoryClass, elementClass, modelClass } = getClassesByView(viewType);\n this.#categoryClass = categoryClass;\n this.#categoryElementClass = elementClass;\n this.#categoryModelClass = modelClass;\n this.#componentId = componentId ?? Guid.createValue();\n this.#componentName = \"CategoriesTreeIdsCache\";\n this.#categoryElementCounts = new ModelCategoryElementsCountCache(this.#queryExecutor, [elementClass], this.#componentId);\n }\n\n public [Symbol.dispose]() {\n this.#categoryElementCounts[Symbol.dispose]();\n }\n\n private queryFilteredElementsModels(filteredElementIds: Id64Arg): Observable<{\n modelId: Id64String;\n id: ElementId;\n }> {\n return defer(() => {\n const query = `\n SELECT Model.Id modelId, ECInstanceId id\n FROM ${this.#categoryElementClass}\n WHERE ECInstanceId IN (${joinId64Arg(filteredElementIds, \",\")})\n `;\n return this.#queryExecutor.createQueryReader(\n { ecsql: query },\n {\n rowFormat: \"ECSqlPropertyNames\",\n limit: \"unbounded\",\n restartToken: `${this.#componentName}/${this.#componentId}/filtered-element-models/${Guid.createValue()}`,\n },\n );\n }).pipe(\n map((row) => {\n return { modelId: row.modelId, id: row.id };\n }),\n );\n }\n\n public getFilteredElementsModels(filteredElementIds: Id64Arg) {\n if (Id64.sizeOf(filteredElementIds) === 0) {\n return of(new Map<ElementId, ModelId>());\n }\n\n this.#filteredElementsModels ??= this.queryFilteredElementsModels(filteredElementIds).pipe(\n reduce((acc, { modelId, id }) => {\n acc.set(id, modelId);\n return acc;\n }, new Map<ElementId, ModelId>()),\n shareReplay(),\n );\n return this.#filteredElementsModels;\n }\n\n public clearFilteredElementsModels() {\n this.#filteredElementsModels = undefined;\n }\n\n private queryElementModelCategories(): Observable<{\n modelId: Id64String;\n categoryId: Id64String;\n }> {\n return defer(() => {\n const query = `\n SELECT this.Model.Id modelId, this.Category.Id categoryId\n FROM ${this.#categoryModelClass} m\n JOIN ${this.#categoryElementClass} this ON m.ECInstanceId = this.Model.Id\n WHERE this.Parent.Id IS NULL AND m.IsPrivate = false\n GROUP BY modelId, categoryId\n `;\n return this.#queryExecutor.createQueryReader(\n { ecsql: query },\n { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\", restartToken: `${this.#componentName}/${this.#componentId}/element-models-and-categories` },\n );\n }).pipe(\n map((row) => {\n return { modelId: row.modelId, categoryId: row.categoryId };\n }),\n );\n }\n\n private queryCategories(): Observable<{\n id: CategoryId;\n modelId: Id64String;\n parentDefinitionContainerExists: boolean;\n subCategoryChildCount: number;\n hasElements: boolean;\n }> {\n return this.getIsDefinitionContainerSupported().pipe(\n mergeMap((isDefinitionContainerSupported) =>\n defer(() => {\n const categoriesQuery = `\n SELECT\n this.ECInstanceId id,\n COUNT(sc.ECInstanceId) subCategoryChildCount,\n this.Model.Id modelId,\n ${\n isDefinitionContainerSupported\n ? `\n IIF(this.Model.Id IN (SELECT dc.ECInstanceId FROM ${CLASS_NAME_DefinitionContainer} dc),\n true,\n false\n )`\n : \"false\"\n } parentDefinitionContainerExists,\n IFNULL(\n (SELECT 1 FROM ${this.#categoryElementClass} e WHERE e.Category.Id = this.ECInstanceId LIMIT 1),\n 0\n ) hasElements\n FROM\n ${this.#categoryClass} this\n JOIN ${CLASS_NAME_SubCategory} sc ON sc.Parent.Id = this.ECInstanceId\n JOIN ${CLASS_NAME_Model} m ON m.ECInstanceId = this.Model.Id\n WHERE\n NOT this.IsPrivate\n AND (NOT m.IsPrivate OR m.ECClassId IS (BisCore.DictionaryModel))\n GROUP BY this.ECInstanceId\n `;\n return this.#queryExecutor.createQueryReader(\n { ecsql: categoriesQuery },\n { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\", restartToken: `${this.#componentName}/${this.#componentId}/categories` },\n );\n }).pipe(\n map((row) => {\n return {\n id: row.id,\n modelId: row.modelId,\n parentDefinitionContainerExists: row.parentDefinitionContainerExists,\n subCategoryChildCount: row.subCategoryChildCount,\n hasElements: !!row.hasElements,\n };\n }),\n ),\n ),\n );\n }\n\n private queryIsDefinitionContainersSupported(): Observable<boolean> {\n return defer(() => {\n const query = `\n SELECT\n 1\n FROM\n ECDbMeta.ECSchemaDef s\n JOIN ECDbMeta.ECClassDef c ON c.Schema.Id = s.ECInstanceId\n WHERE\n s.Name = 'BisCore'\n AND c.Name = 'DefinitionContainer'\n `;\n\n return this.#queryExecutor.createQueryReader(\n { ecsql: query },\n { restartToken: `${this.#componentName}/${this.#componentId}/is-definition-container-supported` },\n );\n }).pipe(\n toArray(),\n map((rows) => rows.length > 0),\n );\n }\n\n private queryDefinitionContainers(): Observable<{ id: DefinitionContainerId; modelId: Id64String; hasElements: boolean }> {\n return defer(() => {\n // DefinitionModel ECInstanceId will always be the same as modeled DefinitionContainer ECInstanceId, if this wasn't the case, we would need to do something like:\n // JOIN BisCore.DefinitionModel dm ON dm.ECInstanceId = ${modelIdAccessor}\n // JOIN BisCore.DefinitionModelBreaksDownDefinitionContainer dr ON dr.SourceECInstanceId = dm.ECInstanceId\n // JOIN BisCore.DefinitionContainer dc ON dc.ECInstanceId = dr.TargetECInstanceId\n const DEFINITION_CONTAINERS_CTE = \"DefinitionContainers\";\n const CATEGORIES_MODELS_CTE = \"CategoriesModels\";\n const ctes = [\n `${CATEGORIES_MODELS_CTE}(ModelId, HasElements) AS (\n SELECT\n c.Model.Id,\n IFNULL((\n SELECT 1\n FROM ${this.#categoryElementClass} e\n WHERE e.Category.Id = c.ECInstanceId\n LIMIT 1\n ), 0)\n FROM\n ${this.#categoryClass} c\n WHERE\n NOT c.IsPrivate\n )`,\n `\n ${DEFINITION_CONTAINERS_CTE}(ECInstanceId, ModelId, HasElements) AS (\n SELECT\n dc.ECInstanceId,\n dc.Model.Id,\n c.HasElements\n FROM ${CLASS_NAME_DefinitionContainer} dc\n JOIN ${CATEGORIES_MODELS_CTE} c ON dc.ECInstanceId = c.ModelId\n WHERE NOT dc.IsPrivate\n\n UNION ALL\n\n SELECT\n pdc.ECInstanceId,\n pdc.Model.Id,\n cdc.HasElements\n FROM\n ${DEFINITION_CONTAINERS_CTE} cdc\n JOIN ${CLASS_NAME_DefinitionContainer} pdc ON pdc.ECInstanceId = cdc.ModelId\n WHERE NOT pdc.IsPrivate\n )\n `,\n ];\n const definitionsQuery = `\n SELECT dc.ECInstanceId id, dc.ModelId modelId, MAX(dc.HasElements) hasElements FROM ${DEFINITION_CONTAINERS_CTE} dc GROUP BY dc.ECInstanceId\n `;\n return this.#queryExecutor.createQueryReader(\n { ctes, ecsql: definitionsQuery },\n { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\", restartToken: `${this.#componentName}/${this.#componentId}/definition-containers` },\n );\n }).pipe(\n map((row) => {\n return { id: row.id, modelId: row.modelId, hasElements: !!row.hasElements };\n }),\n );\n }\n\n private querySubCategories(): Observable<{ id: SubCategoryId; parentId: CategoryId }> {\n return defer(() => {\n const definitionsQuery = `\n SELECT\n sc.ECInstanceId id,\n sc.Parent.Id categoryId\n FROM\n ${CLASS_NAME_SubCategory} sc\n WHERE\n NOT sc.IsPrivate\n `;\n return this.#queryExecutor.createQueryReader(\n { ecsql: definitionsQuery },\n { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\", restartToken: `${this.#componentName}/${this.#componentId}/visible-sub-categories` },\n );\n }).pipe(\n map((row) => {\n return { id: row.id, parentId: row.categoryId };\n }),\n );\n }\n\n private getModelsCategoriesInfo() {\n this.#modelsCategoriesInfo ??= this.queryCategories()\n .pipe(\n reduce((acc, queriedCategory) => {\n let modelCategories = acc.get(queriedCategory.modelId);\n if (modelCategories === undefined) {\n modelCategories = { parentDefinitionContainerExists: queriedCategory.parentDefinitionContainerExists, childCategories: [] };\n acc.set(queriedCategory.modelId, modelCategories);\n }\n modelCategories.childCategories.push({\n id: queriedCategory.id,\n subCategoryChildCount: queriedCategory.subCategoryChildCount,\n hasElements: queriedCategory.hasElements,\n });\n return acc;\n }, new Map<ModelId, CategoriesInfo>()),\n )\n .pipe(shareReplay());\n return this.#modelsCategoriesInfo;\n }\n\n private getElementModelsCategories() {\n this.#elementModelsCategories ??= forkJoin({\n modelCategories: this.queryElementModelCategories().pipe(\n reduce((acc, queriedCategory) => {\n let modelEntry = acc.get(queriedCategory.modelId);\n if (modelEntry === undefined) {\n modelEntry = { categoryIds: new Set() };\n acc.set(queriedCategory.modelId, modelEntry);\n }\n modelEntry.categoryIds.add(queriedCategory.categoryId);\n return acc;\n }, new Map<ModelId, { categoryIds: Id64Set }>()),\n ),\n modelWithCategoryModeledElements: this.getModelWithCategoryModeledElements(),\n }).pipe(\n map(({ modelCategories, modelWithCategoryModeledElements }) => {\n const result = new Map<ModelId, { categoryIds: Set<CategoryId>; isSubModel: boolean }>();\n const subModels = new Set<Id64String>();\n modelWithCategoryModeledElements.forEach((categoryMap) =>\n categoryMap.forEach((categorySubModels) => categorySubModels.forEach((subModelId) => subModels.add(subModelId))),\n );\n for (const [modelId, modelEntry] of modelCategories) {\n const isSubModel = subModels.has(modelId);\n result.set(modelId, { categoryIds: modelEntry.categoryIds, isSubModel });\n }\n return result;\n }),\n shareReplay(),\n );\n return this.#elementModelsCategories;\n }\n\n private queryModeledElements(): Observable<{\n modelId: Id64String;\n modeledElementId: Id64String;\n categoryId: Id64String;\n rootCategoryId: Id64String;\n }> {\n return defer(() => {\n const query = `\n SELECT\n pe.ECInstanceId modeledElementId,\n pe.Category.Id categoryId,\n pe.Model.Id modelId\n FROM ${this.#categoryModelClass} m\n JOIN ${this.#categoryElementClass} pe ON pe.ECInstanceId = m.ModeledElement.Id\n WHERE\n m.IsPrivate = false\n AND m.ECInstanceId IN (SELECT Model.Id FROM ${this.#categoryElementClass})\n `;\n return this.#queryExecutor.createQueryReader(\n { ecsql: query },\n { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\", restartToken: `${this.#componentName}/${this.#componentId}/modeled-elements` },\n );\n }).pipe(\n map((row) => {\n return { modelId: row.modelId, categoryId: row.categoryId, modeledElementId: row.modeledElementId, rootCategoryId: row.rootCategoryId };\n }),\n );\n }\n\n private getModelWithCategoryModeledElements() {\n this.#modelWithCategoryModeledElements ??= this.queryModeledElements().pipe(\n reduce((acc, { modelId, categoryId, modeledElementId }) => {\n let modelEntry = acc.get(modelId);\n if (!modelEntry) {\n modelEntry = new Map();\n acc.set(modelId, modelEntry);\n }\n const categoryEntry = modelEntry.get(categoryId);\n if (!categoryEntry) {\n modelEntry.set(categoryId, new Set([modeledElementId]));\n } else {\n categoryEntry.add(modeledElementId);\n }\n return acc;\n }, new Map<ModelId, Map<CategoryId, Set<ElementId>>>()),\n shareReplay(),\n );\n return this.#modelWithCategoryModeledElements;\n }\n\n public getCategoriesModeledElements(modelId: Id64String, categoryIds: Id64Arg): Observable<Id64Array> {\n return this.getModelWithCategoryModeledElements().pipe(\n mergeMap((modelWithCategoryModeledElements) => {\n const result = new Array<ElementId>();\n const categoryMap = modelWithCategoryModeledElements.get(modelId);\n if (!categoryMap) {\n return of(result);\n }\n return from(Id64.iterable(categoryIds)).pipe(\n map((categoryId) => categoryMap.get(categoryId)),\n mergeMap((elementsSet) => (elementsSet ? from(elementsSet) : EMPTY)),\n toArray(),\n );\n }),\n );\n }\n\n private getSubCategoriesInfo() {\n this.#subCategoriesInfo ??= this.querySubCategories()\n .pipe(\n reduce(\n (acc, queriedSubCategory) => {\n acc.subCategoryCategories.set(queriedSubCategory.id, queriedSubCategory.parentId);\n const entry = acc.categorySubCategories.get(queriedSubCategory.parentId);\n if (entry) {\n entry.push(queriedSubCategory.id);\n } else {\n acc.categorySubCategories.set(queriedSubCategory.parentId, [queriedSubCategory.id]);\n }\n return acc;\n },\n { subCategoryCategories: new Map<SubCategoryId, CategoryId>(), categorySubCategories: new Map<CategoryId, Array<SubCategoryId>>() },\n ),\n )\n .pipe(shareReplay());\n return this.#subCategoriesInfo;\n }\n\n private getDefinitionContainersInfo() {\n this.#definitionContainersInfo ??= forkJoin({\n isDefinitionContainerSupported: this.getIsDefinitionContainerSupported(),\n modelsCategoriesInfo: this.getModelsCategoriesInfo(),\n })\n .pipe(\n mergeMap(({ isDefinitionContainerSupported, modelsCategoriesInfo }) => {\n const definitionContainersInfo = new Map<DefinitionContainerId, DefinitionContainerInfo>();\n if (!isDefinitionContainerSupported || modelsCategoriesInfo.size === 0) {\n return of(definitionContainersInfo);\n }\n return this.queryDefinitionContainers().pipe(\n reduce((acc, queriedDefinitionContainer) => {\n const modelCategoriesInfo = modelsCategoriesInfo.get(queriedDefinitionContainer.id);\n acc.set(queriedDefinitionContainer.id, {\n childCategories: modelCategoriesInfo?.childCategories ?? [],\n modelId: queriedDefinitionContainer.modelId,\n childDefinitionContainers: [],\n parentDefinitionContainerExists: false,\n hasElements: queriedDefinitionContainer.hasElements,\n });\n return acc;\n }, definitionContainersInfo),\n map((result) => {\n for (const [definitionContainerId, definitionContainerInfo] of result) {\n const parentDefinitionContainer = result.get(definitionContainerInfo.modelId);\n if (parentDefinitionContainer !== undefined) {\n parentDefinitionContainer.childDefinitionContainers.push({ id: definitionContainerId, hasElements: definitionContainerInfo.hasElements });\n definitionContainerInfo.parentDefinitionContainerExists = true;\n parentDefinitionContainer.hasElements = parentDefinitionContainer.hasElements || definitionContainerInfo.hasElements;\n }\n }\n\n return result;\n }),\n );\n }),\n )\n .pipe(shareReplay());\n return this.#definitionContainersInfo;\n }\n\n public getDirectChildDefinitionContainersAndCategories({\n parentDefinitionContainerIds,\n includeEmpty,\n }: {\n parentDefinitionContainerIds: Id64Arg;\n includeEmpty?: boolean;\n }): Observable<{ categories: CategoryInfo[]; definitionContainers: Array<DefinitionContainerId> }> {\n return this.getDefinitionContainersInfo().pipe(\n mergeMap((definitionContainersInfo) =>\n from(Id64.iterable(parentDefinitionContainerIds)).pipe(\n reduce(\n (acc, parentDefinitionContainerId) => {\n const parentDefinitionContainerInfo = definitionContainersInfo.get(parentDefinitionContainerId);\n if (parentDefinitionContainerInfo !== undefined) {\n acc.definitionContainers.push(...applyElementsFilter(parentDefinitionContainerInfo.childDefinitionContainers, includeEmpty).map((dc) => dc.id));\n acc.categories.push(...applyElementsFilter(parentDefinitionContainerInfo.childCategories, includeEmpty));\n }\n return acc;\n },\n { definitionContainers: new Array<Id64String>(), categories: new Array<CategoryInfo>() },\n ),\n ),\n ),\n );\n }\n\n public getCategoriesElementModels(categoryIds: Id64Arg, includeSubModels?: boolean): Observable<{ id: CategoryId; models: Array<ModelId> | undefined }> {\n return this.getElementModelsCategories().pipe(\n mergeMap((elementModelsCategories) =>\n from(Id64.iterable(categoryIds)).pipe(\n map((categoryId) => {\n const categoryModels = new Array<ModelId>();\n elementModelsCategories.forEach(({ categoryIds: categories, isSubModel }, modelId) => {\n if ((includeSubModels || !isSubModel) && categories.has(categoryId)) {\n categoryModels.push(modelId);\n }\n });\n return { id: categoryId, models: categoryModels.length > 0 ? categoryModels : undefined };\n }),\n ),\n ),\n );\n }\n\n public getModelCategoryIds(modelId: Id64String): Observable<Id64Array> {\n return this.getElementModelsCategories().pipe(\n map((elementModelsCategories) => {\n return [...(elementModelsCategories.get(modelId)?.categoryIds ?? [])];\n }),\n );\n }\n\n public getAllCategories(): Observable<Id64Set> {\n return this.getModelsCategoriesInfo().pipe(\n mergeMap((modelsCategoriesInfo) => modelsCategoriesInfo.values()),\n reduce((acc, { childCategories }) => {\n childCategories.forEach(({ id }) => acc.add(id));\n return acc;\n }, new Set<Id64String>()),\n );\n }\n\n public hasSubModel(elementId: Id64String): Observable<boolean> {\n return this.getElementModelsCategories().pipe(map((elementModelsCategories) => elementModelsCategories.has(elementId)));\n }\n\n public getAllContainedCategories({\n definitionContainerIds,\n includeEmptyCategories,\n }: {\n definitionContainerIds: Id64Arg;\n includeEmptyCategories?: boolean;\n }): Observable<Id64Set> {\n return this.getDefinitionContainersInfo().pipe(\n mergeMap((definitionContainersInfo) =>\n from(Id64.iterable(definitionContainerIds)).pipe(\n mergeMap((definitionContainerId) => {\n const definitionContainerInfo = definitionContainersInfo.get(definitionContainerId);\n if (definitionContainerInfo === undefined) {\n return of({ directCategories: undefined, indirectCategories: undefined });\n }\n const childDefinitionContainerIds = definitionContainerInfo.childDefinitionContainers.map(({ id }) => id);\n return (\n childDefinitionContainerIds.length > 0\n ? this.getAllContainedCategories({\n definitionContainerIds: childDefinitionContainerIds,\n includeEmptyCategories,\n })\n : of(new Set<CategoryId>())\n ).pipe(\n map((indirectCategories) => {\n return {\n directCategories: applyElementsFilter(definitionContainerInfo.childCategories, includeEmptyCategories).map((category) => category.id),\n indirectCategories,\n };\n }),\n );\n }),\n reduce((acc, { directCategories, indirectCategories }) => {\n directCategories?.forEach((categoryId) => acc.add(categoryId));\n indirectCategories?.forEach((categoryId) => acc.add(categoryId));\n return acc;\n }, new Set<CategoryId>()),\n ),\n ),\n );\n }\n\n public getInstanceKeyPaths(\n props: { categoryId: Id64String } | { definitionContainerId: Id64String } | { subCategoryId: Id64String },\n ): Observable<InstanceKey[]> {\n if (\"subCategoryId\" in props) {\n return this.getSubCategoriesInfo().pipe(\n mergeMap(({ subCategoryCategories, categorySubCategories }) => {\n const categoryOfSubCategory = subCategoryCategories.get(props.subCategoryId);\n if (categoryOfSubCategory === undefined) {\n return of([]);\n }\n const subCategories = categorySubCategories.get(categoryOfSubCategory);\n if (!subCategories || subCategories.length <= 1) {\n return of([]);\n }\n return this.getInstanceKeyPaths({ categoryId: categoryOfSubCategory }).pipe(\n map((pathToCategory) => [...pathToCategory, { id: props.subCategoryId, className: CLASS_NAME_SubCategory }]),\n );\n }),\n );\n }\n\n if (\"categoryId\" in props) {\n return this.getModelsCategoriesInfo().pipe(\n mergeMap((modelsCategoriesInfo) => {\n for (const [modelId, modelCategoriesInfo] of modelsCategoriesInfo) {\n if (modelCategoriesInfo.childCategories.find((childCategory) => childCategory.id === props.categoryId)) {\n const instanceKey = { id: props.categoryId, className: this.#categoryClass };\n if (!modelCategoriesInfo.parentDefinitionContainerExists) {\n return of([instanceKey]);\n }\n\n return this.getInstanceKeyPaths({ definitionContainerId: modelId }).pipe(\n map((pathToDefinitionContainer) => [...pathToDefinitionContainer, instanceKey]),\n );\n }\n }\n return of([]);\n }),\n );\n }\n return this.getDefinitionContainersInfo().pipe(\n mergeMap((definitionContainersInfo) => {\n const definitionContainerInfo = definitionContainersInfo.get(props.definitionContainerId);\n if (definitionContainerInfo === undefined) {\n return of([]);\n }\n const instanceKey = { id: props.definitionContainerId, className: CLASS_NAME_DefinitionContainer };\n if (!definitionContainerInfo.parentDefinitionContainerExists) {\n return of([instanceKey]);\n }\n return this.getInstanceKeyPaths({ definitionContainerId: definitionContainerInfo.modelId }).pipe(\n map((pathToParentDefinitionContainer) => [...pathToParentDefinitionContainer, instanceKey]),\n );\n }),\n );\n }\n\n public getCategoryElementsCount(modelId: Id64String, categoryId: Id64String): Observable<number> {\n return this.#categoryElementCounts.getCategoryElementsCount(modelId, categoryId);\n }\n\n public getAllDefinitionContainersAndCategories(props?: {\n includeEmpty?: boolean;\n }): Observable<{ categories: Array<CategoryId>; definitionContainers: Array<DefinitionContainerId> }> {\n return forkJoin({\n categories: this.getModelsCategoriesInfo().pipe(\n mergeMap((modelsCategoriesInfo) => modelsCategoriesInfo.values()),\n reduce((acc, modelCategoriesInfo) => {\n applyElementsFilter(modelCategoriesInfo.childCategories, props?.includeEmpty).forEach((categoryInfo) => acc.push(categoryInfo.id));\n return acc;\n }, new Array<Id64String>()),\n ),\n definitionContainers: this.getDefinitionContainersInfo().pipe(\n mergeMap((definitionContainersInfo) => definitionContainersInfo.entries()),\n reduce((acc, [definitionContainerId, definitionContainerInfo]) => {\n if (definitionContainerInfo.hasElements || !!props?.includeEmpty) {\n acc.push(definitionContainerId);\n }\n return acc;\n }, new Array<Id64String>()),\n ),\n });\n }\n\n public getRootDefinitionContainersAndCategories(props?: {\n includeEmpty?: boolean;\n }): Observable<{ categories: CategoryInfo[]; definitionContainers: Array<DefinitionContainerId> }> {\n return forkJoin({\n categories: this.getModelsCategoriesInfo().pipe(\n mergeMap((modelsCategoriesInfo) => modelsCategoriesInfo.values()),\n reduce((acc, modelCategoriesInfo) => {\n if (!modelCategoriesInfo.parentDefinitionContainerExists) {\n applyElementsFilter(modelCategoriesInfo.childCategories, props?.includeEmpty).forEach((categoryInfo) => acc.push(categoryInfo));\n }\n return acc;\n }, new Array<CategoryInfo>()),\n ),\n definitionContainers: this.getDefinitionContainersInfo().pipe(\n mergeMap((definitionContainersInfo) => definitionContainersInfo.entries()),\n reduce((acc, [definitionContainerId, definitionContainerInfo]) => {\n if (!definitionContainerInfo.parentDefinitionContainerExists && (definitionContainerInfo.hasElements || !!props?.includeEmpty)) {\n acc.push(definitionContainerId);\n }\n return acc;\n }, new Array<Id64String>()),\n ),\n });\n }\n\n public getSubCategories(categoryId: Id64String): Observable<Array<SubCategoryId>> {\n return this.getSubCategoriesInfo().pipe(map(({ categorySubCategories }) => categorySubCategories.get(categoryId) ?? []));\n }\n\n public getIsDefinitionContainerSupported(): Observable<boolean> {\n this.#isDefinitionContainerSupported ??= this.queryIsDefinitionContainersSupported().pipe(shareReplay());\n return this.#isDefinitionContainerSupported;\n }\n}\n\nfunction applyElementsFilter<T extends { hasElements?: boolean }>(list: T[], includeEmpty: boolean | undefined): T[] {\n return includeEmpty ? list : list.filter(({ hasElements }) => !!hasElements);\n}\n"]}
|
|
@@ -5,23 +5,23 @@ import type { ModelId } from "../../common/internal/Types.js";
|
|
|
5
5
|
import type { CategoriesTreeHierarchyConfiguration } from "../CategoriesTreeDefinition.js";
|
|
6
6
|
import type { CategoriesTreeIdsCache } from "./CategoriesTreeIdsCache.js";
|
|
7
7
|
/** @internal */
|
|
8
|
-
export type
|
|
9
|
-
type
|
|
8
|
+
export type CategoriesTreeSearchError = "tooManySearchMatches" | "unknownSearchError";
|
|
9
|
+
type HierarchySearchPaths = Awaited<ReturnType<Required<VisibilityTreeProps>["getSearchPaths"]>>;
|
|
10
10
|
/** @internal */
|
|
11
|
-
export declare function
|
|
11
|
+
export declare function useSearchPaths({ searchText, viewType, hierarchyConfiguration, getCategoriesTreeIdsCache, onCategoriesFiltered, onSearchPathsChanged, componentId, }: {
|
|
12
12
|
viewType: "2d" | "3d";
|
|
13
|
-
|
|
13
|
+
searchText?: string;
|
|
14
14
|
hierarchyConfiguration: CategoriesTreeHierarchyConfiguration;
|
|
15
15
|
getCategoriesTreeIdsCache: () => CategoriesTreeIdsCache;
|
|
16
16
|
onCategoriesFiltered?: (categories: {
|
|
17
17
|
categories: CategoryInfo[] | undefined;
|
|
18
18
|
models?: Array<ModelId>;
|
|
19
19
|
}) => void;
|
|
20
|
-
|
|
20
|
+
onSearchPathsChanged: (paths: HierarchySearchPaths | undefined) => void;
|
|
21
21
|
componentId: GuidString;
|
|
22
22
|
}): {
|
|
23
|
-
getPaths: VisibilityTreeProps["
|
|
24
|
-
|
|
23
|
+
getPaths: VisibilityTreeProps["getSearchPaths"] | undefined;
|
|
24
|
+
searchError: CategoriesTreeSearchError | undefined;
|
|
25
25
|
};
|
|
26
26
|
export {};
|
|
27
|
-
//# sourceMappingURL=
|
|
27
|
+
//# sourceMappingURL=UseSearchPaths.d.ts.map
|
|
@@ -5,58 +5,58 @@
|
|
|
5
5
|
import { useEffect, useMemo, useState } from "react";
|
|
6
6
|
import { firstValueFrom } from "rxjs";
|
|
7
7
|
import { assert } from "@itwin/core-bentley";
|
|
8
|
-
import {
|
|
8
|
+
import { HierarchyNodeIdentifier, HierarchySearchPath } from "@itwin/presentation-hierarchies";
|
|
9
9
|
import { CLASS_NAME_DefinitionContainer, CLASS_NAME_SubCategory } from "../../common/internal/ClassNameDefinitions.js";
|
|
10
10
|
import { getClassesByView } from "../../common/internal/Utils.js";
|
|
11
|
-
import {
|
|
11
|
+
import { SearchLimitExceededError } from "../../common/TreeErrors.js";
|
|
12
12
|
import { useTelemetryContext } from "../../common/UseTelemetryContext.js";
|
|
13
13
|
import { CategoriesTreeDefinition } from "../CategoriesTreeDefinition.js";
|
|
14
14
|
/** @internal */
|
|
15
|
-
export function
|
|
16
|
-
const [
|
|
15
|
+
export function useSearchPaths({ searchText, viewType, hierarchyConfiguration, getCategoriesTreeIdsCache, onCategoriesFiltered, onSearchPathsChanged, componentId, }) {
|
|
16
|
+
const [searchError, setSearchError] = useState();
|
|
17
17
|
const { onFeatureUsed } = useTelemetryContext();
|
|
18
18
|
useEffect(() => {
|
|
19
|
-
|
|
19
|
+
setSearchError(undefined);
|
|
20
20
|
onCategoriesFiltered?.({ categories: undefined, models: undefined });
|
|
21
|
-
if (!
|
|
22
|
-
|
|
21
|
+
if (!searchText) {
|
|
22
|
+
onSearchPathsChanged(undefined);
|
|
23
23
|
}
|
|
24
|
-
}, [
|
|
25
|
-
const
|
|
26
|
-
if (!
|
|
24
|
+
}, [searchText, onCategoriesFiltered, onSearchPathsChanged]);
|
|
25
|
+
const getSearchPaths = useMemo(() => {
|
|
26
|
+
if (!searchText) {
|
|
27
27
|
return undefined;
|
|
28
28
|
}
|
|
29
29
|
return async ({ imodelAccess, abortSignal }) => {
|
|
30
|
-
onFeatureUsed({ featureId: "
|
|
30
|
+
onFeatureUsed({ featureId: "search", reportInteraction: true });
|
|
31
31
|
try {
|
|
32
32
|
const paths = await CategoriesTreeDefinition.createInstanceKeyPaths({
|
|
33
33
|
imodelAccess,
|
|
34
34
|
abortSignal,
|
|
35
|
-
label:
|
|
35
|
+
label: searchText,
|
|
36
36
|
viewType,
|
|
37
37
|
idsCache: getCategoriesTreeIdsCache(),
|
|
38
38
|
hierarchyConfig: hierarchyConfiguration,
|
|
39
39
|
componentId,
|
|
40
40
|
});
|
|
41
|
-
|
|
41
|
+
onSearchPathsChanged(paths);
|
|
42
42
|
const { elementClass, modelClass } = getClassesByView(viewType);
|
|
43
43
|
onCategoriesFiltered?.(await getCategoriesFromPaths(paths, getCategoriesTreeIdsCache(), elementClass, modelClass, hierarchyConfiguration));
|
|
44
44
|
return paths;
|
|
45
45
|
}
|
|
46
46
|
catch (e) {
|
|
47
|
-
const newError = e instanceof
|
|
48
|
-
if (newError !== "
|
|
47
|
+
const newError = e instanceof SearchLimitExceededError ? "tooManySearchMatches" : "unknownSearchError";
|
|
48
|
+
if (newError !== "tooManySearchMatches") {
|
|
49
49
|
const feature = e instanceof Error && e.message.includes("query too long to execute or server is too busy") ? "error-timeout" : "error-unknown";
|
|
50
50
|
onFeatureUsed({ featureId: feature, reportInteraction: false });
|
|
51
51
|
}
|
|
52
|
-
|
|
52
|
+
setSearchError(newError);
|
|
53
53
|
return [];
|
|
54
54
|
}
|
|
55
55
|
};
|
|
56
|
-
}, [onCategoriesFiltered,
|
|
56
|
+
}, [onCategoriesFiltered, searchText, onSearchPathsChanged, onFeatureUsed, viewType, getCategoriesTreeIdsCache, hierarchyConfiguration, componentId]);
|
|
57
57
|
return {
|
|
58
|
-
getPaths:
|
|
59
|
-
|
|
58
|
+
getPaths: getSearchPaths,
|
|
59
|
+
searchError,
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
62
|
async function getCategoriesFromPaths(paths, idsCache, elementClassName, modelsClassName, hierarchyConfig) {
|
|
@@ -67,7 +67,7 @@ async function getCategoriesFromPaths(paths, idsCache, elementClassName, modelsC
|
|
|
67
67
|
const subModelIds = new Set();
|
|
68
68
|
const categories = new Map();
|
|
69
69
|
for (const path of paths) {
|
|
70
|
-
const currPath =
|
|
70
|
+
const currPath = HierarchySearchPath.normalize(path).path;
|
|
71
71
|
if (currPath.length === 0) {
|
|
72
72
|
continue;
|
|
73
73
|
}
|
|
@@ -133,4 +133,4 @@ async function getCategoriesFromPaths(paths, idsCache, elementClassName, modelsC
|
|
|
133
133
|
models,
|
|
134
134
|
};
|
|
135
135
|
}
|
|
136
|
-
//# sourceMappingURL=
|
|
136
|
+
//# sourceMappingURL=UseSearchPaths.js.map
|
package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/UseSearchPaths.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UseSearchPaths.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/categories-tree/internal/UseSearchPaths.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAE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;KACP,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 { useEffect, useMemo, useState } from \"react\";\nimport { firstValueFrom } from \"rxjs\";\nimport { assert } from \"@itwin/core-bentley\";\nimport { HierarchyNodeIdentifier, HierarchySearchPath } from \"@itwin/presentation-hierarchies\";\nimport { CLASS_NAME_DefinitionContainer, CLASS_NAME_SubCategory } from \"../../common/internal/ClassNameDefinitions.js\";\nimport { getClassesByView } from \"../../common/internal/Utils.js\";\nimport { SearchLimitExceededError } from \"../../common/TreeErrors.js\";\nimport { useTelemetryContext } from \"../../common/UseTelemetryContext.js\";\nimport { CategoriesTreeDefinition } from \"../CategoriesTreeDefinition.js\";\n\nimport type { GuidString } from \"@itwin/core-bentley\";\nimport type { CategoryInfo } from \"../../common/CategoriesVisibilityUtils.js\";\nimport type { VisibilityTreeProps } from \"../../common/components/VisibilityTree.js\";\nimport type { CategoryId, ElementId, ModelId, SubCategoryId } from \"../../common/internal/Types.js\";\nimport type { CategoriesTreeHierarchyConfiguration } from \"../CategoriesTreeDefinition.js\";\nimport type { CategoriesTreeIdsCache } from \"./CategoriesTreeIdsCache.js\";\n\n/** @internal */\nexport type CategoriesTreeSearchError = \"tooManySearchMatches\" | \"unknownSearchError\";\n\ntype HierarchySearchPaths = Awaited<ReturnType<Required<VisibilityTreeProps>[\"getSearchPaths\"]>>;\n\n/** @internal */\nexport function useSearchPaths({\n searchText,\n viewType,\n hierarchyConfiguration,\n getCategoriesTreeIdsCache,\n onCategoriesFiltered,\n onSearchPathsChanged,\n componentId,\n}: {\n viewType: \"2d\" | \"3d\";\n searchText?: string;\n hierarchyConfiguration: CategoriesTreeHierarchyConfiguration;\n getCategoriesTreeIdsCache: () => CategoriesTreeIdsCache;\n onCategoriesFiltered?: (categories: { categories: CategoryInfo[] | undefined; models?: Array<ModelId> }) => void;\n onSearchPathsChanged: (paths: HierarchySearchPaths | undefined) => void;\n componentId: GuidString;\n}): {\n getPaths: VisibilityTreeProps[\"getSearchPaths\"] | undefined;\n searchError: CategoriesTreeSearchError | undefined;\n} {\n const [searchError, setSearchError] = useState<CategoriesTreeSearchError | undefined>();\n const { onFeatureUsed } = useTelemetryContext();\n\n useEffect(() => {\n setSearchError(undefined);\n onCategoriesFiltered?.({ categories: undefined, models: undefined });\n if (!searchText) {\n onSearchPathsChanged(undefined);\n }\n }, [searchText, onCategoriesFiltered, onSearchPathsChanged]);\n\n const getSearchPaths = useMemo<VisibilityTreeProps[\"getSearchPaths\"] | undefined>(() => {\n if (!searchText) {\n return undefined;\n }\n\n return async ({ imodelAccess, abortSignal }) => {\n onFeatureUsed({ featureId: \"search\", reportInteraction: true });\n try {\n const paths = await CategoriesTreeDefinition.createInstanceKeyPaths({\n imodelAccess,\n abortSignal,\n label: searchText,\n viewType,\n idsCache: getCategoriesTreeIdsCache(),\n hierarchyConfig: hierarchyConfiguration,\n componentId,\n });\n onSearchPathsChanged(paths);\n const { elementClass, modelClass } = getClassesByView(viewType);\n onCategoriesFiltered?.(await getCategoriesFromPaths(paths, getCategoriesTreeIdsCache(), elementClass, modelClass, hierarchyConfiguration));\n return paths;\n } catch (e) {\n const newError = e instanceof SearchLimitExceededError ? \"tooManySearchMatches\" : \"unknownSearchError\";\n if (newError !== \"tooManySearchMatches\") {\n const feature = e instanceof Error && e.message.includes(\"query too long to execute or server is too busy\") ? \"error-timeout\" : \"error-unknown\";\n onFeatureUsed({ featureId: feature, reportInteraction: false });\n }\n setSearchError(newError);\n return [];\n }\n };\n }, [onCategoriesFiltered, searchText, onSearchPathsChanged, onFeatureUsed, viewType, getCategoriesTreeIdsCache, hierarchyConfiguration, componentId]);\n\n return {\n getPaths: getSearchPaths,\n searchError,\n };\n}\n\nasync function getCategoriesFromPaths(\n paths: HierarchySearchPaths,\n idsCache: CategoriesTreeIdsCache,\n elementClassName: string,\n modelsClassName: string,\n hierarchyConfig: CategoriesTreeHierarchyConfiguration,\n): Promise<{ categories: CategoryInfo[] | undefined; models?: Array<ModelId> }> {\n if (!paths) {\n return { categories: undefined };\n }\n\n const rootFilteredElementIds = new Set<ElementId>();\n const subModelIds = new Set<ModelId>();\n\n const categories = new Map<CategoryId, Array<SubCategoryId>>();\n for (const path of paths) {\n const currPath = HierarchySearchPath.normalize(path).path;\n if (currPath.length === 0) {\n continue;\n }\n\n let category: HierarchyNodeIdentifier;\n let subCategory: HierarchyNodeIdentifier | undefined;\n\n let lastNodeInfo: { lastNode: HierarchyNodeIdentifier; nodeIndex: number } | undefined;\n\n for (let i = 0; i < currPath.length; ++i) {\n const currentNode = currPath[i];\n if (!HierarchyNodeIdentifier.isInstanceNodeIdentifier(currentNode)) {\n continue;\n }\n if (currentNode.className === elementClassName) {\n rootFilteredElementIds.add(currentNode.id);\n for (let j = i + 1; j < currPath.length; ++j) {\n const childNode = currPath[j];\n if (!HierarchyNodeIdentifier.isInstanceNodeIdentifier(childNode)) {\n continue;\n }\n if (childNode.className === modelsClassName) {\n subModelIds.add(childNode.id);\n }\n }\n break;\n }\n lastNodeInfo = { lastNode: currentNode, nodeIndex: i };\n }\n\n assert(lastNodeInfo !== undefined && HierarchyNodeIdentifier.isInstanceNodeIdentifier(lastNodeInfo.lastNode));\n\n if (lastNodeInfo.lastNode.className === CLASS_NAME_DefinitionContainer) {\n const definitionContainerCategories = await firstValueFrom(\n idsCache.getAllContainedCategories({ definitionContainerIds: lastNodeInfo.lastNode.id, includeEmptyCategories: hierarchyConfig.showEmptyCategories }),\n );\n for (const categoryId of definitionContainerCategories) {\n const value = categories.get(categoryId);\n if (value === undefined) {\n categories.set(categoryId, []);\n }\n }\n continue;\n }\n\n if (lastNodeInfo.lastNode.className === CLASS_NAME_SubCategory) {\n const secondToLastNode = lastNodeInfo.nodeIndex > 0 ? currPath[lastNodeInfo.nodeIndex - 1] : undefined;\n assert(secondToLastNode !== undefined && HierarchyNodeIdentifier.isInstanceNodeIdentifier(secondToLastNode));\n\n subCategory = lastNodeInfo.lastNode;\n category = secondToLastNode;\n } else {\n category = lastNodeInfo.lastNode;\n }\n\n let entry = categories.get(category.id);\n if (entry === undefined) {\n entry = [];\n categories.set(category.id, entry);\n }\n\n if (subCategory) {\n entry.push(subCategory.id);\n }\n }\n const rootElementModelMap = await firstValueFrom(idsCache.getFilteredElementsModels(rootFilteredElementIds));\n const models = [...subModelIds, ...new Set(rootElementModelMap.values())];\n return {\n categories: [...categories.entries()].map(([categoryId, subCategoryIds]) => ({\n categoryId,\n subCategoryIds: subCategoryIds.length === 0 ? undefined : subCategoryIds,\n })),\n models,\n };\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { HierarchyNode } from "@itwin/presentation-hierarchies";
|
|
2
2
|
import { HierarchyVisibilityHandlerImpl } from "../../../common/internal/useTreeHooks/UseCachedVisibility.js";
|
|
3
3
|
import type { Observable } from "rxjs";
|
|
4
|
-
import type {
|
|
4
|
+
import type { HierarchySearchPath } from "@itwin/presentation-hierarchies";
|
|
5
5
|
import type { ECClassHierarchyInspector } from "@itwin/presentation-shared";
|
|
6
6
|
import type { AlwaysAndNeverDrawnElementInfo } from "../../../common/internal/AlwaysAndNeverDrawnElementInfo.js";
|
|
7
7
|
import type { TreeSpecificVisibilityHandler } from "../../../common/internal/visibility/BaseVisibilityHelper.js";
|
|
@@ -9,7 +9,7 @@ import type { TreeWidgetViewport } from "../../../common/TreeWidgetViewport.js";
|
|
|
9
9
|
import type { VisibilityStatus } from "../../../common/UseHierarchyVisibility.js";
|
|
10
10
|
import type { CategoriesTreeHierarchyConfiguration } from "../../CategoriesTreeDefinition.js";
|
|
11
11
|
import type { CategoriesTreeIdsCache } from "../CategoriesTreeIdsCache.js";
|
|
12
|
-
import type {
|
|
12
|
+
import type { CategoriesTreeSearchTargets } from "./SearchResultsTree.js";
|
|
13
13
|
/** @internal */
|
|
14
14
|
export interface CategoriesTreeVisibilityHandlerProps {
|
|
15
15
|
idsCache: CategoriesTreeIdsCache;
|
|
@@ -23,15 +23,15 @@ export interface CategoriesTreeVisibilityHandlerProps {
|
|
|
23
23
|
* This handler knows how to get and change visibility status of nodes created by hierarchy definition.
|
|
24
24
|
* @internal
|
|
25
25
|
*/
|
|
26
|
-
export declare class CategoriesTreeVisibilityHandler implements Disposable, TreeSpecificVisibilityHandler<
|
|
26
|
+
export declare class CategoriesTreeVisibilityHandler implements Disposable, TreeSpecificVisibilityHandler<CategoriesTreeSearchTargets> {
|
|
27
27
|
#private;
|
|
28
28
|
constructor(constructorProps: CategoriesTreeVisibilityHandlerProps);
|
|
29
29
|
[Symbol.dispose](): void;
|
|
30
|
-
|
|
30
|
+
changeSearchTargetsVisibilityStatus(targets: CategoriesTreeSearchTargets, on: boolean): Observable<void>;
|
|
31
31
|
getVisibilityStatus(node: HierarchyNode): Observable<VisibilityStatus>;
|
|
32
32
|
/** Changes visibility of the items represented by the tree node. */
|
|
33
33
|
changeVisibilityStatus(node: HierarchyNode, on: boolean): Observable<void>;
|
|
34
|
-
|
|
34
|
+
getSearchTargetsVisibilityStatus(targets: CategoriesTreeSearchTargets): Observable<VisibilityStatus>;
|
|
35
35
|
private getCategories;
|
|
36
36
|
private getAllCategories;
|
|
37
37
|
private getElementsCount;
|
|
@@ -48,7 +48,7 @@ export declare function createCategoriesTreeVisibilityHandler(props: {
|
|
|
48
48
|
viewport: TreeWidgetViewport;
|
|
49
49
|
idsCache: CategoriesTreeIdsCache;
|
|
50
50
|
imodelAccess: ECClassHierarchyInspector;
|
|
51
|
-
|
|
51
|
+
searchPaths?: HierarchySearchPath[];
|
|
52
52
|
hierarchyConfig: CategoriesTreeHierarchyConfiguration;
|
|
53
|
-
}): HierarchyVisibilityHandlerImpl<
|
|
53
|
+
}): HierarchyVisibilityHandlerImpl<CategoriesTreeSearchTargets>;
|
|
54
54
|
//# sourceMappingURL=CategoriesTreeVisibilityHandler.d.ts.map
|