@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
@@ -2,4 +2,15 @@ export { ModelsTreeComponent } from "./models-tree/ModelsTreeComponent";
2
2
  export { CategoriesTreeComponent } from "./categories-tree/CategoriesTreeComponent";
3
3
  export { IModelContentTreeComponent } from "./imodel-content-tree/IModelContentTreeComponent";
4
4
  export { ExternalSourcesTreeComponent } from "./external-sources-tree/ExternalSourcesTreeComponent";
5
+ export { useModelsTree } from "./models-tree/UseModelsTree";
6
+ export { useCategoriesTree } from "./categories-tree/UseCategoriesTree";
7
+ export { useModelsTreeButtonProps } from "./models-tree/ModelsTreeButtons";
8
+ export { useCategoriesTreeButtonProps } from "./categories-tree/CategoriesTreeButtons";
9
+ export { Tree } from "./common/components/Tree";
10
+ export { VisibilityTree } from "./common/components/VisibilityTree";
11
+ export { TreeRenderer } from "./common/components/TreeRenderer";
12
+ export { VisibilityTreeRenderer } from "./common/components/VisibilityTreeRenderer";
13
+ export { HierarchyVisibilityHandler, VisibilityStatus } from "./common/UseHierarchyVisibility";
14
+ export { TelemetryContextProvider } from "./common/UseTelemetryContext";
15
+ export { ModelsTreeVisibilityHandlerOverrides } from "./models-tree/internal/ModelsTreeVisibilityHandler";
5
16
  //# sourceMappingURL=index.d.ts.map
@@ -4,7 +4,7 @@
4
4
  * See LICENSE.md in the project root for license terms and full copyright notice.
5
5
  *--------------------------------------------------------------------------------------------*/
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.ExternalSourcesTreeComponent = exports.IModelContentTreeComponent = exports.CategoriesTreeComponent = exports.ModelsTreeComponent = void 0;
7
+ exports.TelemetryContextProvider = exports.VisibilityTreeRenderer = exports.TreeRenderer = exports.VisibilityTree = exports.Tree = exports.useCategoriesTreeButtonProps = exports.useModelsTreeButtonProps = exports.useCategoriesTree = exports.useModelsTree = exports.ExternalSourcesTreeComponent = exports.IModelContentTreeComponent = exports.CategoriesTreeComponent = exports.ModelsTreeComponent = void 0;
8
8
  var ModelsTreeComponent_1 = require("./models-tree/ModelsTreeComponent");
9
9
  Object.defineProperty(exports, "ModelsTreeComponent", { enumerable: true, get: function () { return ModelsTreeComponent_1.ModelsTreeComponent; } });
10
10
  var CategoriesTreeComponent_1 = require("./categories-tree/CategoriesTreeComponent");
@@ -13,4 +13,22 @@ var IModelContentTreeComponent_1 = require("./imodel-content-tree/IModelContentT
13
13
  Object.defineProperty(exports, "IModelContentTreeComponent", { enumerable: true, get: function () { return IModelContentTreeComponent_1.IModelContentTreeComponent; } });
14
14
  var ExternalSourcesTreeComponent_1 = require("./external-sources-tree/ExternalSourcesTreeComponent");
15
15
  Object.defineProperty(exports, "ExternalSourcesTreeComponent", { enumerable: true, get: function () { return ExternalSourcesTreeComponent_1.ExternalSourcesTreeComponent; } });
16
+ var UseModelsTree_1 = require("./models-tree/UseModelsTree");
17
+ Object.defineProperty(exports, "useModelsTree", { enumerable: true, get: function () { return UseModelsTree_1.useModelsTree; } });
18
+ var UseCategoriesTree_1 = require("./categories-tree/UseCategoriesTree");
19
+ Object.defineProperty(exports, "useCategoriesTree", { enumerable: true, get: function () { return UseCategoriesTree_1.useCategoriesTree; } });
20
+ var ModelsTreeButtons_1 = require("./models-tree/ModelsTreeButtons");
21
+ Object.defineProperty(exports, "useModelsTreeButtonProps", { enumerable: true, get: function () { return ModelsTreeButtons_1.useModelsTreeButtonProps; } });
22
+ var CategoriesTreeButtons_1 = require("./categories-tree/CategoriesTreeButtons");
23
+ Object.defineProperty(exports, "useCategoriesTreeButtonProps", { enumerable: true, get: function () { return CategoriesTreeButtons_1.useCategoriesTreeButtonProps; } });
24
+ var Tree_1 = require("./common/components/Tree");
25
+ Object.defineProperty(exports, "Tree", { enumerable: true, get: function () { return Tree_1.Tree; } });
26
+ var VisibilityTree_1 = require("./common/components/VisibilityTree");
27
+ Object.defineProperty(exports, "VisibilityTree", { enumerable: true, get: function () { return VisibilityTree_1.VisibilityTree; } });
28
+ var TreeRenderer_1 = require("./common/components/TreeRenderer");
29
+ Object.defineProperty(exports, "TreeRenderer", { enumerable: true, get: function () { return TreeRenderer_1.TreeRenderer; } });
30
+ var VisibilityTreeRenderer_1 = require("./common/components/VisibilityTreeRenderer");
31
+ Object.defineProperty(exports, "VisibilityTreeRenderer", { enumerable: true, get: function () { return VisibilityTreeRenderer_1.VisibilityTreeRenderer; } });
32
+ var UseTelemetryContext_1 = require("./common/UseTelemetryContext");
33
+ Object.defineProperty(exports, "TelemetryContextProvider", { enumerable: true, get: function () { return UseTelemetryContext_1.TelemetryContextProvider; } });
16
34
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/trees/index.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,yEAAwE;AAA/D,0HAAA,mBAAmB,OAAA;AAC5B,qFAAoF;AAA3E,kIAAA,uBAAuB,OAAA;AAChC,+FAA8F;AAArF,wIAAA,0BAA0B,OAAA;AACnC,qGAAoG;AAA3F,4IAAA,4BAA4B,OAAA","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\nexport { ModelsTreeComponent } from \"./models-tree/ModelsTreeComponent\";\nexport { CategoriesTreeComponent } from \"./categories-tree/CategoriesTreeComponent\";\nexport { IModelContentTreeComponent } from \"./imodel-content-tree/IModelContentTreeComponent\";\nexport { ExternalSourcesTreeComponent } from \"./external-sources-tree/ExternalSourcesTreeComponent\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/trees/index.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,yEAAwE;AAA/D,0HAAA,mBAAmB,OAAA;AAC5B,qFAAoF;AAA3E,kIAAA,uBAAuB,OAAA;AAChC,+FAA8F;AAArF,wIAAA,0BAA0B,OAAA;AACnC,qGAAoG;AAA3F,4IAAA,4BAA4B,OAAA;AAErC,6DAA4D;AAAnD,8GAAA,aAAa,OAAA;AACtB,yEAAwE;AAA/D,sHAAA,iBAAiB,OAAA;AAE1B,qEAA2E;AAAlE,6HAAA,wBAAwB,OAAA;AACjC,iFAAuF;AAA9E,qIAAA,4BAA4B,OAAA;AAErC,iDAAgD;AAAvC,4FAAA,IAAI,OAAA;AACb,qEAAoE;AAA3D,gHAAA,cAAc,OAAA;AACvB,iEAAgE;AAAvD,4GAAA,YAAY,OAAA;AACrB,qFAAoF;AAA3E,gIAAA,sBAAsB,OAAA;AAE/B,oEAAwE;AAA/D,+HAAA,wBAAwB,OAAA","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\nexport { ModelsTreeComponent } from \"./models-tree/ModelsTreeComponent\";\nexport { CategoriesTreeComponent } from \"./categories-tree/CategoriesTreeComponent\";\nexport { IModelContentTreeComponent } from \"./imodel-content-tree/IModelContentTreeComponent\";\nexport { ExternalSourcesTreeComponent } from \"./external-sources-tree/ExternalSourcesTreeComponent\";\n\nexport { useModelsTree } from \"./models-tree/UseModelsTree\";\nexport { useCategoriesTree } from \"./categories-tree/UseCategoriesTree\";\n\nexport { useModelsTreeButtonProps } from \"./models-tree/ModelsTreeButtons\";\nexport { useCategoriesTreeButtonProps } from \"./categories-tree/CategoriesTreeButtons\";\n\nexport { Tree } from \"./common/components/Tree\";\nexport { VisibilityTree } from \"./common/components/VisibilityTree\";\nexport { TreeRenderer } from \"./common/components/TreeRenderer\";\nexport { VisibilityTreeRenderer } from \"./common/components/VisibilityTreeRenderer\";\nexport { HierarchyVisibilityHandler, VisibilityStatus } from \"./common/UseHierarchyVisibility\";\nexport { TelemetryContextProvider } from \"./common/UseTelemetryContext\";\n\nexport { ModelsTreeVisibilityHandlerOverrides } from \"./models-tree/internal/ModelsTreeVisibilityHandler\";\n"]}
@@ -1,22 +1,23 @@
1
1
  import { VisibilityTree } from "../common/components/VisibilityTree";
2
- import { ModelsTreeDefinition } from "./ModelsTreeDefinition";
3
2
  import type { ComponentPropsWithoutRef } from "react";
4
3
  import type { Viewport } from "@itwin/core-frontend";
