@itwin/tree-widget-react 4.0.0-alpha.25 → 4.0.0-alpha.26

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.
Files changed (192) hide show
  1. package/CHANGELOG.md +35 -1
  2. package/lib/esm/tree-widget-react/components/TreeWidgetUiItemsProvider.js +2 -1
  3. package/lib/esm/tree-widget-react/components/TreeWidgetUiItemsProvider.js.map +1 -1
  4. package/lib/esm/tree-widget-react/components/tree-header/WidgetHeader.js +1 -1
  5. package/lib/esm/tree-widget-react/components/tree-header/WidgetHeader.js.map +1 -1
  6. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTree.d.ts +4 -1
  7. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTree.js +4 -1
  8. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTree.js.map +1 -1
  9. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.d.ts +1 -0
  10. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.js +36 -47
  11. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.js.map +1 -1
  12. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeComponent.d.ts +2 -0
  13. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeComponent.js +4 -1
  14. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeComponent.js.map +1 -1
  15. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.d.ts +2 -1
  16. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js +75 -38
  17. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js.map +1 -1
  18. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeNode.d.ts +3 -1
  19. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeNode.js.map +1 -1
  20. package/lib/esm/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.d.ts +4 -2
  21. package/lib/esm/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js +38 -23
  22. package/lib/esm/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js.map +1 -1
  23. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.d.ts +11 -21
  24. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js +16 -168
  25. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js.map +1 -1
  26. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeNodeInternal.d.ts +65 -0
  27. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeNodeInternal.js +22 -0
  28. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeNodeInternal.js.map +1 -0
  29. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/UseSearchPaths.d.ts +2 -2
  30. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/UseSearchPaths.js +4 -4
  31. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/UseSearchPaths.js.map +1 -1
  32. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/CategoriesTreeVisibilityHandler.d.ts +6 -10
  33. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/CategoriesTreeVisibilityHandler.js +180 -88
  34. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/CategoriesTreeVisibilityHandler.js.map +1 -1
  35. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/CategoriesTreeVisibilityHelper.d.ts +14 -5
  36. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/CategoriesTreeVisibilityHelper.js +43 -24
  37. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/CategoriesTreeVisibilityHelper.js.map +1 -1
  38. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/SearchResultsTree.d.ts +3 -1
  39. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/SearchResultsTree.js +78 -17
  40. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/SearchResultsTree.js.map +1 -1
  41. package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeComponent.d.ts +2 -0
  42. package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeComponent.js +4 -1
  43. package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeComponent.js.map +1 -1
  44. package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeDefinition.js +91 -114
  45. package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeDefinition.js.map +1 -1
  46. package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeIcon.d.ts +2 -2
  47. package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeIcon.js.map +1 -1
  48. package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeNode.d.ts +1 -3
  49. package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeNode.js +2 -4
  50. package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeNode.js.map +1 -1
  51. package/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTree.d.ts +13 -1
  52. package/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTree.js +62 -32
  53. package/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTree.js.map +1 -1
  54. package/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTreeDefinition.d.ts +12 -9
  55. package/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTreeDefinition.js +42 -38
  56. package/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTreeDefinition.js.map +1 -1
  57. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeIdsCache.d.ts +15 -38
  58. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeIdsCache.js +59 -242
  59. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeIdsCache.js.map +1 -1
  60. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeNodeInternal.d.ts +29 -0
  61. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeNodeInternal.js +19 -0
  62. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeNodeInternal.js.map +1 -0
  63. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/ClassificationsTreeVisibilityHandler.d.ts +4 -8
  64. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/ClassificationsTreeVisibilityHandler.js +154 -78
  65. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/ClassificationsTreeVisibilityHandler.js.map +1 -1
  66. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/ClassificationsTreeVisibilityHelper.js +20 -6
  67. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/ClassificationsTreeVisibilityHelper.js.map +1 -1
  68. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/SearchResultsTree.d.ts +6 -10
  69. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/SearchResultsTree.js +104 -63
  70. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/SearchResultsTree.js.map +1 -1
  71. package/lib/esm/tree-widget-react/components/trees/common/SharedTreeContextProvider.d.ts +7 -0
  72. package/lib/esm/tree-widget-react/components/trees/common/SharedTreeContextProvider.js +14 -0
  73. package/lib/esm/tree-widget-react/components/trees/common/SharedTreeContextProvider.js.map +1 -0
  74. package/lib/esm/tree-widget-react/components/trees/common/TreeWidgetViewport.js +1 -1
  75. package/lib/esm/tree-widget-react/components/trees/common/TreeWidgetViewport.js.map +1 -1
  76. package/lib/esm/tree-widget-react/components/trees/common/UseHierarchyVisibility.js +2 -2
  77. package/lib/esm/tree-widget-react/components/trees/common/UseHierarchyVisibility.js.map +1 -1
  78. package/lib/esm/tree-widget-react/components/trees/common/Utils.js +2 -2
  79. package/lib/esm/tree-widget-react/components/trees/common/Utils.js.map +1 -1
  80. package/lib/esm/tree-widget-react/components/trees/common/components/Tree.d.ts +4 -4
  81. package/lib/esm/tree-widget-react/components/trees/common/components/Tree.js +1 -1
  82. package/lib/esm/tree-widget-react/components/trees/common/components/Tree.js.map +1 -1
  83. package/lib/esm/tree-widget-react/components/trees/common/components/TreeNodeVisibilityButton.d.ts +4 -4
  84. package/lib/esm/tree-widget-react/components/trees/common/components/TreeNodeVisibilityButton.js.map +1 -1
  85. package/lib/esm/tree-widget-react/components/trees/common/components/TreeRenderer.js +7 -5
  86. package/lib/esm/tree-widget-react/components/trees/common/components/TreeRenderer.js.map +1 -1
  87. package/lib/esm/tree-widget-react/components/trees/common/components/UseVisibilityButtonHandler.d.ts +2 -2
  88. package/lib/esm/tree-widget-react/components/trees/common/components/UseVisibilityButtonHandler.js.map +1 -1
  89. package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTreeRenderer.js +5 -5
  90. package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTreeRenderer.js.map +1 -1
  91. package/lib/esm/tree-widget-react/components/trees/common/internal/SharedTreeContextProviderInternal.d.ts +20 -0
  92. package/lib/esm/tree-widget-react/components/trees/common/internal/SharedTreeContextProviderInternal.js +44 -0
  93. package/lib/esm/tree-widget-react/components/trees/common/internal/SharedTreeContextProviderInternal.js.map +1 -0
  94. package/lib/esm/tree-widget-react/components/trees/common/internal/Types.d.ts +4 -0
  95. package/lib/esm/tree-widget-react/components/trees/common/internal/Types.js.map +1 -1
  96. package/lib/esm/tree-widget-react/components/trees/common/internal/UseIModelAccess.d.ts +12 -0
  97. package/lib/esm/tree-widget-react/components/trees/common/internal/UseIModelAccess.js +2 -1
  98. package/lib/esm/tree-widget-react/components/trees/common/internal/UseIModelAccess.js.map +1 -1
  99. package/lib/esm/tree-widget-react/components/trees/common/internal/Utils.d.ts +17 -6
  100. package/lib/esm/tree-widget-react/components/trees/common/internal/Utils.js +58 -29
  101. package/lib/esm/tree-widget-react/components/trees/common/internal/Utils.js.map +1 -1
  102. package/lib/esm/tree-widget-react/components/trees/common/internal/VisibilityUtils.d.ts +8 -14
  103. package/lib/esm/tree-widget-react/components/trees/common/internal/VisibilityUtils.js +22 -26
  104. package/lib/esm/tree-widget-react/components/trees/common/internal/VisibilityUtils.js.map +1 -1
  105. package/lib/esm/tree-widget-react/components/trees/common/internal/{AlwaysAndNeverDrawnElementInfo.d.ts → caches/AlwaysAndNeverDrawnElementInfoCache.d.ts} +15 -21
  106. package/lib/esm/tree-widget-react/components/trees/common/internal/{AlwaysAndNeverDrawnElementInfo.js → caches/AlwaysAndNeverDrawnElementInfoCache.js} +40 -38
  107. package/lib/esm/tree-widget-react/components/trees/common/internal/caches/AlwaysAndNeverDrawnElementInfoCache.js.map +1 -0
  108. package/lib/esm/tree-widget-react/components/trees/common/internal/caches/BaseIdsCache.d.ts +68 -0
  109. package/lib/esm/tree-widget-react/components/trees/common/internal/caches/BaseIdsCache.js +148 -0
  110. package/lib/esm/tree-widget-react/components/trees/common/internal/caches/BaseIdsCache.js.map +1 -0
  111. package/lib/esm/tree-widget-react/components/trees/common/internal/caches/ElementChildrenCache.d.ts +30 -0
  112. package/lib/esm/tree-widget-react/components/trees/common/internal/caches/ElementChildrenCache.js +151 -0
  113. package/lib/esm/tree-widget-react/components/trees/common/internal/caches/ElementChildrenCache.js.map +1 -0
  114. package/lib/esm/tree-widget-react/components/trees/common/internal/caches/ElementModelCategoriesCache.d.ts +32 -0
  115. package/lib/esm/tree-widget-react/components/trees/common/internal/caches/ElementModelCategoriesCache.js +106 -0
  116. package/lib/esm/tree-widget-react/components/trees/common/internal/caches/ElementModelCategoriesCache.js.map +1 -0
  117. package/lib/esm/tree-widget-react/components/trees/common/internal/{ModelCategoryElementsCountCache.d.ts → caches/ModelCategoryElementsCountCache.d.ts} +9 -2
  118. package/lib/esm/tree-widget-react/components/trees/common/internal/{ModelCategoryElementsCountCache.js → caches/ModelCategoryElementsCountCache.js} +17 -21
  119. package/lib/esm/tree-widget-react/components/trees/common/internal/caches/ModelCategoryElementsCountCache.js.map +1 -0
  120. package/lib/esm/tree-widget-react/components/trees/common/internal/caches/ModeledElementsCache.d.ts +27 -0
  121. package/lib/esm/tree-widget-react/components/trees/common/internal/caches/ModeledElementsCache.js +106 -0
  122. package/lib/esm/tree-widget-react/components/trees/common/internal/caches/ModeledElementsCache.js.map +1 -0
  123. package/lib/esm/tree-widget-react/components/trees/common/internal/caches/SubCategoriesCache.d.ts +23 -0
  124. package/lib/esm/tree-widget-react/components/trees/common/internal/caches/SubCategoriesCache.js +56 -0
  125. package/lib/esm/tree-widget-react/components/trees/common/internal/caches/SubCategoriesCache.js.map +1 -0
  126. package/lib/esm/tree-widget-react/components/trees/common/internal/useTreeHooks/UseCachedVisibility.d.ts +6 -6
  127. package/lib/esm/tree-widget-react/components/trees/common/internal/useTreeHooks/UseCachedVisibility.js +27 -17
  128. package/lib/esm/tree-widget-react/components/trees/common/internal/useTreeHooks/UseCachedVisibility.js.map +1 -1
  129. package/lib/esm/tree-widget-react/components/trees/common/internal/useTreeHooks/UseIdsCache.d.ts +7 -13
  130. package/lib/esm/tree-widget-react/components/trees/common/internal/useTreeHooks/UseIdsCache.js +36 -35
  131. package/lib/esm/tree-widget-react/components/trees/common/internal/useTreeHooks/UseIdsCache.js.map +1 -1
  132. package/lib/esm/tree-widget-react/components/trees/common/internal/visibility/BaseSearchResultsTree.d.ts +18 -0
  133. package/lib/esm/tree-widget-react/components/trees/common/internal/visibility/BaseSearchResultsTree.js +14 -1
  134. package/lib/esm/tree-widget-react/components/trees/common/internal/visibility/BaseSearchResultsTree.js.map +1 -1
  135. package/lib/esm/tree-widget-react/components/trees/common/internal/visibility/BaseVisibilityHelper.d.ts +46 -70
  136. package/lib/esm/tree-widget-react/components/trees/common/internal/visibility/BaseVisibilityHelper.js +229 -361
  137. package/lib/esm/tree-widget-react/components/trees/common/internal/visibility/BaseVisibilityHelper.js.map +1 -1
  138. package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.d.ts +2 -2
  139. package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
  140. package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js.map +1 -1
  141. package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.d.ts +2 -2
  142. package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
  143. package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeComponent.js.map +1 -1
  144. package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeDefinition.js +1 -1
  145. package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeDefinition.js.map +1 -1
  146. package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/internal/IModelContentTreeIdsCache.js +32 -19
  147. package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/internal/IModelContentTreeIdsCache.js.map +1 -1
  148. package/lib/esm/tree-widget-react/components/trees/index.d.ts +2 -1
  149. package/lib/esm/tree-widget-react/components/trees/index.js +2 -1
  150. package/lib/esm/tree-widget-react/components/trees/index.js.map +1 -1
  151. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTree.d.ts +4 -1
  152. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTree.js +4 -1
  153. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTree.js.map +1 -1
  154. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.d.ts +7 -3
  155. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.js +36 -35
  156. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.js.map +1 -1
  157. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.d.ts +1 -0
  158. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.js +3 -1
  159. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
  160. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.d.ts +1 -0
  161. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js +56 -26
  162. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js.map +1 -1
  163. package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.d.ts +5 -3
  164. package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.js +25 -12
  165. package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.js.map +1 -1
  166. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.d.ts +11 -23
  167. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js +56 -189
  168. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js.map +1 -1
  169. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeNodeInternal.d.ts +52 -0
  170. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeNodeInternal.js +22 -0
  171. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeNodeInternal.js.map +1 -0
  172. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/UseSearchPaths.d.ts +2 -2
  173. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/UseSearchPaths.js +8 -8
  174. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/UseSearchPaths.js.map +1 -1
  175. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/ModelsTreeVisibilityHandler.d.ts +6 -10
  176. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/ModelsTreeVisibilityHandler.js +179 -72
  177. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/ModelsTreeVisibilityHandler.js.map +1 -1
  178. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/ModelsTreeVisibilityHelper.d.ts +6 -0
  179. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/ModelsTreeVisibilityHelper.js +20 -8
  180. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/ModelsTreeVisibilityHelper.js.map +1 -1
  181. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/SearchResultsTree.d.ts +4 -2
  182. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/SearchResultsTree.js +73 -13
  183. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/SearchResultsTree.js.map +1 -1
  184. package/lib/esm/tree-widget-react-internal.d.ts +1 -0
  185. package/lib/esm/tree-widget-react-internal.js +1 -0
  186. package/lib/esm/tree-widget-react-internal.js.map +1 -1
  187. package/package.json +77 -82
  188. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/UseSearchPaths.d.ts +0 -20
  189. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/UseSearchPaths.js +0 -53
  190. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/UseSearchPaths.js.map +0 -1
  191. package/lib/esm/tree-widget-react/components/trees/common/internal/AlwaysAndNeverDrawnElementInfo.js.map +0 -1
  192. package/lib/esm/tree-widget-react/components/trees/common/internal/ModelCategoryElementsCountCache.js.map +0 -1
