@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,210 +2,26 @@
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 { defer, EMPTY, forkJoin, from, map, mergeMap, of, reduce, shareReplay, toArray } from "rxjs";
5
+ import { defer, from, map, mergeMap, of, reduce, shareReplay } from "rxjs";
6
6
  import { Guid, Id64 } from "@itwin/core-bentley";
7
- import { CLASS_NAME_Classification, CLASS_NAME_ClassificationSystem, CLASS_NAME_ClassificationTable, CLASS_NAME_DrawingCategory, CLASS_NAME_ElementHasClassifications, CLASS_NAME_GeometricElement2d, CLASS_NAME_GeometricElement3d, CLASS_NAME_SpatialCategory, CLASS_NAME_SubCategory, } from "../../common/internal/ClassNameDefinitions.js";
8
- import { ModelCategoryElementsCountCache } from "../../common/internal/ModelCategoryElementsCountCache.js";
7
+ import { BaseIdsCacheImpl } from "../../common/internal/caches/BaseIdsCache.js";
8
+ import { CLASS_NAME_Classification, CLASS_NAME_ClassificationSystem, CLASS_NAME_ClassificationTable, CLASS_NAME_ElementHasClassifications, CLASS_NAME_GeometricElement3d, CLASS_NAME_SpatialCategory, } from "../../common/internal/ClassNameDefinitions.js";
9
9
  import { catchBeSQLiteInterrupts } from "../../common/internal/UseErrorState.js";
10
10
  import { joinId64Arg } from "../../common/internal/Utils.js";
11
11
  /** @internal */
12
- export class ClassificationsTreeIdsCache {
13
- #categoryElementCounts;
14
- #categorySubCategories;
15
- #elementModelsCategories;
16
- #modelWithCategoryModeledElements;
12
+ export class ClassificationsTreeIdsCache extends BaseIdsCacheImpl {
17
13
  #classificationInfos;
18
14
  #filteredElementsData;
19
15
  #queryExecutor;
20
16
  #hierarchyConfig;
21
17
  #componentId;
22
18
  #componentName;
23
- constructor(queryExecutor, hierarchyConfig, componentId) {
24
- this.#queryExecutor = queryExecutor;
25
- this.#hierarchyConfig = hierarchyConfig;
26
- this.#componentId = componentId ?? Guid.createValue();
19
+ constructor(props) {
20
+ super(props);
21
+ this.#queryExecutor = props.queryExecutor;
22
+ this.#hierarchyConfig = props.hierarchyConfig;
23
+ this.#componentId = Guid.createValue();
27
24
  this.#componentName = "ClassificationsTreeIdsCache";
28
- this.#categoryElementCounts = new ModelCategoryElementsCountCache(this.#queryExecutor, ["BisCore.GeometricElement2d", "BisCore.GeometricElement3d"], this.#componentId);
29
- }
30
- [Symbol.dispose]() {
31
- this.#categoryElementCounts[Symbol.dispose]();
32
- }
33
- querySubCategories() {
34
- return defer(() => {
35
- const definitionsQuery = `
36
- SELECT
37
- sc.ECInstanceId id,
38
- sc.Parent.Id categoryId
39
- FROM
40
- ${CLASS_NAME_SubCategory} sc
41
- WHERE
42
- NOT sc.IsPrivate
43
- `;
44
- return this.#queryExecutor.createQueryReader({ ecsql: definitionsQuery }, { rowFormat: "ECSqlPropertyNames", limit: "unbounded", restartToken: `${this.#componentName}/${this.#componentId}/visible-sub-categories` });
45
- }).pipe(catchBeSQLiteInterrupts, map((row) => {
46
- return { id: row.id, parentId: row.categoryId };
47
- }));
48
- }
49
- getSubCategoriesInfo() {
50
- this.#categorySubCategories ??= this.querySubCategories()
51
- .pipe(reduce((acc, queriedSubCategory) => {
52
- const entry = acc.get(queriedSubCategory.parentId);
53
- if (entry) {
54
- entry.push(queriedSubCategory.id);
55
- }
56
- else {
57
- acc.set(queriedSubCategory.parentId, [queriedSubCategory.id]);
58
- }
59
- return acc;
60
- }, new Map()))
61
- .pipe(shareReplay());
62
- return this.#categorySubCategories;
63
- }
64
- getSubCategories(categoryId) {
65
- return this.getSubCategoriesInfo().pipe(map((categorySubCategories) => categorySubCategories.get(categoryId) ?? []));
66
- }
67
- queryElementModelCategories() {
68
- return defer(() => {
69
- const query = `
70
- SELECT * FROM (
71
- SELECT '3d' type, this.Model.Id modelId, this.Category.Id categoryId
72
- FROM BisCore.GeometricModel m
73
- JOIN BisCore.GeometricElement3d this ON m.ECInstanceId = this.Model.Id
74
- WHERE this.Parent.Id IS NULL AND m.IsPrivate = false
75
- GROUP BY modelId, categoryId
76
- )
77
- UNION ALL
78
- SELECT * FROM (
79
- SELECT '2d' type, this.Model.Id modelId, this.Category.Id categoryId
80
- FROM BisCore.GeometricModel m
81
- JOIN BisCore.GeometricElement2d this ON m.ECInstanceId = this.Model.Id
82
- WHERE this.Parent.Id IS NULL AND m.IsPrivate = false
83
- GROUP BY modelId, categoryId
84
- )
85
- `;
86
- return this.#queryExecutor.createQueryReader({ ecsql: query }, { rowFormat: "ECSqlPropertyNames", limit: "unbounded", restartToken: `${this.#componentName}/${this.#componentId}/element-models-and-categories` });
87
- }).pipe(catchBeSQLiteInterrupts, map((row) => {
88
- return { modelId: row.modelId, categoryId: row.categoryId, type: row.type };
89
- }));
90
- }
91
- getElementModelsCategories() {
92
- this.#elementModelsCategories ??= forkJoin({
93
- modelCategories: this.queryElementModelCategories().pipe(reduce((acc, queriedCategory) => {
94
- let modelEntry = acc.get(queriedCategory.modelId);
95
- if (modelEntry === undefined) {
96
- modelEntry = { category2dIds: new Set(), category3dIds: new Set() };
97
- acc.set(queriedCategory.modelId, modelEntry);
98
- }
99
- switch (queriedCategory.type) {
100
- case "2d":
101
- modelEntry.category2dIds.add(queriedCategory.categoryId);
102
- break;
103
- case "3d":
104
- modelEntry.category3dIds.add(queriedCategory.categoryId);
105
- break;
106
- }
107
- return acc;
108
- }, new Map())),
109
- modelWithCategoryModeledElements: this.getModelWithCategoryModeledElements(),
110
- }).pipe(map(({ modelCategories, modelWithCategoryModeledElements }) => {
111
- const result = new Map();
112
- const subModels = new Set();
113
- modelWithCategoryModeledElements.forEach((categoryMap) => categoryMap.forEach((categorySubModels) => categorySubModels.forEach((subModelId) => subModels.add(subModelId))));
114
- for (const [modelId, modelEntry] of modelCategories) {
115
- const isSubModel = subModels.has(modelId);
116
- result.set(modelId, { category2dIds: modelEntry.category2dIds, category3dIds: modelEntry.category3dIds, isSubModel });
117
- }
118
- return result;
119
- }), shareReplay());
120
- return this.#elementModelsCategories;
121
- }
122
- queryModeledElements() {
123
- return defer(() => {
124
- const query = `
125
- SELECT
126
- pe.ECInstanceId modeledElementId,
127
- pe.Category.Id categoryId,
128
- pe.Model.Id modelId
129
- FROM BisCore.GeometricModel m
130
- JOIN BisCore.GeometricElement3d pe ON pe.ECInstanceId = m.ModeledElement.Id
131
- WHERE
132
- m.IsPrivate = false
133
- AND m.ECInstanceId IN (SELECT Model.Id FROM BisCore.Element)
134
- UNION ALL
135
- SELECT
136
- pe.ECInstanceId modeledElementId,
137
- pe.Category.Id categoryId,
138
- pe.Model.Id modelId
139
- FROM BisCore.GeometricModel m
140
- JOIN BisCore.GeometricElement2d pe ON pe.ECInstanceId = m.ModeledElement.Id
141
- WHERE
142
- m.IsPrivate = false
143
- AND m.ECInstanceId IN (SELECT Model.Id FROM BisCore.Element)
144
- `;
145
- return this.#queryExecutor.createQueryReader({ ecsql: query }, { rowFormat: "ECSqlPropertyNames", limit: "unbounded", restartToken: `${this.#componentName}/${this.#componentId}/modeled-elements` });
146
- }).pipe(catchBeSQLiteInterrupts, map((row) => {
147
- return { modelId: row.modelId, categoryId: row.categoryId, modeledElementId: row.modeledElementId, rootCategoryId: row.rootCategoryId };
148
- }));
149
- }
150
- getModelWithCategoryModeledElements() {
151
- this.#modelWithCategoryModeledElements ??= this.queryModeledElements().pipe(reduce((acc, { modelId, categoryId, modeledElementId }) => {
152
- let modelEntry = acc.get(modelId);
153
- if (!modelEntry) {
154
- modelEntry = new Map();
155
- acc.set(modelId, modelEntry);
156
- }
157
- const categoryEntry = modelEntry.get(categoryId);
158
- if (!categoryEntry) {
159
- modelEntry.set(categoryId, new Set([modeledElementId]));
160
- }
161
- else {
162
- categoryEntry.add(modeledElementId);
163
- }
164
- return acc;
165
- }, new Map()), shareReplay());
166
- return this.#modelWithCategoryModeledElements;
167
- }
168
- getCategoriesModeledElements(modelId, categoryIds) {
169
- return this.getModelWithCategoryModeledElements().pipe(mergeMap((modelWithCategoryModeledElements) => {
170
- const result = new Array();
171
- const categoryMap = modelWithCategoryModeledElements.get(modelId);
172
- if (!categoryMap) {
173
- return of(result);
174
- }
175
- return from(Id64.iterable(categoryIds)).pipe(map((categoryId) => categoryMap.get(categoryId)), mergeMap((elementsSet) => (elementsSet ? from(elementsSet) : EMPTY)), toArray());
176
- }));
177
- }
178
- getCategoriesElementModels(categoryIds, includeSubModels) {
179
- return this.getElementModelsCategories().pipe(mergeMap((elementModelsCategories) => from(Id64.iterable(categoryIds)).pipe(map((categoryId) => {
180
- const categoryModels = new Array();
181
- elementModelsCategories.forEach(({ category2dIds, category3dIds, isSubModel }, modelId) => {
182
- if ((includeSubModels || !isSubModel) && (category2dIds.has(categoryId) || category3dIds.has(categoryId))) {
183
- categoryModels.push(modelId);
184
- }
185
- });
186
- return { id: categoryId, models: categoryModels.length > 0 ? categoryModels : undefined };
187
- }))));
188
- }
189
- getModelCategoryIds(modelId) {
190
- return this.getElementModelsCategories().pipe(map((elementModelsCategories) => {
191
- return {
192
- drawing: Array.from(elementModelsCategories.get(modelId)?.category2dIds ?? []),
193
- spatial: Array.from(elementModelsCategories.get(modelId)?.category3dIds ?? []),
194
- };
195
- }));
196
- }
197
- getAllCategories() {
198
- return this.getElementModelsCategories().pipe(mergeMap((modelsCategoriesInfo) => modelsCategoriesInfo.values()), reduce((acc, { category2dIds, category3dIds }) => {
199
- category2dIds.forEach((id) => acc.drawing.add(id));
200
- category3dIds.forEach((id) => acc.spatial.add(id));
201
- return acc;
202
- }, { drawing: new Set(), spatial: new Set() }));
203
- }
204
- hasSubModel(elementId) {
205
- return this.getElementModelsCategories().pipe(map((elementModelsCategories) => elementModelsCategories.has(elementId)));
206
- }
207
- getCategoryElementsCount(modelId, categoryId) {
208
- return this.#categoryElementCounts.getCategoryElementsCount(modelId, categoryId);
209
25
  }
