@itwin/tree-widget-react 3.0.0-dev.2 → 3.0.0-dev.4

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 (276) hide show
  1. package/README.md +225 -1
  2. package/lib/cjs/components/SelectableTree.d.ts +12 -6
  3. package/lib/cjs/components/SelectableTree.js.map +1 -1
  4. package/lib/cjs/components/TreeSelector.d.ts +2 -2
  5. package/lib/cjs/components/TreeSelector.js.map +1 -1
  6. package/lib/cjs/components/TreeWidgetUiItemsProvider.d.ts +3 -2
  7. package/lib/cjs/components/TreeWidgetUiItemsProvider.js.map +1 -1
  8. package/lib/cjs/components/tree-header/TreeHeader.d.ts +11 -9
  9. package/lib/cjs/components/tree-header/TreeHeader.js +4 -6
  10. package/lib/cjs/components/tree-header/TreeHeader.js.map +1 -1
  11. package/lib/cjs/components/tree-header/TreeWithHeader.d.ts +13 -0
  12. package/lib/cjs/components/tree-header/TreeWithHeader.js +20 -0
  13. package/lib/cjs/components/tree-header/TreeWithHeader.js.map +1 -0
  14. package/lib/cjs/components/trees/categories-tree/CategoriesTree.d.ts +7 -10
  15. package/lib/cjs/components/trees/categories-tree/CategoriesTree.js +9 -66
  16. package/lib/cjs/components/trees/categories-tree/CategoriesTree.js.map +1 -1
  17. package/lib/cjs/components/trees/categories-tree/CategoriesTreeButtons.d.ts +12 -5
  18. package/lib/cjs/components/trees/categories-tree/CategoriesTreeButtons.js +27 -7
  19. package/lib/cjs/components/trees/categories-tree/CategoriesTreeButtons.js.map +1 -1
  20. package/lib/cjs/components/trees/categories-tree/CategoriesTreeComponent.d.ts +4 -5
  21. package/lib/cjs/components/trees/categories-tree/CategoriesTreeComponent.js +17 -20
  22. package/lib/cjs/components/trees/categories-tree/CategoriesTreeComponent.js.map +1 -1
  23. package/lib/cjs/components/trees/categories-tree/CategoriesVisibilityHandler.d.ts +1 -9
  24. package/lib/cjs/components/trees/categories-tree/CategoriesVisibilityHandler.js +2 -6
  25. package/lib/cjs/components/trees/categories-tree/CategoriesVisibilityHandler.js.map +1 -1
  26. package/lib/cjs/components/trees/categories-tree/UseCategoriesTree.d.ts +25 -0
  27. package/lib/cjs/components/trees/categories-tree/UseCategoriesTree.js +89 -0
  28. package/lib/cjs/components/trees/categories-tree/UseCategoriesTree.js.map +1 -0
  29. package/lib/cjs/components/trees/common/CategoriesVisibilityUtils.d.ts +7 -11
  30. package/lib/cjs/components/trees/common/CategoriesVisibilityUtils.js +32 -83
  31. package/lib/cjs/components/trees/common/CategoriesVisibilityUtils.js.map +1 -1
  32. package/lib/cjs/components/trees/common/FocusedInstancesContext.d.ts +0 -3
  33. package/lib/cjs/components/trees/common/FocusedInstancesContext.js +0 -2
  34. package/lib/cjs/components/trees/common/FocusedInstancesContext.js.map +1 -1
  35. package/lib/cjs/components/trees/common/FocusedInstancesContextProvider.d.ts +0 -1
  36. package/lib/cjs/components/trees/common/FocusedInstancesContextProvider.js +0 -1
  37. package/lib/cjs/components/trees/common/FocusedInstancesContextProvider.js.map +1 -1
  38. package/lib/cjs/components/trees/common/UseFiltering.d.ts +0 -1
  39. package/lib/cjs/components/trees/common/UseFiltering.js +0 -1
  40. package/lib/cjs/components/trees/common/UseFiltering.js.map +1 -1
  41. package/lib/cjs/components/trees/common/UseHierarchiesLocalization.d.ts +0 -1
  42. package/lib/cjs/components/trees/common/UseHierarchiesLocalization.js +0 -1
  43. package/lib/cjs/components/trees/common/UseHierarchiesLocalization.js.map +1 -1
  44. package/lib/cjs/components/trees/common/UseHierarchyFiltering.d.ts +1 -7
  45. package/lib/cjs/components/trees/common/UseHierarchyFiltering.js +4 -3
  46. package/lib/cjs/components/trees/common/UseHierarchyFiltering.js.map +1 -1
  47. package/lib/cjs/components/trees/common/UseHierarchyVisibility.d.ts +15 -10
  48. package/lib/cjs/components/trees/common/UseHierarchyVisibility.js +20 -17
  49. package/lib/cjs/components/trees/common/UseHierarchyVisibility.js.map +1 -1
  50. package/lib/cjs/components/trees/common/UseIModelChangeListener.d.ts +0 -1
  51. package/lib/cjs/components/trees/common/UseIModelChangeListener.js +0 -1
  52. package/lib/cjs/components/trees/common/UseIModelChangeListener.js.map +1 -1
  53. package/lib/cjs/components/trees/common/UseMultiCheckboxHandler.d.ts +0 -1
  54. package/lib/cjs/components/trees/common/UseMultiCheckboxHandler.js +0 -1
  55. package/lib/cjs/components/trees/common/UseMultiCheckboxHandler.js.map +1 -1
  56. package/lib/cjs/components/trees/common/UseNodeHighlighting.d.ts +9 -5
  57. package/lib/cjs/components/trees/common/UseNodeHighlighting.js +15 -24
  58. package/lib/cjs/components/trees/common/UseNodeHighlighting.js.map +1 -1
  59. package/lib/cjs/components/trees/common/UseTelemetryContext.d.ts +29 -0
  60. package/lib/cjs/components/trees/common/UseTelemetryContext.js +49 -0
  61. package/lib/cjs/components/trees/common/UseTelemetryContext.js.map +1 -0
  62. package/lib/cjs/components/trees/common/Utils.d.ts +3 -0
  63. package/lib/cjs/components/trees/common/Utils.js +11 -1
  64. package/lib/cjs/components/trees/common/Utils.js.map +1 -1
  65. package/lib/cjs/components/trees/common/components/Delayed.d.ts +0 -1
  66. package/lib/cjs/components/trees/common/components/Delayed.js +0 -1
  67. package/lib/cjs/components/trees/common/components/Delayed.js.map +1 -1
  68. package/lib/cjs/components/trees/common/components/ProgressOverlay.d.ts +0 -1
  69. package/lib/cjs/components/trees/common/components/ProgressOverlay.js +0 -1
  70. package/lib/cjs/components/trees/common/components/ProgressOverlay.js.map +1 -1
  71. package/lib/cjs/components/trees/common/components/Tree.d.ts +52 -0
  72. package/lib/cjs/components/trees/common/components/{BaseTree.js → Tree.js} +27 -23
  73. package/lib/cjs/components/trees/common/components/Tree.js.map +1 -0
  74. package/lib/cjs/components/trees/common/components/TreeNodeCheckbox.d.ts +14 -7
  75. package/lib/cjs/components/trees/common/components/TreeNodeCheckbox.js.map +1 -1
  76. package/lib/cjs/components/trees/common/components/TreeNodeRenderer.d.ts +7 -6
  77. package/lib/cjs/components/trees/common/components/TreeNodeRenderer.js +1 -1
  78. package/lib/cjs/components/trees/common/components/TreeNodeRenderer.js.map +1 -1
  79. package/lib/cjs/components/trees/common/components/TreeRenderer.d.ts +11 -1
  80. package/lib/cjs/components/trees/common/components/TreeRenderer.js +4 -1
  81. package/lib/cjs/components/trees/common/components/TreeRenderer.js.map +1 -1
  82. package/lib/cjs/components/trees/common/components/VisibilityTree.d.ts +27 -10
  83. package/lib/cjs/components/trees/common/components/VisibilityTree.js +8 -23
  84. package/lib/cjs/components/trees/common/components/VisibilityTree.js.map +1 -1
  85. package/lib/cjs/components/trees/common/components/VisibilityTreeRenderer.d.ts +12 -0
  86. package/lib/cjs/components/trees/common/components/VisibilityTreeRenderer.js +26 -0
  87. package/lib/cjs/components/trees/common/components/VisibilityTreeRenderer.js.map +1 -0
  88. package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.d.ts +8 -7
  89. package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.js +7 -10
  90. package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
  91. package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTreeComponent.d.ts +5 -5
  92. package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js +3 -4
  93. package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js.map +1 -1
  94. package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.d.ts +8 -7
  95. package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.js +9 -12
  96. package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
  97. package/lib/cjs/components/trees/imodel-content-tree/IModelContentTreeComponent.d.ts +5 -5
  98. package/lib/cjs/components/trees/imodel-content-tree/IModelContentTreeComponent.js +3 -4
  99. package/lib/cjs/components/trees/imodel-content-tree/IModelContentTreeComponent.js.map +1 -1
  100. package/lib/cjs/components/trees/imodel-content-tree/IModelContentTreeDefinition.js.map +1 -1
  101. package/lib/cjs/components/trees/index.d.ts +11 -0
  102. package/lib/cjs/components/trees/index.js +19 -1
  103. package/lib/cjs/components/trees/index.js.map +1 -1
  104. package/lib/cjs/components/trees/models-tree/ModelsTree.d.ts +10 -9
  105. package/lib/cjs/components/trees/models-tree/ModelsTree.js +6 -206
  106. package/lib/cjs/components/trees/models-tree/ModelsTree.js.map +1 -1
  107. package/lib/cjs/components/trees/models-tree/ModelsTreeButtons.d.ts +19 -8
  108. package/lib/cjs/components/trees/models-tree/ModelsTreeButtons.js +31 -8
  109. package/lib/cjs/components/trees/models-tree/ModelsTreeButtons.js.map +1 -1
  110. package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.d.ts +11 -6
  111. package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.js +33 -34
  112. package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
  113. package/lib/cjs/components/trees/models-tree/ModelsTreeDefinition.d.ts +9 -5
  114. package/lib/cjs/components/trees/models-tree/ModelsTreeDefinition.js.map +1 -1
  115. package/lib/cjs/components/trees/models-tree/UseModelsTree.d.ts +29 -0
  116. package/lib/cjs/components/trees/models-tree/UseModelsTree.js +233 -0
  117. package/lib/cjs/components/trees/models-tree/UseModelsTree.js.map +1 -0
  118. package/lib/cjs/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.d.ts +11 -3
  119. package/lib/cjs/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js +1 -1
  120. package/lib/cjs/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js.map +1 -1
  121. package/lib/cjs/tree-widget-react.d.ts +2 -1
  122. package/lib/cjs/tree-widget-react.js +3 -1
  123. package/lib/cjs/tree-widget-react.js.map +1 -1
  124. package/lib/esm/components/SelectableTree.d.ts +12 -6
  125. package/lib/esm/components/SelectableTree.js.map +1 -1
  126. package/lib/esm/components/TreeSelector.d.ts +2 -2
  127. package/lib/esm/components/TreeSelector.js.map +1 -1
  128. package/lib/esm/components/TreeWidgetUiItemsProvider.d.ts +3 -2
  129. package/lib/esm/components/TreeWidgetUiItemsProvider.js.map +1 -1
  130. package/lib/esm/components/tree-header/TreeHeader.d.ts +11 -9
  131. package/lib/esm/components/tree-header/TreeHeader.js +4 -6
  132. package/lib/esm/components/tree-header/TreeHeader.js.map +1 -1
  133. package/lib/esm/components/tree-header/TreeWithHeader.d.ts +13 -0
  134. package/lib/esm/components/tree-header/TreeWithHeader.js +13 -0
  135. package/lib/esm/components/tree-header/TreeWithHeader.js.map +1 -0
  136. package/lib/esm/components/trees/categories-tree/CategoriesTree.d.ts +7 -10
  137. package/lib/esm/components/trees/categories-tree/CategoriesTree.js +9 -66
  138. package/lib/esm/components/trees/categories-tree/CategoriesTree.js.map +1 -1
  139. package/lib/esm/components/trees/categories-tree/CategoriesTreeButtons.d.ts +12 -5
  140. package/lib/esm/components/trees/categories-tree/CategoriesTreeButtons.js +25 -7
  141. package/lib/esm/components/trees/categories-tree/CategoriesTreeButtons.js.map +1 -1
  142. package/lib/esm/components/trees/categories-tree/CategoriesTreeComponent.d.ts +4 -5
  143. package/lib/esm/components/trees/categories-tree/CategoriesTreeComponent.js +18 -18
  144. package/lib/esm/components/trees/categories-tree/CategoriesTreeComponent.js.map +1 -1
  145. package/lib/esm/components/trees/categories-tree/CategoriesVisibilityHandler.d.ts +1 -9
  146. package/lib/esm/components/trees/categories-tree/CategoriesVisibilityHandler.js +2 -6
  147. package/lib/esm/components/trees/categories-tree/CategoriesVisibilityHandler.js.map +1 -1
  148. package/lib/esm/components/trees/categories-tree/UseCategoriesTree.d.ts +25 -0
  149. package/lib/esm/components/trees/categories-tree/UseCategoriesTree.js +85 -0
  150. package/lib/esm/components/trees/categories-tree/UseCategoriesTree.js.map +1 -0
  151. package/lib/esm/components/trees/common/CategoriesVisibilityUtils.d.ts +7 -11
  152. package/lib/esm/components/trees/common/CategoriesVisibilityUtils.js +33 -84
  153. package/lib/esm/components/trees/common/CategoriesVisibilityUtils.js.map +1 -1
  154. package/lib/esm/components/trees/common/FocusedInstancesContext.d.ts +0 -3
  155. package/lib/esm/components/trees/common/FocusedInstancesContext.js +0 -2
  156. package/lib/esm/components/trees/common/FocusedInstancesContext.js.map +1 -1
  157. package/lib/esm/components/trees/common/FocusedInstancesContextProvider.d.ts +0 -1
  158. package/lib/esm/components/trees/common/FocusedInstancesContextProvider.js +0 -1
  159. package/lib/esm/components/trees/common/FocusedInstancesContextProvider.js.map +1 -1
  160. package/lib/esm/components/trees/common/UseFiltering.d.ts +0 -1
  161. package/lib/esm/components/trees/common/UseFiltering.js +0 -1
  162. package/lib/esm/components/trees/common/UseFiltering.js.map +1 -1
  163. package/lib/esm/components/trees/common/UseHierarchiesLocalization.d.ts +0 -1
  164. package/lib/esm/components/trees/common/UseHierarchiesLocalization.js +0 -1
  165. package/lib/esm/components/trees/common/UseHierarchiesLocalization.js.map +1 -1
  166. package/lib/esm/components/trees/common/UseHierarchyFiltering.d.ts +1 -7
  167. package/lib/esm/components/trees/common/UseHierarchyFiltering.js +4 -3
  168. package/lib/esm/components/trees/common/UseHierarchyFiltering.js.map +1 -1
  169. package/lib/esm/components/trees/common/UseHierarchyVisibility.d.ts +15 -10
  170. package/lib/esm/components/trees/common/UseHierarchyVisibility.js +20 -17
  171. package/lib/esm/components/trees/common/UseHierarchyVisibility.js.map +1 -1
  172. package/lib/esm/components/trees/common/UseIModelChangeListener.d.ts +0 -1
  173. package/lib/esm/components/trees/common/UseIModelChangeListener.js +0 -1
  174. package/lib/esm/components/trees/common/UseIModelChangeListener.js.map +1 -1
  175. package/lib/esm/components/trees/common/UseMultiCheckboxHandler.d.ts +0 -1
  176. package/lib/esm/components/trees/common/UseMultiCheckboxHandler.js +0 -1
  177. package/lib/esm/components/trees/common/UseMultiCheckboxHandler.js.map +1 -1
  178. package/lib/esm/components/trees/common/UseNodeHighlighting.d.ts +9 -5
  179. package/lib/esm/components/trees/common/UseNodeHighlighting.js +14 -23
  180. package/lib/esm/components/trees/common/UseNodeHighlighting.js.map +1 -1
  181. package/lib/esm/components/trees/common/UseTelemetryContext.d.ts +29 -0
  182. package/lib/esm/components/trees/common/UseTelemetryContext.js +43 -0
  183. package/lib/esm/components/trees/common/UseTelemetryContext.js.map +1 -0
  184. package/lib/esm/components/trees/common/Utils.d.ts +3 -0
  185. package/lib/esm/components/trees/common/Utils.js +9 -0
  186. package/lib/esm/components/trees/common/Utils.js.map +1 -1
  187. package/lib/esm/components/trees/common/components/Delayed.d.ts +0 -1
  188. package/lib/esm/components/trees/common/components/Delayed.js +0 -1
  189. package/lib/esm/components/trees/common/components/Delayed.js.map +1 -1
  190. package/lib/esm/components/trees/common/components/ProgressOverlay.d.ts +0 -1
  191. package/lib/esm/components/trees/common/components/ProgressOverlay.js +0 -1
  192. package/lib/esm/components/trees/common/components/ProgressOverlay.js.map +1 -1
  193. package/lib/esm/components/trees/common/components/Tree.d.ts +52 -0
  194. package/lib/esm/components/trees/common/components/{BaseTree.js → Tree.js} +26 -22
  195. package/lib/esm/components/trees/common/components/Tree.js.map +1 -0
  196. package/lib/esm/components/trees/common/components/TreeNodeCheckbox.d.ts +14 -7
  197. package/lib/esm/components/trees/common/components/TreeNodeCheckbox.js.map +1 -1
  198. package/lib/esm/components/trees/common/components/TreeNodeRenderer.d.ts +7 -6
  199. package/lib/esm/components/trees/common/components/TreeNodeRenderer.js +1 -1
  200. package/lib/esm/components/trees/common/components/TreeNodeRenderer.js.map +1 -1
  201. package/lib/esm/components/trees/common/components/TreeRenderer.d.ts +11 -1
  202. package/lib/esm/components/trees/common/components/TreeRenderer.js +4 -1
  203. package/lib/esm/components/trees/common/components/TreeRenderer.js.map +1 -1
  204. package/lib/esm/components/trees/common/components/VisibilityTree.d.ts +27 -10
  205. package/lib/esm/components/trees/common/components/VisibilityTree.js +8 -23
  206. package/lib/esm/components/trees/common/components/VisibilityTree.js.map +1 -1
  207. package/lib/esm/components/trees/common/components/VisibilityTreeRenderer.d.ts +12 -0
  208. package/lib/esm/components/trees/common/components/VisibilityTreeRenderer.js +22 -0
  209. package/lib/esm/components/trees/common/components/VisibilityTreeRenderer.js.map +1 -0
  210. package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.d.ts +8 -7
  211. package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.js +7 -10
  212. package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
  213. package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTreeComponent.d.ts +5 -5
  214. package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js +3 -4
  215. package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js.map +1 -1
  216. package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.d.ts +8 -7
  217. package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.js +9 -12
  218. package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
  219. package/lib/esm/components/trees/imodel-content-tree/IModelContentTreeComponent.d.ts +5 -5
  220. package/lib/esm/components/trees/imodel-content-tree/IModelContentTreeComponent.js +3 -4
  221. package/lib/esm/components/trees/imodel-content-tree/IModelContentTreeComponent.js.map +1 -1
  222. package/lib/esm/components/trees/imodel-content-tree/IModelContentTreeDefinition.js.map +1 -1
  223. package/lib/esm/components/trees/index.d.ts +11 -0
  224. package/lib/esm/components/trees/index.js +9 -0
  225. package/lib/esm/components/trees/index.js.map +1 -1
  226. package/lib/esm/components/trees/models-tree/ModelsTree.d.ts +10 -9
  227. package/lib/esm/components/trees/models-tree/ModelsTree.js +7 -207
  228. package/lib/esm/components/trees/models-tree/ModelsTree.js.map +1 -1
  229. package/lib/esm/components/trees/models-tree/ModelsTreeButtons.d.ts +19 -8
  230. package/lib/esm/components/trees/models-tree/ModelsTreeButtons.js +30 -8
  231. package/lib/esm/components/trees/models-tree/ModelsTreeButtons.js.map +1 -1
  232. package/lib/esm/components/trees/models-tree/ModelsTreeComponent.d.ts +11 -6
  233. package/lib/esm/components/trees/models-tree/ModelsTreeComponent.js +35 -33
  234. package/lib/esm/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
  235. package/lib/esm/components/trees/models-tree/ModelsTreeDefinition.d.ts +9 -5
  236. package/lib/esm/components/trees/models-tree/ModelsTreeDefinition.js.map +1 -1
  237. package/lib/esm/components/trees/models-tree/UseModelsTree.d.ts +29 -0
  238. package/lib/esm/components/trees/models-tree/UseModelsTree.js +229 -0
  239. package/lib/esm/components/trees/models-tree/UseModelsTree.js.map +1 -0
  240. package/lib/esm/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.d.ts +11 -3
  241. package/lib/esm/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js +2 -2
  242. package/lib/esm/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js.map +1 -1
  243. package/lib/esm/tree-widget-react.d.ts +2 -1
  244. package/lib/esm/tree-widget-react.js +1 -0
  245. package/lib/esm/tree-widget-react.js.map +1 -1
  246. package/package.json +12 -16
  247. package/lib/cjs/components/trees/categories-tree/UseCategories.d.ts +0 -8
  248. package/lib/cjs/components/trees/categories-tree/UseCategories.js +0 -22
  249. package/lib/cjs/components/trees/categories-tree/UseCategories.js.map +0 -1
  250. package/lib/cjs/components/trees/common/UseFeatureReporting.d.ts +0 -34
  251. package/lib/cjs/components/trees/common/UseFeatureReporting.js +0 -39
  252. package/lib/cjs/components/trees/common/UseFeatureReporting.js.map +0 -1
  253. package/lib/cjs/components/trees/common/UsePerformanceReporting.d.ts +0 -18
  254. package/lib/cjs/components/trees/common/UsePerformanceReporting.js +0 -25
  255. package/lib/cjs/components/trees/common/UsePerformanceReporting.js.map +0 -1
  256. package/lib/cjs/components/trees/common/components/BaseTree.d.ts +0 -34
  257. package/lib/cjs/components/trees/common/components/BaseTree.js.map +0 -1
  258. package/lib/cjs/components/utils/AutoSizer.d.ts +0 -13
  259. package/lib/cjs/components/utils/AutoSizer.js +0 -21
  260. package/lib/cjs/components/utils/AutoSizer.js.map +0 -1
  261. package/lib/esm/components/trees/categories-tree/UseCategories.d.ts +0 -8
  262. package/lib/esm/components/trees/categories-tree/UseCategories.js +0 -18
  263. package/lib/esm/components/trees/categories-tree/UseCategories.js.map +0 -1
  264. package/lib/esm/components/trees/common/UseFeatureReporting.d.ts +0 -34
  265. package/lib/esm/components/trees/common/UseFeatureReporting.js +0 -34
  266. package/lib/esm/components/trees/common/UseFeatureReporting.js.map +0 -1
  267. package/lib/esm/components/trees/common/UsePerformanceReporting.d.ts +0 -18
  268. package/lib/esm/components/trees/common/UsePerformanceReporting.js +0 -21
  269. package/lib/esm/components/trees/common/UsePerformanceReporting.js.map +0 -1
  270. package/lib/esm/components/trees/common/components/BaseTree.d.ts +0 -34
  271. package/lib/esm/components/trees/common/components/BaseTree.js.map +0 -1
  272. package/lib/esm/components/utils/AutoSizer.d.ts +0 -13
  273. package/lib/esm/components/utils/AutoSizer.js +0 -17
  274. package/lib/esm/components/utils/AutoSizer.js.map +0 -1
  275. /package/lib/cjs/components/{trees/Tree.scss → tree-header/TreeWithHeader.scss} +0 -0
  276. /package/lib/esm/components/{trees/Tree.scss → tree-header/TreeWithHeader.scss} +0 -0
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useCategoriesTree = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ /*---------------------------------------------------------------------------------------------
6
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
7
+ * See LICENSE.md in the project root for license terms and full copyright notice.
8
+ *--------------------------------------------------------------------------------------------*/
9
+ const react_1 = require("react");
10
+ const itwinui_icons_react_1 = require("@itwin/itwinui-icons-react");
11
+ const itwinui_react_1 = require("@itwin/itwinui-react");
12
+ const TreeWidget_1 = require("../../../TreeWidget");
13
+ const UseTelemetryContext_1 = require("../common/UseTelemetryContext");
14
+ const CategoriesTreeDefinition_1 = require("./CategoriesTreeDefinition");
15
+ const CategoriesVisibilityHandler_1 = require("./CategoriesVisibilityHandler");
16
+ /**
17
+ * Custom hook to create and manage state for the categories tree.
18
+ * @beta
19
+ */
20
+ function useCategoriesTree({ filter, activeView }) {
21
+ const [filteringError, setFilteringError] = (0, react_1.useState)();
22
+ const visibilityHandlerFactory = (0, react_1.useCallback)(() => {
23
+ const visibilityHandler = new CategoriesVisibilityHandler_1.CategoriesVisibilityHandler({
24
+ viewport: activeView,
25
+ });
26
+ return {
27
+ getVisibilityStatus: async (node) => visibilityHandler.getVisibilityStatus(node),
28
+ changeVisibility: async (node, on) => visibilityHandler.changeVisibility(node, on),
29
+ onVisibilityChange: visibilityHandler.onVisibilityChange,
30
+ dispose: () => visibilityHandler.dispose(),
31
+ };
32
+ }, [activeView]);
33
+ const { onFeatureUsed } = (0, UseTelemetryContext_1.useTelemetryContext)();
34
+ const getHierarchyDefinition = (0, react_1.useCallback)((props) => {
35
+ return new CategoriesTreeDefinition_1.CategoriesTreeDefinition({ ...props, viewType: activeView.view.is2d() ? "2d" : "3d" });
36
+ }, [activeView]);
37
+ const getFilteredPaths = (0, react_1.useMemo)(() => {
38
+ setFilteringError(undefined);
39
+ if (!filter) {
40
+ return undefined;
41
+ }
42
+ return async ({ imodelAccess }) => {
43
+ onFeatureUsed({ featureId: "filtering", reportInteraction: true });
44
+ try {
45
+ return await CategoriesTreeDefinition_1.CategoriesTreeDefinition.createInstanceKeyPaths({ imodelAccess, label: filter, viewType: activeView.view.is2d() ? "2d" : "3d" });
46
+ }
47
+ catch (e) {
48
+ const newError = e instanceof Error && e.message.match(/Filter matches more than \d+ items/) ? "tooManyFilterMatches" : "unknownFilterError";
49
+ if (newError !== "tooManyFilterMatches") {
50
+ const feature = e instanceof Error && e.message.includes("query too long to execute or server is too busy") ? "error-timeout" : "error-unknown";
51
+ onFeatureUsed({ featureId: feature, reportInteraction: false });
52
+ }
53
+ setFilteringError(newError);
54
+ return [];
55
+ }
56
+ };
57
+ }, [filter, activeView, onFeatureUsed]);
58
+ return {
59
+ categoriesTreeProps: {
60
+ treeName: "categories-tree-v2",
61
+ getHierarchyDefinition,
62
+ getFilteredPaths,
63
+ visibilityHandlerFactory,
64
+ noDataMessage: getNoDataMessage(filter, filteringError),
65
+ highlight: filter ? { text: filter } : undefined,
66
+ },
67
+ rendererProps: {
68
+ getIcon,
69
+ getSublabel,
70
+ },
71
+ };
72
+ }
73
+ exports.useCategoriesTree = useCategoriesTree;
74
+ function getNoDataMessage(filter, error) {
75
+ if (error) {
76
+ return (0, jsx_runtime_1.jsx)(itwinui_react_1.Text, { children: TreeWidget_1.TreeWidget.translate(`categoriesTree.filtering.${error}`) });
77
+ }
78
+ if (filter) {
79
+ return (0, jsx_runtime_1.jsx)(itwinui_react_1.Text, { children: TreeWidget_1.TreeWidget.translate("categoriesTree.filtering.noMatches", { filter }) });
80
+ }
81
+ return undefined;
82
+ }
83
+ function getIcon() {
84
+ return (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgLayers, {});
85
+ }
86
+ function getSublabel(node) {
87
+ return node.extendedData?.description;
88
+ }
89
+ //# sourceMappingURL=UseCategoriesTree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UseCategoriesTree.js","sourceRoot":"","sources":["../../../../../src/components/trees/categories-tree/UseCategoriesTree.tsx"],"names":[],"mappings":";;;;AAAA;;;gGAGgG;AAEhG,iCAAuD;AACvD,oEAAuD;AACvD,wDAA4C;AAC5C,oDAAiD;AACjD,uEAAoE;AACpE,yEAAsE;AACtE,+EAA4E;AAgC5E;;;GAGG;AACH,SAAgB,iBAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAA0B;IAC9E,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,IAAA,gBAAQ,GAA4C,CAAC;IACjG,MAAM,wBAAwB,GAAG,IAAA,mBAAW,EAAC,GAAG,EAAE;QAChD,MAAM,iBAAiB,GAAG,IAAI,yDAA2B,CAAC;YACxD,QAAQ,EAAE,UAAU;SACrB,CAAC,CAAC;QACH,OAAO;YACL,mBAAmB,EAAE,KAAK,EAAE,IAAmB,EAAE,EAAE,CAAC,iBAAiB,CAAC,mBAAmB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C;KAC9F;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,OAAO;IACd,OAAO,uBAAC,+BAAS,KAAG,CAAC;AACvB,CAAC;AAED,SAAS,WAAW,CAAC,IAA+B;IAClD,OAAO,IAAI,CAAC,YAAY,EAAE,WAAW,CAAC;AACxC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useCallback, useMemo, useState } from \"react\";\nimport { SvgLayers } from \"@itwin/itwinui-icons-react\";\nimport { Text } from \"@itwin/itwinui-react\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { useTelemetryContext } from \"../common/UseTelemetryContext\";\nimport { CategoriesTreeDefinition } from \"./CategoriesTreeDefinition\";\nimport { CategoriesVisibilityHandler } from \"./CategoriesVisibilityHandler\";\n\nimport type { VisibilityTree } from \"../common/components/VisibilityTree\";\nimport type { ComponentPropsWithoutRef } from \"react\";\nimport type { Viewport } from \"@itwin/core-frontend\";\nimport type { HierarchyNode } from \"@itwin/presentation-hierarchies\";\nimport type { PresentationHierarchyNode } from \"@itwin/presentation-hierarchies-react\";\nimport type { VisibilityTreeRenderer } from \"../common/components/VisibilityTreeRenderer\";\n\ntype CategoriesTreeFilteringError = \"tooManyFilterMatches\" | \"unknownFilterError\";\n\n/** @beta */\ntype VisibilityTreeRendererProps = ComponentPropsWithoutRef<typeof VisibilityTreeRenderer>;\n\n/** @beta */\ntype VisibilityTreeProps = ComponentPropsWithoutRef<typeof VisibilityTree>;\n\n/** @beta */\ninterface UseCategoriesTreeProps {\n filter: string;\n activeView: Viewport;\n}\n\n/** @beta */\ninterface UseCategoriesTreeResult {\n categoriesTreeProps: Pick<\n VisibilityTreeProps,\n \"treeName\" | \"getHierarchyDefinition\" | \"getFilteredPaths\" | \"visibilityHandlerFactory\" | \"highlight\" | \"noDataMessage\"\n >;\n rendererProps: Pick<Required<VisibilityTreeRendererProps>, \"getIcon\" | \"getSublabel\">;\n}\n\n/**\n * Custom hook to create and manage state for the categories tree.\n * @beta\n */\nexport function useCategoriesTree({ filter, activeView }: UseCategoriesTreeProps): UseCategoriesTreeResult {\n const [filteringError, setFilteringError] = useState<CategoriesTreeFilteringError | undefined>();\n const visibilityHandlerFactory = useCallback(() => {\n const visibilityHandler = new CategoriesVisibilityHandler({\n viewport: activeView,\n });\n return {\n getVisibilityStatus: async (node: HierarchyNode) => visibilityHandler.getVisibilityStatus(node),\n changeVisibility: async (node: HierarchyNode, on: boolean) => visibilityHandler.changeVisibility(node, on),\n onVisibilityChange: visibilityHandler.onVisibilityChange,\n dispose: () => visibilityHandler.dispose(),\n };\n }, [activeView]);\n const { onFeatureUsed } = useTelemetryContext();\n\n const getHierarchyDefinition = useCallback<VisibilityTreeProps[\"getHierarchyDefinition\"]>(\n (props) => {\n return new CategoriesTreeDefinition({ ...props, viewType: activeView.view.is2d() ? \"2d\" : \"3d\" });\n },\n [activeView],\n );\n\n const getFilteredPaths = useMemo<VisibilityTreeProps[\"getFilteredPaths\"] | undefined>(() => {\n setFilteringError(undefined);\n if (!filter) {\n return undefined;\n }\n return async ({ imodelAccess }) => {\n onFeatureUsed({ featureId: \"filtering\", reportInteraction: true });\n try {\n return await CategoriesTreeDefinition.createInstanceKeyPaths({ imodelAccess, label: filter, viewType: activeView.view.is2d() ? \"2d\" : \"3d\" });\n } catch (e) {\n const newError = e instanceof Error && e.message.match(/Filter matches more than \\d+ items/) ? \"tooManyFilterMatches\" : \"unknownFilterError\";\n if (newError !== \"tooManyFilterMatches\") {\n const feature = e instanceof Error && e.message.includes(\"query too long to execute or server is too busy\") ? \"error-timeout\" : \"error-unknown\";\n onFeatureUsed({ featureId: feature, reportInteraction: false });\n }\n setFilteringError(newError);\n return [];\n }\n };\n }, [filter, activeView, onFeatureUsed]);\n\n return {\n categoriesTreeProps: {\n treeName: \"categories-tree-v2\",\n getHierarchyDefinition,\n getFilteredPaths,\n visibilityHandlerFactory,\n noDataMessage: getNoDataMessage(filter, filteringError),\n highlight: filter ? { text: filter } : undefined,\n },\n rendererProps: {\n getIcon,\n getSublabel,\n },\n };\n}\n\nfunction getNoDataMessage(filter: string, error?: CategoriesTreeFilteringError) {\n if (error) {\n return <Text>{TreeWidget.translate(`categoriesTree.filtering.${error}`)}</Text>;\n }\n if (filter) {\n return <Text>{TreeWidget.translate(\"categoriesTree.filtering.noMatches\", { filter })}</Text>;\n }\n return undefined;\n}\n\nfunction getIcon() {\n return <SvgLayers />;\n}\n\nfunction getSublabel(node: PresentationHierarchyNode) {\n return node.extendedData?.description;\n}\n"]}
@@ -1,6 +1,7 @@
1
- import type { IModelConnection, ViewManager, Viewport } from "@itwin/core-frontend";
1
+ import type { Viewport } from "@itwin/core-frontend";
2
2
  /**
3
3
  * Data structure that describes category.
4
+ * @beta
4
5
  */