@@ -2,9 +2,11 @@
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 { concat, EMPTY, from, map, mergeMap, reduce } from "rxjs";
5
+ import { concat, EMPTY, from, map, mergeAll, mergeMap, toArray } from "rxjs";
6
+ import { HierarchyNodeKey } from "@itwin/presentation-hierarchies";
7
+ import { getIdsFromChildrenTree, getParentElementsIdsPath } from "../../../common/internal/Utils.js";
6
8
  import { BaseVisibilityHelper } from "../../../common/internal/visibility/BaseVisibilityHelper.js";
7
- import { enableCategoryDisplay, mergeVisibilityStatuses } from "../../../common/internal/VisibilityUtils.js";
9
+ import { mergeVisibilityStatuses } from "../../../common/internal/VisibilityUtils.js";
8
10
  /**
9
11
  * Visibility status helper for categories tree.
10
12
  *
@@ -31,18 +33,24 @@ export class CategoriesTreeVisibilityHelper extends BaseVisibilityHelper {
31
33
  .pipe(mergeMap((categoryIds) => this.getCategoriesVisibilityStatus({
32
34
  categoryIds,
33
35
  modelId: undefined,
34
- type: this.#props.viewport.viewType === "2d" ? "DrawingCategory" : "SpatialCategory",
35
36
  })));
36
37
  }
37
38
  /** Gets grouped elements visibility status. */
38
39
  getGroupedElementsVisibilityStatus(props) {
39
- const { modelElementsMap, categoryId } = props;
40
- return from(modelElementsMap).pipe(mergeMap(([modelId, elementIds]) => this.getElementsVisibilityStatus({
40
+ const { modelElementsMap, categoryId, topMostParentElementId } = props;
41
+ return from(modelElementsMap).pipe(mergeMap(([modelId, { elementIds, categoryOfTopMostParentElement }]) => this.getElementsVisibilityStatus({
41
42
  elementIds,
42
43
  modelId,
43
44
  categoryId,
44
- type: this.#props.viewport.viewType === "2d" ? "GeometricElement2d" : "GeometricElement3d",
45
- })), mergeVisibilityStatuses);
45
+ parentElementsIdsPath: topMostParentElementId
46
+ ? getParentElementsIdsPath({
47
+ parentInstanceKeys: props.parentKeys.filter((key) => HierarchyNodeKey.isInstances(key)).map((key) => key.instanceKeys),
48
+ topMostParentElementId,
49
+ })
50
+ : [],
51
+ childrenCount: props.childrenCount,
52
+ categoryOfTopMostParentElement,
53
+ })), mergeVisibilityStatuses());
46
54
  }
47
55
  /**
48
56
  * Changes visibility status of definition containers.
@@ -65,27 +73,38 @@ export class CategoriesTreeVisibilityHelper extends BaseVisibilityHelper {
65
73
  changeSubCategoriesVisibilityStatus(props) {
66
74
  return concat(
67
75
  // make sure parent category and models are enabled
68
- props.on
69
- ? concat(from(enableCategoryDisplay(this.#props.viewport, props.categoryId, props.on, false)), this.enableCategoriesElementModelsVisibilityStatus(props.categoryId))
70
- : EMPTY, from(props.subCategoryIds).pipe(map((subCategoryId) => this.#props.viewport.changeSubCategoryDisplay({ subCategoryId, display: props.on }))));
76
+ props.on ? this.enableCategoryWithoutEnablingOtherCategories(props.categoryId) : EMPTY, from(props.subCategoryIds).pipe(map((subCategoryId) => this.#props.viewport.changeSubCategoryDisplay({ subCategoryId, display: props.on }))));
71
77
  }
72
78
  /** Changes grouped elements visibility status. */
73
79
  changeGroupedElementsVisibilityStatus(props) {
74
- return from(props.modelElementsMap).pipe(mergeMap(([modelId, elementIds]) => {
75
- return this.changeElementsVisibilityStatus({ modelId, elementIds, categoryId: props.categoryId, on: props.on });
76
- }));
80
+ const elementIds = new Array();
81
+ for (const { elementIds: ids } of props.modelElementsMap.values()) {
82
+ for (const id of ids) {
83
+ elementIds.push(id);
84
+ }
85
+ }
86
+ return this.#props.idsCache.getChildElementsTree({ elementIds }).pipe(map((childrenTree) => getIdsFromChildrenTree({ tree: childrenTree, predicate: ({ depth }) => depth > 0 })), mergeMap((children) => from(props.modelElementsMap).pipe(mergeMap(([modelId, { elementIds: modelElementIds }]) => {
87
+ return this.changeElementsVisibilityStatus({ modelId, elementIds: modelElementIds, categoryId: props.categoryId, on: props.on, children });
88
+ }))));
77
89
  }
78
- /** Turns on visibility status of models (that are not yet turned on) that are related to categories. */
79
- enableCategoriesElementModelsVisibilityStatus(categoryIds) {
80
- return this.#props.idsCache.getCategoriesElementModels(categoryIds, true).pipe(reduce((acc, { models }) => {
81
- models?.forEach((modelId) => {
82
- if (!this.#props.viewport.viewsModel(modelId)) {
83
- acc.add(modelId);
84
- }
85
- });
86
- return acc;
87
- }, new Set()), map((hiddenModels) => {
88
- if (hiddenModels.size > 0) {
90
+ /** Turns on category and its' related models. Does not turn on other categories contained in those models.*/
91
+ enableCategoryWithoutEnablingOtherCategories(categoryId) {
92
+ this.#props.viewport.changeCategoryDisplay({ categoryIds: categoryId, display: true });
93
+ return this.#props.idsCache.getModels({ categoryId, includeSubModels: true }).pipe(mergeAll(), mergeMap((modelId) => {
94
+ this.#props.viewport.setPerModelCategoryOverride({ modelIds: modelId, categoryIds: categoryId, override: "none" });
95
+ return this.#props.viewport.viewsModel(modelId)
96
+ ? EMPTY
97
+ : this.#props.idsCache.getCategories({ modelId }).pipe(map((allModelCategories) => {
98
+ // Add 'Hide' override to categories that were hidden before model is turned on
99
+ for (const modelCategoryId of allModelCategories) {
100
+ if (modelCategoryId !== categoryId) {
101
+ this.#props.viewport.setPerModelCategoryOverride({ modelIds: modelId, categoryIds: modelCategoryId, override: "hide" });
102
+ }
103
+ }
104
+ return modelId;
105
+ }));
106
+ }), toArray(), map((hiddenModels) => {
107
+ if (hiddenModels.length > 0) {
89
108
  this.#props.viewport.changeModelDisplay({ modelIds: hiddenModels, display: true });
90
109
  }
91
110
  }));