4
+ import type { ModelsTreeVisibilityHandlerOverrides } from "./internal/ModelsTreeVisibilityHandler";
5
+ import type { ModelsTreeHierarchyConfiguration } from "./ModelsTreeDefinition";
6
+ /** @beta */
5
7
  interface ModelsTreeOwnProps {
6
8
  activeView: Viewport;
7
9
  hierarchyLevelConfig?: {
8
10
  sizeLimit?: number;
9
11
  };
12
+ hierarchyConfig?: Partial<ModelsTreeHierarchyConfiguration>;
13
+ visibilityHandlerOverrides?: ModelsTreeVisibilityHandlerOverrides;
10
14
  filter?: string;
11
- onPerformanceMeasured?: (featureId: string, duration: number) => void;
12
- onFeatureUsed?: (feature: string) => void;
13
15
  }
16
+ /** @beta */
14
17
  type VisibilityTreeProps = ComponentPropsWithoutRef<typeof VisibilityTree>;
15
- type ModelsTreeHierarchyConfiguration = ConstructorParameters<typeof ModelsTreeDefinition>[0]["hierarchyConfig"];
16
- type ModelsTreeProps = ModelsTreeOwnProps & Pick<VisibilityTreeProps, "imodel" | "getSchemaContext" | "height" | "width" | "density" | "selectionMode"> & {
17
- hierarchyConfig?: Partial<ModelsTreeHierarchyConfiguration>;
18
- };
19
- /** @internal */
20
- export declare function ModelsTree({ imodel, getSchemaContext, height, width, activeView, filter, density, hierarchyLevelConfig, hierarchyConfig, selectionMode, onPerformanceMeasured, onFeatureUsed, }: ModelsTreeProps): JSX.Element;
18
+ /** @beta */
19
+ type ModelsTreeProps = ModelsTreeOwnProps & Pick<VisibilityTreeProps, "imodel" | "getSchemaContext" | "selectionStorage" | "density" | "selectionMode">;
20
+ /** @beta */
21
+ export declare function ModelsTree({ imodel, getSchemaContext, selectionStorage, activeView, filter, density, hierarchyLevelConfig, hierarchyConfig, selectionMode, visibilityHandlerOverrides, }: ModelsTreeProps): JSX.Element;
21
22
  export {};
22
23
  //# sourceMappingURL=ModelsTree.d.ts.map
@@ -6,213 +6,13 @@ const jsx_runtime_1 = require("react/jsx-runtime");
6
6
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
7
7
  * See LICENSE.md in the project root for license terms and full copyright notice.
8
8
  *--------------------------------------------------------------------------------------------*/
9
- const react_1 = require("react");
10
- const core_frontend_1 = require("@itwin/core-frontend");
11
- const itwinui_icons_react_1 = require("@itwin/itwinui-icons-react");
12
- const itwinui_react_1 = require("@itwin/itwinui-react");
13
- const presentation_core_interop_1 = require("@itwin/presentation-core-interop");
14
- const presentation_hierarchies_1 = require("@itwin/presentation-hierarchies");
15
- const TreeWidget_1 = require("../../../TreeWidget");
16
9
  const VisibilityTree_1 = require("../common/components/VisibilityTree");