210
26
  queryClassifications() {
211
27
  return defer(() => {
@@ -245,14 +61,6 @@ export class ClassificationsTreeIdsCache {
245
61
  cl.ClassificationId id,
246
62
  cl.ClassificationTableId tableId,
247
63
  cl.ParentClassificationId parentId,
248
- (
249
- SELECT group_concat(IdToHex(cat.ECInstanceId))
250
- FROM ${CLASS_NAME_GeometricElement2d} e
251
- JOIN ${CLASS_NAME_DrawingCategory} cat ON cat.ECInstanceId = e.Category.Id
252
- JOIN ${CLASS_NAME_ElementHasClassifications} ehc ON ehc.SourceECInstanceId = e.ECInstanceId
253
- WHERE e.Parent.Id IS NULL AND NOT cat.IsPrivate AND ehc.TargetECInstanceId = cl.ClassificationId
254
- GROUP BY ehc.TargetECInstanceId
255
- ) relatedCategories2d,
256
64
  (
257
65
  SELECT group_concat(IdToHex(cat.ECInstanceId))
258
66
  FROM ${CLASS_NAME_GeometricElement3d} e
@@ -260,7 +68,7 @@ export class ClassificationsTreeIdsCache {
260
68
  JOIN ${CLASS_NAME_ElementHasClassifications} ehc ON ehc.SourceECInstanceId = e.ECInstanceId
261
69
  WHERE e.Parent.Id IS NULL AND NOT cat.IsPrivate AND ehc.TargetECInstanceId = cl.ClassificationId
262
70
  GROUP BY ehc.TargetECInstanceId
263
- ) relatedCategories3d
71
+ ) relatedCategories
264
72
  FROM ${CLASSIFICATIONS_CTE} cl
265
73
  `;
266
74
  return this.#queryExecutor.createQueryReader({ ctes, ecsql }, { rowFormat: "ECSqlPropertyNames", limit: "unbounded", restartToken: `${this.#componentName}/${this.#componentId}/classifications` });
@@ -269,23 +77,22 @@ export class ClassificationsTreeIdsCache {
269
77
  id: row.id,
270
78
  tableId: row.tableId,
271
79
  parentId: row.parentId,
272
- relatedCategories2d: row.relatedCategories2d ? row.relatedCategories2d.split(",") : [],
273
- relatedCategories3d: row.relatedCategories3d ? row.relatedCategories3d.split(",") : [],
80
+ relatedCategories: row.relatedCategories ? row.relatedCategories.split(",") : [],
274
81
  };
275
82
  }));
276
83
  }
277
84
  getClassificationsInfo() {
278
- this.#classificationInfos ??= this.queryClassifications().pipe(reduce((acc, { id, tableId, parentId, relatedCategories2d, relatedCategories3d }) => {
85
+ this.#classificationInfos ??= this.queryClassifications().pipe(reduce((acc, { id, tableId, parentId, relatedCategories }) => {
279
86
  const tableOrParentId = tableId ?? parentId;
280
87
  let parentInfo = acc.get(tableOrParentId);
281
88
  if (!parentInfo) {
282
- parentInfo = { childClassificationIds: [], relatedCategories2d: [], relatedCategories3d: [], parentClassificationOrTableId: undefined };
89
+ parentInfo = { childClassificationIds: [], relatedCategories: [], parentClassificationOrTableId: undefined };
283
90
  acc.set(tableOrParentId, parentInfo);
284
91
  }
285
92
  parentInfo.childClassificationIds.push(id);
286
93
  let classificationEntry = acc.get(id);
287
94
  if (!classificationEntry) {
288
- classificationEntry = { childClassificationIds: [], relatedCategories2d, relatedCategories3d, parentClassificationOrTableId: tableOrParentId };
95
+ classificationEntry = { childClassificationIds: [], relatedCategories, parentClassificationOrTableId: tableOrParentId };
289
96
  acc.set(id, classificationEntry);
290
97
  }
291
98
  else {
@@ -296,7 +103,7 @@ export class ClassificationsTreeIdsCache {
296
103
  return this.#classificationInfos;
297
104
  }
298
105
  getAllContainedCategories(classificationOrTableIds) {
299
- const result = { drawing: new Array(), spatial: new Array() };
106
+ const result = new Array();
300
107
  if (Id64.sizeOf(classificationOrTableIds) === 0) {
301
108
  return of(result);
302
109
  }
@@ -305,18 +112,16 @@ export class ClassificationsTreeIdsCache {
305
112
  if (classificationInfo === undefined) {
306
113
  return acc;
307
114
  }
308
- acc.drawing.push(...classificationInfo.relatedCategories2d);
309
- acc.spatial.push(...classificationInfo.relatedCategories3d);
310
- acc.childClassifications.push(...classificationInfo.childClassificationIds);
115
+ classificationInfo.relatedCategories.forEach((id) => acc.categories.push(id));
116
+ classificationInfo.childClassificationIds.forEach((id) => acc.childClassifications.push(id));
311
117
  return acc;
312
- }, { drawing: new Array(), spatial: new Array(), childClassifications: new Array() }), mergeMap(({ drawing, spatial, childClassifications }) => {
118
+ }, { categories: new Array(), childClassifications: new Array() }), mergeMap(({ categories, childClassifications }) => {
313
119
  if (childClassifications.length === 0) {
314
- return of({ drawing, spatial });
120
+ return of(categories);
315
121
  }
316
- return this.getAllContainedCategories(childClassifications).pipe(map((childResult) => {
317
- drawing.push(...childResult.drawing);
318
- spatial.push(...childResult.spatial);
319
- return { drawing, spatial };
122
+ return this.getAllContainedCategories(childClassifications).pipe(map((childCategories) => {
123
+ childCategories.forEach((id) => categories.push(id));
124
+ return categories;
320
125
  }));
321
126
  }))));
322
127
  }
@@ -328,7 +133,7 @@ export class ClassificationsTreeIdsCache {
328
133
  return this.getClassificationsInfo().pipe(mergeMap((classificationsInfo) => from(Id64.iterable(classificationOrTableIds)).pipe(reduce((acc, classificationOrTableId) => {
329
134
  const classificationInfo = classificationsInfo.get(classificationOrTableId);
330
135
  if (classificationInfo !== undefined) {
331
- acc.push(...classificationInfo.childClassificationIds);
136
+ classificationInfo.childClassificationIds.forEach((id) => acc.push(id));
332
137
  }
333
138
  return acc;
334
139
  }, result))));
@@ -355,42 +160,54 @@ export class ClassificationsTreeIdsCache {
355
160
  getAllClassifications() {
356
161
  return this.getClassificationsInfo().pipe(map((classificationsInfo) => [...classificationsInfo.keys()]));
357
162
  }
358
- queryFilteredElementsData({ element2dIds, element3dIds }) {
163
+ queryFilteredElementsData({ elementIds }) {
359
164
  return defer(() => {
360
- const queries = new Array();
361
- if (Id64.sizeOf(element2dIds) > 0) {
362
- queries.push(`
363
- SELECT Model.Id modelId, Category.Id categoryId, ECInstanceId id
364
- FROM ${CLASS_NAME_GeometricElement2d}
365
- WHERE ECInstanceId IN (${joinId64Arg(element2dIds, ",")})
366
- `);
367
- }
368
- if (Id64.sizeOf(element3dIds) > 0) {
369
- queries.push(`
370
- SELECT Model.Id modelId, Category.Id categoryId, ECInstanceId id
371
- FROM ${CLASS_NAME_GeometricElement3d}
372
- WHERE ECInstanceId IN (${joinId64Arg(element3dIds, ",")})
373
- `);
374
- }
375
- return this.#queryExecutor.createQueryReader({ ecsql: queries.join(" UNION ALL ") }, {
165
+ const query = `
166
+ SELECT
167
+ this.Model.Id modelId,
168
+ this.Category.Id categoryId,
169
+ this.ECInstanceId id,
170
+ (
171
+ WITH RECURSIVE
172
+ ParentWithCategory(id, categoryId, parentId) AS (
173
+ SELECT e.ECInstanceId, e.Category.Id, e.Parent.Id
174
+ FROM ${CLASS_NAME_GeometricElement3d} e
175
+ WHERE e.ECInstanceId = this.ECInstanceId
176
+ UNION ALL
177
+ SELECT p.ECInstanceId, p.Category.Id, p.Parent.Id
178
+ FROM ${CLASS_NAME_GeometricElement3d} p
179
+ JOIN ParentWithCategory c ON p.ECInstanceId = c.parentId
180
+ )
181
+ SELECT IdToHex(categoryId)
182
+ FROM ParentWithCategory
183
+ WHERE parentId IS NULL
184
+ ) categoryOfTopMostParentElement
185
+ FROM ${CLASS_NAME_GeometricElement3d} this
186
+ WHERE ECInstanceId IN (${joinId64Arg(elementIds, ",")})
187
+ `;
188
+ return this.#queryExecutor.createQueryReader({ ecsql: query }, {
376
189
  rowFormat: "ECSqlPropertyNames",
377
190
  limit: "unbounded",
378
191
  restartToken: `${this.#componentName}/${this.#componentId}/filtered-elements/${Guid.createValue()}`,
379
192
  });
380
193
  }).pipe(catchBeSQLiteInterrupts, map((row) => {
381
- return { modelId: row.modelId, id: row.id, categoryId: row.categoryId };
194
+ return {
195
+ modelId: row.modelId,
196
+ id: row.id,
197
+ categoryId: row.categoryId,
198
+ categoryOfTopMostParentElement: row.categoryOfTopMostParentElement,
199
+ };
382
200
  }));
383
201
  }
384
- getFilteredElementsData({ element2dIds, element3dIds, }) {
202
+ getFilteredElementsData({ elementIds, }) {
385
203
  const result = new Map();
386
- if (Id64.sizeOf(element2dIds) === 0 && Id64.sizeOf(element3dIds) === 0) {
204
+ if (Id64.sizeOf(elementIds) === 0) {
387
205
  return of(result);
388
206
  }
389
207
  this.#filteredElementsData ??= this.queryFilteredElementsData({
390
- element2dIds,
391
- element3dIds,
392
- }).pipe(reduce((acc, { modelId, id, categoryId }) => {
393
- acc.set(id, { modelId, categoryId });
208
+ elementIds,
209
+ }).pipe(reduce((acc, { modelId, id, categoryId, categoryOfTopMostParentElement }) => {
210
+ acc.set(id, { modelId, categoryId, categoryOfTopMostParentElement });
394
211
  return acc;
395
212
  }, result), shareReplay());
396
213
  return this.#filteredElementsData;
@@ -1 +1 @@
1
- {"version":3,"file":"ClassificationsTreeIdsCache.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeIdsCache.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO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SAAS,CAAC;IACzC,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 { defer, EMPTY, forkJoin, from, map, mergeMap, of, reduce, shareReplay, toArray } from \"rxjs\";\nimport { Guid, Id64 } from \"@itwin/core-bentley\";\nimport {\n CLASS_NAME_Classification,\n CLASS_NAME_ClassificationSystem,\n CLASS_NAME_ClassificationTable,\n CLASS_NAME_DrawingCategory,\n CLASS_NAME_ElementHasClassifications,\n CLASS_NAME_GeometricElement2d,\n CLASS_NAME_GeometricElement3d,\n CLASS_NAME_SpatialCategory,\n CLASS_NAME_SubCategory,\n} from \"../../common/internal/ClassNameDefinitions.js\";\nimport { ModelCategoryElementsCountCache } from \"../../common/internal/ModelCategoryElementsCountCache.js\";\nimport { catchBeSQLiteInterrupts } from \"../../common/internal/UseErrorState.js\";\nimport { joinId64Arg } from \"../../common/internal/Utils.js\";\n\nimport type { Observable } from \"rxjs\";\nimport type { GuidString, Id64Arg, Id64Array, Id64Set, Id64String } from \"@itwin/core-bentley\";\nimport type { HierarchyNodeIdentifiersPath, LimitingECSqlQueryExecutor } from \"@itwin/presentation-hierarchies\";\nimport type { CategoryId, ElementId, ModelId, SubCategoryId } from \"../../common/internal/Types.js\";\nimport type { ClassificationsTreeHierarchyConfiguration } from \"../ClassificationsTreeDefinition.js\";\n\n/** @internal */\nexport type ClassificationId = Id64String;\n/** @internal */\nexport type ClassificationTableId = Id64String;\n\ninterface ClassificationInfo {\n parentClassificationOrTableId: ClassificationId | ClassificationTableId | undefined;\n childClassificationIds: ClassificationId[];\n relatedCategories2d: CategoryId[];\n relatedCategories3d: CategoryId[];\n}\n\n/** @internal */\nexport class ClassificationsTreeIdsCache implements Disposable {\n readonly #categoryElementCounts: ModelCategoryElementsCountCache;\n #categorySubCategories: Observable<Map<CategoryId, Array<SubCategoryId>>> | undefined;\n #elementModelsCategories: Observable<Map<ModelId, { category2dIds: Id64Set; category3dIds: Id64Set; isSubModel: boolean }>> | undefined;\n #modelWithCategoryModeledElements: Observable<Map<ModelId, Map<CategoryId, Set<ElementId>>>> | undefined;\n #classificationInfos: Observable<Map<ClassificationId | ClassificationTableId, ClassificationInfo>> | undefined;\n #filteredElementsData: Observable<Map<ElementId, { modelId: Id64String; categoryId: Id64String }>> | undefined;\n #queryExecutor: LimitingECSqlQueryExecutor;\n #hierarchyConfig: ClassificationsTreeHierarchyConfiguration;\n #componentId: GuidString;\n #componentName: string;\n\n constructor(queryExecutor: LimitingECSqlQueryExecutor, hierarchyConfig: ClassificationsTreeHierarchyConfiguration, componentId?: GuidString) {\n this.#queryExecutor = queryExecutor;\n this.#hierarchyConfig = hierarchyConfig;\n this.#componentId = componentId ?? Guid.createValue();\n this.#componentName = \"ClassificationsTreeIdsCache\";\n this.#categoryElementCounts = new ModelCategoryElementsCountCache(\n this.#queryExecutor,\n [\"BisCore.GeometricElement2d\", \"BisCore.GeometricElement3d\"],\n this.#componentId,\n );\n }\n\n public [Symbol.dispose]() {\n this.#categoryElementCounts[Symbol.dispose]();\n }\n\n private querySubCategories(): Observable<{ id: SubCategoryId; parentId: CategoryId }> {\n return defer(() => {\n const definitionsQuery = `\n SELECT\n sc.ECInstanceId id,\n sc.Parent.Id categoryId\n FROM\n ${CLASS_NAME_SubCategory} sc\n WHERE\n NOT sc.IsPrivate\n `;\n return this.#queryExecutor.createQueryReader(\n { ecsql: definitionsQuery },\n { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\", restartToken: `${this.#componentName}/${this.#componentId}/visible-sub-categories` },\n );\n }).pipe(\n catchBeSQLiteInterrupts,\n map((row) => {\n return { id: row.id, parentId: row.categoryId };\n }),\n );\n }\n private getSubCategoriesInfo() {\n this.#categorySubCategories ??= this.querySubCategories()\n .pipe(\n reduce((acc, queriedSubCategory) => {\n const entry = acc.get(queriedSubCategory.parentId);\n if (entry) {\n entry.push(queriedSubCategory.id);\n } else {\n acc.set(queriedSubCategory.parentId, [queriedSubCategory.id]);\n }\n return acc;\n }, new Map<CategoryId, Array<SubCategoryId>>()),\n )\n .pipe(shareReplay());\n return this.#categorySubCategories;\n }\n\n public getSubCategories(categoryId: Id64String): Observable<Array<SubCategoryId>> {\n return this.getSubCategoriesInfo().pipe(map((categorySubCategories) => categorySubCategories.get(categoryId) ?? []));\n }\n\n private queryElementModelCategories(): Observable<{\n modelId: Id64String;\n categoryId: Id64String;\n type: \"2d\" | \"3d\";\n }> {\n return defer(() => {\n const query = `\n SELECT * FROM (\n SELECT '3d' type, this.Model.Id modelId, this.Category.Id categoryId\n FROM BisCore.GeometricModel m\n JOIN BisCore.GeometricElement3d this ON m.ECInstanceId = this.Model.Id\n WHERE this.Parent.Id IS NULL AND m.IsPrivate = false\n GROUP BY modelId, categoryId\n )\n UNION ALL\n SELECT * FROM (\n SELECT '2d' type, this.Model.Id modelId, this.Category.Id categoryId\n FROM BisCore.GeometricModel m\n JOIN BisCore.GeometricElement2d this ON m.ECInstanceId = this.Model.Id\n WHERE this.Parent.Id IS NULL AND m.IsPrivate = false\n GROUP BY modelId, categoryId\n )\n `;\n return this.#queryExecutor.createQueryReader(\n { ecsql: query },\n { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\", restartToken: `${this.#componentName}/${this.#componentId}/element-models-and-categories` },\n );\n }).pipe(\n catchBeSQLiteInterrupts,\n map((row) => {\n return { modelId: row.modelId, categoryId: row.categoryId, type: row.type };\n }),\n );\n }\n\n private getElementModelsCategories() {\n this.#elementModelsCategories ??= forkJoin({\n modelCategories: this.queryElementModelCategories().pipe(\n reduce((acc, queriedCategory) => {\n let modelEntry = acc.get(queriedCategory.modelId);\n if (modelEntry === undefined) {\n modelEntry = { category2dIds: new Set(), category3dIds: new Set() };\n acc.set(queriedCategory.modelId, modelEntry);\n }\n switch (queriedCategory.type) {\n case \"2d\":\n modelEntry.category2dIds.add(queriedCategory.categoryId);\n break;\n case \"3d\":\n modelEntry.category3dIds.add(queriedCategory.categoryId);\n break;\n }\n return acc;\n }, new Map<ModelId, { category2dIds: Id64Set; category3dIds: Id64Set }>()),\n ),\n modelWithCategoryModeledElements: this.getModelWithCategoryModeledElements(),\n }).pipe(\n map(({ modelCategories, modelWithCategoryModeledElements }) => {\n const result = new Map<ModelId, { category2dIds: Id64Set; category3dIds: Id64Set; isSubModel: boolean }>();\n const subModels = new Set<Id64String>();\n modelWithCategoryModeledElements.forEach((categoryMap) =>\n categoryMap.forEach((categorySubModels) => categorySubModels.forEach((subModelId) => subModels.add(subModelId))),\n );\n for (const [modelId, modelEntry] of modelCategories) {\n const isSubModel = subModels.has(modelId);\n result.set(modelId, { category2dIds: modelEntry.category2dIds, category3dIds: modelEntry.category3dIds, isSubModel });\n }\n return result;\n }),\n shareReplay(),\n );\n return this.#elementModelsCategories;\n }\n\n private queryModeledElements(): Observable<{\n modelId: Id64String;\n modeledElementId: Id64String;\n categoryId: Id64String;\n rootCategoryId: Id64String;\n }> {\n return defer(() => {\n const query = `\n SELECT\n pe.ECInstanceId modeledElementId,\n pe.Category.Id categoryId,\n pe.Model.Id modelId\n FROM BisCore.GeometricModel m\n JOIN BisCore.GeometricElement3d pe ON pe.ECInstanceId = m.ModeledElement.Id\n WHERE\n m.IsPrivate = false\n AND m.ECInstanceId IN (SELECT Model.Id FROM BisCore.Element)\n UNION ALL\n SELECT\n pe.ECInstanceId modeledElementId,\n pe.Category.Id categoryId,\n pe.Model.Id modelId\n FROM BisCore.GeometricModel m\n JOIN BisCore.GeometricElement2d pe ON pe.ECInstanceId = m.ModeledElement.Id\n WHERE\n m.IsPrivate = false\n AND m.ECInstanceId IN (SELECT Model.Id FROM BisCore.Element)\n `;\n return this.#queryExecutor.createQueryReader(\n { ecsql: query },\n { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\", restartToken: `${this.#componentName}/${this.#componentId}/modeled-elements` },\n );\n }).pipe(\n catchBeSQLiteInterrupts,\n map((row) => {\n return { modelId: row.modelId, categoryId: row.categoryId, modeledElementId: row.modeledElementId, rootCategoryId: row.rootCategoryId };\n }),\n );\n }\n\n private getModelWithCategoryModeledElements() {\n this.#modelWithCategoryModeledElements ??= this.queryModeledElements().pipe(\n reduce((acc, { modelId, categoryId, modeledElementId }) => {\n let modelEntry = acc.get(modelId);\n if (!modelEntry) {\n modelEntry = new Map();\n acc.set(modelId, modelEntry);\n }\n const categoryEntry = modelEntry.get(categoryId);\n if (!categoryEntry) {\n modelEntry.set(categoryId, new Set([modeledElementId]));\n } else {\n categoryEntry.add(modeledElementId);\n }\n return acc;\n }, new Map<ModelId, Map<CategoryId, Set<ElementId>>>()),\n shareReplay(),\n );\n return this.#modelWithCategoryModeledElements;\n }\n\n public getCategoriesModeledElements(modelId: Id64String, categoryIds: Id64Arg): Observable<Id64Array> {\n return this.getModelWithCategoryModeledElements().pipe(\n mergeMap((modelWithCategoryModeledElements) => {\n const result = new Array<ElementId>();\n const categoryMap = modelWithCategoryModeledElements.get(modelId);\n if (!categoryMap) {\n return of(result);\n }\n return from(Id64.iterable(categoryIds)).pipe(\n map((categoryId) => categoryMap.get(categoryId)),\n mergeMap((elementsSet) => (elementsSet ? from(elementsSet) : EMPTY)),\n toArray(),\n );\n }),\n );\n }\n\n public getCategoriesElementModels(categoryIds: Id64Arg, includeSubModels?: boolean): Observable<{ id: CategoryId; models: Array<ModelId> | undefined }> {\n return this.getElementModelsCategories().pipe(\n mergeMap((elementModelsCategories) =>\n from(Id64.iterable(categoryIds)).pipe(\n map((categoryId) => {\n const categoryModels = new Array<ModelId>();\n elementModelsCategories.forEach(({ category2dIds, category3dIds, isSubModel }, modelId) => {\n if ((includeSubModels || !isSubModel) && (category2dIds.has(categoryId) || category3dIds.has(categoryId))) {\n categoryModels.push(modelId);\n }\n });\n return { id: categoryId, models: categoryModels.length > 0 ? categoryModels : undefined };\n }),\n ),\n ),\n );\n }\n\n public getModelCategoryIds(modelId: Id64String): Observable<{ drawing: Id64Array; spatial: Id64Array }> {\n return this.getElementModelsCategories().pipe(\n map((elementModelsCategories) => {\n return {\n drawing: Array.from(elementModelsCategories.get(modelId)?.category2dIds ?? []),\n spatial: Array.from(elementModelsCategories.get(modelId)?.category3dIds ?? []),\n };\n }),\n );\n }\n\n public getAllCategories(): Observable<{ drawing: Id64Set; spatial: Id64Set }> {\n return this.getElementModelsCategories().pipe(\n mergeMap((modelsCategoriesInfo) => modelsCategoriesInfo.values()),\n reduce(\n (acc, { category2dIds, category3dIds }) => {\n category2dIds.forEach((id) => acc.drawing.add(id));\n category3dIds.forEach((id) => acc.spatial.add(id));\n return acc;\n },\n { drawing: new Set<Id64String>(), spatial: new Set<Id64String>() },\n ),\n );\n }\n\n public hasSubModel(elementId: Id64String): Observable<boolean> {\n return this.getElementModelsCategories().pipe(map((elementModelsCategories) => elementModelsCategories.has(elementId)));\n }\n\n public getCategoryElementsCount(modelId: Id64String, categoryId: Id64String): Observable<number> {\n return this.#categoryElementCounts.getCategoryElementsCount(modelId, categoryId);\n }\n\n private queryClassifications(): Observable<\n {\n id: Id64String;\n relatedCategories2d: CategoryId[];\n relatedCategories3d: CategoryId[];\n } & ({ tableId: ClassificationTableId; parentId: undefined } | { tableId: undefined; parentId: ClassificationId })\n > {\n return defer(() => {\n const CLASSIFICATIONS_CTE = \"Classifications\";\n const ctes = [\n `\n ${CLASSIFICATIONS_CTE}(ClassificationId, ClassificationTableId, ParentClassificationId) AS (\n SELECT\n cl.ECInstanceId,\n ct.ECInstanceId,\n NULL\n FROM ${CLASS_NAME_Classification} cl\n JOIN ${CLASS_NAME_ClassificationTable} ct ON ct.ECInstanceId = cl.Model.Id\n JOIN ${CLASS_NAME_ClassificationSystem} cs ON cs.ECInstanceId = ct.Parent.Id\n WHERE\n cs.CodeValue = '${this.#hierarchyConfig.rootClassificationSystemCode}'\n AND NOT ct.IsPrivate\n AND NOT cl.IsPrivate\n AND cl.Parent.Id IS NULL\n\n UNION ALL\n\n SELECT\n cl.ECInstanceId,\n NULL,\n cl.Parent.Id\n FROM\n ${CLASSIFICATIONS_CTE} cte\n JOIN ${CLASS_NAME_Classification} cl ON cl.Parent.Id = cte.ClassificationId\n WHERE\n NOT cl.IsPrivate\n )\n `,\n ];\n const ecsql = `\n SELECT\n cl.ClassificationId id,\n cl.ClassificationTableId tableId,\n cl.ParentClassificationId parentId,\n (\n SELECT group_concat(IdToHex(cat.ECInstanceId))\n FROM ${CLASS_NAME_GeometricElement2d} e\n JOIN ${CLASS_NAME_DrawingCategory} cat ON cat.ECInstanceId = e.Category.Id\n JOIN ${CLASS_NAME_ElementHasClassifications} ehc ON ehc.SourceECInstanceId = e.ECInstanceId\n WHERE e.Parent.Id IS NULL AND NOT cat.IsPrivate AND ehc.TargetECInstanceId = cl.ClassificationId\n GROUP BY ehc.TargetECInstanceId\n ) relatedCategories2d,\n (\n SELECT group_concat(IdToHex(cat.ECInstanceId))\n FROM ${CLASS_NAME_GeometricElement3d} e\n JOIN ${CLASS_NAME_SpatialCategory} cat ON cat.ECInstanceId = e.Category.Id\n JOIN ${CLASS_NAME_ElementHasClassifications} ehc ON ehc.SourceECInstanceId = e.ECInstanceId\n WHERE e.Parent.Id IS NULL AND NOT cat.IsPrivate AND ehc.TargetECInstanceId = cl.ClassificationId\n GROUP BY ehc.TargetECInstanceId\n ) relatedCategories3d\n FROM ${CLASSIFICATIONS_CTE} cl\n `;\n return this.#queryExecutor.createQueryReader(\n { ctes, ecsql },\n { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\", restartToken: `${this.#componentName}/${this.#componentId}/classifications` },\n );\n }).pipe(\n catchBeSQLiteInterrupts,\n map((row) => {\n return {\n id: row.id,\n tableId: row.tableId,\n parentId: row.parentId,\n relatedCategories2d: row.relatedCategories2d ? (row.relatedCategories2d as string).split(\",\") : [],\n relatedCategories3d: row.relatedCategories3d ? (row.relatedCategories3d as string).split(\",\") : [],\n };\n }),\n );\n }\n\n private getClassificationsInfo() {\n this.#classificationInfos ??= this.queryClassifications().pipe(\n reduce((acc, { id, tableId, parentId, relatedCategories2d, relatedCategories3d }) => {\n const tableOrParentId = tableId ?? parentId;\n let parentInfo = acc.get(tableOrParentId);\n if (!parentInfo) {\n parentInfo = { childClassificationIds: [], relatedCategories2d: [], relatedCategories3d: [], parentClassificationOrTableId: undefined };\n acc.set(tableOrParentId, parentInfo);\n }\n parentInfo.childClassificationIds.push(id);\n let classificationEntry = acc.get(id);\n if (!classificationEntry) {\n classificationEntry = { childClassificationIds: [], relatedCategories2d, relatedCategories3d, parentClassificationOrTableId: tableOrParentId };\n acc.set(id, classificationEntry);\n } else {\n classificationEntry.parentClassificationOrTableId = tableOrParentId;\n }\n return acc;\n }, new Map<ClassificationId | ClassificationTableId, ClassificationInfo>()),\n shareReplay(),\n );\n return this.#classificationInfos;\n }\n\n public getAllContainedCategories(classificationOrTableIds: Id64Arg): Observable<{ drawing: Id64Array; spatial: Id64Array }> {\n const result = { drawing: new Array<CategoryId>(), spatial: new Array<CategoryId>() };\n if (Id64.sizeOf(classificationOrTableIds) === 0) {\n return of(result);\n }\n return this.getClassificationsInfo().pipe(\n mergeMap((classificationsInfo) =>\n from(Id64.iterable(classificationOrTableIds)).pipe(\n reduce(\n (acc, classificationOrTableId) => {\n const classificationInfo = classificationsInfo.get(classificationOrTableId);\n if (classificationInfo === undefined) {\n return acc;\n }\n acc.drawing.push(...classificationInfo.relatedCategories2d);\n acc.spatial.push(...classificationInfo.relatedCategories3d);\n acc.childClassifications.push(...classificationInfo.childClassificationIds);\n return acc;\n },\n { drawing: new Array<Id64String>(), spatial: new Array<Id64String>(), childClassifications: new Array<Id64String>() },\n ),\n mergeMap(({ drawing, spatial, childClassifications }) => {\n if (childClassifications.length === 0) {\n return of({ drawing, spatial });\n }\n return this.getAllContainedCategories(childClassifications).pipe(\n map((childResult) => {\n drawing.push(...childResult.drawing);\n spatial.push(...childResult.spatial);\n return { drawing, spatial };\n }),\n );\n }),\n ),\n ),\n );\n }\n\n public getDirectChildClassifications(classificationOrTableIds: Id64Arg): Observable<ClassificationId[]> {\n const result = new Array<ClassificationId>();\n if (Id64.sizeOf(classificationOrTableIds) === 0) {\n return of(result);\n }\n return this.getClassificationsInfo().pipe(\n mergeMap((classificationsInfo) =>\n from(Id64.iterable(classificationOrTableIds)).pipe(\n reduce((acc, classificationOrTableId) => {\n const classificationInfo = classificationsInfo.get(classificationOrTableId);\n if (classificationInfo !== undefined) {\n acc.push(...classificationInfo.childClassificationIds);\n }\n return acc;\n }, result),\n ),\n ),\n );\n }\n\n public getClassificationsPathObs(classificationIds: Id64Arg): Observable<HierarchyNodeIdentifiersPath> {\n return from(this.getClassificationsInfo()).pipe(\n mergeMap((classificationsInfo) => {\n return from(Id64.iterable(classificationIds)).pipe(\n map((classificationId) => {\n const path: HierarchyNodeIdentifiersPath = [{ id: classificationId, className: CLASS_NAME_Classification }];\n let parentId = classificationsInfo.get(classificationId)?.parentClassificationOrTableId;\n while (parentId !== undefined) {\n const parentIdOfParent = classificationsInfo.get(parentId)?.parentClassificationOrTableId;\n if (parentIdOfParent) {\n path.push({ className: CLASS_NAME_Classification, id: parentId });\n } else {\n path.push({ className: CLASS_NAME_ClassificationTable, id: parentId });\n }\n parentId = parentIdOfParent;\n }\n return path.reverse();\n }),\n );\n }),\n );\n }\n\n public getAllClassifications(): Observable<ClassificationId[]> {\n return this.getClassificationsInfo().pipe(map((classificationsInfo) => [...classificationsInfo.keys()]));\n }\n\n private queryFilteredElementsData({ element2dIds, element3dIds }: { element2dIds: Id64Arg; element3dIds: Id64Arg }): Observable<{\n modelId: Id64String;\n id: ElementId;\n categoryId: Id64String;\n }> {\n return defer(() => {\n const queries = new Array<string>();\n if (Id64.sizeOf(element2dIds) > 0) {\n queries.push(`\n SELECT Model.Id modelId, Category.Id categoryId, ECInstanceId id\n FROM ${CLASS_NAME_GeometricElement2d}\n WHERE ECInstanceId IN (${joinId64Arg(element2dIds, \",\")})\n `);\n }\n if (Id64.sizeOf(element3dIds) > 0) {\n queries.push(`\n SELECT Model.Id modelId, Category.Id categoryId, ECInstanceId id\n FROM ${CLASS_NAME_GeometricElement3d}\n WHERE ECInstanceId IN (${joinId64Arg(element3dIds, \",\")})\n `);\n }\n return this.#queryExecutor.createQueryReader(\n { ecsql: queries.join(\" UNION ALL \") },\n {\n rowFormat: \"ECSqlPropertyNames\",\n limit: \"unbounded\",\n restartToken: `${this.#componentName}/${this.#componentId}/filtered-elements/${Guid.createValue()}`,\n },\n );\n }).pipe(\n catchBeSQLiteInterrupts,\n map((row) => {\n return { modelId: row.modelId, id: row.id, categoryId: row.categoryId };\n }),\n );\n }\n\n public getFilteredElementsData({\n element2dIds,\n element3dIds,\n }: {\n element2dIds: Id64Arg;\n element3dIds: Id64Arg;\n }): Observable<Map<ElementId, { categoryId: Id64String; modelId: Id64String }>> {\n const result = new Map<ElementId, { categoryId: Id64String; modelId: Id64String }>();\n if (Id64.sizeOf(element2dIds) === 0 && Id64.sizeOf(element3dIds) === 0) {\n return of(result);\n }\n this.#filteredElementsData ??= this.queryFilteredElementsData({\n element2dIds,\n element3dIds,\n }).pipe(\n reduce((acc, { modelId, id, categoryId }) => {\n acc.set(id, { modelId, categoryId });\n return acc;\n }, result),\n shareReplay(),\n );\n return this.#filteredElementsData;\n }\n\n public clearFilteredElementsData() {\n this.#filteredElementsData = undefined;\n }\n}\n"]}
1
+ {"version":3,"file":"ClassificationsTreeIdsCache.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeIdsCache.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AAC3E,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAC;AAChF,OAAO,EACL,yBAAyB,EACzB,+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AC,IAAI,CACL,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,8BAA8B,EAAE,EAAE,EAAE;YAC1E,GAAG,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,8BAA8B,EAAE,CAAC,CAAC;YACrE,OAAO,GAAG,CAAC;QACb,CAAC,EAAE,MAAM,CAAC,EACV,WAAW,EAAE,CACd,CAAC;QACF,OAAO,IAAI,CAAC,qBAAqB,CAAC;IACpC,CAAC;IAEM,yBAAyB;QAC9B,IAAI,CAAC,qBAAqB,GAAG,SAAS,CAAC;IACzC,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 { defer, from, map, mergeMap, of, reduce, shareReplay } from \"rxjs\";\nimport { Guid, Id64 } from \"@itwin/core-bentley\";\nimport { BaseIdsCacheImpl } from \"../../common/internal/caches/BaseIdsCache.js\";\nimport {\n CLASS_NAME_Classification,\n CLASS_NAME_ClassificationSystem,\n CLASS_NAME_ClassificationTable,\n CLASS_NAME_ElementHasClassifications,\n CLASS_NAME_GeometricElement3d,\n CLASS_NAME_SpatialCategory,\n} from \"../../common/internal/ClassNameDefinitions.js\";\nimport { catchBeSQLiteInterrupts } from \"../../common/internal/UseErrorState.js\";\nimport { joinId64Arg } from \"../../common/internal/Utils.js\";\n\nimport type { Observable } from \"rxjs\";\nimport type { GuidString, Id64Arg, Id64Array, Id64String } from \"@itwin/core-bentley\";\nimport type { HierarchyNodeIdentifiersPath, LimitingECSqlQueryExecutor } from \"@itwin/presentation-hierarchies\";\nimport type { BaseIdsCacheImplProps } from \"../../common/internal/caches/BaseIdsCache.js\";\nimport type { CategoryId, ClassificationId, ClassificationTableId, ElementId } from \"../../common/internal/Types.js\";\nimport type { ClassificationsTreeHierarchyConfiguration } from \"../ClassificationsTreeDefinition.js\";\n\ninterface ClassificationInfo {\n parentClassificationOrTableId: ClassificationId | ClassificationTableId | undefined;\n childClassificationIds: ClassificationId[];\n relatedCategories: CategoryId[];\n}\n\ninterface ClassificationsTreeIdsCacheProps extends BaseIdsCacheImplProps {\n queryExecutor: LimitingECSqlQueryExecutor;\n hierarchyConfig: ClassificationsTreeHierarchyConfiguration;\n}\n\n/** @internal */\nexport class ClassificationsTreeIdsCache extends BaseIdsCacheImpl {\n #classificationInfos: Observable<Map<ClassificationId | ClassificationTableId, ClassificationInfo>> | undefined;\n #filteredElementsData: Observable<Map<ElementId, { modelId: Id64String; categoryId: Id64String; categoryOfTopMostParentElement: CategoryId }>> | undefined;\n #queryExecutor: LimitingECSqlQueryExecutor;\n #hierarchyConfig: ClassificationsTreeHierarchyConfiguration;\n #componentId: GuidString;\n #componentName: string;\n\n constructor(props: ClassificationsTreeIdsCacheProps) {\n super(props);\n this.#queryExecutor = props.queryExecutor;\n this.#hierarchyConfig = props.hierarchyConfig;\n this.#componentId = Guid.createValue();\n this.#componentName = \"ClassificationsTreeIdsCache\";\n }\n\n private queryClassifications(): Observable<\n {\n id: Id64String;\n relatedCategories: CategoryId[];\n } & ({ tableId: ClassificationTableId; parentId: undefined } | { tableId: undefined; parentId: ClassificationId })\n > {\n return defer(() => {\n const CLASSIFICATIONS_CTE = \"Classifications\";\n const ctes = [\n `\n ${CLASSIFICATIONS_CTE}(ClassificationId, ClassificationTableId, ParentClassificationId) AS (\n SELECT\n cl.ECInstanceId,\n ct.ECInstanceId,\n NULL\n FROM ${CLASS_NAME_Classification} cl\n JOIN ${CLASS_NAME_ClassificationTable} ct ON ct.ECInstanceId = cl.Model.Id\n JOIN ${CLASS_NAME_ClassificationSystem} cs ON cs.ECInstanceId = ct.Parent.Id\n WHERE\n cs.CodeValue = '${this.#hierarchyConfig.rootClassificationSystemCode}'\n AND NOT ct.IsPrivate\n AND NOT cl.IsPrivate\n AND cl.Parent.Id IS NULL\n\n UNION ALL\n\n SELECT\n cl.ECInstanceId,\n NULL,\n cl.Parent.Id\n FROM\n ${CLASSIFICATIONS_CTE} cte\n JOIN ${CLASS_NAME_Classification} cl ON cl.Parent.Id = cte.ClassificationId\n WHERE\n NOT cl.IsPrivate\n )\n `,\n ];\n const ecsql = `\n SELECT\n cl.ClassificationId id,\n cl.ClassificationTableId tableId,\n cl.ParentClassificationId parentId,\n (\n SELECT group_concat(IdToHex(cat.ECInstanceId))\n FROM ${CLASS_NAME_GeometricElement3d} e\n JOIN ${CLASS_NAME_SpatialCategory} cat ON cat.ECInstanceId = e.Category.Id\n JOIN ${CLASS_NAME_ElementHasClassifications} ehc ON ehc.SourceECInstanceId = e.ECInstanceId\n WHERE e.Parent.Id IS NULL AND NOT cat.IsPrivate AND ehc.TargetECInstanceId = cl.ClassificationId\n GROUP BY ehc.TargetECInstanceId\n ) relatedCategories\n FROM ${CLASSIFICATIONS_CTE} cl\n `;\n return this.#queryExecutor.createQueryReader(\n { ctes, ecsql },\n { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\", restartToken: `${this.#componentName}/${this.#componentId}/classifications` },\n );\n }).pipe(\n catchBeSQLiteInterrupts,\n map((row) => {\n return {\n id: row.id,\n tableId: row.tableId,\n parentId: row.parentId,\n relatedCategories: row.relatedCategories ? (row.relatedCategories as string).split(\",\") : [],\n };\n }),\n );\n }\n\n private getClassificationsInfo() {\n this.#classificationInfos ??= this.queryClassifications().pipe(\n reduce((acc, { id, tableId, parentId, relatedCategories }) => {\n const tableOrParentId = tableId ?? parentId;\n let parentInfo = acc.get(tableOrParentId);\n if (!parentInfo) {\n parentInfo = { childClassificationIds: [], relatedCategories: [], parentClassificationOrTableId: undefined };\n acc.set(tableOrParentId, parentInfo);\n }\n parentInfo.childClassificationIds.push(id);\n let classificationEntry = acc.get(id);\n if (!classificationEntry) {\n classificationEntry = { childClassificationIds: [], relatedCategories, parentClassificationOrTableId: tableOrParentId };\n acc.set(id, classificationEntry);\n } else {\n classificationEntry.parentClassificationOrTableId = tableOrParentId;\n }\n return acc;\n }, new Map<ClassificationId | ClassificationTableId, ClassificationInfo>()),\n shareReplay(),\n );\n return this.#classificationInfos;\n }\n\n public getAllContainedCategories(classificationOrTableIds: Id64Arg): Observable<Id64Array> {\n const result = new Array<CategoryId>();\n if (Id64.sizeOf(classificationOrTableIds) === 0) {\n return of(result);\n }\n return this.getClassificationsInfo().pipe(\n mergeMap((classificationsInfo) =>\n from(Id64.iterable(classificationOrTableIds)).pipe(\n reduce(\n (acc, classificationOrTableId) => {\n const classificationInfo = classificationsInfo.get(classificationOrTableId);\n if (classificationInfo === undefined) {\n return acc;\n }\n classificationInfo.relatedCategories.forEach((id) => acc.categories.push(id));\n classificationInfo.childClassificationIds.forEach((id) => acc.childClassifications.push(id));\n return acc;\n },\n { categories: new Array<CategoryId>(), childClassifications: new Array<Id64String>() },\n ),\n mergeMap(({ categories, childClassifications }) => {\n if (childClassifications.length === 0) {\n return of(categories);\n }\n return this.getAllContainedCategories(childClassifications).pipe(\n map((childCategories) => {\n childCategories.forEach((id) => categories.push(id));\n return categories;\n }),\n );\n }),\n ),\n ),\n );\n }\n\n public getDirectChildClassifications(classificationOrTableIds: Id64Arg): Observable<ClassificationId[]> {\n const result = new Array<ClassificationId>();\n if (Id64.sizeOf(classificationOrTableIds) === 0) {\n return of(result);\n }\n return this.getClassificationsInfo().pipe(\n mergeMap((classificationsInfo) =>\n from(Id64.iterable(classificationOrTableIds)).pipe(\n reduce((acc, classificationOrTableId) => {\n const classificationInfo = classificationsInfo.get(classificationOrTableId);\n if (classificationInfo !== undefined) {\n classificationInfo.childClassificationIds.forEach((id) => acc.push(id));\n }\n return acc;\n }, result),\n ),\n ),\n );\n }\n\n public getClassificationsPathObs(classificationIds: Id64Arg): Observable<HierarchyNodeIdentifiersPath> {\n return from(this.getClassificationsInfo()).pipe(\n mergeMap((classificationsInfo) => {\n return from(Id64.iterable(classificationIds)).pipe(\n map((classificationId) => {\n const path: HierarchyNodeIdentifiersPath = [{ id: classificationId, className: CLASS_NAME_Classification }];\n let parentId = classificationsInfo.get(classificationId)?.parentClassificationOrTableId;\n while (parentId !== undefined) {\n const parentIdOfParent = classificationsInfo.get(parentId)?.parentClassificationOrTableId;\n if (parentIdOfParent) {\n path.push({ className: CLASS_NAME_Classification, id: parentId });\n } else {\n path.push({ className: CLASS_NAME_ClassificationTable, id: parentId });\n }\n parentId = parentIdOfParent;\n }\n return path.reverse();\n }),\n );\n }),\n );\n }\n\n public getAllClassifications(): Observable<ClassificationId[]> {\n return this.getClassificationsInfo().pipe(map((classificationsInfo) => [...classificationsInfo.keys()]));\n }\n\n private queryFilteredElementsData({ elementIds }: { elementIds: Id64Arg }): Observable<{\n modelId: Id64String;\n id: ElementId;\n categoryId: Id64String;\n categoryOfTopMostParentElement: Id64String;\n }> {\n return defer(() => {\n const query = `\n SELECT\n this.Model.Id modelId,\n this.Category.Id categoryId,\n this.ECInstanceId id,\n (\n WITH RECURSIVE\n ParentWithCategory(id, categoryId, parentId) AS (\n SELECT e.ECInstanceId, e.Category.Id, e.Parent.Id\n FROM ${CLASS_NAME_GeometricElement3d} e\n WHERE e.ECInstanceId = this.ECInstanceId\n UNION ALL\n SELECT p.ECInstanceId, p.Category.Id, p.Parent.Id\n FROM ${CLASS_NAME_GeometricElement3d} p\n JOIN ParentWithCategory c ON p.ECInstanceId = c.parentId\n )\n SELECT IdToHex(categoryId)\n FROM ParentWithCategory\n WHERE parentId IS NULL\n ) categoryOfTopMostParentElement\n FROM ${CLASS_NAME_GeometricElement3d} this\n WHERE ECInstanceId IN (${joinId64Arg(elementIds, \",\")})\n `;\n return this.#queryExecutor.createQueryReader(\n { ecsql: query },\n {\n rowFormat: \"ECSqlPropertyNames\",\n limit: \"unbounded\",\n restartToken: `${this.#componentName}/${this.#componentId}/filtered-elements/${Guid.createValue()}`,\n },\n );\n }).pipe(\n catchBeSQLiteInterrupts,\n map((row) => {\n return {\n modelId: row.modelId,\n id: row.id,\n categoryId: row.categoryId,\n categoryOfTopMostParentElement: row.categoryOfTopMostParentElement,\n };\n }),\n );\n }\n\n public getFilteredElementsData({\n elementIds,\n }: {\n elementIds: Id64Arg;\n }): Observable<Map<ElementId, { categoryId: Id64String; modelId: Id64String; categoryOfTopMostParentElement: CategoryId }>> {\n const result = new Map<ElementId, { categoryId: Id64String; modelId: Id64String; categoryOfTopMostParentElement: CategoryId }>();\n if (Id64.sizeOf(elementIds) === 0) {\n return of(result);\n }\n this.#filteredElementsData ??= this.queryFilteredElementsData({\n elementIds,\n }).pipe(\n reduce((acc, { modelId, id, categoryId, categoryOfTopMostParentElement }) => {\n acc.set(id, { modelId, categoryId, categoryOfTopMostParentElement });\n return acc;\n }, result),\n shareReplay(),\n );\n return this.#filteredElementsData;\n }\n\n public clearFilteredElementsData() {\n this.#filteredElementsData = undefined;\n }\n}\n"]}
@@ -0,0 +1,29 @@
1
+ import type { Id64String } from "@itwin/core-bentley";
2
+ import type { HierarchyNode, InstancesNodeKey, NonGroupingHierarchyNode } from "@itwin/presentation-hierarchies";
3
+ /**
4
+ * Contains utility functions for working with Classifications Tree nodes.
5
+ *
6
+ * It is a wrapper around `ClassificationsTreeNode` that exposes some internal details that should not be exposed via public api.
7
+ *
8
+ * @internal
9
+ */
10
+ export declare namespace ClassificationsTreeNodeInternal {
11
+ const isClassificationTableNode: (node: Pick<HierarchyNode, "extendedData">) => node is NonGroupingHierarchyNode & {
12
+ key: InstancesNodeKey;
13
+ };
14
+ const isClassificationNode: (node: Pick<HierarchyNode, "extendedData">) => node is NonGroupingHierarchyNode & {
15
+ key: InstancesNodeKey;
16
+ };
17
+ const isGeometricElementNode: (node: Pick<HierarchyNode, "extendedData">) => node is Omit<NonGroupingHierarchyNode, "extendedData"> & {
18
+ key: InstancesNodeKey;
19
+ } & {
20
+ extendedData: {
21
+ modelId: Id64String;
22
+ categoryId: Id64String;
23
+ childrenCount: number;
24
+ categoryOfTopMostParentElement: Id64String;
25
+ topMostParentElementId: Id64String;
26
+ };
27
+ };
28
+ }
29
+ //# sourceMappingURL=ClassificationsTreeNodeInternal.d.ts.map
@@ -0,0 +1,19 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ import { ClassificationsTreeNode } from "../ClassificationsTreeNode.js";
6
+ /**
7
+ * Contains utility functions for working with Classifications Tree nodes.
8
+ *
9
+ * It is a wrapper around `ClassificationsTreeNode` that exposes some internal details that should not be exposed via public api.
10
+ *
11
+ * @internal
12
+ */
13
+ export var ClassificationsTreeNodeInternal;
14
+ (function (ClassificationsTreeNodeInternal) {
15
+ ClassificationsTreeNodeInternal.isClassificationTableNode = ClassificationsTreeNode.isClassificationTableNode;
16
+ ClassificationsTreeNodeInternal.isClassificationNode = ClassificationsTreeNode.isClassificationNode;
17
+ ClassificationsTreeNodeInternal.isGeometricElementNode = (node) => ClassificationsTreeNode.isGeometricElementNode(node);
18
+ })(ClassificationsTreeNodeInternal || (ClassificationsTreeNodeInternal = {}));
19
+ //# sourceMappingURL=ClassificationsTreeNodeInternal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ClassificationsTreeNodeInternal.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeNodeInternal.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAKxE;;;;;;GAMG;AACH,MAAM,KAAW,+BAA+B,CAgB/C;AAhBD,WAAiB,+BAA+B;IACjC,yDAAyB,GAAG,uBAAuB,CAAC,yBAAyB,CAAC;IAE9E,oDAAoB,GAAG,uBAAuB,CAAC,oBAAoB,CAAC;IAEpE,sDAAsB,GAAG,CACpC,IAAyC,EASzC,EAAE,CAAC,uBAAuB,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC;AAC5D,CAAC,EAhBgB,+BAA+B,KAA/B,+BAA+B,QAgB/C","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 { ClassificationsTreeNode } from \"../ClassificationsTreeNode.js\";\n\nimport type { Id64String } from \"@itwin/core-bentley\";\nimport type { HierarchyNode, InstancesNodeKey, NonGroupingHierarchyNode } from \"@itwin/presentation-hierarchies\";\n\n/**\n * Contains utility functions for working with Classifications Tree nodes.\n *\n * It is a wrapper around `ClassificationsTreeNode` that exposes some internal details that should not be exposed via public api.\n *\n * @internal\n */\nexport namespace ClassificationsTreeNodeInternal {\n export const isClassificationTableNode = ClassificationsTreeNode.isClassificationTableNode;\n\n export const isClassificationNode = ClassificationsTreeNode.isClassificationNode;\n\n export const isGeometricElementNode = (\n node: Pick<HierarchyNode, \"extendedData\">,\n ): node is Omit<NonGroupingHierarchyNode, \"extendedData\"> & { key: InstancesNodeKey } & {\n extendedData: {\n modelId: Id64String;\n categoryId: Id64String;\n childrenCount: number;\n categoryOfTopMostParentElement: Id64String;\n topMostParentElementId: Id64String;\n };\n } => ClassificationsTreeNode.isGeometricElementNode(node);\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import type { Observable } from "rxjs";
2
2
  import type { HierarchyNode } from "@itwin/presentation-hierarchies";
3
- import type { AlwaysAndNeverDrawnElementInfo } from "../../../common/internal/AlwaysAndNeverDrawnElementInfo.js";
3
+ import type { AlwaysAndNeverDrawnElementInfoCache } from "../../../common/internal/caches/AlwaysAndNeverDrawnElementInfoCache.js";
4
4
  import type { TreeSpecificVisibilityHandler } from "../../../common/internal/visibility/BaseVisibilityHelper.js";
5
5
  import type { TreeWidgetViewport } from "../../../common/TreeWidgetViewport.js";
6
6
  import type { VisibilityStatus } from "../../../common/UseHierarchyVisibility.js";
@@ -10,7 +10,7 @@ import type { ClassificationsTreeSearchTargets } from "./SearchResultsTree.js";
10
10
  export interface ClassificationsTreeVisibilityHandlerProps {
11
11
  idsCache: ClassificationsTreeIdsCache;
12
12
  viewport: TreeWidgetViewport;
13
- alwaysAndNeverDrawnElementInfo: AlwaysAndNeverDrawnElementInfo;
13
+ alwaysAndNeverDrawnElementInfo: AlwaysAndNeverDrawnElementInfoCache;
14
14
  }
15
15
  /**
16
16
  * Handles visibility status of classifications tree nodes.
@@ -23,15 +23,11 @@ export declare class ClassificationsTreeVisibilityHandler implements Disposable,
23
23
  constructor(constructorProps: ClassificationsTreeVisibilityHandlerProps);
24
24
  [Symbol.dispose](): void;
25
25
  changeSearchTargetsVisibilityStatus(targets: ClassificationsTreeSearchTargets, on: boolean): Observable<void>;
26
+ private changeSearchTargetElementsVisibilityStatus;
26
27
  getVisibilityStatus(node: HierarchyNode): Observable<VisibilityStatus>;
27
28
  /** Changes visibility of the items represented by the tree node. */
28
29
  changeVisibilityStatus(node: HierarchyNode, on: boolean): Observable<void>;
29
30
  getSearchTargetsVisibilityStatus(targets: ClassificationsTreeSearchTargets): Observable<VisibilityStatus>;
30
- private getCategories;
31
- private getAllCategories;
32
- private getElementsCount;
33
- private getModels;
34
- private getSubCategories;
35
- private getSubModels;
31
+ private getSearchTargetElementsVisibilityStatus;
36
32
  }
37
33
  //# sourceMappingURL=ClassificationsTreeVisibilityHandler.d.ts.map