@@ -1 +1 @@
1
- {"version":3,"file":"CategoriesTreeVisibilityHelper.js","sourceRoot":"","sources":["../../../../../../../../src/tree-widget-react/components/trees/categories-tree/internal/visibility/CategoriesTreeVisibilityHelper.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6DAA6D,CAAC;AACnG,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,6CAA6C,CAAC;AAgB7G;;;;;GAKG;AACH,MAAM,OAAO,8BAA+B,SAAQ,oBAAoB;IACtE,MAAM,CAAsC;IAC5C,YAAY,KAA0C;QACpD,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAED;;;;OAIG;IACI,uCAAuC,CA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,IAAI,CAC5E,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;YACzB,MAAM,EAAE,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;gBAC1B,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;oBAC9C,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;gBACnB,CAAC;YACH,CAAC,CAAC,CAAC;YACH,OAAO,GAAG,CAAC;QACb,CAAC,EAAE,IAAI,GAAG,EAAc,CAAC,EACzB,GAAG,CAAC,CAAC,YAAY,EAAE,EAAE;YACnB,IAAI,YAAY,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;gBAC1B,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;YACrF,CAAC;QACH,CAAC,CAAC,CACH,CAAC;IACJ,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { concat, EMPTY, from, map, mergeMap, reduce } from \"rxjs\";\nimport { BaseVisibilityHelper } from \"../../../common/internal/visibility/BaseVisibilityHelper.js\";\nimport { enableCategoryDisplay, mergeVisibilityStatuses } from \"../../../common/internal/VisibilityUtils.js\";\n\nimport type { Observable } from \"rxjs\";\nimport type { Id64Arg, Id64String } from \"@itwin/core-bentley\";\nimport type { ElementId, ModelId } from \"../../../common/internal/Types.js\";\nimport type { BaseVisibilityHelperProps } from \"../../../common/internal/visibility/BaseVisibilityHelper.js\";\nimport type { VisibilityStatus } from \"../../../common/UseHierarchyVisibility.js\";\nimport type { CategoriesTreeHierarchyConfiguration } from \"../../CategoriesTreeDefinition.js\";\nimport type { CategoriesTreeIdsCache } from \"../CategoriesTreeIdsCache.js\";\n\n/** @internal */\nexport type CategoriesTreeVisibilityHelperProps = BaseVisibilityHelperProps & {\n idsCache: CategoriesTreeIdsCache;\n hierarchyConfig: CategoriesTreeHierarchyConfiguration;\n};\n\n/**\n * Visibility status helper for categories tree.\n *\n * It extends base visibility status helper and provides methods to get and change visibility status of definition containers and grouped elements.\n * @internal\n */\nexport class CategoriesTreeVisibilityHelper extends BaseVisibilityHelper {\n #props: CategoriesTreeVisibilityHelperProps;\n constructor(props: CategoriesTreeVisibilityHelperProps) {\n super(props);\n this.#props = props;\n }\n\n /**\n * Gets visibility status of definition containers.\n *\n * Determines visibility status by checking visibility status of related categories.\n */\n public getDefinitionContainersVisibilityStatus(props: { definitionContainerIds: Id64Arg }): Observable<VisibilityStatus> {\n return this.#props.idsCache\n .getAllContainedCategories({\n definitionContainerIds: props.definitionContainerIds,\n includeEmptyCategories: this.#props.hierarchyConfig.showEmptyCategories,\n })\n .pipe(\n mergeMap((categoryIds) =>\n this.getCategoriesVisibilityStatus({\n categoryIds,\n modelId: undefined,\n type: this.#props.viewport.viewType === \"2d\" ? \"DrawingCategory\" : \"SpatialCategory\",\n }),\n ),\n );\n }\n\n /** Gets grouped elements visibility status. */\n public getGroupedElementsVisibilityStatus(props: { modelElementsMap: Map<ModelId, Set<ElementId>>; categoryId: Id64String }): Observable<VisibilityStatus> {\n const { modelElementsMap, categoryId } = props;\n return from(modelElementsMap).pipe(\n mergeMap(([modelId, elementIds]) =>\n this.getElementsVisibilityStatus({\n elementIds,\n modelId,\n categoryId,\n type: this.#props.viewport.viewType === \"2d\" ? \"GeometricElement2d\" : \"GeometricElement3d\",\n }),\n ),\n mergeVisibilityStatuses,\n );\n }\n\n /**\n * Changes visibility status of definition containers.\n *\n * Does this by changing visibility status of related categories.\n */\n public changeDefinitionContainersVisibilityStatus(props: { definitionContainerIds: Id64Arg; on: boolean }): Observable<void> {\n return this.#props.idsCache\n .getAllContainedCategories({\n definitionContainerIds: props.definitionContainerIds,\n includeEmptyCategories: this.#props.hierarchyConfig.showEmptyCategories,\n })\n .pipe(mergeMap((categoryIds) => this.changeCategoriesVisibilityStatus({ categoryIds, modelId: undefined, on: props.on })));\n }\n\n /**\n * Changes visibility status of sub-categories.\n *\n * Also, enables parent categories if `on` is true.\n */\n public changeSubCategoriesVisibilityStatus(props: { categoryId: Id64String; subCategoryIds: Id64Arg; on: boolean }): Observable<void> {\n return concat(\n // make sure parent category and models are enabled\n props.on\n ? concat(\n from(enableCategoryDisplay(this.#props.viewport, props.categoryId, props.on, false)),\n this.enableCategoriesElementModelsVisibilityStatus(props.categoryId),\n )\n : EMPTY,\n from(props.subCategoryIds).pipe(map((subCategoryId) => this.#props.viewport.changeSubCategoryDisplay({ subCategoryId, display: props.on }))),\n );\n }\n\n /** Changes grouped elements visibility status. */\n public changeGroupedElementsVisibilityStatus(props: {\n modelElementsMap: Map<ModelId, Set<ElementId>>;\n categoryId: Id64String;\n on: boolean;\n }): Observable<void> {\n return from(props.modelElementsMap).pipe(\n mergeMap(([modelId, elementIds]) => {\n return this.changeElementsVisibilityStatus({ modelId, elementIds, categoryId: props.categoryId, on: props.on });\n }),\n );\n }\n\n /** Turns on visibility status of models (that are not yet turned on) that are related to categories. */\n private enableCategoriesElementModelsVisibilityStatus(categoryIds: Id64Arg): Observable<void> {\n return this.#props.idsCache.getCategoriesElementModels(categoryIds, true).pipe(\n reduce((acc, { models }) => {\n models?.forEach((modelId) => {\n if (!this.#props.viewport.viewsModel(modelId)) {\n acc.add(modelId);\n }\n });\n return acc;\n }, new Set<Id64String>()),\n map((hiddenModels) => {\n if (hiddenModels.size > 0) {\n this.#props.viewport.changeModelDisplay({ modelIds: hiddenModels, display: true });\n }\n }),\n );\n }\n}\n"]}
1
+ {"version":3,"file":"CategoriesTreeVisibilityHelper.js","sourceRoot":"","sources":["../../../../../../../../src/tree-widget-react/components/trees/categories-tree/internal/visibility/CategoriesTreeVisibilityHelper.ts"],"names":[],"mappings":"AAAA;;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YACrF,CAAC;QACH,CAAC,CAAC,CACH,CAAC;IACJ,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { concat, EMPTY, from, map, mergeAll, mergeMap, toArray } from \"rxjs\";\nimport { HierarchyNodeKey } from \"@itwin/presentation-hierarchies\";\nimport { getIdsFromChildrenTree, getParentElementsIdsPath } from \"../../../common/internal/Utils.js\";\nimport { BaseVisibilityHelper } from \"../../../common/internal/visibility/BaseVisibilityHelper.js\";\nimport { mergeVisibilityStatuses } from \"../../../common/internal/VisibilityUtils.js\";\n\nimport type { Observable } from \"rxjs\";\nimport type { Id64Arg, Id64String } from \"@itwin/core-bentley\";\nimport type { CategoryId, ElementId, ModelId } from \"../../../common/internal/Types.js\";\nimport type { BaseVisibilityHelperProps } from \"../../../common/internal/visibility/BaseVisibilityHelper.js\";\nimport type { VisibilityStatus } from \"../../../common/UseHierarchyVisibility.js\";\nimport type { CategoriesTreeHierarchyConfiguration } from \"../../CategoriesTreeDefinition.js\";\nimport type { CategoriesTreeIdsCache } from \"../CategoriesTreeIdsCache.js\";\n\n/** @internal */\nexport type CategoriesTreeVisibilityHelperProps = BaseVisibilityHelperProps & {\n idsCache: CategoriesTreeIdsCache;\n hierarchyConfig: CategoriesTreeHierarchyConfiguration;\n};\n\n/**\n * Visibility status helper for categories tree.\n *\n * It extends base visibility status helper and provides methods to get and change visibility status of definition containers and grouped elements.\n * @internal\n */\nexport class CategoriesTreeVisibilityHelper extends BaseVisibilityHelper {\n #props: CategoriesTreeVisibilityHelperProps;\n constructor(props: CategoriesTreeVisibilityHelperProps) {\n super(props);\n this.#props = props;\n }\n\n /**\n * Gets visibility status of definition containers.\n *\n * Determines visibility status by checking visibility status of related categories.\n */\n public getDefinitionContainersVisibilityStatus(props: { definitionContainerIds: Id64Arg }): Observable<VisibilityStatus> {\n return this.#props.idsCache\n .getAllContainedCategories({\n definitionContainerIds: props.definitionContainerIds,\n includeEmptyCategories: this.#props.hierarchyConfig.showEmptyCategories,\n })\n .pipe(\n mergeMap((categoryIds) =>\n this.getCategoriesVisibilityStatus({\n categoryIds,\n modelId: undefined,\n }),\n ),\n );\n }\n\n /** Gets grouped elements visibility status. */\n public getGroupedElementsVisibilityStatus(props: {\n modelElementsMap: Map<ModelId, { elementIds: Set<ElementId>; categoryOfTopMostParentElement: CategoryId }>;\n categoryId: Id64String;\n parentKeys: HierarchyNodeKey[];\n childrenCount: number;\n topMostParentElementId?: ElementId;\n }): Observable<VisibilityStatus> {\n const { modelElementsMap, categoryId, topMostParentElementId } = props;\n return from(modelElementsMap).pipe(\n mergeMap(([modelId, { elementIds, categoryOfTopMostParentElement }]) =>\n this.getElementsVisibilityStatus({\n elementIds,\n modelId,\n categoryId,\n parentElementsIdsPath: topMostParentElementId\n ? getParentElementsIdsPath({\n parentInstanceKeys: props.parentKeys.filter((key) => HierarchyNodeKey.isInstances(key)).map((key) => key.instanceKeys),\n topMostParentElementId,\n })\n : [],\n childrenCount: props.childrenCount,\n categoryOfTopMostParentElement,\n }),\n ),\n mergeVisibilityStatuses(),\n );\n }\n\n /**\n * Changes visibility status of definition containers.\n *\n * Does this by changing visibility status of related categories.\n */\n public changeDefinitionContainersVisibilityStatus(props: { definitionContainerIds: Id64Arg; on: boolean }): Observable<void> {\n return this.#props.idsCache\n .getAllContainedCategories({\n definitionContainerIds: props.definitionContainerIds,\n includeEmptyCategories: this.#props.hierarchyConfig.showEmptyCategories,\n })\n .pipe(mergeMap((categoryIds) => this.changeCategoriesVisibilityStatus({ categoryIds, modelId: undefined, on: props.on })));\n }\n\n /**\n * Changes visibility status of sub-categories.\n *\n * Also, enables parent categories if `on` is true.\n */\n public changeSubCategoriesVisibilityStatus(props: { categoryId: Id64String; subCategoryIds: Id64Arg; on: boolean }): Observable<void> {\n return concat(\n // make sure parent category and models are enabled\n props.on ? this.enableCategoryWithoutEnablingOtherCategories(props.categoryId) : EMPTY,\n from(props.subCategoryIds).pipe(map((subCategoryId) => this.#props.viewport.changeSubCategoryDisplay({ subCategoryId, display: props.on }))),\n );\n }\n\n /** Changes grouped elements visibility status. */\n public changeGroupedElementsVisibilityStatus(props: {\n modelElementsMap: Map<ModelId, { elementIds: Set<ElementId> }>;\n categoryId: Id64String;\n on: boolean;\n }): Observable<void> {\n const elementIds = new Array<ElementId>();\n for (const { elementIds: ids } of props.modelElementsMap.values()) {\n for (const id of ids) {\n elementIds.push(id);\n }\n }\n return this.#props.idsCache.getChildElementsTree({ elementIds }).pipe(\n map((childrenTree) => getIdsFromChildrenTree({ tree: childrenTree, predicate: ({ depth }) => depth > 0 })),\n mergeMap((children) =>\n from(props.modelElementsMap).pipe(\n mergeMap(([modelId, { elementIds: modelElementIds }]) => {\n return this.changeElementsVisibilityStatus({ modelId, elementIds: modelElementIds, categoryId: props.categoryId, on: props.on, children });\n }),\n ),\n ),\n );\n }\n\n /** Turns on category and its' related models. Does not turn on other categories contained in those models.*/\n private enableCategoryWithoutEnablingOtherCategories(categoryId: Id64String): Observable<void> {\n this.#props.viewport.changeCategoryDisplay({ categoryIds: categoryId, display: true });\n return this.#props.idsCache.getModels({ categoryId, includeSubModels: true }).pipe(\n mergeAll(),\n mergeMap((modelId) => {\n this.#props.viewport.setPerModelCategoryOverride({ modelIds: modelId, categoryIds: categoryId, override: \"none\" });\n return this.#props.viewport.viewsModel(modelId)\n ? EMPTY\n : this.#props.idsCache.getCategories({ modelId }).pipe(\n map((allModelCategories) => {\n // Add 'Hide' override to categories that were hidden before model is turned on\n for (const modelCategoryId of allModelCategories) {\n if (modelCategoryId !== categoryId) {\n this.#props.viewport.setPerModelCategoryOverride({ modelIds: modelId, categoryIds: modelCategoryId, override: \"hide\" });\n }\n }\n return modelId;\n }),\n );\n }),\n toArray(),\n map((hiddenModels) => {\n if (hiddenModels.length > 0) {\n this.#props.viewport.changeModelDisplay({ modelIds: hiddenModels, display: true });\n }\n }),\n );\n }\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import type { Id64Set, Id64String } from "@itwin/core-bentley";
2
2
  import type { HierarchySearchPath } from "@itwin/presentation-hierarchies";
3
- import type { ECClassHierarchyInspector } from "@itwin/presentation-shared";
3
+ import type { ECClassHierarchyInspector, InstanceKey } from "@itwin/presentation-shared";
4
4
  import type { ElementId } from "../../../common/internal/Types.js";
5
5
  import type { SearchResultsTree } from "../../../common/internal/visibility/BaseSearchResultsTree.js";
6
6
  import type { CategoriesTreeIdsCache } from "../CategoriesTreeIdsCache.js";
@@ -11,11 +11,13 @@ export interface CategoriesTreeSearchTargets {
11
11
  categoryIds: Id64Set;
12
12
  }>;
13
13
  elements?: Array<{
14
+ pathToElements: InstanceKey[];
14
15
  modelId: Id64String;
15
16
  categoryId: Id64String;
16
17
  elements: Map<ElementId, {
17
18
  isSearchTarget: boolean;
18
19
  }>;
20
+ topMostParentElementId?: ElementId;
19
21
  }>;
20
22
  definitionContainerIds?: Id64Set;
21
23
  modelIds?: Id64Set;
@@ -4,7 +4,7 @@
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
  import { firstValueFrom } from "rxjs";
6
6
  import { assert } from "@itwin/core-bentley";
7
- import { CLASS_NAME_SubCategory } from "../../../common/internal/ClassNameDefinitions.js";
7
+ import { CLASS_NAME_DefinitionContainer, CLASS_NAME_SubCategory } from "../../../common/internal/ClassNameDefinitions.js";
8
8
  import { createSearchResultsTree, SearchResultsNodesHandler } from "../../../common/internal/visibility/BaseSearchResultsTree.js";
9
9
  /** @internal */
10
10
  export async function createCategoriesSearchResultsTree(props) {
@@ -31,17 +31,17 @@ class CategoriesTreeSearchResultsNodesHandler extends SearchResultsNodesHandler
31
31
  const result = {
32
32
  searchResultsElements: new Map(),
33
33
  };
34
- this.searchResultsNodesArr.forEach((node) => {
34
+ for (const node of this.searchResultsNodesArr) {
35
35
  if (node.type === "element") {
36
36
  searchResultsTemporaryElements.set(node.id, node);
37
37
  }
38
- });
38
+ }
39
39
  const searchResultsElementsModels = await firstValueFrom(this.#props.idsCache.getFilteredElementsModels([...searchResultsTemporaryElements.keys()]));
40
- searchResultsTemporaryElements.forEach((element, id) => {
40
+ for (const [id, element] of searchResultsTemporaryElements) {
41
41
  const modelId = searchResultsElementsModels.get(element.id);
42
42
  assert(modelId !== undefined);
43
43
  result.searchResultsElements.set(id, { ...element, modelId });
44
- });
44
+ }
45
45
  return result;
46
46
  }
47
47
  convertNodesToSearchTargets(searchResultsNodes, processedSearchResultsNodes) {
@@ -49,6 +49,26 @@ class CategoriesTreeSearchResultsNodesHandler extends SearchResultsNodesHandler
49
49
  searchResultsNodes.forEach((searchResultsNode) => this.collectSearchTargets(searchTargets, searchResultsNode, processedSearchResultsNodes));
50
50
  return this.convertInternalSearchTargets(searchTargets);
51
51
  }
52
+ convertInternalSearchTargetElementsRecursively(searchTargetsInternalElements, currentPath) {
53
+ const result = [];
54
+ // Internal search target elements are stored in a tree structure, need to convert that to array structure.
55
+ for (const [identifierAsString, entry] of searchTargetsInternalElements) {
56
+ const identifier = this.convertSearchResultsNodeIdentifierStringToHierarchyNodeIdentifier(identifierAsString);
57
+ if (entry.modelCategoryElements) {
58
+ for (const [modelCategoryKey, elements] of entry.modelCategoryElements) {
59
+ const { modelId, categoryId } = this.parseModelCategoryKey(modelCategoryKey);
60
+ result.push({ pathToElements: [...currentPath, identifier], modelId, categoryId, elements, topMostParentElementId: entry.topMostParentElementId });
61
+ }
62
+ }
63
+ if (!entry.children) {
64
+ continue;
65
+ }
66
+ for (const childValue of this.convertInternalSearchTargetElementsRecursively(entry.children, [...currentPath, identifier])) {
67
+ result.push(childValue);
68
+ }
69
+ }
70
+ return result;
71
+ }
52
72
  convertInternalSearchTargets(searchTargets) {
53
73
  if (!searchTargets.categories &&
54
74
  !searchTargets.definitionContainerIds &&
@@ -63,12 +83,7 @@ class CategoriesTreeSearchResultsNodesHandler extends SearchResultsNodesHandler
63
83
  return { modelId, categoryIds };
64
84
  })
65
85
  : undefined,
66
- elements: searchTargets.elements
67
- ? [...searchTargets.elements.entries()].map(([modelCategoryKey, elements]) => {
68
- const { modelId, categoryId } = this.parseModelCategoryKey(modelCategoryKey);
69
- return { modelId, categoryId, elements };
70
- })
71
- : undefined,
86
+ elements: searchTargets.elements ? this.convertInternalSearchTargetElementsRecursively(searchTargets.elements, []) : undefined,
72
87
  definitionContainerIds: searchTargets.definitionContainerIds,
73
88
  modelIds: searchTargets.modelIds,
74
89
  subCategories: searchTargets.subCategories
@@ -121,13 +136,37 @@ class CategoriesTreeSearchResultsNodesHandler extends SearchResultsNodesHandler
121
136
  searchTargets.categories.set(node.modelId, new Set([node.id]));
122
137
  return;
123
138
  case "element":
139
+ // Internal search target elements need to have path saved in some way.
140
+ // For this, a tree structure is used, where keys are stringified identifiers of parent nodes depending on the hierarchy.
124
141
  const modelCategoryKey = this.createModelCategoryKey(node.modelId, node.categoryId);
125
- const elements = (searchTargets.elements ??= new Map()).get(modelCategoryKey);
126
- if (elements) {
127
- elements.set(node.id, { isSearchTarget: node.isSearchTarget });
128
- }
129
- else {
130
- searchTargets.elements.set(modelCategoryKey, new Map([[node.id, { isSearchTarget: node.isSearchTarget }]]));
142
+ searchTargets.elements ??= new Map();
143
+ let entry = searchTargets.elements;
144
+ let topMostParentElementId;
145
+ for (let i = 0; i < node.pathToNode.length; ++i) {
146
+ if (topMostParentElementId === undefined && node.pathToNode[i].type === "element") {
147
+ topMostParentElementId = node.pathToNode[i].id;
148
+ }
149
+ const identifierAsString = this.convertSearchResultsNodeIdentifierToString(node.pathToNode[i]);
150
+ let identifierEntry = entry.get(identifierAsString);
151
+ // create a new entry for parent node if it does not exist
152
+ if (!identifierEntry) {
153
+ identifierEntry = { topMostParentElementId };
154
+ entry.set(identifierAsString, identifierEntry);
155
+ }
156
+ // last entry in the path don't need to have children
157
+ if (i < node.pathToNode.length - 1) {
158
+ identifierEntry.children ??= new Map();
159
+ entry = identifierEntry.children;
160
+ continue;
161
+ }
162
+ const elements = (identifierEntry.modelCategoryElements ??= new Map()).get(modelCategoryKey);
163
+ // Add elements who share the same path to the modelCategoryElements map
164
+ if (elements) {
165
+ elements.set(node.id, { isSearchTarget: node.isSearchTarget });
166
+ }
167
+ else {
168
+ identifierEntry.modelCategoryElements.set(modelCategoryKey, new Map([[node.id, { isSearchTarget: node.isSearchTarget }]]));
169
+ }
131
170
  }
132
171
  }
133
172
  }
@@ -139,11 +178,13 @@ class CategoriesTreeSearchResultsNodesHandler extends SearchResultsNodesHandler
139
178
  return { modelId, categoryId };
140
179
  }