17
- const FocusedInstancesContext_1 = require("../common/FocusedInstancesContext");
18
- const UseFeatureReporting_1 = require("../common/UseFeatureReporting");
19
- const UseIModelChangeListener_1 = require("../common/UseIModelChangeListener");
20
- const ModelsTreeIdsCache_1 = require("./internal/ModelsTreeIdsCache");
21
- const ModelsTreeVisibilityHandler_1 = require("./internal/ModelsTreeVisibilityHandler");
22
- const ModelsTreeComponent_1 = require("./ModelsTreeComponent");
23
- const ModelsTreeDefinition_1 = require("./ModelsTreeDefinition");
24
- /** @internal */
25
- function ModelsTree({ imodel, getSchemaContext, height, width, activeView, filter, density, hierarchyLevelConfig, hierarchyConfig, selectionMode, onPerformanceMeasured, onFeatureUsed, }) {
26
- const [filteringError, setFilteringError] = (0, react_1.useState)(undefined);
27
- const hierarchyConfiguration = (0, react_1.useMemo)(() => ({
28
- ...ModelsTreeDefinition_1.defaultHierarchyConfiguration,
29
- ...hierarchyConfig,
30
- }),
31
- // eslint-disable-next-line react-hooks/exhaustive-deps
32
- Object.values(hierarchyConfig ?? {}));
33
- const { getModelsTreeIdsCache, visibilityHandlerFactory } = useCachedVisibility(activeView, hierarchyConfiguration);
34
- const { loadInstanceKeys: loadFocusedInstancesKeys } = (0, FocusedInstancesContext_1.useFocusedInstancesContext)();
35
- const { reportUsage } = (0, UseFeatureReporting_1.useFeatureReporting)({ onFeatureUsed, treeIdentifier: ModelsTreeComponent_1.ModelsTreeComponent.id });
36
- const getHierarchyDefinition = (0, react_1.useCallback)(({ imodelAccess }) => new ModelsTreeDefinition_1.ModelsTreeDefinition({ imodelAccess, idsCache: getModelsTreeIdsCache(), hierarchyConfig: hierarchyConfiguration }), [getModelsTreeIdsCache, hierarchyConfiguration]);
37
- const onNodeDoubleClick = (0, react_1.useCallback)(async ({ nodeData, extendedData }) => {
38
- if (!presentation_hierarchies_1.HierarchyNode.isInstancesNode(nodeData) || (extendedData && (extendedData.isSubject || extendedData.isModel || extendedData.isCategory))) {
39
- return;
40
- }
41
- const instanceIds = nodeData.key.instanceKeys.map((instanceKey) => instanceKey.id);
42
- await core_frontend_1.IModelApp.viewManager.selectedView?.zoomToElements(instanceIds);
43
- reportUsage({ featureId: "zoom-to-node", reportInteraction: false });
44
- }, [reportUsage]);
45
- const getFocusedFilteredPaths = (0, react_1.useMemo)(() => {
46
- setFilteringError(undefined);
47
- if (!loadFocusedInstancesKeys) {
48
- return undefined;
49
- }
50
- return async ({ imodelAccess }) => {
51
- try {
52
- const targetKeys = await collectTargetKeys(loadFocusedInstancesKeys);
53
- return await ModelsTreeDefinition_1.ModelsTreeDefinition.createInstanceKeyPaths({
54
- imodelAccess,
55
- idsCache: getModelsTreeIdsCache(),
56
- keys: targetKeys,
57
- hierarchyConfig: hierarchyConfiguration,
58
- });
59
- }
60
- catch (e) {
61
- const newError = e instanceof Error && e.message.match(/Filter matches more than \d+ items/) ? "tooManyInstancesFocused" : "unknownInstanceFocusError";
62
- setFilteringError(newError);
63
- return [];
64
- }
65
- };
66
- }, [loadFocusedInstancesKeys, getModelsTreeIdsCache, hierarchyConfiguration]);
67
- const getSearchFilteredPaths = (0, react_1.useMemo)(() => {
68
- setFilteringError(undefined);
69
- if (!filter) {
70
- return undefined;
71
- }
72
- return async ({ imodelAccess }) => {
73
- reportUsage?.({ featureId: "filtering", reportInteraction: true });
74
- try {
75
- return await ModelsTreeDefinition_1.ModelsTreeDefinition.createInstanceKeyPaths({
76
- imodelAccess,
77
- label: filter,
78
- idsCache: getModelsTreeIdsCache(),
79
- hierarchyConfig: hierarchyConfiguration,
80
- });
81
- }
82
- catch (e) {
83
- const newError = e instanceof Error && e.message.match(/Filter matches more than \d+ items/) ? "tooManyFilterMatches" : "unknownFilterError";
84
- setFilteringError(newError);
85
- return [];
86
- }
87
- };
88
- }, [filter, getModelsTreeIdsCache, reportUsage, hierarchyConfiguration]);
89
- const getFilteredPaths = getFocusedFilteredPaths ?? getSearchFilteredPaths;
90
- return ((0, jsx_runtime_1.jsx)(VisibilityTree_1.VisibilityTree, { height: height, width: width, imodel: imodel, treeName: ModelsTreeComponent_1.ModelsTreeComponent.id, getSchemaContext: getSchemaContext, visibilityHandlerFactory: visibilityHandlerFactory, getHierarchyDefinition: getHierarchyDefinition, getFilteredPaths: getFilteredPaths, hierarchyLevelSizeLimit: hierarchyLevelConfig?.sizeLimit, getIcon: getIcon, density: density, noDataMessage: getNoDataMessage(filter, filteringError), selectionMode: selectionMode, onPerformanceMeasured: (action, duration) => {
91
- onPerformanceMeasured?.(`${ModelsTreeComponent_1.ModelsTreeComponent.id}-${action}`, duration);
92
- }, reportUsage: reportUsage, onNodeDoubleClick: onNodeDoubleClick, searchText: filter }));
10
+ const VisibilityTreeRenderer_1 = require("../common/components/VisibilityTreeRenderer");
11
+ const UseModelsTree_1 = require("./UseModelsTree");
12
+ /** @beta */
13
+ function ModelsTree({ imodel, getSchemaContext, selectionStorage, activeView, filter, density, hierarchyLevelConfig, hierarchyConfig, selectionMode, visibilityHandlerOverrides, }) {
14
+ const { modelsTreeProps, rendererProps } = (0, UseModelsTree_1.useModelsTree)({ activeView, filter, hierarchyConfig, visibilityHandlerOverrides });
15
+ return ((0, jsx_runtime_1.jsx)(VisibilityTree_1.VisibilityTree, { ...modelsTreeProps, imodel: imodel, selectionStorage: selectionStorage, getSchemaContext: getSchemaContext, hierarchyLevelSizeLimit: hierarchyLevelConfig?.sizeLimit, density: density, selectionMode: selectionMode, treeRenderer: (treeProps) => (0, jsx_runtime_1.jsx)(VisibilityTreeRenderer_1.VisibilityTreeRenderer, { ...treeProps, ...rendererProps }) }));
93
16
  }
94
17
  exports.ModelsTree = ModelsTree;
95
- function getNoDataMessage(filter, error) {
96
- if (isInstanceFocusError(error)) {
97
- return (0, jsx_runtime_1.jsx)(InstanceFocusError, { error: error });
98
- }
99
- if (isFilterError(error)) {
100
- return (0, jsx_runtime_1.jsx)(itwinui_react_1.Text, { children: TreeWidget_1.TreeWidget.translate(`modelsTree.filtering.${error}`) });
101
- }
102
- if (filter) {
103
- return (0, jsx_runtime_1.jsx)(itwinui_react_1.Text, { children: TreeWidget_1.TreeWidget.translate("modelsTree.filtering.noMatches", { filter }) });
104
- }
105
- return undefined;
106
- }
107
- function isFilterError(error) {
108
- return error === "tooManyFilterMatches" || error === "unknownFilterError";
109
- }
110
- function isInstanceFocusError(error) {
111
- return error === "tooManyInstancesFocused" || error === "unknownInstanceFocusError";
112
- }
113
- function InstanceFocusError({ error }) {
114
- const { toggle } = (0, FocusedInstancesContext_1.useFocusedInstancesContext)();
115
- const localizedMessage = createLocalizedMessage(TreeWidget_1.TreeWidget.translate(`modelsTree.filtering.${error}`), () => toggle());
116
- return (0, jsx_runtime_1.jsx)(itwinui_react_1.Text, { children: localizedMessage });
117
- }
118
- function getIcon(node) {
119
- if (node.extendedData?.imageId === undefined) {
120
- return undefined;
121
- }
122
- switch (node.extendedData.imageId) {
123
- case "icon-layers":
124
- return (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgLayers, {});
125
- case "icon-item":
126
- return (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgItem, {});
127
- case "icon-ec-class":
128
- return (0, jsx_runtime_1.jsx)(SvgClassGrouping, {});
129
- case "icon-imodel-hollow-2":
130
- return (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgImodelHollow, {});
131
- case "icon-folder":
132
- return (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgFolder, {});
133
- case "icon-model":
134
- return (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgModel, {});
135
- }
136
- return undefined;
137
- }
138
- function createVisibilityHandlerFactory(activeView, idsCacheGetter) {
139
- return (imodelAccess) => (0, ModelsTreeVisibilityHandler_1.createModelsTreeVisibilityHandler)({ viewport: activeView, idsCache: idsCacheGetter(), imodelAccess });
140
- }
141
- function useCachedVisibility(activeView, hierarchyConfig) {
142
- const cacheRef = (0, react_1.useRef)();
143
- const currentIModelRef = (0, react_1.useRef)(activeView.iModel);
144
- const getModelsTreeIdsCache = (0, react_1.useCallback)(() => {
145
- if (!cacheRef.current) {
146
- cacheRef.current = new ModelsTreeIdsCache_1.ModelsTreeIdsCache((0, presentation_core_interop_1.createECSqlQueryExecutor)(currentIModelRef.current), hierarchyConfig);
147
- }
148
- return cacheRef.current;
149
- }, [hierarchyConfig]);
150
- const [visibilityHandlerFactory, setVisibilityHandlerFactory] = (0, react_1.useState)(() => createVisibilityHandlerFactory(activeView, getModelsTreeIdsCache));
151
- (0, UseIModelChangeListener_1.useIModelChangeListener)({
152
- imodel: activeView.iModel,
153
- action: (0, react_1.useCallback)(() => {
154
- cacheRef.current = undefined;
155
- setVisibilityHandlerFactory(() => createVisibilityHandlerFactory(activeView, getModelsTreeIdsCache));
156
- }, [activeView, getModelsTreeIdsCache]),
157
- });
158
- (0, react_1.useEffect)(() => {
159
- currentIModelRef.current = activeView.iModel;
160
- cacheRef.current = undefined;
161
- setVisibilityHandlerFactory(() => createVisibilityHandlerFactory(activeView, getModelsTreeIdsCache));
162
- }, [activeView, getModelsTreeIdsCache]);
163
- return {
164
- getModelsTreeIdsCache,
165
- visibilityHandlerFactory,
166
- };
167
- }
168
- function SvgClassGrouping() {
169
- return ((0, jsx_runtime_1.jsx)(itwinui_react_1.Icon, { children: (0, jsx_runtime_1.jsx)("svg", { id: "Calque_1", "data-name": "Calque 1", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 16 16", children: (0, jsx_runtime_1.jsx)("path", { d: "M8.00933,0,0,3.97672V11.986L8.00933,16,16,11.93V3.97651ZM1.66173,11.27642c-.26155.03734-.59754-.26154-.76553-.69085-.168-.41066-.09334-.784.168-.82152.26154-.03734.59754.26154.76553.67219C1.99772,10.86577,1.92306,11.23909,1.66173,11.27642Zm0-3.32319c-.26155.03733-.59754-.28-.76553-.69086-.168-.42932-.09334-.80285.168-.84.26133-.03733.59754.28.76532.69086C1.99772,7.54236,1.92306,7.89723,1.66173,7.95323Zm4.31276,5.52621a.18186.18186,0,0,1-.16821-.01866L3.41657,12.15394a.94275.94275,0,0,1-.29887-.80285c.03754-.33621.22421-.52265.41108-.41066L5.9185,12.24727a.88656.88656,0,0,1,.28.80285A.5057.5057,0,0,1,5.97449,13.47944Zm0-3.37919a.18184.18184,0,0,1-.16821-.01867L3.41657,8.77475a.943.943,0,0,1-.29887-.80286c.03754-.3362.22421-.52286.41108-.42953L5.9185,8.86786a.83112.83112,0,0,1,.28.78419A.51684.51684,0,0,1,5.97449,10.10025Z" }) }) }));
170
- }
171
- async function collectTargetKeys(loadFocusedInstancesKeys) {
172
- const targetKeys = [];
173
- const groupingNodeInfos = [];
174
- for await (const key of loadFocusedInstancesKeys()) {
175
- if ("id" in key) {
176
- targetKeys.push(key);
177
- continue;
178
- }
179
- if (!presentation_hierarchies_1.HierarchyNodeKey.isClassGrouping(key.key)) {
180
- targetKeys.push(...key.groupedInstanceKeys);
181
- continue;
182
- }
183
- if (!key.nonGroupingAncestor || !presentation_hierarchies_1.HierarchyNodeKey.isInstances(key.nonGroupingAncestor.key)) {
184
- continue;
185
- }
186
- const parentKey = key.nonGroupingAncestor.key;
187
- const type = key.nonGroupingAncestor.extendedData?.isCategory ? "category" : "element";
188
- const modelIds = (key.nonGroupingAncestor.extendedData?.modelIds ?? []).flatMap((ids) => ids);
189
- const groupInfo = groupingNodeInfos.find((group) => presentation_hierarchies_1.HierarchyNodeKey.equals(group.parentKey, parentKey));
190
- if (groupInfo) {
191
- groupInfo.classes.push(key.key.className);
192
- }
193
- else {
194
- groupingNodeInfos.push({ classes: [key.key.className], parentType: type, parentKey, modelIds });
195
- }
196
- }
197
- targetKeys.push(...groupingNodeInfos.map(({ parentKey, parentType, classes, modelIds }) => ({
198
- parent: parentType === "element"
199
- ? { type: "element", ids: parentKey.instanceKeys.map((key) => key.id) }
200
- : { type: "category", ids: parentKey.instanceKeys.map((key) => key.id), modelIds },
201
- classes,
202
- })));
203
- return targetKeys;
204
- }
205
- function createLocalizedMessage(message, onClick) {
206
- const exp = new RegExp("<link>(.*)</link>");
207
- const match = message.match(exp);
208
- if (!match) {
209
- return message;
210
- }
211
- const [fullText, innerText] = match;
212
- const [textBefore, textAfter] = message.split(fullText);
213
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [textBefore ? textBefore : null, (0, jsx_runtime_1.jsx)(itwinui_react_1.Anchor, { underline: true, onClick: (e) => {
214
- e.stopPropagation();
215
- onClick?.();
216
- }, children: innerText }), textAfter ? textAfter : null] }));
217
- }
218
18
  //# sourceMappingURL=ModelsTree.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ModelsTree.js","sourceRoot":"","sources":["../../../../../src/components/trees/models-tree/ModelsTree.tsx"],"names":[],"mappings":";;;;AAAA;;;gGAGgG;AAEhG,iCAA0E;AAC1E,wDAAiD;AACjD,oEAAsG;AACtG,wDAA0D;AAC1D,gFAA4E;AAC5E,8EAAkF;AAClF,oDAAiD;AACjD,wEAAqE;AACrE,+EAA+E;AAC/E,uEAAoE;AACpE,+EAA4E;AAC5E,sEAAmE;AACnE,wFAA2F;AAC3F,+DAA4D;AAC5D,iEAA6F;AAgC7F,gBAAgB;AAChB,SAAgB,UAAU,CAAC,EACzB,MAAM,EACN,gBAAgB,EAChB,MAAM,EACN,KAAK,EACL,UAAU,EACV,MAAM,EACN,OAAO,EACP,oBAAoB,EACpB,eAAe,EACf,aAAa,EACb,qBAAqB,EACrB,aAAa,GACG;IAChB,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,IAAA,gBAAQ,EAAuC,SAAS,CAAC,CAAC;IACtG,MAAM,sBAAsB,GAAG,IAAA,eAAO,EACpC,GAAG,EAAE,CAAC,CAAC;QACL,GAAG,oDAA6B;QAChC,GAAG,eAAe;KACnB,CAAC;IACF,uDAAuD;IACvD,MAAM,CAAC,MAAM,CAAC,eAAe,IAAI,EAAE,CAAC,CACrC,CAAC;IAEF,MAAM,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,GAAG,mBAAmB,CAAC,UAAU,EAAE,sBAAsB,CAAC,CAAC;IACpH,MAAM,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,GAAG,IAAA,oDAA0B,GAAE,CAAC;IACpF,MAAM,EAAE,WAAW,EAAE,GAAG,IAAA,yCAAmB,EAAC,EAAE,aAAa,EAAE,cAAc,EAAE,yCAA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pB,CAAC;AAED,SAAS,sBAAsB,CAAC,OAAe,EAAE,OAAoB;IACnE,MAAM,GAAG,GAAG,IAAI,MAAM,CAAC,mBAAmB,CAAC,CAAC;IAC5C,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACjC,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,OAAO,CAAC;KAChB;IAED,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,GAAG,KAAK,CAAC;IACpC,MAAM,CAAC,UAAU,EAAE,SAAS,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAExD,OAAO,CACL,6DACG,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,EAC/B,uBAAC,sBAAM,IACL,SAAS,QACT,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;oBACb,CAAC,CAAC,eAAe,EAAE,CAAC;oBACpB,OAAO,EAAE,EAAE,CAAC;gBACd,CAAC,YAEA,SAAS,GACH,EACR,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,IAC5B,CACJ,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 { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { SvgFolder, SvgImodelHollow, SvgItem, SvgLayers, SvgModel } from \"@itwin/itwinui-icons-react\";\nimport { Anchor, Icon, Text } from \"@itwin/itwinui-react\";\nimport { createECSqlQueryExecutor } from \"@itwin/presentation-core-interop\";\nimport { HierarchyNode, HierarchyNodeKey } from \"@itwin/presentation-hierarchies\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { VisibilityTree } from \"../common/components/VisibilityTree\";\nimport { useFocusedInstancesContext } from \"../common/FocusedInstancesContext\";\nimport { useFeatureReporting } from \"../common/UseFeatureReporting\";\nimport { useIModelChangeListener } from \"../common/UseIModelChangeListener\";\nimport { ModelsTreeIdsCache } from \"./internal/ModelsTreeIdsCache\";\nimport { createModelsTreeVisibilityHandler } from \"./internal/ModelsTreeVisibilityHandler\";\nimport { ModelsTreeComponent } from \"./ModelsTreeComponent\";\nimport { defaultHierarchyConfiguration, ModelsTreeDefinition } from \"./ModelsTreeDefinition\";\n\nimport type { Id64String } from \"@itwin/core-bentley\";\nimport type { GroupingHierarchyNode, InstancesNodeKey } from \"@itwin/presentation-hierarchies\";\nimport type { ElementsGroupInfo } from \"./ModelsTreeDefinition\";\nimport type { ECClassHierarchyInspector, InstanceKey } from \"@itwin/presentation-shared\";\nimport type { ComponentPropsWithoutRef, ReactElement } from \"react\";\nimport type { Viewport } from \"@itwin/core-frontend\";\nimport type { PresentationHierarchyNode } from \"@itwin/presentation-hierarchies-react\";\n\ntype ModelsTreeFilteringError = \"tooManyFilterMatches\" | \"tooManyInstancesFocused\" | \"unknownFilterError\" | \"unknownInstanceFocusError\";\n\ninterface ModelsTreeOwnProps {\n activeView: Viewport;\n hierarchyLevelConfig?: {\n sizeLimit?: number;\n };\n filter?: string;\n onPerformanceMeasured?: (featureId: string, duration: number) => void;\n onFeatureUsed?: (feature: string) => void;\n}\n\ntype VisibilityTreeProps = ComponentPropsWithoutRef<typeof VisibilityTree>;\ntype GetFilteredPathsCallback = VisibilityTreeProps[\"getFilteredPaths\"];\ntype GetHierarchyDefinitionCallback = VisibilityTreeProps[\"getHierarchyDefinition\"];\ntype ModelsTreeHierarchyConfiguration = ConstructorParameters<typeof ModelsTreeDefinition>[0][\"hierarchyConfig\"];\n\ntype ModelsTreeProps = ModelsTreeOwnProps &\n Pick<VisibilityTreeProps, \"imodel\" | \"getSchemaContext\" | \"height\" | \"width\" | \"density\" | \"selectionMode\"> & {\n hierarchyConfig?: Partial<ModelsTreeHierarchyConfiguration>;\n };\n\n/** @internal */\nexport function ModelsTree({\n imodel,\n getSchemaContext,\n height,\n width,\n activeView,\n filter,\n density,\n hierarchyLevelConfig,\n hierarchyConfig,\n selectionMode,\n onPerformanceMeasured,\n onFeatureUsed,\n}: ModelsTreeProps) {\n const [filteringError, setFilteringError] = useState<ModelsTreeFilteringError | undefined>(undefined);\n const hierarchyConfiguration = useMemo<ModelsTreeHierarchyConfiguration>(\n () => ({\n ...defaultHierarchyConfiguration,\n ...hierarchyConfig,\n }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n Object.values(hierarchyConfig ?? {}),\n );\n\n const { getModelsTreeIdsCache, visibilityHandlerFactory } = useCachedVisibility(activeView, hierarchyConfiguration);\n const { loadInstanceKeys: loadFocusedInstancesKeys } = useFocusedInstancesContext();\n const { reportUsage } = useFeatureReporting({ onFeatureUsed, treeIdentifier: ModelsTreeComponent.id });\n\n const getHierarchyDefinition = useCallback<GetHierarchyDefinitionCallback>(\n ({ imodelAccess }) => new ModelsTreeDefinition({ imodelAccess, idsCache: getModelsTreeIdsCache(), hierarchyConfig: hierarchyConfiguration }),\n [getModelsTreeIdsCache, hierarchyConfiguration],\n );\n\n const onNodeDoubleClick = useCallback(\n async ({ nodeData, extendedData }: PresentationHierarchyNode) => {\n if (!HierarchyNode.isInstancesNode(nodeData) || (extendedData && (extendedData.isSubject || extendedData.isModel || extendedData.isCategory))) {\n return;\n }\n const instanceIds = nodeData.key.instanceKeys.map((instanceKey) => instanceKey.id);\n await IModelApp.viewManager.selectedView?.zoomToElements(instanceIds);\n reportUsage({ featureId: \"zoom-to-node\", reportInteraction: false });\n },\n [reportUsage],\n );\n\n const getFocusedFilteredPaths = useMemo<GetFilteredPathsCallback | undefined>(() => {\n setFilteringError(undefined);\n if (!loadFocusedInstancesKeys) {\n return undefined;\n }\n return async ({ imodelAccess }) => {\n try {\n const targetKeys = await collectTargetKeys(loadFocusedInstancesKeys);\n return await ModelsTreeDefinition.createInstanceKeyPaths({\n imodelAccess,\n idsCache: getModelsTreeIdsCache(),\n keys: targetKeys,\n hierarchyConfig: hierarchyConfiguration,\n });\n } catch (e) {\n const newError = e instanceof Error && e.message.match(/Filter matches more than \\d+ items/) ? \"tooManyInstancesFocused\" : \"unknownInstanceFocusError\";\n setFilteringError(newError);\n return [];\n }\n };\n }, [loadFocusedInstancesKeys, getModelsTreeIdsCache, hierarchyConfiguration]);\n\n const getSearchFilteredPaths = useMemo<GetFilteredPathsCallback | undefined>(() => {\n setFilteringError(undefined);\n if (!filter) {\n return undefined;\n }\n return async ({ imodelAccess }) => {\n reportUsage?.({ featureId: \"filtering\", reportInteraction: true });\n try {\n return await ModelsTreeDefinition.createInstanceKeyPaths({\n imodelAccess,\n label: filter,\n idsCache: getModelsTreeIdsCache(),\n hierarchyConfig: hierarchyConfiguration,\n });\n } catch (e) {\n const newError = e instanceof Error && e.message.match(/Filter matches more than \\d+ items/) ? \"tooManyFilterMatches\" : \"unknownFilterError\";\n setFilteringError(newError);\n return [];\n }\n };\n }, [filter, getModelsTreeIdsCache, reportUsage, hierarchyConfiguration]);\n\n const getFilteredPaths = getFocusedFilteredPaths ?? getSearchFilteredPaths;\n\n return (\n <VisibilityTree\n height={height}\n width={width}\n imodel={imodel}\n treeName={ModelsTreeComponent.id}\n getSchemaContext={getSchemaContext}\n visibilityHandlerFactory={visibilityHandlerFactory}\n getHierarchyDefinition={getHierarchyDefinition}\n getFilteredPaths={getFilteredPaths}\n hierarchyLevelSizeLimit={hierarchyLevelConfig?.sizeLimit}\n getIcon={getIcon}\n density={density}\n noDataMessage={getNoDataMessage(filter, filteringError)}\n selectionMode={selectionMode}\n onPerformanceMeasured={(action, duration) => {\n onPerformanceMeasured?.(`${ModelsTreeComponent.id}-${action}`, duration);\n }}\n reportUsage={reportUsage}\n onNodeDoubleClick={onNodeDoubleClick}\n searchText={filter}\n />\n );\n}\n\nfunction getNoDataMessage(filter?: string, error?: ModelsTreeFilteringError) {\n if (isInstanceFocusError(error)) {\n return <InstanceFocusError error={error!} />;\n }\n if (isFilterError(error)) {\n return <Text>{TreeWidget.translate(`modelsTree.filtering.${error}`)}</Text>;\n }\n if (filter) {\n return <Text>{TreeWidget.translate(\"modelsTree.filtering.noMatches\", { filter })}</Text>;\n }\n return undefined;\n}\n\nfunction isFilterError(error: ModelsTreeFilteringError | undefined) {\n return error === \"tooManyFilterMatches\" || error === \"unknownFilterError\";\n}\n\nfunction isInstanceFocusError(error: ModelsTreeFilteringError | undefined) {\n return error === \"tooManyInstancesFocused\" || error === \"unknownInstanceFocusError\";\n}\n\nfunction InstanceFocusError({ error }: { error: ModelsTreeFilteringError }) {\n const { toggle } = useFocusedInstancesContext();\n const localizedMessage = createLocalizedMessage(TreeWidget.translate(`modelsTree.filtering.${error}`), () => toggle());\n return <Text>{localizedMessage}</Text>;\n}\n\nfunction getIcon(node: PresentationHierarchyNode): ReactElement | undefined {\n if (node.extendedData?.imageId === undefined) {\n return undefined;\n }\n\n switch (node.extendedData.imageId) {\n case \"icon-layers\":\n return <SvgLayers />;\n case \"icon-item\":\n return <SvgItem />;\n case \"icon-ec-class\":\n return <SvgClassGrouping />;\n case \"icon-imodel-hollow-2\":\n return <SvgImodelHollow />;\n case \"icon-folder\":\n return <SvgFolder />;\n case \"icon-model\":\n return <SvgModel />;\n }\n\n return undefined;\n}\n\nfunction createVisibilityHandlerFactory(activeView: Viewport, idsCacheGetter: () => ModelsTreeIdsCache) {\n return (imodelAccess: ECClassHierarchyInspector) => createModelsTreeVisibilityHandler({ viewport: activeView, idsCache: idsCacheGetter(), imodelAccess });\n}\n\nfunction useCachedVisibility(activeView: Viewport, hierarchyConfig: ModelsTreeHierarchyConfiguration) {\n const cacheRef = useRef<ModelsTreeIdsCache>();\n const currentIModelRef = useRef(activeView.iModel);\n\n const getModelsTreeIdsCache = useCallback(() => {\n if (!cacheRef.current) {\n cacheRef.current = new ModelsTreeIdsCache(createECSqlQueryExecutor(currentIModelRef.current), hierarchyConfig);\n }\n return cacheRef.current;\n }, [hierarchyConfig]);\n\n const [visibilityHandlerFactory, setVisibilityHandlerFactory] = useState(() => createVisibilityHandlerFactory(activeView, getModelsTreeIdsCache));\n\n useIModelChangeListener({\n imodel: activeView.iModel,\n action: useCallback(() => {\n cacheRef.current = undefined;\n setVisibilityHandlerFactory(() => createVisibilityHandlerFactory(activeView, getModelsTreeIdsCache));\n }, [activeView, getModelsTreeIdsCache]),\n });\n\n useEffect(() => {\n currentIModelRef.current = activeView.iModel;\n cacheRef.current = undefined;\n setVisibilityHandlerFactory(() => createVisibilityHandlerFactory(activeView, getModelsTreeIdsCache));\n }, [activeView, getModelsTreeIdsCache]);\n\n return {\n getModelsTreeIdsCache,\n visibilityHandlerFactory,\n };\n}\n\nfunction SvgClassGrouping() {\n return (\n <Icon>\n <svg id=\"Calque_1\" data-name=\"Calque 1\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\">\n <path d=\"M8.00933,0,0,3.97672V11.986L8.00933,16,16,11.93V3.97651ZM1.66173,11.27642c-.26155.03734-.59754-.26154-.76553-.69085-.168-.41066-.09334-.784.168-.82152.26154-.03734.59754.26154.76553.67219C1.99772,10.86577,1.92306,11.23909,1.66173,11.27642Zm0-3.32319c-.26155.03733-.59754-.28-.76553-.69086-.168-.42932-.09334-.80285.168-.84.26133-.03733.59754.28.76532.69086C1.99772,7.54236,1.92306,7.89723,1.66173,7.95323Zm4.31276,5.52621a.18186.18186,0,0,1-.16821-.01866L3.41657,12.15394a.94275.94275,0,0,1-.29887-.80285c.03754-.33621.22421-.52265.41108-.41066L5.9185,12.24727a.88656.88656,0,0,1,.28.80285A.5057.5057,0,0,1,5.97449,13.47944Zm0-3.37919a.18184.18184,0,0,1-.16821-.01867L3.41657,8.77475a.943.943,0,0,1-.29887-.80286c.03754-.3362.22421-.52286.41108-.42953L5.9185,8.86786a.83112.83112,0,0,1,.28.78419A.51684.51684,0,0,1,5.97449,10.10025Z\" />\n </svg>\n </Icon>\n );\n}\n\nasync function collectTargetKeys(loadFocusedInstancesKeys: () => AsyncIterableIterator<InstanceKey | GroupingHierarchyNode>) {\n const targetKeys: Array<InstanceKey | ElementsGroupInfo> = [];\n const groupingNodeInfos: Array<{ parentKey: InstancesNodeKey; parentType: \"element\" | \"category\"; classes: string[]; modelIds: Id64String[] }> = [];\n for await (const key of loadFocusedInstancesKeys()) {\n if (\"id\" in key) {\n targetKeys.push(key);\n continue;\n }\n\n if (!HierarchyNodeKey.isClassGrouping(key.key)) {\n targetKeys.push(...key.groupedInstanceKeys);\n continue;\n }\n\n if (!key.nonGroupingAncestor || !HierarchyNodeKey.isInstances(key.nonGroupingAncestor.key)) {\n continue;\n }\n\n const parentKey = key.nonGroupingAncestor.key;\n const type = key.nonGroupingAncestor.extendedData?.isCategory ? \"category\" : \"element\";\n const modelIds = ((key.nonGroupingAncestor.extendedData?.modelIds as Id64String[][]) ?? []).flatMap((ids) => ids);\n const groupInfo = groupingNodeInfos.find((group) => HierarchyNodeKey.equals(group.parentKey, parentKey));\n if (groupInfo) {\n groupInfo.classes.push(key.key.className);\n } else {\n groupingNodeInfos.push({ classes: [key.key.className], parentType: type, parentKey, modelIds });\n }\n }\n targetKeys.push(\n ...groupingNodeInfos.map(({ parentKey, parentType, classes, modelIds }) => ({\n parent:\n parentType === \"element\"\n ? { type: \"element\" as const, ids: parentKey.instanceKeys.map((key) => key.id) }\n : { type: \"category\" as const, ids: parentKey.instanceKeys.map((key) => key.id), modelIds },\n classes,\n })),\n );\n return targetKeys;\n}\n\nfunction createLocalizedMessage(message: string, onClick?: () => void) {\n const exp = new RegExp(\"<link>(.*)</link>\");\n const match = message.match(exp);\n if (!match) {\n return message;\n }\n\n const [fullText, innerText] = match;\n const [textBefore, textAfter] = message.split(fullText);\n\n return (\n <>\n {textBefore ? textBefore : null}\n <Anchor\n underline\n onClick={(e) => {\n e.stopPropagation();\n onClick?.();\n }}\n >\n {innerText}\n </Anchor>\n {textAfter ? textAfter : null}\n </>\n );\n}\n"]}
1
+ {"version":3,"file":"ModelsTree.js","sourceRoot":"","sources":["../../../../../src/components/trees/models-tree/ModelsTree.tsx"],"names":[],"mappings":";;;;AAAA;;;gGAGgG;AAEhG,wEAAqE;AACrE,wFAAqF;AACrF,mDAAgD;AAwBhD,YAAY;AACZ,SAAgB,UAAU,CAAC,EACzB,MAAM,EACN,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACV,MAAM,EACN,OAAO,EACP,oBAAoB,EACpB,eAAe,EACf,aAAa,EACb,0BAA0B,GACV;IAChB,MAAM,EAAE,eAAe,EAAE,aAAa,EAAE,GAAG,IAAA,6BAAa,EAAC,EAAE,UAAU,EAAE,MAAM,EAAE,eAAe,EAAE,0BAA0B,EAAE,CAAC,CAAC;IAE9H,OAAO,CACL,uBAAC,+BAAc,OACT,eAAe,EACnB,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,gBAAgB,EAClC,gBAAgB,EAAE,gBAAgB,EAClC,uBAAuB,EAAE,oBAAoB,EAAE,SAAS,EACxD,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,uBAAC,+CAAsB,OAAK,SAAS,KAAM,aAAa,GAAI,GACzF,CACH,CAAC;AACJ,CAAC;AA1BD,gCA0BC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { VisibilityTree } from \"../common/components/VisibilityTree\";\nimport { VisibilityTreeRenderer } from \"../common/components/VisibilityTreeRenderer\";\nimport { useModelsTree } from \"./UseModelsTree\";\n\nimport type { ComponentPropsWithoutRef } from \"react\";\nimport type { Viewport } from \"@itwin/core-frontend\";\nimport type { ModelsTreeVisibilityHandlerOverrides } from \"./internal/ModelsTreeVisibilityHandler\";\nimport type { ModelsTreeHierarchyConfiguration } from \"./ModelsTreeDefinition\";\n\n/** @beta */\ninterface ModelsTreeOwnProps {\n activeView: Viewport;\n hierarchyLevelConfig?: {\n sizeLimit?: number;\n };\n hierarchyConfig?: Partial<ModelsTreeHierarchyConfiguration>;\n visibilityHandlerOverrides?: ModelsTreeVisibilityHandlerOverrides;\n filter?: string;\n}\n\n/** @beta */\ntype VisibilityTreeProps = ComponentPropsWithoutRef<typeof VisibilityTree>;\n\n/** @beta */\ntype ModelsTreeProps = ModelsTreeOwnProps & Pick<VisibilityTreeProps, \"imodel\" | \"getSchemaContext\" | \"selectionStorage\" | \"density\" | \"selectionMode\">;\n\n/** @beta */\nexport function ModelsTree({\n imodel,\n getSchemaContext,\n selectionStorage,\n activeView,\n filter,\n density,\n hierarchyLevelConfig,\n hierarchyConfig,\n selectionMode,\n visibilityHandlerOverrides,\n}: ModelsTreeProps) {\n const { modelsTreeProps, rendererProps } = useModelsTree({ activeView, filter, hierarchyConfig, visibilityHandlerOverrides });\n\n return (\n <VisibilityTree\n {...modelsTreeProps}\n imodel={imodel}\n selectionStorage={selectionStorage}\n getSchemaContext={getSchemaContext}\n hierarchyLevelSizeLimit={hierarchyLevelConfig?.sizeLimit}\n density={density}\n selectionMode={selectionMode}\n treeRenderer={(treeProps) => <VisibilityTreeRenderer {...treeProps} {...rendererProps} />}\n />\n );\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import type { TreeHeaderButtonProps } from "../../tree-header/TreeHeader";
3
- import type { IModelConnection } from "@itwin/core-frontend";
3
+ import type { IModelConnection, Viewport } from "@itwin/core-frontend";
4
4
  /**
5
5
  * Information about a single Model.
6
6
  * @public
@@ -18,16 +18,27 @@ export interface ModelsTreeHeaderButtonProps extends TreeHeaderButtonProps {
18
18
  /** A list of models available in the iModel. */
19
19
  models: ModelInfo[];
20
20
  }
21
- /** @internal */
22
- export declare function useAvailableModels(imodel: IModelConnection): ModelInfo[];
23
- /** @internal */
21
+ /**
22
+ * Custom hook that creates props required to render `ModelsTreeComponent` header button.
23
+ * @public
24
+ */
25
+ export declare function useModelsTreeButtonProps({ imodel, viewport, }: {
26
+ imodel: IModelConnection;
27
+ viewport: Viewport;
28
+ }): Pick<ModelsTreeHeaderButtonProps, "models" | "viewport">;
29
+ /** @public */
24
30
  export declare function ShowAllButton(props: ModelsTreeHeaderButtonProps): JSX.Element;
25
- /** @internal */
31
+ /** @public */
26
32
  export declare function HideAllButton(props: ModelsTreeHeaderButtonProps): JSX.Element;
27
- /** @internal */
33
+ /** @public */
28
34
  export declare function InvertButton(props: ModelsTreeHeaderButtonProps): JSX.Element;
29
- /** @internal */
35
+ /** @public */
30
36
  export declare function View2DButton(props: ModelsTreeHeaderButtonProps): JSX.Element;
31
- /** @internal */
37
+ /** @public */
32
38
  export declare function View3DButton(props: ModelsTreeHeaderButtonProps): JSX.Element;
39
+ /** @public */
40
+ export declare function ToggleInstancesFocusButton({ density, onFeatureUsed }: {
41
+ density?: "default" | "enlarged";
42
+ onFeatureUsed?: (feature: string) => void;
43
+ }): JSX.Element;
33
44
  //# sourceMappingURL=ModelsTreeButtons.d.ts.map
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.View3DButton = exports.View2DButton = exports.InvertButton = exports.HideAllButton = exports.ShowAllButton = exports.useAvailableModels = void 0;
3
+ exports.ToggleInstancesFocusButton = exports.View3DButton = exports.View2DButton = exports.InvertButton = exports.HideAllButton = exports.ShowAllButton = exports.useModelsTreeButtonProps = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  /*---------------------------------------------------------------------------------------------
6
6
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
@@ -10,8 +10,20 @@ const react_1 = require("react");
10
10
  const itwinui_icons_react_1 = require("@itwin/itwinui-icons-react");
11
11
  const itwinui_react_1 = require("@itwin/itwinui-react");
12
12
  const TreeWidget_1 = require("../../../TreeWidget");
13
+ const FocusedInstancesContext_1 = require("../common/FocusedInstancesContext");
13
14
  const ModelsTreeVisibilityHandler_1 = require("./internal/ModelsTreeVisibilityHandler");
14
- /** @internal */
15
+ /**
16
+ * Custom hook that creates props required to render `ModelsTreeComponent` header button.
17
+ * @public
18
+ */
19
+ function useModelsTreeButtonProps({ imodel, viewport, }) {
20
+ const models = useAvailableModels(imodel);
21
+ return {
22
+ models,
23
+ viewport,
24
+ };
25
+ }
26
+ exports.useModelsTreeButtonProps = useModelsTreeButtonProps;
15
27
  function useAvailableModels(imodel) {
16
28
  const [availableModels, setAvailableModels] = (0, react_1.useState)([]);
17
29
  (0, react_1.useEffect)(() => {
@@ -25,7 +37,6 @@ function useAvailableModels(imodel) {
25
37
  }, [imodel]);
26
38
  return availableModels;
27
39
  }
28
- exports.useAvailableModels = useAvailableModels;
29
40
  async function queryModelsForHeaderActions(iModel) {
30
41
  const queryParams = {
31
42
  from: "BisCore.GeometricModel3d",
@@ -42,7 +53,7 @@ async function queryModelsForHeaderActions(iModel) {
42
53
  const modelProps = await iModel.models.queryProps(queryParams);
43
54
  return modelProps.map(({ id, isPlanProjection }) => ({ id, isPlanProjection })).filter(({ id }) => id);
44
55
  }
45
- /** @internal */
56
+ /** @public */
46
57
  function ShowAllButton(props) {
47
58
  return ((0, jsx_runtime_1.jsx)(itwinui_react_1.IconButton, { size: props.density === "enlarged" ? "large" : "small", styleType: "borderless", title: TreeWidget_1.TreeWidget.translate("modelsTree.buttons.showAll.tooltip"), onClick: () => {
48
59
  props.onFeatureUsed?.("models-tree-showall");
@@ -50,7 +61,7 @@ function ShowAllButton(props) {
50
61
  }, children: (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgVisibilityShow, {}) }));
51
62
  }
52
63
  exports.ShowAllButton = ShowAllButton;
53
- /** @internal */
64
+ /** @public */
54
65
  function HideAllButton(props) {
55
66
  return ((0, jsx_runtime_1.jsx)(itwinui_react_1.IconButton, { size: props.density === "enlarged" ? "large" : "small", styleType: "borderless", title: TreeWidget_1.TreeWidget.translate("modelsTree.buttons.hideAll.tooltip"), onClick: () => {
56
67
  props.onFeatureUsed?.("models-tree-hideall");
@@ -58,7 +69,7 @@ function HideAllButton(props) {
58
69
  }, children: (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgVisibilityHide, {}) }));
59
70
  }
60
71
  exports.HideAllButton = HideAllButton;
61
- /** @internal */
72
+ /** @public */
62
73
  function InvertButton(props) {
63
74
  return ((0, jsx_runtime_1.jsx)(itwinui_react_1.IconButton, { size: props.density === "enlarged" ? "large" : "small", styleType: "borderless", title: TreeWidget_1.TreeWidget.translate("modelsTree.buttons.invert.tooltip"), onClick: () => {
64
75
  props.onFeatureUsed?.("models-tree-invert");
@@ -66,7 +77,7 @@ function InvertButton(props) {
66
77
  }, children: (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgVisibilityHalf, {}) }));
67
78
  }
68
79
  exports.InvertButton = InvertButton;
69
- /** @internal */
80
+ /** @public */
70
81
  function View2DButton(props) {
71
82
  const models2d = (0, react_1.useMemo)(() => {
72
83
  return props.models.filter((model) => model.isPlanProjection).map((model) => model.id);
@@ -82,7 +93,7 @@ function View2DButton(props) {
82
93
  }, disabled: models2d.length === 0, endIcon: is2dToggleActive ? (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgVisibilityShow, {}) : (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgVisibilityHide, {}), children: TreeWidget_1.TreeWidget.translate("modelsTree.buttons.toggle2d.label") }));
83
94
  }
84
95
  exports.View2DButton = View2DButton;
85
- /** @internal */
96
+ /** @public */
86
97
  function View3DButton(props) {
87
98
  const models3d = (0, react_1.useMemo)(() => {
88
99
  return props.models.filter((model) => !model.isPlanProjection).map((model) => model.id);
@@ -98,4 +109,16 @@ function View3DButton(props) {
98
109
  }, disabled: models3d.length === 0, endIcon: is3dToggleActive ? (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgVisibilityShow, {}) : (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgVisibilityHide, {}), children: TreeWidget_1.TreeWidget.translate("modelsTree.buttons.toggle3d.label") }));
99
110
  }
100
111
  exports.View3DButton = View3DButton;
112
+ /** @public */
113
+ function ToggleInstancesFocusButton({ density, onFeatureUsed }) {
114
+ const { enabled, toggle } = (0, FocusedInstancesContext_1.useFocusedInstancesContext)();
115
+ const title = enabled
116
+ ? TreeWidget_1.TreeWidget.translate("modelsTree.buttons.toggleFocusMode.disable.tooltip")
117
+ : TreeWidget_1.TreeWidget.translate("modelsTree.buttons.toggleFocusMode.enable.tooltip");
118
+ return ((0, jsx_runtime_1.jsx)(itwinui_react_1.IconButton, { styleType: "borderless", size: density === "enlarged" ? "large" : "small", title: title, onClick: () => {
119
+ onFeatureUsed?.("models-tree-instancesfocus");
120
+ toggle();
121
+ }, isActive: enabled, children: (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgCursorClick, {}) }));
122
+ }
123
+ exports.ToggleInstancesFocusButton = ToggleInstancesFocusButton;
101
124
  //# sourceMappingURL=ModelsTreeButtons.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ModelsTreeButtons.js","sourceRoot":"","sources":["../../../../../src/components/trees/models-tree/ModelsTreeButtons.tsx"],"names":[],"mappings":";;;;AAAA;;;gGAGgG;AAEhG,iCAAqD;AACrD,oEAAqG;AACrG,wDAA0D;AAC1D,oDAAiD;AACjD,wFAA0I;AAyB1I,gBAAgB;AAChB,SAAgB,kBAAkB,CAAC,MAAwB;IACzD,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,IAAA,gBAAQ,EAAc,EAAE,CAAC,CAAC;IAExE,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,2BAA2B,CAAC,MAAM,CAAC;aAChC,IAAI,CAAC,CAAC,UAAuB,EAAE,EAAE;YAChC,kBAAkB,CAAC,UAAU,CAAC,CAAC;QACjC,CAAC,CAAC;aACD,KAAK,CAAC,GAAG,EAAE;YACV,kBAAkB,CAAC,EAAE,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;IACP,CAAC,EAAE,CAAC,MAAM,CAAC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KAAK,CAAC,QAAQ,CAAC,CAAC;QAChE,CAAC,EACD,QAAQ,EAAE,QAAQ,CAAC,MAAM,KAAK,CAAC,EAC/B,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC,uBAAC,uCAAiB,KAAG,CAAC,CAAC,CAAC,uBAAC,uCAAiB,KAAG,YAExE,uBAAU,CAAC,SAAS,CAAC,mCAAmC,CAAC,GACnD,CACV,CAAC;AACJ,CAAC;AA3BD,oCA2BC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useEffect, useMemo, useState } from \"react\";\nimport { SvgVisibilityHalf, SvgVisibilityHide, SvgVisibilityShow } from \"@itwin/itwinui-icons-react\";\nimport { Button, IconButton } from \"@itwin/itwinui-react\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { areAllModelsVisible, hideAllModels, invertAllModels, showAllModels, toggleModels } from \"./internal/ModelsTreeVisibilityHandler\";\n\nimport type { GeometricModel3dProps, ModelQueryParams } from \"@itwin/core-common\";\nimport type { TreeHeaderButtonProps } from \"../../tree-header/TreeHeader\";\nimport type { IModelConnection, Viewport } from \"@itwin/core-frontend\";\n\n/**\n * Information about a single Model.\n * @public\n */\nexport interface ModelInfo {\n id: string;\n isPlanProjection?: boolean;\n}\n\n/**\n * Props that get passed to `ModelsTreeComponent` header button renderer.\n * @see ModelTreeComponentProps.headerButtons\n * @public\n */\nexport interface ModelsTreeHeaderButtonProps extends TreeHeaderButtonProps {\n /** A list of models available in the iModel. */\n models: ModelInfo[];\n}\n\n/** @internal */\nexport function useAvailableModels(imodel: IModelConnection) {\n const [availableModels, setAvailableModels] = useState<ModelInfo[]>([]);\n\n useEffect(() => {\n queryModelsForHeaderActions(imodel)\n .then((modelInfos: ModelInfo[]) => {\n setAvailableModels(modelInfos);\n })\n .catch(() => {\n setAvailableModels([]);\n });\n }, [imodel]);\n\n return availableModels;\n}\n\nasync function queryModelsForHeaderActions(iModel: IModelConnection) {\n const queryParams: ModelQueryParams = {\n from: \"BisCore.GeometricModel3d\",\n where: `\n EXISTS (\n SELECT 1\n FROM BisCore.Element e\n WHERE e.ECClassId IS (BisCore.GeometricElement3d, BisCore.InformationPartitionElement)\n AND e.ECInstanceId = GeometricModel3d.ModeledElement.Id\n )\n `,\n wantPrivate: false,\n };\n\n const modelProps = await iModel.models.queryProps(queryParams);\n return modelProps.map(({ id, isPlanProjection }: GeometricModel3dProps) => ({ id, isPlanProjection })).filter(({ id }) => id) as ModelInfo[];\n}\n\n/** @internal */\nexport function ShowAllButton(props: ModelsTreeHeaderButtonProps) {\n return (\n <IconButton\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"modelsTree.buttons.showAll.tooltip\")}\n onClick={() => {\n props.onFeatureUsed?.(\"models-tree-showall\");\n void showAllModels(\n props.models.map((model) => model.id),\n props.viewport,\n );\n }}\n >\n <SvgVisibilityShow />\n </IconButton>\n );\n}\n\n/** @internal */\nexport function HideAllButton(props: ModelsTreeHeaderButtonProps) {\n return (\n <IconButton\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"modelsTree.buttons.hideAll.tooltip\")}\n onClick={() => {\n props.onFeatureUsed?.(\"models-tree-hideall\");\n void hideAllModels(\n props.models.map((model) => model.id),\n props.viewport,\n );\n }}\n >\n <SvgVisibilityHide />\n </IconButton>\n );\n}\n\n/** @internal */\nexport function InvertButton(props: ModelsTreeHeaderButtonProps) {\n return (\n <IconButton\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"modelsTree.buttons.invert.tooltip\")}\n onClick={() => {\n props.onFeatureUsed?.(\"models-tree-invert\");\n void invertAllModels(\n props.models.map((model) => model.id),\n props.viewport,\n );\n }}\n >\n <SvgVisibilityHalf />\n </IconButton>\n );\n}\n\n/** @internal */\nexport function View2DButton(props: ModelsTreeHeaderButtonProps) {\n const models2d = useMemo(() => {\n return props.models.filter((model) => model.isPlanProjection).map((model) => model.id);\n }, [props.models]);\n\n const [is2dToggleActive, setIs2dToggleActive] = useState(false);\n\n useEffect(() => {\n setIs2dToggleActive(areAllModelsVisible(models2d, props.viewport));\n return props.viewport.onViewedModelsChanged.addListener((vp: Viewport) => setIs2dToggleActive(areAllModelsVisible(models2d, vp)));\n }, [models2d, props.viewport]);\n\n return (\n <Button\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"modelsTree.buttons.toggle2d.tooltip\")}\n onClick={() => {\n props.onFeatureUsed?.(\"models-tree-view2d\");\n void toggleModels(models2d, is2dToggleActive, props.viewport);\n }}\n disabled={models2d.length === 0}\n endIcon={is2dToggleActive ? <SvgVisibilityShow /> : <SvgVisibilityHide />}\n >\n {TreeWidget.translate(\"modelsTree.buttons.toggle2d.label\")}\n </Button>\n );\n}\n\n/** @internal */\nexport function View3DButton(props: ModelsTreeHeaderButtonProps) {\n const models3d = useMemo(() => {\n return props.models.filter((model) => !model.isPlanProjection).map((model) => model.id);\n }, [props.models]);\n\n const [is3dToggleActive, setIs3dToggleActive] = useState(false);\n\n useEffect(() => {\n setIs3dToggleActive(areAllModelsVisible(models3d, props.viewport));\n return props.viewport.onViewedModelsChanged.addListener((vp: Viewport) => setIs3dToggleActive(areAllModelsVisible(models3d, vp)));\n }, [models3d, props.viewport]);\n\n return (\n <Button\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"modelsTree.buttons.toggle3d.tooltip\")}\n onClick={() => {\n props.onFeatureUsed?.(\"models-tree-view3d\");\n void toggleModels(models3d, is3dToggleActive, props.viewport);\n }}\n disabled={models3d.length === 0}\n endIcon={is3dToggleActive ? <SvgVisibilityShow /> : <SvgVisibilityHide />}\n >\n {TreeWidget.translate(\"modelsTree.buttons.toggle3d.label\")}\n </Button>\n );\n}\n"]}
1
+ {"version":3,"file":"ModelsTreeButtons.js","sourceRoot":"","sources":["../../../../../src/components/trees/models-tree/ModelsTreeButtons.tsx"],"names":[],"mappings":";;;;AAAA;;;gGAGgG;AAEhG,iCAAqD;AACrD,oEAAqH;AACrH,wDAA0D;AAC1D,oDAAiD;AACjD,+EAA+E;AAC/E,wFAA0I;AAwB1I;;;GAGG;AACH,SAAgB,wBAAwB,CAAC,EACvC,MAAM,EACN,QAAQ,GAIT;IACC,MAAM,MAAM,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAC1C,OAAO;QACL,MAAM;QACN,QAAQ;KACT,CAAC;AACJ,CAAC;AAZD,4DAYC;AAED,SAAS,kBAAkB,CAAC,MAAwB;IAClD,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,IAAA,gBAAQ,EAAc,EAAE,CAAC,CAAC;IAExE,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,2BAA2B,CAAC,MAAM,CAAC;aAChC,IAAI,CAAC,CAAC,UAAuB,EAAE,EAAE;YAChC,kBAAkB,CAAC,UAAU,CAAC,CAAC;QACjC,CAAC,CAAC;aACD,KAAK,CAAC,GAAG,EAAE;YACV,kBAAkB,CAAC,EAAE,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;IACP,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEb,OAAO,eAAe,CAAC;AACzB,CAAC;AAED,KAAK,UAAU,2BAA2B,CAAC,MAAwB;IACjE,MAAM,WAAW,GAAqB;QACpC,IAAI,EAAE,0BAA0B;QAChC,KAAK,EAAE;;;;;;;OAOJ;QACH,WAAW,EAAE,KAAK;KACnB,CAAC;IAEF,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IAC/D,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,g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AAE,MAAM,EAAE,GAAG,IAAA,oDAA0B,GAAE,CAAC;IACzD,MAAM,KAAK,GAAG,OAAO;QACnB,CAAC,CAAC,uBAAU,CAAC,SAAS,CAAC,oDAAoD,CAAC;QAC5E,CAAC,CAAC,uBAAU,CAAC,SAAS,CAAC,mDAAmD,CAAC,CAAC;IAC9E,OAAO,CACL,uBAAC,0BAAU,IACT,SAAS,EAAC,YAAY,EACtB,IAAI,EAAE,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,EAChD,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,GAAG,EAAE;YACZ,aAAa,EAAE,CAAC,4BAA4B,CAAC,CAAC;YAC9C,MAAM,EAAE,CAAC;QACX,CAAC,EACD,QAAQ,EAAE,OAAO,YAEjB,uBAAC,oCAAc,KAAG,GACP,CACd,CAAC;AACJ,CAAC;AAnBD,gEAmBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useEffect, useMemo, useState } from \"react\";\nimport { SvgCursorClick, SvgVisibilityHalf, SvgVisibilityHide, SvgVisibilityShow } from \"@itwin/itwinui-icons-react\";\nimport { Button, IconButton } from \"@itwin/itwinui-react\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { useFocusedInstancesContext } from \"../common/FocusedInstancesContext\";\nimport { areAllModelsVisible, hideAllModels, invertAllModels, showAllModels, toggleModels } from \"./internal/ModelsTreeVisibilityHandler\";\n\nimport type { GeometricModel3dProps, ModelQueryParams } from \"@itwin/core-common\";\nimport type { TreeHeaderButtonProps } from \"../../tree-header/TreeHeader\";\nimport type { IModelConnection, Viewport } from \"@itwin/core-frontend\";\n/**\n * Information about a single Model.\n * @public\n */\nexport interface ModelInfo {\n id: string;\n isPlanProjection?: boolean;\n}\n\n/**\n * Props that get passed to `ModelsTreeComponent` header button renderer.\n * @see ModelTreeComponentProps.headerButtons\n * @public\n */\nexport interface ModelsTreeHeaderButtonProps extends TreeHeaderButtonProps {\n /** A list of models available in the iModel. */\n models: ModelInfo[];\n}\n\n/**\n * Custom hook that creates props required to render `ModelsTreeComponent` header button.\n * @public\n */\nexport function useModelsTreeButtonProps({\n imodel,\n viewport,\n}: {\n imodel: IModelConnection;\n viewport: Viewport;\n}): Pick<ModelsTreeHeaderButtonProps, \"models\" | \"viewport\"> {\n const models = useAvailableModels(imodel);\n return {\n models,\n viewport,\n };\n}\n\nfunction useAvailableModels(imodel: IModelConnection): ModelInfo[] {\n const [availableModels, setAvailableModels] = useState<ModelInfo[]>([]);\n\n useEffect(() => {\n queryModelsForHeaderActions(imodel)\n .then((modelInfos: ModelInfo[]) => {\n setAvailableModels(modelInfos);\n })\n .catch(() => {\n setAvailableModels([]);\n });\n }, [imodel]);\n\n return availableModels;\n}\n\nasync function queryModelsForHeaderActions(iModel: IModelConnection) {\n const queryParams: ModelQueryParams = {\n from: \"BisCore.GeometricModel3d\",\n where: `\n EXISTS (\n SELECT 1\n FROM BisCore.Element e\n WHERE e.ECClassId IS (BisCore.GeometricElement3d, BisCore.InformationPartitionElement)\n AND e.ECInstanceId = GeometricModel3d.ModeledElement.Id\n )\n `,\n wantPrivate: false,\n };\n\n const modelProps = await iModel.models.queryProps(queryParams);\n return modelProps.map(({ id, isPlanProjection }: GeometricModel3dProps) => ({ id, isPlanProjection })).filter(({ id }) => id) as ModelInfo[];\n}\n\n/** @public */\nexport function ShowAllButton(props: ModelsTreeHeaderButtonProps) {\n return (\n <IconButton\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"modelsTree.buttons.showAll.tooltip\")}\n onClick={() => {\n props.onFeatureUsed?.(\"models-tree-showall\");\n void showAllModels(\n props.models.map((model) => model.id),\n props.viewport,\n );\n }}\n >\n <SvgVisibilityShow />\n </IconButton>\n );\n}\n\n/** @public */\nexport function HideAllButton(props: ModelsTreeHeaderButtonProps) {\n return (\n <IconButton\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"modelsTree.buttons.hideAll.tooltip\")}\n onClick={() => {\n props.onFeatureUsed?.(\"models-tree-hideall\");\n void hideAllModels(\n props.models.map((model) => model.id),\n props.viewport,\n );\n }}\n >\n <SvgVisibilityHide />\n </IconButton>\n );\n}\n\n/** @public */\nexport function InvertButton(props: ModelsTreeHeaderButtonProps) {\n return (\n <IconButton\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"modelsTree.buttons.invert.tooltip\")}\n onClick={() => {\n props.onFeatureUsed?.(\"models-tree-invert\");\n void invertAllModels(\n props.models.map((model) => model.id),\n props.viewport,\n );\n }}\n >\n <SvgVisibilityHalf />\n </IconButton>\n );\n}\n\n/** @public */\nexport function View2DButton(props: ModelsTreeHeaderButtonProps) {\n const models2d = useMemo(() => {\n return props.models.filter((model) => model.isPlanProjection).map((model) => model.id);\n }, [props.models]);\n\n const [is2dToggleActive, setIs2dToggleActive] = useState(false);\n\n useEffect(() => {\n setIs2dToggleActive(areAllModelsVisible(models2d, props.viewport));\n return props.viewport.onViewedModelsChanged.addListener((vp: Viewport) => setIs2dToggleActive(areAllModelsVisible(models2d, vp)));\n }, [models2d, props.viewport]);\n\n return (\n <Button\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"modelsTree.buttons.toggle2d.tooltip\")}\n onClick={() => {\n props.onFeatureUsed?.(\"models-tree-view2d\");\n void toggleModels(models2d, is2dToggleActive, props.viewport);\n }}\n disabled={models2d.length === 0}\n endIcon={is2dToggleActive ? <SvgVisibilityShow /> : <SvgVisibilityHide />}\n >\n {TreeWidget.translate(\"modelsTree.buttons.toggle2d.label\")}\n </Button>\n );\n}\n\n/** @public */\nexport function View3DButton(props: ModelsTreeHeaderButtonProps) {\n const models3d = useMemo(() => {\n return props.models.filter((model) => !model.isPlanProjection).map((model) => model.id);\n }, [props.models]);\n\n const [is3dToggleActive, setIs3dToggleActive] = useState(false);\n\n useEffect(() => {\n setIs3dToggleActive(areAllModelsVisible(models3d, props.viewport));\n return props.viewport.onViewedModelsChanged.addListener((vp: Viewport) => setIs3dToggleActive(areAllModelsVisible(models3d, vp)));\n }, [models3d, props.viewport]);\n\n return (\n <Button\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"modelsTree.buttons.toggle3d.tooltip\")}\n onClick={() => {\n props.onFeatureUsed?.(\"models-tree-view3d\");\n void toggleModels(models3d, is3dToggleActive, props.viewport);\n }}\n disabled={models3d.length === 0}\n endIcon={is3dToggleActive ? <SvgVisibilityShow /> : <SvgVisibilityHide />}\n >\n {TreeWidget.translate(\"modelsTree.buttons.toggle3d.label\")}\n </Button>\n );\n}\n\n/** @public */\nexport function ToggleInstancesFocusButton({ density, onFeatureUsed }: { density?: \"default\" | \"enlarged\"; onFeatureUsed?: (feature: string) => void }) {\n const { enabled, toggle } = useFocusedInstancesContext();\n const title = enabled\n ? TreeWidget.translate(\"modelsTree.buttons.toggleFocusMode.disable.tooltip\")\n : TreeWidget.translate(\"modelsTree.buttons.toggleFocusMode.enable.tooltip\");\n return (\n <IconButton\n styleType=\"borderless\"\n size={density === \"enlarged\" ? \"large\" : \"small\"}\n title={title}\n onClick={() => {\n onFeatureUsed?.(\"models-tree-instancesfocus\");\n toggle();\n }}\n isActive={enabled}\n >\n <SvgCursorClick />\n </IconButton>\n );\n}\n"]}