5
6
  export interface CategoryInfo {
6
7
  categoryId: string;
@@ -8,26 +9,21 @@ export interface CategoryInfo {
8
9
  }
9
10
  /**
10
11
  * Toggles visibility of categories to show or hide.
11
- * @internal
12
12
  */
13
- export declare function toggleAllCategories(viewManager: ViewManager, imodel: IModelConnection, display: boolean, viewport?: Viewport, forAllViewports?: boolean): Promise<void>;
13
+ export declare function toggleAllCategories(viewport: Viewport, display: boolean): Promise<void>;
14
14
  /**
15
15
  * Gets ids of all categories from specified imodel and viewport.
16
- * @internal
17
16
  */
18
- export declare function getCategories(imodel: IModelConnection, viewport?: Viewport): Promise<string[]>;
17
+ export declare function getCategories(viewport: Viewport): Promise<string[]>;
19
18
  /**
20
19
  * Changes category display in the viewport.
21
- * @internal
22
20
  */
23
- export declare function enableCategoryDisplay(viewManager: ViewManager, imodel: IModelConnection, ids: string[], enabled: boolean, forAllViewports: boolean, enableAllSubCategories?: boolean): Promise<void>;
21
+ export declare function enableCategoryDisplay(viewport: Viewport, ids: string[], enabled: boolean, enableAllSubCategories?: boolean): Promise<void>;
24
22
  /**
25
23
  * Changes subcategory display in the viewport
26
- * @internal
27
24
  */
28
- export declare function enableSubCategoryDisplay(viewManager: ViewManager, key: string, enabled: boolean, forAllViewports?: boolean): void;
29
- /** @internal */
30
- export declare function loadCategoriesFromViewport(iModel?: IModelConnection, vp?: Viewport): Promise<CategoryInfo[]>;
25
+ export declare function enableSubCategoryDisplay(viewport: Viewport, key: string, enabled: boolean): void;
26
+ export declare function loadCategoriesFromViewport(vp: Viewport): Promise<CategoryInfo[]>;
31
27
  /**
32
28
  * Enable display of all given categories.
33
29
  * @public
@@ -9,123 +9,72 @@ const core_common_1 = require("@itwin/core-common");
9
9
  const core_frontend_1 = require("@itwin/core-frontend");
10
10
  /**
11
11
  * Toggles visibility of categories to show or hide.
12
- * @internal
13
12
  */
14
- async function toggleAllCategories(viewManager, imodel, display, viewport, forAllViewports) {
15
- // istanbul ignore next
16
- const activeView = viewport ?? viewManager.getFirstOpenView();
17
- const ids = await getCategories(imodel, activeView);
18
- // istanbul ignore if
13
+ async function toggleAllCategories(viewport, display) {
14
+ const ids = await getCategories(viewport);
19
15
  if (ids.length === 0) {
20
16
  return;
21
17
  }
22
- await enableCategoryDisplay(viewManager, imodel, ids, display, forAllViewports ?? false);
18
+ await enableCategoryDisplay(viewport, ids, display);
23
19
  }
24
20
  exports.toggleAllCategories = toggleAllCategories;
25
21
  /**
26
22
  * Gets ids of all categories from specified imodel and viewport.
27
- * @internal
28
23
  */
29
- async function getCategories(imodel, viewport) {
30
- const categories = await loadCategoriesFromViewport(imodel, viewport);
24
+ async function getCategories(viewport) {
25
+ const categories = await loadCategoriesFromViewport(viewport);
31
26
  return categories.map((category) => category.categoryId);
32
27
  }
33
28
  exports.getCategories = getCategories;
34
29
  /**
35
30
  * Changes category display in the viewport.
36
- * @internal
37
31
  */
38
- async function enableCategoryDisplay(viewManager, imodel, ids, enabled, forAllViewports, enableAllSubCategories = true) {
39
- if (!viewManager.selectedView) {
40
- return;
41
- }
42
- const updateViewport = async (vp) => {
43
- // Only act on viewports that are both 3D or both 2D. Important if we have multiple viewports opened and we
44
- // are using 'allViewports' property
45
- if (viewManager.selectedView && viewManager.selectedView.view.is3d() === vp.view.is3d()) {
46
- vp.changeCategoryDisplay(ids, enabled, enableAllSubCategories);
47
- // remove category overrides per model
48
- const modelsContainingOverrides = [];
49
- for (const ovr of vp.perModelCategoryVisibility) {
50
- // istanbul ignore else
51
- if (ids.findIndex((id) => id === ovr.categoryId) !== -1) {
52
- modelsContainingOverrides.push(ovr.modelId);
53
- }
54
- }
55
- vp.perModelCategoryVisibility.setOverride(modelsContainingOverrides, ids, core_frontend_1.PerModelCategoryVisibility.Override.None);
56
- // changeCategoryDisplay only enables subcategories, it does not disabled them. So we must do that ourselves.
57
- if (false === enabled) {
58
- (await imodel.categories.getCategoryInfo(ids)).forEach((categoryInfo) => {
59
- categoryInfo.subCategories.forEach((value) => enableSubCategoryDisplay(viewManager, value.id, false, forAllViewports));
60
- });
61
- }
62
- }
63
- };
64
- // This property let us act on all viewports or just on the selected one, configurable by the app
65
- if (forAllViewports) {
66
- for (const viewport of viewManager) {
67
- await updateViewport(viewport);
32
+ async function enableCategoryDisplay(viewport, ids, enabled, enableAllSubCategories = true) {
33
+ viewport.changeCategoryDisplay(ids, enabled, enableAllSubCategories);
34
+ // remove category overrides per model
35
+ const modelsContainingOverrides = [];
36
+ for (const ovr of viewport.perModelCategoryVisibility) {
37
+ // istanbul ignore else
38
+ if (ids.findIndex((id) => id === ovr.categoryId) !== -1) {
39
+ modelsContainingOverrides.push(ovr.modelId);
68
40
  }
69
41
  }
70
- else {
71
- await updateViewport(viewManager.selectedView);
42
+ viewport.perModelCategoryVisibility.setOverride(modelsContainingOverrides, ids, core_frontend_1.PerModelCategoryVisibility.Override.None);
43
+ // changeCategoryDisplay only enables subcategories, it does not disabled them. So we must do that ourselves.
44
+ if (false === enabled) {
45
+ (await viewport.iModel.categories.getCategoryInfo(ids)).forEach((categoryInfo) => {
46
+ categoryInfo.subCategories.forEach((value) => enableSubCategoryDisplay(viewport, value.id, false));
47
+ });
72
48
  }
73
49
  }
74
50
  exports.enableCategoryDisplay = enableCategoryDisplay;
75
51
  /**
76
52
  * Changes subcategory display in the viewport
77
- * @internal
78
53
  */
79
- function enableSubCategoryDisplay(viewManager, key, enabled, forAllViewports) {
80
- if (!viewManager.selectedView) {
81
- return;
82
- }
83
- const updateViewport = (vp) => {
84
- // Only act on viewports that are both 3D or both 2D. Important if we have multiple viewports opened and we
85
- // are using 'allViewports' property
86
- if (viewManager.selectedView && viewManager.selectedView.view.is3d() === vp.view.is3d()) {
87
- vp.changeSubCategoryDisplay(key, enabled);
88
- }
89
- };
90
- // This property let us act on all viewports or just on the selected one, configurable by the app
91
- if (forAllViewports) {
92
- for (const viewport of viewManager) {
93
- updateViewport(viewport);
94
- }
95
- }
96
- else {
97
- updateViewport(viewManager.selectedView);
98
- }
54
+ function enableSubCategoryDisplay(viewport, key, enabled) {
55
+ viewport.changeSubCategoryDisplay(key, enabled);
99
56
  }
100
57
  exports.enableSubCategoryDisplay = enableSubCategoryDisplay;
101
- /** @internal */
102
- async function loadCategoriesFromViewport(iModel, vp) {
103
- if (!vp) {
104
- return EMPTY_CATEGORIES_ARRAY;
105
- }
58
+ async function loadCategoriesFromViewport(vp) {
106
59
  // Query categories and add them to state
107
60
  const selectUsedSpatialCategoryIds = "SELECT DISTINCT Category.Id as id from BisCore.GeometricElement3d WHERE Category.Id IN (SELECT ECInstanceId from BisCore.SpatialCategory)";
108
61
  const selectUsedDrawingCategoryIds = "SELECT DISTINCT Category.Id as id from BisCore.GeometricElement2d WHERE Model.Id=? AND Category.Id IN (SELECT ECInstanceId from BisCore.DrawingCategory)";
109
62
  const ecsql = vp.view.is3d() ? selectUsedSpatialCategoryIds : selectUsedDrawingCategoryIds;
110
63
  const ecsql2 = `SELECT ECInstanceId as id FROM ${vp.view.is3d() ? "BisCore.SpatialCategory" : "BisCore.DrawingCategory"} WHERE ECInstanceId IN (${ecsql})`;
111
64
  const categories = [];
112
- // istanbul ignore else
113
- if (iModel) {
114
- const rows = await iModel.createQueryReader(ecsql2, undefined, { rowFormat: core_common_1.QueryRowFormat.UseJsPropertyNames }).toArray();
115
- (await iModel.categories.getCategoryInfo(rows.map((row) => row.id))).forEach((val) => {
116
- categories.push({ categoryId: val.id, subCategoryIds: val.subCategories.size ? [...val.subCategories.keys()] : undefined });
117
- });
118
- }
65
+ const rows = await vp.iModel.createQueryReader(ecsql2, undefined, { rowFormat: core_common_1.QueryRowFormat.UseJsPropertyNames }).toArray();
66
+ (await vp.iModel.categories.getCategoryInfo(rows.map((row) => row.id))).forEach((val) => {
67
+ categories.push({ categoryId: val.id, subCategoryIds: val.subCategories.size ? [...val.subCategories.keys()] : undefined });
68
+ });
119
69
  return categories;
120
70
  }
121
71
  exports.loadCategoriesFromViewport = loadCategoriesFromViewport;
122
- const EMPTY_CATEGORIES_ARRAY = [];
123
72
  /**
124
73
  * Enable display of all given categories.
125
74
  * @public
126
75
  */
127
76
  async function showAllCategories(categories, viewport) {
128
- await enableCategoryDisplay(core_frontend_1.IModelApp.viewManager, viewport.iModel, categories, true, true);
77
+ await enableCategoryDisplay(viewport, categories, true, true);
129
78
  }
130
79
  exports.showAllCategories = showAllCategories;
131
80
  /**
@@ -133,7 +82,7 @@ exports.showAllCategories = showAllCategories;
133
82
  * @public
134
83
  */
135
84
  async function hideAllCategories(categories, viewport) {
136
- await enableCategoryDisplay(core_frontend_1.IModelApp.viewManager, viewport.iModel, categories, false, true);
85
+ await enableCategoryDisplay(viewport, categories, false, true);
137
86
  }
138
87
  exports.hideAllCategories = hideAllCategories;
139
88
  /**
@@ -161,11 +110,11 @@ async function invertAllCategories(categories, viewport) {
161
110
  }
162
111
  }
163
112
  // Disable enabled
164
- enabledSubCategories.forEach((subCategory) => enableSubCategoryDisplay(core_frontend_1.IModelApp.viewManager, subCategory, false, true));
165
- await enableCategoryDisplay(core_frontend_1.IModelApp.viewManager, viewport.iModel, enabled, false, true);
113
+ enabledSubCategories.forEach((subCategory) => enableSubCategoryDisplay(viewport, subCategory, false));
114
+ await enableCategoryDisplay(viewport, enabled, false, true);
166
115
  // Enable disabled
167
- disabledSubCategories.forEach((subCategory) => enableSubCategoryDisplay(core_frontend_1.IModelApp.viewManager, subCategory, true, true));
168
- await enableCategoryDisplay(core_frontend_1.IModelApp.viewManager, viewport.iModel, disabled, true, true);
116
+ disabledSubCategories.forEach((subCategory) => enableSubCategoryDisplay(viewport, subCategory, true));
117
+ await enableCategoryDisplay(viewport, disabled, true, true);
169
118
  }
170
119
  exports.invertAllCategories = invertAllCategories;
171
120
  //# sourceMappingURL=CategoriesVisibilityUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CategoriesVisibilityUtils.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/CategoriesVisibilityUtils.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,oDAAoD;AACpD,wDAA6E;AAY7E;;;GAGG;AACI,KAAK,UAAU,mBAAmB,CACvC,WAAwB,EACxB,MAAwB,EACxB,OAAgB,EAChB,QAAmB,EACnB,eAAyB;IAEzB,uBAAuB;IACvB,MAAM,UAAU,GAAG,QAAQ,IAAI,WAAW,CAAC,gBAAgB,EAAE,CAAC;IAC9D,MAAM,GAAG,GAAG,MAAM,aAAa,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAEpD,qBAAqB;IACrB,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE;QACpB,OAAO;KACR;IAED,MAAM,qBAAqB,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,eAAe,IAAI,KAAK,CAAC,CAAC;AAC3F,CAAC;AAjBD,kDAiBC;AAED;;;GAGG;AACI,KAAK,UAAU,aAAa,CAAC,MAAwB,EAAE,QAAmB;IAC/E,MAAM,UAAU,GAAG,MAAM,0BAA0B,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACtE,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAA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B,CAAC,yBAAS,CAAC,WAAW,EAAE,WAAW,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;IAEzH,MAAM,qBAAqB,CAAC,yBAAS,CAAC,WAAW,EAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;IAE1F,kBAAkB;IAClB,qBAAqB,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,wBAAwB,CAAC,yBAAS,CAAC,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IAEzH,MAAM,qBAAqB,CAAC,yBAAS,CAAC,WAAW,EAAE,QAAQ,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAC5F,CAAC;AA9BD,kDA8BC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { QueryRowFormat } from \"@itwin/core-common\";\nimport { IModelApp, PerModelCategoryVisibility } from \"@itwin/core-frontend\";\n\nimport type { IModelConnection, ViewManager, Viewport } from \"@itwin/core-frontend\";\n\n/**\n * Data structure that describes category.\n */\nexport interface CategoryInfo {\n categoryId: string;\n subCategoryIds?: string[];\n}\n\n/**\n * Toggles visibility of categories to show or hide.\n * @internal\n */\nexport async function toggleAllCategories(\n viewManager: ViewManager,\n imodel: IModelConnection,\n display: boolean,\n viewport?: Viewport,\n forAllViewports?: boolean,\n) {\n // istanbul ignore next\n const activeView = viewport ?? viewManager.getFirstOpenView();\n const ids = await getCategories(imodel, activeView);\n\n // istanbul ignore if\n if (ids.length === 0) {\n return;\n }\n\n await enableCategoryDisplay(viewManager, imodel, ids, display, forAllViewports ?? false);\n}\n\n/**\n * Gets ids of all categories from specified imodel and viewport.\n * @internal\n */\nexport async function getCategories(imodel: IModelConnection, viewport?: Viewport) {\n const categories = await loadCategoriesFromViewport(imodel, viewport);\n return categories.map((category) => category.categoryId);\n}\n\n/**\n * Changes category display in the viewport.\n * @internal\n */\nexport async function enableCategoryDisplay(\n viewManager: ViewManager,\n imodel: IModelConnection,\n ids: string[],\n enabled: boolean,\n forAllViewports: boolean,\n enableAllSubCategories = true,\n) {\n if (!viewManager.selectedView) {\n return;\n }\n\n const updateViewport = async (vp: Viewport) => {\n // Only act on viewports that are both 3D or both 2D. Important if we have multiple viewports opened and we\n // are using 'allViewports' property\n if (viewManager.selectedView && viewManager.selectedView.view.is3d() === vp.view.is3d()) {\n vp.changeCategoryDisplay(ids, enabled, enableAllSubCategories);\n\n // remove category overrides per model\n const modelsContainingOverrides: string[] = [];\n for (const ovr of vp.perModelCategoryVisibility) {\n // istanbul ignore else\n if (ids.findIndex((id) => id === ovr.categoryId) !== -1) {\n modelsContainingOverrides.push(ovr.modelId);\n }\n }\n vp.perModelCategoryVisibility.setOverride(modelsContainingOverrides, ids, PerModelCategoryVisibility.Override.None);\n\n // changeCategoryDisplay only enables subcategories, it does not disabled them. So we must do that ourselves.\n if (false === enabled) {\n (await imodel.categories.getCategoryInfo(ids)).forEach((categoryInfo) => {\n categoryInfo.subCategories.forEach((value) => enableSubCategoryDisplay(viewManager, value.id, false, forAllViewports));\n });\n }\n }\n };\n\n // This property let us act on all viewports or just on the selected one, configurable by the app\n if (forAllViewports) {\n for (const viewport of viewManager) {\n await updateViewport(viewport);\n }\n } else {\n await updateViewport(viewManager.selectedView);\n }\n}\n\n/**\n * Changes subcategory display in the viewport\n * @internal\n */\nexport function enableSubCategoryDisplay(viewManager: ViewManager, key: string, enabled: boolean, forAllViewports?: boolean) {\n if (!viewManager.selectedView) {\n return;\n }\n\n const updateViewport = (vp: Viewport) => {\n // Only act on viewports that are both 3D or both 2D. Important if we have multiple viewports opened and we\n // are using 'allViewports' property\n if (viewManager.selectedView && viewManager.selectedView.view.is3d() === vp.view.is3d()) {\n vp.changeSubCategoryDisplay(key, enabled);\n }\n };\n\n // This property let us act on all viewports or just on the selected one, configurable by the app\n if (forAllViewports) {\n for (const viewport of viewManager) {\n updateViewport(viewport);\n }\n } else {\n updateViewport(viewManager.selectedView);\n }\n}\n\n/** @internal */\nexport async function loadCategoriesFromViewport(iModel?: IModelConnection, vp?: Viewport) {\n if (!vp) {\n return EMPTY_CATEGORIES_ARRAY;\n }\n\n // Query categories and add them to state\n const selectUsedSpatialCategoryIds =\n \"SELECT DISTINCT Category.Id as id from BisCore.GeometricElement3d WHERE Category.Id IN (SELECT ECInstanceId from BisCore.SpatialCategory)\";\n const selectUsedDrawingCategoryIds =\n \"SELECT DISTINCT Category.Id as id from BisCore.GeometricElement2d WHERE Model.Id=? AND Category.Id IN (SELECT ECInstanceId from BisCore.DrawingCategory)\";\n const ecsql = vp.view.is3d() ? selectUsedSpatialCategoryIds : selectUsedDrawingCategoryIds;\n const ecsql2 = `SELECT ECInstanceId as id FROM ${vp.view.is3d() ? \"BisCore.SpatialCategory\" : \"BisCore.DrawingCategory\"} WHERE ECInstanceId IN (${ecsql})`;\n\n const categories: CategoryInfo[] = [];\n\n // istanbul ignore else\n if (iModel) {\n const rows = await iModel.createQueryReader(ecsql2, undefined, { rowFormat: QueryRowFormat.UseJsPropertyNames }).toArray();\n (await iModel.categories.getCategoryInfo(rows.map((row) => row.id))).forEach((val) => {\n categories.push({ categoryId: val.id, subCategoryIds: val.subCategories.size ? [...val.subCategories.keys()] : undefined });\n });\n }\n return categories;\n}\nconst EMPTY_CATEGORIES_ARRAY: CategoryInfo[] = [];\n\n/**\n * Enable display of all given categories.\n * @public\n */\nexport async function showAllCategories(categories: string[], viewport: Viewport) {\n await enableCategoryDisplay(IModelApp.viewManager, viewport.iModel, categories, true, true);\n}\n\n/**\n * Disable display of all given categories.\n * @public\n */\nexport async function hideAllCategories(categories: string[], viewport: Viewport) {\n await enableCategoryDisplay(IModelApp.viewManager, viewport.iModel, categories, false, true);\n}\n\n/**\n * Invert display of all given categories.\n * @public\n */\nexport async function invertAllCategories(categories: CategoryInfo[], viewport: Viewport) {\n const enabled: string[] = [];\n const disabled: string[] = [];\n const enabledSubCategories: string[] = [];\n const disabledSubCategories: string[] = [];\n\n for (const category of categories) {\n if (!viewport.view.viewsCategory(category.categoryId)) {\n disabled.push(category.categoryId);\n continue;\n }\n // First, we need to check if at least one subcategory is disabled. If it is true, then only subcategories should change display, not categories.\n if (category.subCategoryIds?.some((subCategory) => !viewport.isSubCategoryVisible(subCategory))) {\n for (const subCategory of category.subCategoryIds) {\n viewport.isSubCategoryVisible(subCategory) ? enabledSubCategories.push(subCategory) : disabledSubCategories.push(subCategory);\n }\n } else {\n enabled.push(category.categoryId);\n }\n }\n\n // Disable enabled\n enabledSubCategories.forEach((subCategory) => enableSubCategoryDisplay(IModelApp.viewManager, subCategory, false, true));\n\n await enableCategoryDisplay(IModelApp.viewManager, viewport.iModel, enabled, false, true);\n\n // Enable disabled\n disabledSubCategories.forEach((subCategory) => enableSubCategoryDisplay(IModelApp.viewManager, subCategory, true, true));\n\n await enableCategoryDisplay(IModelApp.viewManager, viewport.iModel, disabled, true, true);\n}\n"]}
1
+ {"version":3,"file":"CategoriesVisibilityUtils.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/CategoriesVisibilityUtils.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,oDAAoD;AACpD,wDAAkE;AAalE;;GAEG;AACI,KAAK,UAAU,mBAAmB,CAAC,QAAkB,EAAE,OAAgB;IAC5E,MAAM,GAAG,GAAG,MAAM,aAAa,CAAC,QAAQ,CAAC,CAAC;IAC1C,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE;QACpB,OAAO;KACR;IAED,MAAM,qBAAqB,CAAC,QAAQ,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;AACtD,CAAC;AAPD,kDAOC;AAED;;GAEG;AACI,KAAK,UAAU,aAAa,CAAC,QAAkB;IACpD,MAAM,UAAU,GAAG,MAAM,0BAA0B,CAAC,Q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BAAoB,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,wBAAwB,CAAC,QAAQ,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC;IAEtG,MAAM,qBAAqB,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;IAE5D,kBAAkB;IAClB,qBAAqB,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,wBAAwB,CAAC,QAAQ,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC;IAEtG,MAAM,qBAAqB,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAC9D,CAAC;AA9BD,kDA8BC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { QueryRowFormat } from \"@itwin/core-common\";\nimport { PerModelCategoryVisibility } from \"@itwin/core-frontend\";\n\nimport type { Viewport } from \"@itwin/core-frontend\";\n\n/**\n * Data structure that describes category.\n * @beta\n */\nexport interface CategoryInfo {\n categoryId: string;\n subCategoryIds?: string[];\n}\n\n/**\n * Toggles visibility of categories to show or hide.\n */\nexport async function toggleAllCategories(viewport: Viewport, display: boolean) {\n const ids = await getCategories(viewport);\n if (ids.length === 0) {\n return;\n }\n\n await enableCategoryDisplay(viewport, ids, display);\n}\n\n/**\n * Gets ids of all categories from specified imodel and viewport.\n */\nexport async function getCategories(viewport: Viewport) {\n const categories = await loadCategoriesFromViewport(viewport);\n return categories.map((category) => category.categoryId);\n}\n\n/**\n * Changes category display in the viewport.\n */\nexport async function enableCategoryDisplay(viewport: Viewport, ids: string[], enabled: boolean, enableAllSubCategories = true) {\n viewport.changeCategoryDisplay(ids, enabled, enableAllSubCategories);\n\n // remove category overrides per model\n const modelsContainingOverrides: string[] = [];\n for (const ovr of viewport.perModelCategoryVisibility) {\n // istanbul ignore else\n if (ids.findIndex((id) => id === ovr.categoryId) !== -1) {\n modelsContainingOverrides.push(ovr.modelId);\n }\n }\n viewport.perModelCategoryVisibility.setOverride(modelsContainingOverrides, ids, PerModelCategoryVisibility.Override.None);\n\n // changeCategoryDisplay only enables subcategories, it does not disabled them. So we must do that ourselves.\n if (false === enabled) {\n (await viewport.iModel.categories.getCategoryInfo(ids)).forEach((categoryInfo) => {\n categoryInfo.subCategories.forEach((value) => enableSubCategoryDisplay(viewport, value.id, false));\n });\n }\n}\n\n/**\n * Changes subcategory display in the viewport\n */\nexport function enableSubCategoryDisplay(viewport: Viewport, key: string, enabled: boolean) {\n viewport.changeSubCategoryDisplay(key, enabled);\n}\n\nexport async function loadCategoriesFromViewport(vp: Viewport) {\n // Query categories and add them to state\n const selectUsedSpatialCategoryIds =\n \"SELECT DISTINCT Category.Id as id from BisCore.GeometricElement3d WHERE Category.Id IN (SELECT ECInstanceId from BisCore.SpatialCategory)\";\n const selectUsedDrawingCategoryIds =\n \"SELECT DISTINCT Category.Id as id from BisCore.GeometricElement2d WHERE Model.Id=? AND Category.Id IN (SELECT ECInstanceId from BisCore.DrawingCategory)\";\n const ecsql = vp.view.is3d() ? selectUsedSpatialCategoryIds : selectUsedDrawingCategoryIds;\n const ecsql2 = `SELECT ECInstanceId as id FROM ${vp.view.is3d() ? \"BisCore.SpatialCategory\" : \"BisCore.DrawingCategory\"} WHERE ECInstanceId IN (${ecsql})`;\n\n const categories: CategoryInfo[] = [];\n\n const rows = await vp.iModel.createQueryReader(ecsql2, undefined, { rowFormat: QueryRowFormat.UseJsPropertyNames }).toArray();\n (await vp.iModel.categories.getCategoryInfo(rows.map((row) => row.id))).forEach((val) => {\n categories.push({ categoryId: val.id, subCategoryIds: val.subCategories.size ? [...val.subCategories.keys()] : undefined });\n });\n return categories;\n}\n\n/**\n * Enable display of all given categories.\n * @public\n */\nexport async function showAllCategories(categories: string[], viewport: Viewport) {\n await enableCategoryDisplay(viewport, categories, true, true);\n}\n\n/**\n * Disable display of all given categories.\n * @public\n */\nexport async function hideAllCategories(categories: string[], viewport: Viewport) {\n await enableCategoryDisplay(viewport, categories, false, true);\n}\n\n/**\n * Invert display of all given categories.\n * @public\n */\nexport async function invertAllCategories(categories: CategoryInfo[], viewport: Viewport) {\n const enabled: string[] = [];\n const disabled: string[] = [];\n const enabledSubCategories: string[] = [];\n const disabledSubCategories: string[] = [];\n\n for (const category of categories) {\n if (!viewport.view.viewsCategory(category.categoryId)) {\n disabled.push(category.categoryId);\n continue;\n }\n // First, we need to check if at least one subcategory is disabled. If it is true, then only subcategories should change display, not categories.\n if (category.subCategoryIds?.some((subCategory) => !viewport.isSubCategoryVisible(subCategory))) {\n for (const subCategory of category.subCategoryIds) {\n viewport.isSubCategoryVisible(subCategory) ? enabledSubCategories.push(subCategory) : disabledSubCategories.push(subCategory);\n }\n } else {\n enabled.push(category.categoryId);\n }\n }\n\n // Disable enabled\n enabledSubCategories.forEach((subCategory) => enableSubCategoryDisplay(viewport, subCategory, false));\n\n await enableCategoryDisplay(viewport, enabled, false, true);\n\n // Enable disabled\n disabledSubCategories.forEach((subCategory) => enableSubCategoryDisplay(viewport, subCategory, true));\n\n await enableCategoryDisplay(viewport, disabled, true, true);\n}\n"]}
@@ -1,14 +1,11 @@
1
1
  /// <reference types="react" />
2
2
  import type { InstanceKey } from "@itwin/presentation-shared";
3
3
  import type { GroupingHierarchyNode } from "@itwin/presentation-hierarchies";
4
- /** @internal */
5
4
  export interface FocusedInstancesContext {
6
5
  loadInstanceKeys?: () => AsyncIterableIterator<InstanceKey | GroupingHierarchyNode>;
7
6
  enabled: boolean;
8
7
  toggle: () => void;
9
8
  }
10
- /** @internal */
11
9
  export declare const focusedInstancesContext: import("react").Context<FocusedInstancesContext>;
12
- /** @internal */
13
10
  export declare function useFocusedInstancesContext(): FocusedInstancesContext;
14
11
  //# sourceMappingURL=FocusedInstancesContext.d.ts.map
@@ -6,9 +6,7 @@
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.useFocusedInstancesContext = exports.focusedInstancesContext = void 0;
8
8
  const react_1 = require("react");
9
- /** @internal */
10
9
  exports.focusedInstancesContext = (0, react_1.createContext)({ enabled: false, toggle: () => { } });
11
- /** @internal */
12
10
  function useFocusedInstancesContext() {
13
11
  return (0, react_1.useContext)(exports.focusedInstancesContext);
14
12
  }
@@ -1 +1 @@
1
- {"version":3,"file":"FocusedInstancesContext.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/FocusedInstancesContext.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,iCAAkD;AAYlD,gBAAgB;AACH,QAAA,uBAAuB,GAAG,IAAA,qBAAa,EAA0B,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,CAAC,CAAC;AAEpH,gBAAgB;AAChB,SAAgB,0BAA0B;IACxC,OAAO,IAAA,kBAAU,EAAC,+BAAuB,CAAC,CAAC;AAC7C,CAAC;AAFD,gEAEC","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 { createContext, useContext } from \"react\";\n\nimport type { InstanceKey } from \"@itwin/presentation-shared\";\nimport type { GroupingHierarchyNode } from \"@itwin/presentation-hierarchies\";\n\n/** @internal */\nexport interface FocusedInstancesContext {\n loadInstanceKeys?: () => AsyncIterableIterator<InstanceKey | GroupingHierarchyNode>;\n enabled: boolean;\n toggle: () => void;\n}\n\n/** @internal */\nexport const focusedInstancesContext = createContext<FocusedInstancesContext>({ enabled: false, toggle: () => {} });\n\n/** @internal */\nexport function useFocusedInstancesContext() {\n return useContext(focusedInstancesContext);\n}\n"]}
1
+ {"version":3,"file":"FocusedInstancesContext.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/FocusedInstancesContext.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,iCAAkD;AAWrC,QAAA,uBAAuB,GAAG,IAAA,qBAAa,EAA0B,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,CAAC,CAAC;AAEpH,SAAgB,0BAA0B;IACxC,OAAO,IAAA,kBAAU,EAAC,+BAAuB,CAAC,CAAC;AAC7C,CAAC;AAFD,gEAEC","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 { createContext, useContext } from \"react\";\n\nimport type { InstanceKey } from \"@itwin/presentation-shared\";\nimport type { GroupingHierarchyNode } from \"@itwin/presentation-hierarchies\";\n\nexport interface FocusedInstancesContext {\n loadInstanceKeys?: () => AsyncIterableIterator<InstanceKey | GroupingHierarchyNode>;\n enabled: boolean;\n toggle: () => void;\n}\n\nexport const focusedInstancesContext = createContext<FocusedInstancesContext>({ enabled: false, toggle: () => {} });\n\nexport function useFocusedInstancesContext() {\n return useContext(focusedInstancesContext);\n}\n"]}
@@ -1,6 +1,5 @@
1
1
  import type { SelectionStorage } from "@itwin/presentation-hierarchies-react";
2
2
  import type { PropsWithChildren } from "react";
3
- /** @internal */
4
3
  export declare function FocusedInstancesContextProvider({ selectionStorage, imodelKey, children, }: PropsWithChildren<{
5
4
  selectionStorage: SelectionStorage;
6
5
  imodelKey: string;
@@ -10,7 +10,6 @@ const react_1 = require("react");
10
10
  const presentation_hierarchies_react_1 = require("@itwin/presentation-hierarchies-react");
11
11
  const unified_selection_1 = require("@itwin/unified-selection");
12
12
  const FocusedInstancesContext_1 = require("./FocusedInstancesContext");
13
- /** @internal */
14
13
  function FocusedInstancesContextProvider({ selectionStorage, imodelKey, children, }) {
15
14
  const [state, setState] = (0, react_1.useState)({
16
15
  enabled: false,
@@ -1 +1 @@
1
- {"version":3,"file":"FocusedInstancesContextProvider.js","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CAAC;AAhED,0EAgEC;AAED,SAAS,eAAe,CAAC,IAAa;IACpC,OAAO,CAAC,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,KAAK,IAAI,IAAI,CAAC;AAC7D,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useEffect, useState } from \"react\";\nimport { HierarchyNode } from \"@itwin/presentation-hierarchies-react\";\nimport { Selectable, Selectables } from \"@itwin/unified-selection\";\nimport { focusedInstancesContext } from \"./FocusedInstancesContext\";\n\nimport type { SelectionStorage } from \"@itwin/presentation-hierarchies-react\";\nimport type { PropsWithChildren } from \"react\";\nimport type { InstanceKey } from \"@itwin/presentation-common\";\nimport type { FocusedInstancesContext } from \"./FocusedInstancesContext\";\nimport type { GroupingHierarchyNode } from \"@itwin/presentation-hierarchies\";\n\n/** @internal */\nexport function FocusedInstancesContextProvider({\n selectionStorage,\n imodelKey,\n children,\n}: PropsWithChildren<{ selectionStorage: SelectionStorage; imodelKey: string }>) {\n const [state, setState] = useState<FocusedInstancesContext>({\n enabled: false,\n toggle: () => {\n setState((prev) => ({ ...prev, enabled: !prev.enabled }));\n },\n });\n const enabled = state.enabled;\n\n useEffect(() => {\n if (!enabled) {\n setState((prev) => ({ ...prev, loadInstanceKeys: undefined }));\n return;\n }\n\n const onSelectionChanged = () => {\n const selection = selectionStorage.getSelection({ imodelKey, level: 0 });\n if (Selectables.isEmpty(selection)) {\n setState((prev) => ({ ...prev, loadInstanceKeys: undefined }));\n return;\n }\n\n const selected: Array<InstanceKey | GroupingHierarchyNode | (() => AsyncIterableIterator<InstanceKey>)> = [];\n Selectables.forEach(selection, (selectable) => {\n if (Selectable.isInstanceKey(selectable)) {\n selected.push(selectable);\n return;\n }\n\n if (isHierarchyNode(selectable.data) && HierarchyNode.isGroupingNode(selectable.data)) {\n selected.push(selectable.data);\n return;\n }\n\n selected.push(selectable.loadInstanceKeys);\n });\n\n const loadInstanceKeys: () => AsyncIterableIterator<InstanceKey | GroupingHierarchyNode> = async function* () {\n for (const item of selected) {\n if (typeof item === \"function\") {\n yield* item();\n } else {\n yield item;\n }\n }\n };\n\n setState((prev) => ({ ...prev, loadInstanceKeys }));\n };\n\n onSelectionChanged();\n return selectionStorage.selectionChangeEvent.addListener(({ imodelKey: changeImodelKey, level }) => {\n if (changeImodelKey !== imodelKey || level !== 0) {\n return;\n }\n onSelectionChanged();\n });\n }, [enabled, imodelKey, selectionStorage]);\n\n return <focusedInstancesContext.Provider value={state}>{children}</focusedInstancesContext.Provider>;\n}\n\nfunction isHierarchyNode(data: unknown): data is HierarchyNode {\n return !!data && typeof data === \"object\" && \"key\" in data;\n}\n"]}
1
+ {"version":3,"file":"FocusedInstancesContextProvider.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/FocusedInstancesContextProvider.tsx"],"names":[],"mappings":";;;;AAAA;;;gGAGgG;AAEhG,iCAA4C;AAC5C,0FAAsE;AACtE,gEAAmE;AACnE,uEAAoE;AAQpE,SAAgB,+BAA+B,CAAC,EAC9C,gBAAgB,EAChB,SAAS,EACT,QAAQ,GACqE;IAC7E,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EAA0B;QAC1D,OAAO,EAAE,KAAK;QACd,MAAM,EAAE,GAAG,EAAE;YACX,QAAQ,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QAC5D,CAAC;KACF,CAAC,CAAC;IACH,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;IAE9B,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,CAAC,OAAO,EAAE;YACZ,QAAQ,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,E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E,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,gBAAgB,EAAE,CAAC,CAAC,CAAC;QACtD,CAAC,CAAC;QAEF,kBAAkB,EAAE,CAAC;QACrB,OAAO,gBAAgB,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,KAAK,EAAE,EAAE,EAAE;YACjG,IAAI,eAAe,KAAK,SAAS,IAAI,KAAK,KAAK,CAAC,EAAE;gBAChD,OAAO;aACR;YACD,kBAAkB,EAAE,CAAC;QACvB,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,OAAO,EAAE,SAAS,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAE3C,OAAO,uBAAC,iDAAuB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAAoC,CAAC;AACvG,CAAC;AAhED,0EAgEC;AAED,SAAS,eAAe,CAAC,IAAa;IACpC,OAAO,CAAC,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,KAAK,IAAI,IAAI,CAAC;AAC7D,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useEffect, useState } from \"react\";\nimport { HierarchyNode } from \"@itwin/presentation-hierarchies-react\";\nimport { Selectable, Selectables } from \"@itwin/unified-selection\";\nimport { focusedInstancesContext } from \"./FocusedInstancesContext\";\n\nimport type { SelectionStorage } from \"@itwin/presentation-hierarchies-react\";\nimport type { PropsWithChildren } from \"react\";\nimport type { InstanceKey } from \"@itwin/presentation-common\";\nimport type { FocusedInstancesContext } from \"./FocusedInstancesContext\";\nimport type { GroupingHierarchyNode } from \"@itwin/presentation-hierarchies\";\n\nexport function FocusedInstancesContextProvider({\n selectionStorage,\n imodelKey,\n children,\n}: PropsWithChildren<{ selectionStorage: SelectionStorage; imodelKey: string }>) {\n const [state, setState] = useState<FocusedInstancesContext>({\n enabled: false,\n toggle: () => {\n setState((prev) => ({ ...prev, enabled: !prev.enabled }));\n },\n });\n const enabled = state.enabled;\n\n useEffect(() => {\n if (!enabled) {\n setState((prev) => ({ ...prev, loadInstanceKeys: undefined }));\n return;\n }\n\n const onSelectionChanged = () => {\n const selection = selectionStorage.getSelection({ imodelKey, level: 0 });\n if (Selectables.isEmpty(selection)) {\n setState((prev) => ({ ...prev, loadInstanceKeys: undefined }));\n return;\n }\n\n const selected: Array<InstanceKey | GroupingHierarchyNode | (() => AsyncIterableIterator<InstanceKey>)> = [];\n Selectables.forEach(selection, (selectable) => {\n if (Selectable.isInstanceKey(selectable)) {\n selected.push(selectable);\n return;\n }\n\n if (isHierarchyNode(selectable.data) && HierarchyNode.isGroupingNode(selectable.data)) {\n selected.push(selectable.data);\n return;\n }\n\n selected.push(selectable.loadInstanceKeys);\n });\n\n const loadInstanceKeys: () => AsyncIterableIterator<InstanceKey | GroupingHierarchyNode> = async function* () {\n for (const item of selected) {\n if (typeof item === \"function\") {\n yield* item();\n } else {\n yield item;\n }\n }\n };\n\n setState((prev) => ({ ...prev, loadInstanceKeys }));\n };\n\n onSelectionChanged();\n return selectionStorage.selectionChangeEvent.addListener(({ imodelKey: changeImodelKey, level }) => {\n if (changeImodelKey !== imodelKey || level !== 0) {\n return;\n }\n onSelectionChanged();\n });\n }, [enabled, imodelKey, selectionStorage]);\n\n return <focusedInstancesContext.Provider value={state}>{children}</focusedInstancesContext.Provider>;\n}\n\nfunction isHierarchyNode(data: unknown): data is HierarchyNode {\n return !!data && typeof data === \"object\" && \"key\" in data;\n}\n"]}
@@ -6,7 +6,6 @@ interface UseFilteringResult {
6
6
  clearFilter: () => void;
7
7
  onHighlightChanged: (index: number, matches?: number) => void;
8
8
  }
9
- /** @internal */
10
9
  export declare function useFiltering(): UseFilteringResult;
11
10
  export {};
12
11
  //# sourceMappingURL=UseFiltering.d.ts.map
@@ -6,7 +6,6 @@
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.useFiltering = void 0;
8
8
  const react_1 = require("react");
9
- /** @internal */
10
9
  function useFiltering() {
11
10
  const [filter, setFilter] = (0, react_1.useState)("");
12
11
  const [activeMatchIndex, setActiveMatchIndex] = (0, react_1.useState)(0);
@@ -1 +1 @@
1
- {"version":3,"file":"UseFiltering.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/UseFiltering.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,iCAA8C;AAW9C,gBAAgB;AAChB,SAAgB,YAAY;IAC1B,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAA,gBAAQ,EAAC,EAAE,CAAC,CAAC;IACzC,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,IAAA,gBAAQ,EAAC,CAAC,CAAC,CAAC;IAC5D,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,IAAA,gBAAQ,EAAC,CAAC,CAAC,CAAC;IAEpD,MAAM,WAAW,GAAG,IAAA,mBAAW,EAAC,CAAC,SAAiB,EAAE,EAAE;QACpD,mBAAmB,CAAC,CAAC,CAAC,CAAC;QACvB,SAAS,CAAC,SAAS,CAAC,CAAC;IACvB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,WAAW,GAAG,IAAA,mBAAW,EAAC,GAAG,EAAE;QACnC,mBAAmB,CAAC,CAAC,CAAC,CAAC;QACvB,SAAS,CAAC,EAAE,CAAC,CAAC;IAChB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,kBAAkB,GAAG,IAAA,mBAAW,EAAC,CAAC,KAAa,EAAE,OAAgB,EAAE,EAAE;QACzE,mBAAmB,CAAC,KAAK,CAAC,CAAC;QAC3B,OAAO,IAAI,eAAe,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,kBAAkB,EAAE,CAAC;AAClG,CAAC;AArBD,oCAqBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useCallback, useState } from \"react\";\n\ninterface UseFilteringResult {\n filter: string;\n activeMatchIndex: number;\n totalMatches: number;\n applyFilter: (filter: string) => void;\n clearFilter: () => void;\n onHighlightChanged: (index: number, matches?: number) => void;\n}\n\n/** @internal */\nexport function useFiltering(): UseFilteringResult {\n const [filter, setFilter] = useState(\"\");\n const [activeMatchIndex, setActiveMatchIndex] = useState(0);\n const [totalMatches, setTotalMatches] = useState(0);\n\n const applyFilter = useCallback((newFilter: string) => {\n setActiveMatchIndex(0);\n setFilter(newFilter);\n }, []);\n\n const clearFilter = useCallback(() => {\n setActiveMatchIndex(0);\n setFilter(\"\");\n }, []);\n\n const onHighlightChanged = useCallback((index: number, matches?: number) => {\n setActiveMatchIndex(index);\n matches && setTotalMatches(matches);\n }, []);\n\n return { filter, activeMatchIndex, totalMatches, applyFilter, clearFilter, onHighlightChanged };\n}\n"]}
1
+ {"version":3,"file":"UseFiltering.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/UseFiltering.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,iCAA8C;AAW9C,SAAgB,YAAY;IAC1B,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAA,gBAAQ,EAAC,EAAE,CAAC,CAAC;IACzC,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,IAAA,gBAAQ,EAAC,CAAC,CAAC,CAAC;IAC5D,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,IAAA,gBAAQ,EAAC,CAAC,CAAC,CAAC;IAEpD,MAAM,WAAW,GAAG,IAAA,mBAAW,EAAC,CAAC,SAAiB,EAAE,EAAE;QACpD,mBAAmB,CAAC,CAAC,CAAC,CAAC;QACvB,SAAS,CAAC,SAAS,CAAC,CAAC;IACvB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,WAAW,GAAG,IAAA,mBAAW,EAAC,GAAG,EAAE;QACnC,mBAAmB,CAAC,CAAC,CAAC,CAAC;QACvB,SAAS,CAAC,EAAE,CAAC,CAAC;IAChB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,kBAAkB,GAAG,IAAA,mBAAW,EAAC,CAAC,KAAa,EAAE,OAAgB,EAAE,EAAE;QACzE,mBAAmB,CAAC,KAAK,CAAC,CAAC;QAC3B,OAAO,IAAI,eAAe,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,kBAAkB,EAAE,CAAC;AAClG,CAAC;AArBD,oCAqBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useCallback, useState } from \"react\";\n\ninterface UseFilteringResult {\n filter: string;\n activeMatchIndex: number;\n totalMatches: number;\n applyFilter: (filter: string) => void;\n clearFilter: () => void;\n onHighlightChanged: (index: number, matches?: number) => void;\n}\n\nexport function useFiltering(): UseFilteringResult {\n const [filter, setFilter] = useState(\"\");\n const [activeMatchIndex, setActiveMatchIndex] = useState(0);\n const [totalMatches, setTotalMatches] = useState(0);\n\n const applyFilter = useCallback((newFilter: string) => {\n setActiveMatchIndex(0);\n setFilter(newFilter);\n }, []);\n\n const clearFilter = useCallback(() => {\n setActiveMatchIndex(0);\n setFilter(\"\");\n }, []);\n\n const onHighlightChanged = useCallback((index: number, matches?: number) => {\n setActiveMatchIndex(index);\n matches && setTotalMatches(matches);\n }, []);\n\n return { filter, activeMatchIndex, totalMatches, applyFilter, clearFilter, onHighlightChanged };\n}\n"]}
@@ -2,7 +2,6 @@ import type { TreeRenderer, useTree } from "@itwin/presentation-hierarchies-reac
2
2
  type UseTreeLocalizedStrings = Parameters<typeof useTree>[0]["localizedStrings"];
3
3
  type TreeRendererLocalizedStrings = Parameters<typeof TreeRenderer>[0]["localizedStrings"];
4
4
  type UseHierarchiesLocalizationResult = UseTreeLocalizedStrings & TreeRendererLocalizedStrings;
5
- /** @internal */
6
5
  export declare function useHierarchiesLocalization(): UseHierarchiesLocalizationResult;
7
6
  export {};
8
7
  //# sourceMappingURL=UseHierarchiesLocalization.d.ts.map
@@ -7,7 +7,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.useHierarchiesLocalization = void 0;
8
8
  const react_1 = require("react");
9
9
  const TreeWidget_1 = require("../../../TreeWidget");
10
- /** @internal */
11
10
  function useHierarchiesLocalization() {
12
11
  const stringValues = Object.values(getLocalizedStrings());
13
12
  const localizedStrings = (0, react_1.useMemo)(getLocalizedStrings, stringValues);
@@ -1 +1 @@
1
- {"version":3,"file":"UseHierarchiesLocalization.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/UseHierarchiesLocalization.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,iCAAgC;AAChC,oDAAiD;AASjD,gBAAgB;AAChB,SAAgB,0BAA0B;IACxC,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,mBAAmB,EAAG,CAAC,CAAC;IAC3D,MAAM,gBAAgB,GAAG,IAAA,eAAO,EAAC,mBAAmB,EAAE,YAAY,CAAC,CAAC;IACpE,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAJD,gEAIC;AAED,SAAS,mBAAmB;IAC1B,OAAO;QACL,iDAAiD;QACjD,WAAW,EAAE,uBAAU,CAAC,SAAS,CAAC,sCAAsC,CAAC;QACzE,KAAK,EAAE,uBAAU,CAAC,SAAS,CAAC,gCAAgC,CAAC;QAE7D,oDAAoD;QACpD,OAAO,EAAE,uBAAU,CAAC,SAAS,CAAC,kCAAkC,CAAC;QACjE,oBAAoB,EAAE,uBAAU,CAAC,SAAS,CAAC,+CAA+C,CAAC;QAC3F,yBAAyB,EAAE,uBAAU,CAAC,SAAS,CAAC,oDAAoD,CAAC;QACrG,kBAAkB,EAAE,uBAAU,CAAC,SAAS,CAAC,6CAA6C,CAAC;QACvF,mBAAmB,EAAE,uBAAU,CAAC,SAAS,CAAC,8CAA8C,CAAC;QACzF,gCAAgC,EAAE,uBAAU,CAAC,SAAS,CAAC,2DAA2D,CAAC;QACnH,sBAAsB,EAAE,uBAAU,CAAC,SAAS,CAAC,iDAAiD,CAAC;QAC/F,mCAAmC,EAAE,uBAAU,CAAC,SAAS,CAAC,8DAA8D,CAAC;QACzH,KAAK,EAAE,uBAAU,CAAC,SAAS,CAAC,gCAAgC,CAAC;KAC9D,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useMemo } from \"react\";\nimport { TreeWidget } from \"../../../TreeWidget\";\n\nimport type { TreeRenderer, useTree } from \"@itwin/presentation-hierarchies-react\";\n\ntype UseTreeLocalizedStrings = Parameters<typeof useTree>[0][\"localizedStrings\"];\ntype TreeRendererLocalizedStrings = Parameters<typeof TreeRenderer>[0][\"localizedStrings\"];\n\ntype UseHierarchiesLocalizationResult = UseTreeLocalizedStrings & TreeRendererLocalizedStrings;\n\n/** @internal */\nexport function useHierarchiesLocalization(): UseHierarchiesLocalizationResult {\n const stringValues = Object.values(getLocalizedStrings()!);\n const localizedStrings = useMemo(getLocalizedStrings, stringValues);\n return localizedStrings;\n}\n\nfunction getLocalizedStrings(): UseHierarchiesLocalizationResult {\n return {\n // strings for the `useUnifiedSelectionTree` hook\n unspecified: TreeWidget.translate(\"presentation-hierarchies.unspecified\"),\n other: TreeWidget.translate(\"presentation-hierarchies.other\"),\n\n // strings for `TreeRenderer` and `TreeNodeRenderer`\n loading: TreeWidget.translate(\"presentation-hierarchies.loading\"),\n filterHierarchyLevel: TreeWidget.translate(\"presentation-hierarchies.filterHierarchyLevel\"),\n clearHierarchyLevelFilter: TreeWidget.translate(\"presentation-hierarchies.clearHierarchyLevelFilter\"),\n noFilteredChildren: TreeWidget.translate(\"presentation-hierarchies.noFilteredChildren\"),\n resultLimitExceeded: TreeWidget.translate(\"presentation-hierarchies.resultLimitExceeded\"),\n resultLimitExceededWithFiltering: TreeWidget.translate(\"presentation-hierarchies.resultLimitExceededWithFiltering\"),\n increaseHierarchyLimit: TreeWidget.translate(\"presentation-hierarchies.increaseHierarchyLimit\"),\n increaseHierarchyLimitWithFiltering: TreeWidget.translate(\"presentation-hierarchies.increaseHierarchyLimitWithFiltering\"),\n retry: TreeWidget.translate(\"presentation-hierarchies.retry\"),\n };\n}\n"]}
1
+ {"version":3,"file":"UseHierarchiesLocalization.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/UseHierarchiesLocalization.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,iCAAgC;AAChC,oDAAiD;AASjD,SAAgB,0BAA0B;IACxC,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,mBAAmB,EAAG,CAAC,CAAC;IAC3D,MAAM,gBAAgB,GAAG,IAAA,eAAO,EAAC,mBAAmB,EAAE,YAAY,CAAC,CAAC;IACpE,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAJD,gEAIC;AAED,SAAS,mBAAmB;IAC1B,OAAO;QACL,iDAAiD;QACjD,WAAW,EAAE,uBAAU,CAAC,SAAS,CAAC,sCAAsC,CAAC;QACzE,KAAK,EAAE,uBAAU,CAAC,SAAS,CAAC,gCAAgC,CAAC;QAE7D,oDAAoD;QACpD,OAAO,EAAE,uBAAU,CAAC,SAAS,CAAC,kCAAkC,CAAC;QACjE,oBAAoB,EAAE,uBAAU,CAAC,SAAS,CAAC,+CAA+C,CAAC;QAC3F,yBAAyB,EAAE,uBAAU,CAAC,SAAS,CAAC,oDAAoD,CAAC;QACrG,kBAAkB,EAAE,uBAAU,CAAC,SAAS,CAAC,6CAA6C,CAAC;QACvF,mBAAmB,EAAE,uBAAU,CAAC,SAAS,CAAC,8CAA8C,CAAC;QACzF,gCAAgC,EAAE,uBAAU,CAAC,SAAS,CAAC,2DAA2D,CAAC;QACnH,sBAAsB,EAAE,uBAAU,CAAC,SAAS,CAAC,iDAAiD,CAAC;QAC/F,mCAAmC,EAAE,uBAAU,CAAC,SAAS,CAAC,8DAA8D,CAAC;QACzH,KAAK,EAAE,uBAAU,CAAC,SAAS,CAAC,gCAAgC,CAAC;KAC9D,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useMemo } from \"react\";\nimport { TreeWidget } from \"../../../TreeWidget\";\n\nimport type { TreeRenderer, useTree } from \"@itwin/presentation-hierarchies-react\";\n\ntype UseTreeLocalizedStrings = Parameters<typeof useTree>[0][\"localizedStrings\"];\ntype TreeRendererLocalizedStrings = Parameters<typeof TreeRenderer>[0][\"localizedStrings\"];\n\ntype UseHierarchiesLocalizationResult = UseTreeLocalizedStrings & TreeRendererLocalizedStrings;\n\nexport function useHierarchiesLocalization(): UseHierarchiesLocalizationResult {\n const stringValues = Object.values(getLocalizedStrings()!);\n const localizedStrings = useMemo(getLocalizedStrings, stringValues);\n return localizedStrings;\n}\n\nfunction getLocalizedStrings(): UseHierarchiesLocalizationResult {\n return {\n // strings for the `useUnifiedSelectionTree` hook\n unspecified: TreeWidget.translate(\"presentation-hierarchies.unspecified\"),\n other: TreeWidget.translate(\"presentation-hierarchies.other\"),\n\n // strings for `TreeRenderer` and `TreeNodeRenderer`\n loading: TreeWidget.translate(\"presentation-hierarchies.loading\"),\n filterHierarchyLevel: TreeWidget.translate(\"presentation-hierarchies.filterHierarchyLevel\"),\n clearHierarchyLevelFilter: TreeWidget.translate(\"presentation-hierarchies.clearHierarchyLevelFilter\"),\n noFilteredChildren: TreeWidget.translate(\"presentation-hierarchies.noFilteredChildren\"),\n resultLimitExceeded: TreeWidget.translate(\"presentation-hierarchies.resultLimitExceeded\"),\n resultLimitExceededWithFiltering: TreeWidget.translate(\"presentation-hierarchies.resultLimitExceededWithFiltering\"),\n increaseHierarchyLimit: TreeWidget.translate(\"presentation-hierarchies.increaseHierarchyLimit\"),\n increaseHierarchyLimitWithFiltering: TreeWidget.translate(\"presentation-hierarchies.increaseHierarchyLimitWithFiltering\"),\n retry: TreeWidget.translate(\"presentation-hierarchies.retry\"),\n };\n}\n"]}
@@ -1,17 +1,11 @@
1
1
  /// <reference types="react" />
2
2
  import type { IModelConnection } from "@itwin/core-frontend";
3
3
  import type { HierarchyLevelDetails } from "@itwin/presentation-hierarchies-react";
4
- import type { UsageTrackedFeatures } from "./UseFeatureReporting";
5
4
  interface UseHierarchyLevelFilteringProps {
6
5
  imodel: IModelConnection;
7
6
  defaultHierarchyLevelSizeLimit: number;
8
- reportUsage?: (props: {
9
- featureId?: UsageTrackedFeatures;
10
- reportInteraction: true;
11
- }) => void;
12
7
  }
13
- /** @internal */
14
- export declare function useHierarchyLevelFiltering({ imodel, defaultHierarchyLevelSizeLimit, reportUsage }: UseHierarchyLevelFilteringProps): {
8
+ export declare function useHierarchyLevelFiltering({ imodel, defaultHierarchyLevelSizeLimit }: UseHierarchyLevelFilteringProps): {
15
9
  onFilterClick: import("react").Dispatch<import("react").SetStateAction<HierarchyLevelDetails | undefined>>;
16
10
  filteringDialog: JSX.Element;
17
11
  };
@@ -16,9 +16,10 @@ const presentation_frontend_1 = require("@itwin/presentation-frontend");
16
16
  const presentation_hierarchies_1 = require("@itwin/presentation-hierarchies");
17
17
  const TreeWidget_1 = require("../../../TreeWidget");
18
18
  const Delayed_1 = require("./components/Delayed");
19
- /** @internal */
20
- function useHierarchyLevelFiltering({ imodel, defaultHierarchyLevelSizeLimit, reportUsage }) {
19
+ const UseTelemetryContext_1 = require("./UseTelemetryContext");
20
+ function useHierarchyLevelFiltering({ imodel, defaultHierarchyLevelSizeLimit }) {
21
21
  const [filteringOptions, setFilteringOptions] = (0, react_1.useState)();
22
+ const { onFeatureUsed } = (0, UseTelemetryContext_1.useTelemetryContext)();
22
23
  const propertiesSource = (0, react_1.useMemo)(() => {
23
24
  if (!filteringOptions) {
24
25
  return undefined;
@@ -63,7 +64,7 @@ function useHierarchyLevelFiltering({ imodel, defaultHierarchyLevelSizeLimit, re
63
64
  if (!filteringOptions) {
64
65
  return;
65
66
  }
66
- reportUsage?.({ featureId: info ? "hierarchy-level-filtering" : undefined, reportInteraction: true });
67
+ onFeatureUsed({ featureId: info ? "hierarchy-level-filtering" : undefined, reportInteraction: true });
67
68
  filteringOptions.setInstanceFilter(toGenericFilter(info));
68
69
  setFilteringOptions(undefined);
69
70
  }, onClose: () => {