141
180
  createSearchResultsTreeNode({ type, id, isSearchTarget, parent, }) {
181
+ const pathToNode = "pathToNode" in parent ? [...parent.pathToNode, { type: parent.type, id: parent.id }] : [];
142
182
  if (type === "definitionContainer") {
143
183
  return {
144
184
  id,
145
185
  isSearchTarget,
146
186
  type,
187
+ pathToNode,
147
188
  };
148
189
  }
149
190
  if (type === "subCategory") {
@@ -153,6 +194,7 @@ class CategoriesTreeSearchResultsNodesHandler extends SearchResultsNodesHandler
153
194
  isSearchTarget,
154
195
  type,
155
196
  categoryId: parent.id,
197
+ pathToNode,
156
198
  };
157
199
  }
158
200
  if (type === "category") {
@@ -162,12 +204,14 @@ class CategoriesTreeSearchResultsNodesHandler extends SearchResultsNodesHandler
162
204
  isSearchTarget,
163
205
  type,
164
206
  modelId: parent.id,
207
+ pathToNode,
165
208
  };
166
209
  }
167
210
  return {
168
211
  id,
169
212
  isSearchTarget,
170
213
  type,
214
+ pathToNode,
171
215
  };
172
216
  }
173
217
  if (type === "model") {
@@ -177,6 +221,7 @@ class CategoriesTreeSearchResultsNodesHandler extends SearchResultsNodesHandler
177
221
  isSearchTarget,
178
222
  type,
179
223
  categoryId: parent.type === "category" ? parent.id : undefined,
224
+ pathToNode,
180
225
  };
181
226
  }
182
227
  if ("type" in parent) {
@@ -187,6 +232,7 @@ class CategoriesTreeSearchResultsNodesHandler extends SearchResultsNodesHandler
187
232
  type,
188
233
  categoryId: parent.id,
189
234
  modelId: undefined,
235
+ pathToNode,
190
236
  };
191
237
  }
192
238
  assert(parent.type === "element");
@@ -196,6 +242,7 @@ class CategoriesTreeSearchResultsNodesHandler extends SearchResultsNodesHandler
196
242
  type,
197
243
  categoryId: parent.categoryId,
198
244
  modelId: undefined,
245
+ pathToNode,
199
246
  };
200
247
  }
201
248
  throw new Error("Invalid parent node type");
@@ -215,5 +262,19 @@ class CategoriesTreeSearchResultsNodesHandler extends SearchResultsNodesHandler
215
262
  }
216
263
  return "definitionContainer";
217
264
  }
265
+ getClassName(type) {
266
+ switch (type) {
267
+ case "definitionContainer":
268
+ return CLASS_NAME_DefinitionContainer;
269
+ case "subCategory":
270
+ return CLASS_NAME_SubCategory;
271
+ case "category":
272
+ return this.#props.categoryClassName;
273
+ case "model":
274
+ return this.#props.categoryModelClassName;
275
+ default:
276
+ return this.#props.categoryElementClassName;
277
+ }
278
+ }
218
279
  }
219
280
  //# sourceMappingURL=SearchResultsTree.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SearchResultsTree.js","sourceRoot":"","sources":["../../../../../../../../src/tree-widget-react/components/trees/categories-tree/internal/visibility/SearchResultsTree.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,kDAAkD,CAAC;AAC1F,OAAO,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,8DAA8D,CAAC;AAkElI,gBAAgB;AAChB,MAAM,CAAC,KAAK,UAAU,iCAAiC,CAAC,KAOvD;IACC,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAC3H,OAAO,uBAAuB,CAAC;QAC7B,yBAAyB,EAAE,IAAI,uCAAuC,CAAC;YACrE,QAAQ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C,wBAAwB,CAAC,EAAE,CAAC;YACrG,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,IAAI,MAAM,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,gBAAgB,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,EAAE,CAAC;YAC9F,OAAO,UAAU,CAAC;QACpB,CAAC;QACD,IAAI,MAAM,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,gBAAgB,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,sBAAsB,CAAC,EAAE,CAAC;YACnG,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,OAAO,qBAAqB,CAAC;IAC/B,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { firstValueFrom } from \"rxjs\";\nimport { assert } from \"@itwin/core-bentley\";\nimport { CLASS_NAME_SubCategory } from \"../../../common/internal/ClassNameDefinitions.js\";\nimport { createSearchResultsTree, SearchResultsNodesHandler } from \"../../../common/internal/visibility/BaseSearchResultsTree.js\";\n\nimport type { Id64Set, Id64String } from \"@itwin/core-bentley\";\nimport type { HierarchySearchPath } from \"@itwin/presentation-hierarchies\";\nimport type { ECClassHierarchyInspector } from \"@itwin/presentation-shared\";\nimport type { CategoryId, ElementId, ModelId, SubCategoryId } from \"../../../common/internal/Types.js\";\nimport type {\n BaseSearchResultsTreeNode,\n SearchResultsTree,\n SearchResultsTreeNodeChildren,\n SearchResultsTreeRootNode,\n} from \"../../../common/internal/visibility/BaseSearchResultsTree.js\";\nimport type { CategoriesTreeIdsCache } from \"../CategoriesTreeIdsCache.js\";\n\n/** @internal */\nexport interface CategoriesTreeSearchTargets {\n categories?: Array<{ modelId: Id64String | undefined; categoryIds: Id64Set }>;\n elements?: Array<{ modelId: Id64String; categoryId: Id64String; elements: Map<ElementId, { isSearchTarget: boolean }> }>;\n definitionContainerIds?: Id64Set;\n modelIds?: Id64Set;\n subCategories?: Array<{ categoryId: Id64String; subCategoryIds: Id64Set }>;\n}\n\ninterface CategorySearchResultsTreeNode extends BaseSearchResultsTreeNode<CategorySearchResultsTreeNode> {\n type: \"category\";\n modelId?: Id64String;\n}\n\ninterface ModelSearchResultsTreeNode extends BaseSearchResultsTreeNode<ModelSearchResultsTreeNode> {\n type: \"model\";\n categoryId?: Id64String;\n}\ninterface SubCategorySearchResultsTreeNode extends BaseSearchResultsTreeNode<SubCategorySearchResultsTreeNode> {\n type: \"subCategory\";\n categoryId: Id64String;\n}\n\ninterface DefinitionContainerSearchResultsTreeNode extends BaseSearchResultsTreeNode<DefinitionContainerSearchResultsTreeNode> {\n type: \"definitionContainer\";\n}\n\ninterface ElementSearchResultsTreeNode extends BaseSearchResultsTreeNode<ElementSearchResultsTreeNode> {\n type: \"element\";\n categoryId: Id64String;\n modelId: Id64String;\n}\n\ntype SearchResultsTreeNode =\n | DefinitionContainerSearchResultsTreeNode\n | SubCategorySearchResultsTreeNode\n | CategorySearchResultsTreeNode\n | ElementSearchResultsTreeNode\n | ModelSearchResultsTreeNode;\n\ntype TemporaryElementSearchResultsNode = Omit<ElementSearchResultsTreeNode, \"modelId\" | \"children\"> & {\n modelId: string | undefined;\n children?: SearchResultsTreeNodeChildren<TemporaryElementSearchResultsNode>;\n};\n\ntype TemporarySearchResultsTreeNode =\n | DefinitionContainerSearchResultsTreeNode\n | SubCategorySearchResultsTreeNode\n | CategorySearchResultsTreeNode\n | TemporaryElementSearchResultsNode\n | ModelSearchResultsTreeNode;\n\n/** @internal */\nexport async function createCategoriesSearchResultsTree(props: {\n imodelAccess: ECClassHierarchyInspector;\n searchPaths: HierarchySearchPath[];\n categoryClassName: string;\n categoryElementClassName: string;\n categoryModelClassName: string;\n idsCache: CategoriesTreeIdsCache;\n}): Promise<SearchResultsTree<CategoriesTreeSearchTargets>> {\n const { imodelAccess, searchPaths, categoryClassName, categoryElementClassName, categoryModelClassName, idsCache } = props;\n return createSearchResultsTree({\n searchResultsNodesHandler: new CategoriesTreeSearchResultsNodesHandler({\n idsCache,\n imodelAccess,\n categoryClassName,\n categoryElementClassName,\n categoryModelClassName,\n }),\n searchPaths,\n });\n}\n\ninterface SearchTargetsInternal {\n elements?: Map<ModelCategoryKey, Map<ElementId, { isSearchTarget: boolean }>>;\n categories?: Map<ModelId | undefined, Set<CategoryId>>;\n definitionContainerIds?: Id64Set;\n modelIds?: Id64Set;\n subCategories?: Map<CategoryId, Set<SubCategoryId>>;\n}\n\ninterface CategoriesTreeSearchResultsNodesHandlerProps {\n idsCache: CategoriesTreeIdsCache;\n imodelAccess: ECClassHierarchyInspector;\n categoryClassName: string;\n categoryElementClassName: string;\n categoryModelClassName: string;\n}\n\ntype ModelCategoryKey = `${ModelId}-${CategoryId}`;\n\ninterface ProcessedSearchResultsNodes {\n searchResultsElements: Map<Id64String, Omit<ElementSearchResultsTreeNode, \"children\">>;\n}\n\nclass CategoriesTreeSearchResultsNodesHandler extends SearchResultsNodesHandler<\n ProcessedSearchResultsNodes,\n CategoriesTreeSearchTargets,\n TemporarySearchResultsTreeNode\n> {\n readonly #props: CategoriesTreeSearchResultsNodesHandlerProps;\n constructor(props: CategoriesTreeSearchResultsNodesHandlerProps) {\n super();\n this.#props = props;\n }\n\n public async getProcessedSearchResultsNodes(): Promise<ProcessedSearchResultsNodes> {\n const searchResultsTemporaryElements = new Map<Id64String, Omit<TemporaryElementSearchResultsNode, \"children\">>();\n const result: ProcessedSearchResultsNodes = {\n searchResultsElements: new Map(),\n };\n this.searchResultsNodesArr.forEach((node) => {\n if (node.type === \"element\") {\n searchResultsTemporaryElements.set(node.id, node);\n }\n });\n\n const searchResultsElementsModels = await firstValueFrom(this.#props.idsCache.getFilteredElementsModels([...searchResultsTemporaryElements.keys()]));\n searchResultsTemporaryElements.forEach((element, id) => {\n const modelId = searchResultsElementsModels.get(element.id);\n assert(modelId !== undefined);\n result.searchResultsElements.set(id, { ...element, modelId });\n });\n return result;\n }\n\n public convertNodesToSearchTargets(\n searchResultsNodes: TemporarySearchResultsTreeNode[],\n processedSearchResultsNodes: ProcessedSearchResultsNodes,\n ): CategoriesTreeSearchTargets | undefined {\n const searchTargets: SearchTargetsInternal = {};\n\n searchResultsNodes.forEach((searchResultsNode) => this.collectSearchTargets(searchTargets, searchResultsNode, processedSearchResultsNodes));\n\n return this.convertInternalSearchTargets(searchTargets);\n }\n\n private convertInternalSearchTargets(searchTargets: SearchTargetsInternal): CategoriesTreeSearchTargets | undefined {\n if (\n !searchTargets.categories &&\n !searchTargets.definitionContainerIds &&\n !searchTargets.elements &&\n !searchTargets.modelIds &&\n !searchTargets.subCategories\n ) {\n return undefined;\n }\n return {\n categories: searchTargets.categories\n ? [...searchTargets.categories.entries()].map(([modelId, categoryIds]) => {\n return { modelId, categoryIds };\n })\n : undefined,\n elements: searchTargets.elements\n ? [...searchTargets.elements.entries()].map(([modelCategoryKey, elements]) => {\n const { modelId, categoryId } = this.parseModelCategoryKey(modelCategoryKey);\n return { modelId, categoryId, elements };\n })\n : undefined,\n definitionContainerIds: searchTargets.definitionContainerIds,\n modelIds: searchTargets.modelIds,\n subCategories: searchTargets.subCategories\n ? [...searchTargets.subCategories.entries()].map(([categoryId, subCategoryIds]) => {\n return { categoryId, subCategoryIds };\n })\n : undefined,\n };\n }\n\n private collectSearchTargets(\n searchTargets: SearchTargetsInternal,\n node: TemporarySearchResultsTreeNode,\n processedSearchResultsNodes: ProcessedSearchResultsNodes,\n ) {\n const searchResultsNode = node.type !== \"element\" ? node : processedSearchResultsNodes.searchResultsElements.get(node.id);\n assert(searchResultsNode !== undefined);\n if (searchResultsNode.isSearchTarget) {\n this.addTarget(searchTargets, searchResultsNode);\n return;\n }\n\n if (searchResultsNode.type === \"element\") {\n // need to add parent ids as search target will be an element\n this.addTarget(searchTargets, searchResultsNode);\n }\n\n if (!node.children) {\n return;\n }\n\n for (const child of node.children.values()) {\n this.collectSearchTargets(searchTargets, child, processedSearchResultsNodes);\n }\n }\n\n private addTarget(searchTargets: SearchTargetsInternal, node: SearchResultsTreeNode) {\n switch (node.type) {\n case \"definitionContainer\":\n (searchTargets.definitionContainerIds ??= new Set()).add(node.id);\n return;\n case \"model\":\n (searchTargets.modelIds ??= new Set()).add(node.id);\n return;\n case \"subCategory\":\n const subCategories = (searchTargets.subCategories ??= new Map()).get(node.categoryId);\n if (subCategories) {\n subCategories.add(node.id);\n return;\n }\n searchTargets.subCategories.set(node.categoryId, new Set([node.id]));\n return;\n case \"category\":\n const categories = (searchTargets.categories ??= new Map()).get(node.modelId);\n if (!categories) {\n categories.add(node.id);\n return;\n }\n searchTargets.categories.set(node.modelId, new Set([node.id]));\n return;\n case \"element\":\n const modelCategoryKey = this.createModelCategoryKey(node.modelId, node.categoryId);\n const elements = (searchTargets.elements ??= new Map()).get(modelCategoryKey);\n if (elements) {\n elements.set(node.id, { isSearchTarget: node.isSearchTarget });\n } else {\n searchTargets.elements.set(modelCategoryKey, new Map([[node.id, { isSearchTarget: node.isSearchTarget }]]));\n }\n }\n }\n\n private createModelCategoryKey(modelId: Id64String, categoryId: Id64String): ModelCategoryKey {\n return `${modelId}-${categoryId}`;\n }\n\n private parseModelCategoryKey(key: ModelCategoryKey): { modelId: Id64String; categoryId: Id64String } {\n const [modelId, categoryId] = key.split(\"-\");\n return { modelId, categoryId };\n }\n\n public createSearchResultsTreeNode({\n type,\n id,\n isSearchTarget,\n parent,\n }: {\n type: SearchResultsTreeNode[\"type\"];\n id: Id64String;\n isSearchTarget: boolean;\n parent: TemporarySearchResultsTreeNode | SearchResultsTreeRootNode<TemporarySearchResultsTreeNode>;\n }): TemporarySearchResultsTreeNode {\n if (type === \"definitionContainer\") {\n return {\n id,\n isSearchTarget,\n type,\n };\n }\n if (type === \"subCategory\") {\n assert(\"id\" in parent);\n return {\n id,\n isSearchTarget,\n type,\n categoryId: parent.id,\n };\n }\n if (type === \"category\") {\n if (\"type\" in parent && parent.type === \"model\") {\n return {\n id,\n isSearchTarget,\n type,\n modelId: parent.id,\n };\n }\n return {\n id,\n isSearchTarget,\n type,\n };\n }\n if (type === \"model\") {\n assert(\"id\" in parent);\n return {\n id,\n isSearchTarget,\n type,\n categoryId: parent.type === \"category\" ? parent.id : undefined,\n };\n }\n\n if (\"type\" in parent) {\n if (parent.type === \"category\") {\n return {\n id,\n isSearchTarget,\n type,\n categoryId: parent.id,\n modelId: undefined,\n };\n }\n assert(parent.type === \"element\");\n return {\n id,\n isSearchTarget,\n type,\n categoryId: parent.categoryId,\n modelId: undefined,\n };\n }\n\n throw new Error(\"Invalid parent node type\");\n }\n\n public async getType(className: string): Promise<TemporarySearchResultsTreeNode[\"type\"]> {\n if (await this.#props.imodelAccess.classDerivesFrom(className, CLASS_NAME_SubCategory)) {\n return \"subCategory\";\n }\n if (await this.#props.imodelAccess.classDerivesFrom(className, this.#props.categoryElementClassName)) {\n return \"element\";\n }\n if (await this.#props.imodelAccess.classDerivesFrom(className, this.#props.categoryClassName)) {\n return \"category\";\n }\n if (await this.#props.imodelAccess.classDerivesFrom(className, this.#props.categoryModelClassName)) {\n return \"model\";\n }\n return \"definitionContainer\";\n }\n}\n"]}
1
+ {"version":3,"file":"SearchResultsTree.js","sourceRoot":"","sources":["../../../../../../../../src/tree-widget-react/components/trees/categories-tree/internal/visibility/SearchResultsTree.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,8BAA8B,EAAE,sBAAsB,EAAE,MAAM,kDAAkD,CAAC;AAC1H,OAAO,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,8DAA8D,CAAC;AAyElI,gBAAgB;AAChB,MAAM,CAAC,KAAK,UAAU,iCAAiC,CAAC,KAOvD;IACC,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,iBAAi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9F,OAAO,UAAU,CAAC;QACpB,CAAC;QACD,IAAI,MAAM,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,gBAAgB,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,sBAAsB,CAAC,EAAE,CAAC;YACnG,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,OAAO,qBAAqB,CAAC;IAC/B,CAAC;IAEM,YAAY,CAAC,IAA4C;QAC9D,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,qBAAqB;gBACxB,OAAO,8BAA8B,CAAC;YACxC,KAAK,aAAa;gBAChB,OAAO,sBAAsB,CAAC;YAChC,KAAK,UAAU;gBACb,OAAO,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC;YACvC,KAAK,OAAO;gBACV,OAAO,IAAI,CAAC,MAAM,CAAC,sBAAsB,CAAC;YAC5C;gBACE,OAAO,IAAI,CAAC,MAAM,CAAC,wBAAwB,CAAC;QAChD,CAAC;IACH,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { firstValueFrom } from \"rxjs\";\nimport { assert } from \"@itwin/core-bentley\";\nimport { CLASS_NAME_DefinitionContainer, CLASS_NAME_SubCategory } from \"../../../common/internal/ClassNameDefinitions.js\";\nimport { createSearchResultsTree, SearchResultsNodesHandler } from \"../../../common/internal/visibility/BaseSearchResultsTree.js\";\n\nimport type { Id64Set, Id64String } from \"@itwin/core-bentley\";\nimport type { HierarchySearchPath } from \"@itwin/presentation-hierarchies\";\nimport type { ECClassHierarchyInspector, InstanceKey } from \"@itwin/presentation-shared\";\nimport type { CategoryId, ElementId, ModelId, SubCategoryId } from \"../../../common/internal/Types.js\";\nimport type {\n BaseSearchResultsTreeNode,\n SearchResultsNodeIdentifierAsString,\n SearchResultsTree,\n SearchResultsTreeNodeChildren,\n SearchResultsTreeRootNode,\n} from \"../../../common/internal/visibility/BaseSearchResultsTree.js\";\nimport type { CategoriesTreeIdsCache } from \"../CategoriesTreeIdsCache.js\";\n\n/** @internal */\nexport interface CategoriesTreeSearchTargets {\n categories?: Array<{ modelId: Id64String | undefined; categoryIds: Id64Set }>;\n elements?: Array<{\n pathToElements: InstanceKey[];\n modelId: Id64String;\n categoryId: Id64String;\n elements: Map<ElementId, { isSearchTarget: boolean }>;\n topMostParentElementId?: ElementId;\n }>;\n definitionContainerIds?: Id64Set;\n modelIds?: Id64Set;\n subCategories?: Array<{ categoryId: Id64String; subCategoryIds: Id64Set }>;\n}\n\ninterface CategorySearchResultsTreeNode extends BaseSearchResultsTreeNode<CategorySearchResultsTreeNode> {\n type: \"category\";\n modelId?: Id64String;\n}\n\ninterface ModelSearchResultsTreeNode extends BaseSearchResultsTreeNode<ModelSearchResultsTreeNode> {\n type: \"model\";\n categoryId?: Id64String;\n}\ninterface SubCategorySearchResultsTreeNode extends BaseSearchResultsTreeNode<SubCategorySearchResultsTreeNode> {\n type: \"subCategory\";\n categoryId: Id64String;\n}\n\ninterface DefinitionContainerSearchResultsTreeNode extends BaseSearchResultsTreeNode<DefinitionContainerSearchResultsTreeNode> {\n type: \"definitionContainer\";\n}\n\ninterface ElementSearchResultsTreeNode extends BaseSearchResultsTreeNode<ElementSearchResultsTreeNode> {\n type: \"element\";\n categoryId: Id64String;\n modelId: Id64String;\n}\n\ntype SearchResultsTreeNode =\n | DefinitionContainerSearchResultsTreeNode\n | SubCategorySearchResultsTreeNode\n | CategorySearchResultsTreeNode\n | ElementSearchResultsTreeNode\n | ModelSearchResultsTreeNode;\n\ntype TemporaryElementSearchResultsNode = Omit<ElementSearchResultsTreeNode, \"modelId\" | \"children\"> & {\n modelId: string | undefined;\n children?: SearchResultsTreeNodeChildren<TemporaryElementSearchResultsNode>;\n};\n\ntype TemporarySearchResultsTreeNode =\n | DefinitionContainerSearchResultsTreeNode\n | SubCategorySearchResultsTreeNode\n | CategorySearchResultsTreeNode\n | TemporaryElementSearchResultsNode\n | ModelSearchResultsTreeNode;\n\n/** @internal */\nexport async function createCategoriesSearchResultsTree(props: {\n imodelAccess: ECClassHierarchyInspector;\n searchPaths: HierarchySearchPath[];\n categoryClassName: string;\n categoryElementClassName: string;\n categoryModelClassName: string;\n idsCache: CategoriesTreeIdsCache;\n}): Promise<SearchResultsTree<CategoriesTreeSearchTargets>> {\n const { imodelAccess, searchPaths, categoryClassName, categoryElementClassName, categoryModelClassName, idsCache } = props;\n return createSearchResultsTree({\n searchResultsNodesHandler: new CategoriesTreeSearchResultsNodesHandler({\n idsCache,\n imodelAccess,\n categoryClassName,\n categoryElementClassName,\n categoryModelClassName,\n }),\n searchPaths,\n });\n}\n\ntype SearchTargetsInternalElements = Map<\n SearchResultsNodeIdentifierAsString,\n {\n children?: SearchTargetsInternalElements;\n topMostParentElementId?: Id64String;\n modelCategoryElements?: Map<ModelCategoryKey, Map<ElementId, { isSearchTarget: boolean }>>;\n }\n>;\n\ninterface SearchTargetsInternal {\n elements?: SearchTargetsInternalElements;\n categories?: Map<ModelId | undefined, Set<CategoryId>>;\n definitionContainerIds?: Id64Set;\n modelIds?: Id64Set;\n subCategories?: Map<CategoryId, Set<SubCategoryId>>;\n}\n\ninterface CategoriesTreeSearchResultsNodesHandlerProps {\n idsCache: CategoriesTreeIdsCache;\n imodelAccess: ECClassHierarchyInspector;\n categoryClassName: string;\n categoryElementClassName: string;\n categoryModelClassName: string;\n}\n\ntype ModelCategoryKey = `${ModelId}-${CategoryId}`;\n\ninterface ProcessedSearchResultsNodes {\n searchResultsElements: Map<Id64String, Omit<ElementSearchResultsTreeNode, \"children\">>;\n}\n\nclass CategoriesTreeSearchResultsNodesHandler extends SearchResultsNodesHandler<\n ProcessedSearchResultsNodes,\n CategoriesTreeSearchTargets,\n TemporarySearchResultsTreeNode\n> {\n readonly #props: CategoriesTreeSearchResultsNodesHandlerProps;\n constructor(props: CategoriesTreeSearchResultsNodesHandlerProps) {\n super();\n this.#props = props;\n }\n\n public async getProcessedSearchResultsNodes(): Promise<ProcessedSearchResultsNodes> {\n const searchResultsTemporaryElements = new Map<Id64String, Omit<TemporaryElementSearchResultsNode, \"children\">>();\n const result: ProcessedSearchResultsNodes = {\n searchResultsElements: new Map(),\n };\n for (const node of this.searchResultsNodesArr) {\n if (node.type === \"element\") {\n searchResultsTemporaryElements.set(node.id, node);\n }\n }\n\n const searchResultsElementsModels = await firstValueFrom(this.#props.idsCache.getFilteredElementsModels([...searchResultsTemporaryElements.keys()]));\n for (const [id, element] of searchResultsTemporaryElements) {\n const modelId = searchResultsElementsModels.get(element.id);\n assert(modelId !== undefined);\n result.searchResultsElements.set(id, { ...element, modelId });\n }\n return result;\n }\n\n public convertNodesToSearchTargets(\n searchResultsNodes: TemporarySearchResultsTreeNode[],\n processedSearchResultsNodes: ProcessedSearchResultsNodes,\n ): CategoriesTreeSearchTargets | undefined {\n const searchTargets: SearchTargetsInternal = {};\n\n searchResultsNodes.forEach((searchResultsNode) => this.collectSearchTargets(searchTargets, searchResultsNode, processedSearchResultsNodes));\n\n return this.convertInternalSearchTargets(searchTargets);\n }\n\n private convertInternalSearchTargetElementsRecursively(\n searchTargetsInternalElements: SearchTargetsInternalElements,\n currentPath: InstanceKey[],\n ): Required<CategoriesTreeSearchTargets>[\"elements\"] {\n const result: Required<CategoriesTreeSearchTargets>[\"elements\"] = [];\n // Internal search target elements are stored in a tree structure, need to convert that to array structure.\n for (const [identifierAsString, entry] of searchTargetsInternalElements) {\n const identifier = this.convertSearchResultsNodeIdentifierStringToHierarchyNodeIdentifier(identifierAsString);\n if (entry.modelCategoryElements) {\n for (const [modelCategoryKey, elements] of entry.modelCategoryElements) {\n const { modelId, categoryId } = this.parseModelCategoryKey(modelCategoryKey);\n result.push({ pathToElements: [...currentPath, identifier], modelId, categoryId, elements, topMostParentElementId: entry.topMostParentElementId });\n }\n }\n if (!entry.children) {\n continue;\n }\n for (const childValue of this.convertInternalSearchTargetElementsRecursively(entry.children, [...currentPath, identifier])) {\n result.push(childValue);\n }\n }\n return result;\n }\n\n private convertInternalSearchTargets(searchTargets: SearchTargetsInternal): CategoriesTreeSearchTargets | undefined {\n if (\n !searchTargets.categories &&\n !searchTargets.definitionContainerIds &&\n !searchTargets.elements &&\n !searchTargets.modelIds &&\n !searchTargets.subCategories\n ) {\n return undefined;\n }\n return {\n categories: searchTargets.categories\n ? [...searchTargets.categories.entries()].map(([modelId, categoryIds]) => {\n return { modelId, categoryIds };\n })\n : undefined,\n elements: searchTargets.elements ? this.convertInternalSearchTargetElementsRecursively(searchTargets.elements, []) : undefined,\n definitionContainerIds: searchTargets.definitionContainerIds,\n modelIds: searchTargets.modelIds,\n subCategories: searchTargets.subCategories\n ? [...searchTargets.subCategories.entries()].map(([categoryId, subCategoryIds]) => {\n return { categoryId, subCategoryIds };\n })\n : undefined,\n };\n }\n\n private collectSearchTargets(\n searchTargets: SearchTargetsInternal,\n node: TemporarySearchResultsTreeNode,\n processedSearchResultsNodes: ProcessedSearchResultsNodes,\n ) {\n const searchResultsNode = node.type !== \"element\" ? node : processedSearchResultsNodes.searchResultsElements.get(node.id);\n assert(searchResultsNode !== undefined);\n if (searchResultsNode.isSearchTarget) {\n this.addTarget(searchTargets, searchResultsNode);\n return;\n }\n\n if (searchResultsNode.type === \"element\") {\n // need to add parent ids as search target will be an element\n this.addTarget(searchTargets, searchResultsNode);\n }\n\n if (!node.children) {\n return;\n }\n\n for (const child of node.children.values()) {\n this.collectSearchTargets(searchTargets, child, processedSearchResultsNodes);\n }\n }\n\n private addTarget(searchTargets: SearchTargetsInternal, node: SearchResultsTreeNode) {\n switch (node.type) {\n case \"definitionContainer\":\n (searchTargets.definitionContainerIds ??= new Set()).add(node.id);\n return;\n case \"model\":\n (searchTargets.modelIds ??= new Set()).add(node.id);\n return;\n case \"subCategory\":\n const subCategories = (searchTargets.subCategories ??= new Map()).get(node.categoryId);\n if (subCategories) {\n subCategories.add(node.id);\n return;\n }\n searchTargets.subCategories.set(node.categoryId, new Set([node.id]));\n return;\n case \"category\":\n const categories = (searchTargets.categories ??= new Map()).get(node.modelId);\n if (!categories) {\n categories.add(node.id);\n return;\n }\n searchTargets.categories.set(node.modelId, new Set([node.id]));\n return;\n case \"element\":\n // Internal search target elements need to have path saved in some way.\n // For this, a tree structure is used, where keys are stringified identifiers of parent nodes depending on the hierarchy.\n const modelCategoryKey = this.createModelCategoryKey(node.modelId, node.categoryId);\n searchTargets.elements ??= new Map();\n let entry = searchTargets.elements;\n let topMostParentElementId: Id64String | undefined;\n for (let i = 0; i < node.pathToNode.length; ++i) {\n if (topMostParentElementId === undefined && node.pathToNode[i].type === \"element\") {\n topMostParentElementId = node.pathToNode[i].id;\n }\n const identifierAsString = this.convertSearchResultsNodeIdentifierToString(node.pathToNode[i]);\n let identifierEntry = entry.get(identifierAsString);\n // create a new entry for parent node if it does not exist\n if (!identifierEntry) {\n identifierEntry = { topMostParentElementId };\n entry.set(identifierAsString, identifierEntry);\n }\n // last entry in the path don't need to have children\n if (i < node.pathToNode.length - 1) {\n identifierEntry.children ??= new Map();\n entry = identifierEntry.children;\n continue;\n }\n\n const elements = (identifierEntry.modelCategoryElements ??= new Map()).get(modelCategoryKey);\n // Add elements who share the same path to the modelCategoryElements map\n if (elements) {\n elements.set(node.id, { isSearchTarget: node.isSearchTarget });\n } else {\n identifierEntry.modelCategoryElements.set(modelCategoryKey, new Map([[node.id, { isSearchTarget: node.isSearchTarget }]]));\n }\n }\n }\n }\n\n private createModelCategoryKey(modelId: Id64String, categoryId: Id64String): ModelCategoryKey {\n return `${modelId}-${categoryId}`;\n }\n\n private parseModelCategoryKey(key: ModelCategoryKey): { modelId: Id64String; categoryId: Id64String } {\n const [modelId, categoryId] = key.split(\"-\");\n return { modelId, categoryId };\n }\n\n public createSearchResultsTreeNode({\n type,\n id,\n isSearchTarget,\n parent,\n }: {\n type: SearchResultsTreeNode[\"type\"];\n id: Id64String;\n isSearchTarget: boolean;\n parent: TemporarySearchResultsTreeNode | SearchResultsTreeRootNode<TemporarySearchResultsTreeNode>;\n }): TemporarySearchResultsTreeNode {\n const pathToNode = \"pathToNode\" in parent ? [...parent.pathToNode, { type: parent.type, id: parent.id }] : [];\n if (type === \"definitionContainer\") {\n return {\n id,\n isSearchTarget,\n type,\n pathToNode,\n };\n }\n if (type === \"subCategory\") {\n assert(\"id\" in parent);\n return {\n id,\n isSearchTarget,\n type,\n categoryId: parent.id,\n pathToNode,\n };\n }\n if (type === \"category\") {\n if (\"type\" in parent && parent.type === \"model\") {\n return {\n id,\n isSearchTarget,\n type,\n modelId: parent.id,\n pathToNode,\n };\n }\n return {\n id,\n isSearchTarget,\n type,\n pathToNode,\n };\n }\n if (type === \"model\") {\n assert(\"id\" in parent);\n return {\n id,\n isSearchTarget,\n type,\n categoryId: parent.type === \"category\" ? parent.id : undefined,\n pathToNode,\n };\n }\n\n if (\"type\" in parent) {\n if (parent.type === \"category\") {\n return {\n id,\n isSearchTarget,\n type,\n categoryId: parent.id,\n modelId: undefined,\n pathToNode,\n };\n }\n assert(parent.type === \"element\");\n return {\n id,\n isSearchTarget,\n type,\n categoryId: parent.categoryId,\n modelId: undefined,\n pathToNode,\n };\n }\n\n throw new Error(\"Invalid parent node type\");\n }\n\n public async getType(className: string): Promise<TemporarySearchResultsTreeNode[\"type\"]> {\n if (await this.#props.imodelAccess.classDerivesFrom(className, CLASS_NAME_SubCategory)) {\n return \"subCategory\";\n }\n if (await this.#props.imodelAccess.classDerivesFrom(className, this.#props.categoryElementClassName)) {\n return \"element\";\n }\n if (await this.#props.imodelAccess.classDerivesFrom(className, this.#props.categoryClassName)) {\n return \"category\";\n }\n if (await this.#props.imodelAccess.classDerivesFrom(className, this.#props.categoryModelClassName)) {\n return \"model\";\n }\n return \"definitionContainer\";\n }\n\n public getClassName(type: TemporarySearchResultsTreeNode[\"type\"]): string {\n switch (type) {\n case \"definitionContainer\":\n return CLASS_NAME_DefinitionContainer;\n case \"subCategory\":\n return CLASS_NAME_SubCategory;\n case \"category\":\n return this.#props.categoryClassName;\n case \"model\":\n return this.#props.categoryModelClassName;\n default:\n return this.#props.categoryElementClassName;\n }\n }\n}\n"]}
@@ -14,6 +14,8 @@ interface ClassificationsTreeComponentProps extends Pick<ClassificationsTreeProp
14
14
  }
15
15
  /**
16
16
  * A component that renders `ClassificationsTree` with active iModel and viewport.
17
+ *
18
+ * **Note:** Wrap tree components with a single `SharedTreeContextProvider` to improve trees' performance.
17
19
  * @alpha
18
20
  */
19
21
  export declare const ClassificationsTreeComponent: {
@@ -7,11 +7,14 @@ import { useActiveIModelConnection } from "@itwin/appui-react";
7
7
  import { SchemaKey, SchemaMatchType } from "@itwin/ecschema-metadata";
8
8
  import { TreeWidget } from "../../../TreeWidget.js";
9
9
  import { SelectableTree } from "../../tree-header/SelectableTree.js";
10
+ import { SharedTreeContextProviderInternal } from "../common/internal/SharedTreeContextProviderInternal.js";
10
11
  import { useActiveTreeWidgetViewport } from "../common/internal/UseActiveTreeWidgetViewport.js";
11
12
  import { TelemetryContextProvider } from "../common/UseTelemetryContext.js";
12
13
  import { ClassificationsTree } from "./ClassificationsTree.js";
13
14
  /**
14
15
  * A component that renders `ClassificationsTree` with active iModel and viewport.
16
+ *
17
+ * **Note:** Wrap tree components with a single `SharedTreeContextProvider` to improve trees' performance.
15
18
  * @alpha
16
19
  */
17
20
  export const ClassificationsTreeComponent = (props) => {
@@ -20,7 +23,7 @@ export const ClassificationsTreeComponent = (props) => {
20
23
  if (!iModel || !viewport) {
21
24
  return null;
22
25
  }
23
- return _jsx(ClassificationsTreeComponentImpl, { ...props, iModel: iModel, viewport: viewport });
26
+ return (_jsx(SharedTreeContextProviderInternal, { showWarning: true, children: _jsx(ClassificationsTreeComponentImpl, { ...props, iModel: iModel, viewport: viewport }) }));
24
27
  };
25
28
  /**
26
29
  * Id of the component. May be used when a creating a `TreeDefinition`.
@@ -1 +1 @@
1
- {"version":3,"file":"ClassificationsTreeComponent.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees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AuB,CAAC,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC;IACtH,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC,CAAC;AAEF,SAAS,gCAAgC,CAAC,EACxC,MAAM,EACN,QAAQ,EACR,qBAAqB,EACrB,aAAa,EACb,UAAU,EACV,SAAS,EACT,GAAG,SAAS,EACmF;IAC/F,OAAO,CACL,KAAC,wBAAwB,IAAC,mBAAmB,EAAE,4BAA4B,CAAC,EAAE,EAAE,aAAa,EAAE,aAAa,EAAE,qBAAqB,EAAE,qBAAqB,YACxJ,KAAC,cAAc,cACb,KAAC,mBAAmB,OAAK,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,GAAI,GAC3G,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 { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport { SchemaKey, SchemaMatchType } from \"@itwin/ecschema-metadata\";\nimport { TreeWidget } from \"../../../TreeWidget.js\";\nimport { SelectableTree } from \"../../tree-header/SelectableTree.js\";\nimport { useActiveTreeWidgetViewport } from \"../common/internal/UseActiveTreeWidgetViewport.js\";\nimport { TelemetryContextProvider } from \"../common/UseTelemetryContext.js\";\nimport { ClassificationsTree } from \"./ClassificationsTree.js\";\n\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport type { TreeWidgetViewport } from \"../common/TreeWidgetViewport.js\";\nimport type { ClassificationsTreeProps } from \"./ClassificationsTree.js\";\n\n/** @alpha */\ninterface ClassificationsTreeComponentProps\n extends Pick<\n ClassificationsTreeProps,\n | \"selectionStorage\"\n | \"hierarchyLevelConfig\"\n | \"selectionMode\"\n | \"searchText\"\n | \"emptyTreeContent\"\n | \"getInlineActions\"\n | \"getMenuActions\"\n | \"getContextMenuActions\"\n | \"getTreeItemProps\"\n | \"hierarchyConfig\"\n | \"getEditingProps\"\n | \"treeLabel\"\n > {\n /**\n * Viewport used for visibility controls.\n *\n * When viewport is not provided, `IModelApp.viewManager.selectedView` will be used.\n */\n viewport?: TreeWidgetViewport;\n onPerformanceMeasured?: (featureId: string, duration: number) => void;\n onFeatureUsed?: (feature: string) => void;\n}\n\n/**\n * A component that renders `ClassificationsTree` with active iModel and viewport.\n * @alpha\n */\nexport const ClassificationsTreeComponent = (props: ClassificationsTreeComponentProps) => {\n const iModel = useActiveIModelConnection();\n const viewport = useActiveTreeWidgetViewport({ treeWidgetViewport: props.viewport });\n\n if (!iModel || !viewport) {\n return null;\n }\n\n return <ClassificationsTreeComponentImpl {...props} iModel={iModel} viewport={viewport} />;\n};\n\n/**\n * Id of the component. May be used when a creating a `TreeDefinition`.\n * @alpha\n */\nClassificationsTreeComponent.id = \"classifications-tree\";\n\n/**\n * Label of the component. May be used when a creating a `TreeDefinition`.\n * @alpha\n */\nClassificationsTreeComponent.getLabel = () => TreeWidget.translate(\"classificationsTree.label\");\n\n/** @alpha */\nClassificationsTreeComponent.isSupportedByIModel = async (imodel: IModelConnection) => {\n try {\n return !!(await imodel.schemaContext.getSchemaInfo(new SchemaKey(\"ClassificationSystems\"), SchemaMatchType.Latest));\n } catch {\n return false;\n }\n};\n\nfunction ClassificationsTreeComponentImpl({\n iModel,\n viewport,\n onPerformanceMeasured,\n onFeatureUsed,\n searchText,\n treeLabel,\n ...treeProps\n}: ClassificationsTreeComponentProps & { iModel: IModelConnection; viewport: TreeWidgetViewport }) {\n return (\n <TelemetryContextProvider componentIdentifier={ClassificationsTreeComponent.id} onFeatureUsed={onFeatureUsed} onPerformanceMeasured={onPerformanceMeasured}>\n <SelectableTree>\n <ClassificationsTree {...treeProps} imodel={iModel} activeView={viewport} searchText={searchText} treeLabel={treeLabel} />\n </SelectableTree>\n </TelemetryContextProvider>\n );\n}\n"]}
1
+ {"version":3,"file":"ClassificationsTreeComponent.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeComponent.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,iCAAiC,EAAE,MAAM,yDAAyD,CAAC;AAC5G,OAAO,EAAE,2BAA2B,EAAE,MAAM,mDAAmD,CAAC;AAChG,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAgC/D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,KAAwC,EAAE,EAAE;IACvF,MAAM,MAAM,GAAG,yBAAyB,EAAE,CAAC;IAC3C,MAAM,QAAQ,GAAG,2BAA2B,CAAC,EAAE,kBAAkB,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;IAErF,IAAI,CAAC,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,CACL,KAAC,iCAAiC,IAAC,WAAW,EAAE,IAAI,YAClD,KAAC,gCAAgC,OAAK,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAI,GACjD,CACrC,CAAC;AACJ,CAAC,CAAC;AAEF;;;GAGG;AACH,4BAA4B,CAAC,EAAE,GAAG,sBAAsB,CAAC;AAEzD;;;GAGG;AACH,4BAA4B,CAAC,QAAQ,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,2BAA2B,CAAC,CAAC;AAEhG,aAAa;AACb,4BAA4B,CAAC,mBAAmB,GAAG,KAAK,EAAE,MAAwB,EAAE,EAAE;IACpF,IAAI,CAAC;QACH,OAAO,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,aAAa,CAAC,aAAa,CAAC,IAAI,SAAS,CAAC,uBAAuB,CAAC,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC;IACtH,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC,CAAC;AAEF,SAAS,gCAAgC,CAAC,EACxC,MAAM,EACN,QAAQ,EACR,qBAAqB,EACrB,aAAa,EACb,UAAU,EACV,SAAS,EACT,GAAG,SAAS,EACmF;IAC/F,OAAO,CACL,KAAC,wBAAwB,IAAC,mBAAmB,EAAE,4BAA4B,CAAC,EAAE,EAAE,aAAa,EAAE,aAAa,EAAE,qBAAqB,EAAE,qBAAqB,YACxJ,KAAC,cAAc,cACb,KAAC,mBAAmB,OAAK,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,GAAI,GAC3G,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 { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport { SchemaKey, SchemaMatchType } from \"@itwin/ecschema-metadata\";\nimport { TreeWidget } from \"../../../TreeWidget.js\";\nimport { SelectableTree } from \"../../tree-header/SelectableTree.js\";\nimport { SharedTreeContextProviderInternal } from \"../common/internal/SharedTreeContextProviderInternal.js\";\nimport { useActiveTreeWidgetViewport } from \"../common/internal/UseActiveTreeWidgetViewport.js\";\nimport { TelemetryContextProvider } from \"../common/UseTelemetryContext.js\";\nimport { ClassificationsTree } from \"./ClassificationsTree.js\";\n\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport type { TreeWidgetViewport } from \"../common/TreeWidgetViewport.js\";\nimport type { ClassificationsTreeProps } from \"./ClassificationsTree.js\";\n\n/** @alpha */\ninterface ClassificationsTreeComponentProps extends Pick<\n ClassificationsTreeProps,\n | \"selectionStorage\"\n | \"hierarchyLevelConfig\"\n | \"selectionMode\"\n | \"searchText\"\n | \"emptyTreeContent\"\n | \"getInlineActions\"\n | \"getMenuActions\"\n | \"getContextMenuActions\"\n | \"getTreeItemProps\"\n | \"hierarchyConfig\"\n | \"getEditingProps\"\n | \"treeLabel\"\n> {\n /**\n * Viewport used for visibility controls.\n *\n * When viewport is not provided, `IModelApp.viewManager.selectedView` will be used.\n */\n viewport?: TreeWidgetViewport;\n onPerformanceMeasured?: (featureId: string, duration: number) => void;\n onFeatureUsed?: (feature: string) => void;\n}\n\n/**\n * A component that renders `ClassificationsTree` with active iModel and viewport.\n *\n * **Note:** Wrap tree components with a single `SharedTreeContextProvider` to improve trees' performance.\n * @alpha\n */\nexport const ClassificationsTreeComponent = (props: ClassificationsTreeComponentProps) => {\n const iModel = useActiveIModelConnection();\n const viewport = useActiveTreeWidgetViewport({ treeWidgetViewport: props.viewport });\n\n if (!iModel || !viewport) {\n return null;\n }\n\n return (\n <SharedTreeContextProviderInternal showWarning={true}>\n <ClassificationsTreeComponentImpl {...props} iModel={iModel} viewport={viewport} />\n </SharedTreeContextProviderInternal>\n );\n};\n\n/**\n * Id of the component. May be used when a creating a `TreeDefinition`.\n * @alpha\n */\nClassificationsTreeComponent.id = \"classifications-tree\";\n\n/**\n * Label of the component. May be used when a creating a `TreeDefinition`.\n * @alpha\n */\nClassificationsTreeComponent.getLabel = () => TreeWidget.translate(\"classificationsTree.label\");\n\n/** @alpha */\nClassificationsTreeComponent.isSupportedByIModel = async (imodel: IModelConnection) => {\n try {\n return !!(await imodel.schemaContext.getSchemaInfo(new SchemaKey(\"ClassificationSystems\"), SchemaMatchType.Latest));\n } catch {\n return false;\n }\n};\n\nfunction ClassificationsTreeComponentImpl({\n iModel,\n viewport,\n onPerformanceMeasured,\n onFeatureUsed,\n searchText,\n treeLabel,\n ...treeProps\n}: ClassificationsTreeComponentProps & { iModel: IModelConnection; viewport: TreeWidgetViewport }) {\n return (\n <TelemetryContextProvider componentIdentifier={ClassificationsTreeComponent.id} onFeatureUsed={onFeatureUsed} onPerformanceMeasured={onPerformanceMeasured}>\n <SelectableTree>\n <ClassificationsTree {...treeProps} imodel={iModel} activeView={viewport} searchText={searchText} treeLabel={treeLabel} />\n </SelectableTree>\n </TelemetryContextProvider>\n );\n}\n"]}