@itwin/tree-widget-react 3.0.0-dev.1 → 3.0.0-dev.3

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 (233) hide show
  1. package/README.md +136 -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 +1 -1
  9. package/lib/cjs/components/tree-header/TreeHeader.js.map +1 -1
  10. package/lib/cjs/components/trees/categories-tree/CategoriesTree.d.ts +6 -5
  11. package/lib/cjs/components/trees/categories-tree/CategoriesTree.js +8 -9
  12. package/lib/cjs/components/trees/categories-tree/CategoriesTree.js.map +1 -1
  13. package/lib/cjs/components/trees/categories-tree/CategoriesTreeButtons.d.ts +3 -3
  14. package/lib/cjs/components/trees/categories-tree/CategoriesTreeButtons.js +3 -3
  15. package/lib/cjs/components/trees/categories-tree/CategoriesTreeButtons.js.map +1 -1
  16. package/lib/cjs/components/trees/categories-tree/CategoriesTreeComponent.d.ts +4 -4
  17. package/lib/cjs/components/trees/categories-tree/CategoriesTreeComponent.js +7 -7
  18. package/lib/cjs/components/trees/categories-tree/CategoriesTreeComponent.js.map +1 -1
  19. package/lib/cjs/components/trees/common/CategoriesVisibilityUtils.d.ts +1 -5
  20. package/lib/cjs/components/trees/common/CategoriesVisibilityUtils.js +0 -5
  21. package/lib/cjs/components/trees/common/CategoriesVisibilityUtils.js.map +1 -1
  22. package/lib/cjs/components/trees/common/FocusedInstancesContext.d.ts +0 -3
  23. package/lib/cjs/components/trees/common/FocusedInstancesContext.js +0 -2
  24. package/lib/cjs/components/trees/common/FocusedInstancesContext.js.map +1 -1
  25. package/lib/cjs/components/trees/common/FocusedInstancesContextProvider.d.ts +0 -1
  26. package/lib/cjs/components/trees/common/FocusedInstancesContextProvider.js +0 -1
  27. package/lib/cjs/components/trees/common/FocusedInstancesContextProvider.js.map +1 -1
  28. package/lib/cjs/components/trees/common/UseFiltering.d.ts +0 -1
  29. package/lib/cjs/components/trees/common/UseFiltering.js +0 -1
  30. package/lib/cjs/components/trees/common/UseFiltering.js.map +1 -1
  31. package/lib/cjs/components/trees/common/UseHierarchiesLocalization.d.ts +0 -1
  32. package/lib/cjs/components/trees/common/UseHierarchiesLocalization.js +1 -1
  33. package/lib/cjs/components/trees/common/UseHierarchiesLocalization.js.map +1 -1
  34. package/lib/cjs/components/trees/common/UseHierarchyFiltering.d.ts +1 -7
  35. package/lib/cjs/components/trees/common/UseHierarchyFiltering.js +4 -3
  36. package/lib/cjs/components/trees/common/UseHierarchyFiltering.js.map +1 -1
  37. package/lib/cjs/components/trees/common/UseHierarchyVisibility.d.ts +15 -10
  38. package/lib/cjs/components/trees/common/UseHierarchyVisibility.js +20 -17
  39. package/lib/cjs/components/trees/common/UseHierarchyVisibility.js.map +1 -1
  40. package/lib/cjs/components/trees/common/UseIModelChangeListener.d.ts +0 -1
  41. package/lib/cjs/components/trees/common/UseIModelChangeListener.js +0 -1
  42. package/lib/cjs/components/trees/common/UseIModelChangeListener.js.map +1 -1
  43. package/lib/cjs/components/trees/common/UseMultiCheckboxHandler.d.ts +0 -1
  44. package/lib/cjs/components/trees/common/UseMultiCheckboxHandler.js +0 -1
  45. package/lib/cjs/components/trees/common/UseMultiCheckboxHandler.js.map +1 -1
  46. package/lib/cjs/components/trees/common/UseNodeHighlighting.d.ts +9 -5
  47. package/lib/cjs/components/trees/common/UseNodeHighlighting.js +15 -24
  48. package/lib/cjs/components/trees/common/UseNodeHighlighting.js.map +1 -1
  49. package/lib/cjs/components/trees/common/UseTelemetryContext.d.ts +29 -0
  50. package/lib/cjs/components/trees/common/UseTelemetryContext.js +49 -0
  51. package/lib/cjs/components/trees/common/UseTelemetryContext.js.map +1 -0
  52. package/lib/cjs/components/trees/common/Utils.d.ts +3 -0
  53. package/lib/cjs/components/trees/common/Utils.js +11 -1
  54. package/lib/cjs/components/trees/common/Utils.js.map +1 -1
  55. package/lib/cjs/components/trees/common/components/Delayed.d.ts +0 -1
  56. package/lib/cjs/components/trees/common/components/Delayed.js +0 -1
  57. package/lib/cjs/components/trees/common/components/Delayed.js.map +1 -1
  58. package/lib/cjs/components/trees/common/components/ProgressOverlay.d.ts +0 -1
  59. package/lib/cjs/components/trees/common/components/ProgressOverlay.js +0 -1
  60. package/lib/cjs/components/trees/common/components/ProgressOverlay.js.map +1 -1
  61. package/lib/cjs/components/trees/common/components/Tree.d.ts +54 -0
  62. package/lib/cjs/components/trees/common/components/{BaseTree.js → Tree.js} +26 -22
  63. package/lib/cjs/components/trees/common/components/Tree.js.map +1 -0
  64. package/lib/cjs/components/trees/common/components/TreeNodeCheckbox.d.ts +14 -7
  65. package/lib/cjs/components/trees/common/components/TreeNodeCheckbox.js.map +1 -1
  66. package/lib/cjs/components/trees/common/components/TreeNodeRenderer.d.ts +7 -6
  67. package/lib/cjs/components/trees/common/components/TreeNodeRenderer.js +1 -1
  68. package/lib/cjs/components/trees/common/components/TreeNodeRenderer.js.map +1 -1
  69. package/lib/cjs/components/trees/common/components/TreeRenderer.d.ts +13 -5
  70. package/lib/cjs/components/trees/common/components/TreeRenderer.js +21 -4
  71. package/lib/cjs/components/trees/common/components/TreeRenderer.js.map +1 -1
  72. package/lib/cjs/components/trees/common/components/VisibilityTree.d.ts +27 -9
  73. package/lib/cjs/components/trees/common/components/VisibilityTree.js +8 -23
  74. package/lib/cjs/components/trees/common/components/VisibilityTree.js.map +1 -1
  75. package/lib/cjs/components/trees/common/components/VisibilityTreeRenderer.d.ts +12 -0
  76. package/lib/cjs/components/trees/common/components/VisibilityTreeRenderer.js +26 -0
  77. package/lib/cjs/components/trees/common/components/VisibilityTreeRenderer.js.map +1 -0
  78. package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.d.ts +8 -7
  79. package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.js +7 -10
  80. package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
  81. package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTreeComponent.d.ts +5 -5
  82. package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js +3 -3
  83. package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js.map +1 -1
  84. package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.d.ts +8 -7
  85. package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.js +9 -12
  86. package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
  87. package/lib/cjs/components/trees/imodel-content-tree/IModelContentTreeComponent.d.ts +5 -5
  88. package/lib/cjs/components/trees/imodel-content-tree/IModelContentTreeComponent.js +3 -3
  89. package/lib/cjs/components/trees/imodel-content-tree/IModelContentTreeComponent.js.map +1 -1
  90. package/lib/cjs/components/trees/imodel-content-tree/IModelContentTreeDefinition.js.map +1 -1
  91. package/lib/cjs/components/trees/index.d.ts +7 -0
  92. package/lib/cjs/components/trees/index.js +11 -1
  93. package/lib/cjs/components/trees/index.js.map +1 -1
  94. package/lib/cjs/components/trees/models-tree/ModelsTree.d.ts +10 -9
  95. package/lib/cjs/components/trees/models-tree/ModelsTree.js +19 -20
  96. package/lib/cjs/components/trees/models-tree/ModelsTree.js.map +1 -1
  97. package/lib/cjs/components/trees/models-tree/ModelsTreeButtons.d.ts +10 -5
  98. package/lib/cjs/components/trees/models-tree/ModelsTreeButtons.js +19 -6
  99. package/lib/cjs/components/trees/models-tree/ModelsTreeButtons.js.map +1 -1
  100. package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.d.ts +11 -5
  101. package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.js +15 -23
  102. package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
  103. package/lib/cjs/components/trees/models-tree/ModelsTreeDefinition.d.ts +9 -5
  104. package/lib/cjs/components/trees/models-tree/ModelsTreeDefinition.js.map +1 -1
  105. package/lib/cjs/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.d.ts +11 -3
  106. package/lib/cjs/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js.map +1 -1
  107. package/lib/cjs/tree-widget-react.d.ts +1 -1
  108. package/lib/cjs/tree-widget-react.js.map +1 -1
  109. package/lib/esm/components/SelectableTree.d.ts +12 -6
  110. package/lib/esm/components/SelectableTree.js.map +1 -1
  111. package/lib/esm/components/TreeSelector.d.ts +2 -2
  112. package/lib/esm/components/TreeSelector.js.map +1 -1
  113. package/lib/esm/components/TreeWidgetUiItemsProvider.d.ts +3 -2
  114. package/lib/esm/components/TreeWidgetUiItemsProvider.js.map +1 -1
  115. package/lib/esm/components/tree-header/TreeHeader.d.ts +1 -1
  116. package/lib/esm/components/tree-header/TreeHeader.js.map +1 -1
  117. package/lib/esm/components/trees/categories-tree/CategoriesTree.d.ts +6 -5
  118. package/lib/esm/components/trees/categories-tree/CategoriesTree.js +8 -9
  119. package/lib/esm/components/trees/categories-tree/CategoriesTree.js.map +1 -1
  120. package/lib/esm/components/trees/categories-tree/CategoriesTreeButtons.d.ts +3 -3
  121. package/lib/esm/components/trees/categories-tree/CategoriesTreeButtons.js +3 -3
  122. package/lib/esm/components/trees/categories-tree/CategoriesTreeButtons.js.map +1 -1
  123. package/lib/esm/components/trees/categories-tree/CategoriesTreeComponent.d.ts +4 -4
  124. package/lib/esm/components/trees/categories-tree/CategoriesTreeComponent.js +7 -7
  125. package/lib/esm/components/trees/categories-tree/CategoriesTreeComponent.js.map +1 -1
  126. package/lib/esm/components/trees/common/CategoriesVisibilityUtils.d.ts +1 -5
  127. package/lib/esm/components/trees/common/CategoriesVisibilityUtils.js +0 -5
  128. package/lib/esm/components/trees/common/CategoriesVisibilityUtils.js.map +1 -1
  129. package/lib/esm/components/trees/common/FocusedInstancesContext.d.ts +0 -3
  130. package/lib/esm/components/trees/common/FocusedInstancesContext.js +0 -2
  131. package/lib/esm/components/trees/common/FocusedInstancesContext.js.map +1 -1
  132. package/lib/esm/components/trees/common/FocusedInstancesContextProvider.d.ts +0 -1
  133. package/lib/esm/components/trees/common/FocusedInstancesContextProvider.js +0 -1
  134. package/lib/esm/components/trees/common/FocusedInstancesContextProvider.js.map +1 -1
  135. package/lib/esm/components/trees/common/UseFiltering.d.ts +0 -1
  136. package/lib/esm/components/trees/common/UseFiltering.js +0 -1
  137. package/lib/esm/components/trees/common/UseFiltering.js.map +1 -1
  138. package/lib/esm/components/trees/common/UseHierarchiesLocalization.d.ts +0 -1
  139. package/lib/esm/components/trees/common/UseHierarchiesLocalization.js +1 -1
  140. package/lib/esm/components/trees/common/UseHierarchiesLocalization.js.map +1 -1
  141. package/lib/esm/components/trees/common/UseHierarchyFiltering.d.ts +1 -7
  142. package/lib/esm/components/trees/common/UseHierarchyFiltering.js +4 -3
  143. package/lib/esm/components/trees/common/UseHierarchyFiltering.js.map +1 -1
  144. package/lib/esm/components/trees/common/UseHierarchyVisibility.d.ts +15 -10
  145. package/lib/esm/components/trees/common/UseHierarchyVisibility.js +20 -17
  146. package/lib/esm/components/trees/common/UseHierarchyVisibility.js.map +1 -1
  147. package/lib/esm/components/trees/common/UseIModelChangeListener.d.ts +0 -1
  148. package/lib/esm/components/trees/common/UseIModelChangeListener.js +0 -1
  149. package/lib/esm/components/trees/common/UseIModelChangeListener.js.map +1 -1
  150. package/lib/esm/components/trees/common/UseMultiCheckboxHandler.d.ts +0 -1
  151. package/lib/esm/components/trees/common/UseMultiCheckboxHandler.js +0 -1
  152. package/lib/esm/components/trees/common/UseMultiCheckboxHandler.js.map +1 -1
  153. package/lib/esm/components/trees/common/UseNodeHighlighting.d.ts +9 -5
  154. package/lib/esm/components/trees/common/UseNodeHighlighting.js +14 -23
  155. package/lib/esm/components/trees/common/UseNodeHighlighting.js.map +1 -1
  156. package/lib/esm/components/trees/common/UseTelemetryContext.d.ts +29 -0
  157. package/lib/esm/components/trees/common/UseTelemetryContext.js +43 -0
  158. package/lib/esm/components/trees/common/UseTelemetryContext.js.map +1 -0
  159. package/lib/esm/components/trees/common/Utils.d.ts +3 -0
  160. package/lib/esm/components/trees/common/Utils.js +9 -0
  161. package/lib/esm/components/trees/common/Utils.js.map +1 -1
  162. package/lib/esm/components/trees/common/components/Delayed.d.ts +0 -1
  163. package/lib/esm/components/trees/common/components/Delayed.js +0 -1
  164. package/lib/esm/components/trees/common/components/Delayed.js.map +1 -1
  165. package/lib/esm/components/trees/common/components/ProgressOverlay.d.ts +0 -1
  166. package/lib/esm/components/trees/common/components/ProgressOverlay.js +0 -1
  167. package/lib/esm/components/trees/common/components/ProgressOverlay.js.map +1 -1
  168. package/lib/esm/components/trees/common/components/Tree.d.ts +54 -0
  169. package/lib/esm/components/trees/common/components/{BaseTree.js → Tree.js} +25 -21
  170. package/lib/esm/components/trees/common/components/Tree.js.map +1 -0
  171. package/lib/esm/components/trees/common/components/TreeNodeCheckbox.d.ts +14 -7
  172. package/lib/esm/components/trees/common/components/TreeNodeCheckbox.js.map +1 -1
  173. package/lib/esm/components/trees/common/components/TreeNodeRenderer.d.ts +7 -6
  174. package/lib/esm/components/trees/common/components/TreeNodeRenderer.js +1 -1
  175. package/lib/esm/components/trees/common/components/TreeNodeRenderer.js.map +1 -1
  176. package/lib/esm/components/trees/common/components/TreeRenderer.d.ts +13 -5
  177. package/lib/esm/components/trees/common/components/TreeRenderer.js +21 -4
  178. package/lib/esm/components/trees/common/components/TreeRenderer.js.map +1 -1
  179. package/lib/esm/components/trees/common/components/VisibilityTree.d.ts +27 -9
  180. package/lib/esm/components/trees/common/components/VisibilityTree.js +8 -23
  181. package/lib/esm/components/trees/common/components/VisibilityTree.js.map +1 -1
  182. package/lib/esm/components/trees/common/components/VisibilityTreeRenderer.d.ts +12 -0
  183. package/lib/esm/components/trees/common/components/VisibilityTreeRenderer.js +22 -0
  184. package/lib/esm/components/trees/common/components/VisibilityTreeRenderer.js.map +1 -0
  185. package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.d.ts +8 -7
  186. package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.js +7 -10
  187. package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
  188. package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTreeComponent.d.ts +5 -5
  189. package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js +3 -3
  190. package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js.map +1 -1
  191. package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.d.ts +8 -7
  192. package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.js +9 -12
  193. package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
  194. package/lib/esm/components/trees/imodel-content-tree/IModelContentTreeComponent.d.ts +5 -5
  195. package/lib/esm/components/trees/imodel-content-tree/IModelContentTreeComponent.js +3 -3
  196. package/lib/esm/components/trees/imodel-content-tree/IModelContentTreeComponent.js.map +1 -1
  197. package/lib/esm/components/trees/imodel-content-tree/IModelContentTreeDefinition.js.map +1 -1
  198. package/lib/esm/components/trees/index.d.ts +7 -0
  199. package/lib/esm/components/trees/index.js +5 -0
  200. package/lib/esm/components/trees/index.js.map +1 -1
  201. package/lib/esm/components/trees/models-tree/ModelsTree.d.ts +10 -9
  202. package/lib/esm/components/trees/models-tree/ModelsTree.js +19 -20
  203. package/lib/esm/components/trees/models-tree/ModelsTree.js.map +1 -1
  204. package/lib/esm/components/trees/models-tree/ModelsTreeButtons.d.ts +10 -5
  205. package/lib/esm/components/trees/models-tree/ModelsTreeButtons.js +18 -6
  206. package/lib/esm/components/trees/models-tree/ModelsTreeButtons.js.map +1 -1
  207. package/lib/esm/components/trees/models-tree/ModelsTreeComponent.d.ts +11 -5
  208. package/lib/esm/components/trees/models-tree/ModelsTreeComponent.js +16 -24
  209. package/lib/esm/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
  210. package/lib/esm/components/trees/models-tree/ModelsTreeDefinition.d.ts +9 -5
  211. package/lib/esm/components/trees/models-tree/ModelsTreeDefinition.js.map +1 -1
  212. package/lib/esm/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.d.ts +11 -3
  213. package/lib/esm/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js.map +1 -1
  214. package/lib/esm/tree-widget-react.d.ts +1 -1
  215. package/lib/esm/tree-widget-react.js.map +1 -1
  216. package/lib/public/locales/en/TreeWidget.json +2 -1
  217. package/package.json +2 -2
  218. package/lib/cjs/components/trees/common/UseFeatureReporting.d.ts +0 -34
  219. package/lib/cjs/components/trees/common/UseFeatureReporting.js +0 -39
  220. package/lib/cjs/components/trees/common/UseFeatureReporting.js.map +0 -1
  221. package/lib/cjs/components/trees/common/UsePerformanceReporting.d.ts +0 -18
  222. package/lib/cjs/components/trees/common/UsePerformanceReporting.js +0 -25
  223. package/lib/cjs/components/trees/common/UsePerformanceReporting.js.map +0 -1
  224. package/lib/cjs/components/trees/common/components/BaseTree.d.ts +0 -34
  225. package/lib/cjs/components/trees/common/components/BaseTree.js.map +0 -1
  226. package/lib/esm/components/trees/common/UseFeatureReporting.d.ts +0 -34
  227. package/lib/esm/components/trees/common/UseFeatureReporting.js +0 -34
  228. package/lib/esm/components/trees/common/UseFeatureReporting.js.map +0 -1
  229. package/lib/esm/components/trees/common/UsePerformanceReporting.d.ts +0 -18
  230. package/lib/esm/components/trees/common/UsePerformanceReporting.js +0 -21
  231. package/lib/esm/components/trees/common/UsePerformanceReporting.js.map +0 -1
  232. package/lib/esm/components/trees/common/components/BaseTree.d.ts +0 -34
  233. package/lib/esm/components/trees/common/components/BaseTree.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"TreeHeader.js","sourceRoot":"","sources":["../../../../src/components/tree-header/TreeHeader.tsx"],"names":[],"mappings":";AAAA;;;gGAGg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AAK,EAAE,UAAU,CAAC,SAAS,CAAC,uBAAuB,CAAC,EACpD,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,OAAO,EAAE,GAAG,EAAE;oBACZ,IAAI,aAAa,GAAG,KAAK,EAAE;wBACzB,MAAM,CAAC,aAAa,GAAG,CAAC,CAAC,CAAC;qBAC3B;gBACH,CAAC,YAED,KAAC,iBAAiB,KAAG,GACJ,IAClB,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 \"./TreeHeader.scss\";\nimport classnames from \"classnames\";\nimport { Children, useEffect, useRef, useState } from \"react\";\nimport { SvgCaretDownSmall, SvgCaretUpSmall, SvgMore } from \"@itwin/itwinui-icons-react\";\nimport { ButtonGroup, Divider, DropdownMenu, IconButton, SearchBox } from \"@itwin/itwinui-react\";\nimport { TreeWidget } from \"../../TreeWidget\";\nimport { useFocusedInstancesContext } from \"../trees/common/FocusedInstancesContext\";\n\nimport type { Viewport } from \"@itwin/core-frontend\";\nimport type { CommonProps } from \"@itwin/core-react\";\n\n/** @internal */\nexport interface TreeHeaderButtonProps {\n viewport: Viewport;\n density?: \"default\" | \"enlarged\";\n onFeatureUsed?: (feature: string) => void;\n}\n\n/** @internal */\nexport interface TreeHeaderProps extends CommonProps {\n /** Filtering is cleared after everything's loaded */\n onFilterStart: (newFilter: string) => void;\n /** listens for onClick event for Clear (x) icon */\n onFilterClear: () => void;\n /** Total number of results/entries */\n resultCount?: number;\n /** Current selected result index */\n selectedIndex?: number;\n /** Callback to currently selected result/entry change */\n onSelectedChanged: (index: number) => void;\n /** Header buttons */\n children?: React.ReactNode;\n /** Modifies the density of tree header. `enlarged` header contains larger content */\n density?: \"default\" | \"enlarged\";\n}\n\n/** @internal */\nexport function TreeHeader(props: TreeHeaderProps) {\n const { onFilterStart, onFilterClear, resultCount, selectedIndex, onSelectedChanged, children, density, className } = props;\n const [isSearchOpen, setIsSearchOpen] = useState<boolean>(false);\n const { enabled: instanceFocusEnabled } = useFocusedInstancesContext();\n const size = density === \"enlarged\" ? \"large\" : \"small\";\n\n useEffect(() => {\n // istanbul ignore if\n if (instanceFocusEnabled) {\n onFilterClear();\n setIsSearchOpen(false);\n }\n }, [instanceFocusEnabled, onFilterClear]);\n\n return (\n <div className={classnames(\"tree-widget-tree-header\", className)}>\n <HeaderButtons contracted={isSearchOpen} size={size}>\n {children}\n </HeaderButtons>\n <DebouncedSearchBox\n isOpened={isSearchOpen}\n onOpen={() => setIsSearchOpen(true)}\n onClose={() => setIsSearchOpen(false)}\n onChange={(value) => (value ? onFilterStart(value) : onFilterClear())}\n delay={500}\n selectedResultIndex={selectedIndex}\n resultCount={resultCount}\n onSelectedResultChanged={onSelectedChanged}\n size={size}\n isDisabled={instanceFocusEnabled}\n />\n </div>\n );\n}\n\ninterface DebouncedSearchBoxProps {\n isOpened: boolean;\n onOpen: () => void;\n onClose: () => void;\n onChange: (value: string) => void;\n delay: number;\n selectedResultIndex?: number;\n resultCount?: number;\n onSelectedResultChanged: (index: number) => void;\n size: \"large\" | \"small\";\n isDisabled?: boolean;\n}\n\nfunction DebouncedSearchBox({\n isOpened,\n selectedResultIndex,\n resultCount,\n onSelectedResultChanged,\n onChange,\n onOpen,\n onClose,\n delay,\n size,\n isDisabled,\n}: DebouncedSearchBoxProps) {\n const [inputValue, setInputValue] = useState<string>(\"\");\n const onChangeRef = useRef(onChange);\n // save latest `onChange` reference into `useRef` to avoid restarting timeout when `onChange` reference changes.\n onChangeRef.current = onChange;\n\n useEffect(() => {\n if (!inputValue) {\n onChangeRef.current(\"\");\n return;\n }\n\n const timeoutId = setTimeout(() => {\n onChangeRef.current(inputValue);\n }, delay);\n\n return () => {\n clearTimeout(timeoutId);\n };\n }, [inputValue, delay]);\n\n return (\n <SearchBox\n expandable\n isExpanded={isOpened}\n onExpand={onOpen}\n onCollapse={onClose}\n size={size}\n className={classnames(\"tree-widget-search-box\", !isOpened && \"contracted\")}\n isDisabled={isDisabled}\n >\n <SearchBox.CollapsedState>\n <SearchBox.ExpandButton\n title={TreeWidget.translate(\"header.searchBox.searchForSomething\")}\n aria-label={TreeWidget.translate(\"header.searchBox.open\")}\n size={size}\n styleType=\"borderless\"\n />\n </SearchBox.CollapsedState>\n <SearchBox.ExpandedState>\n <SearchBox.Input placeholder={TreeWidget.translate(\"header.searchBox.search\")} onChange={(e) => setInputValue(e.currentTarget.value)} />\n <SearchResultStepper selectedIndex={selectedResultIndex} total={resultCount} onStep={onSelectedResultChanged} size={size} />\n <SearchBox.CollapseButton\n onClick={() => {\n setInputValue(\"\");\n onClose();\n }}\n size={size}\n aria-label={TreeWidget.translate(\"header.searchBox.close\")}\n />\n </SearchBox.ExpandedState>\n </SearchBox>\n );\n}\n\ninterface HeaderButtonsProps {\n contracted: boolean;\n children?: React.ReactNode;\n size: \"large\" | \"small\";\n}\n\nfunction HeaderButtons(props: HeaderButtonsProps) {\n const className = classnames(\"button-container\", props.contracted && \"contracted\");\n\n return (\n <ButtonGroup\n className={className}\n overflowButton={(overflowStart) => (\n <DropdownMenu\n menuItems={() =>\n Children.toArray(props.children)\n .slice(overflowStart)\n .map((btn, index) => (\n <li key={index} className=\"dropdown-item\" role=\"menuitem\">\n {btn}\n </li>\n ))\n }\n className=\"tree-header-button-dropdown-container\"\n >\n <IconButton title={TreeWidget.translate(\"header.dropdownMore\")} styleType=\"borderless\" size={props.size}>\n <SvgMore />\n </IconButton>\n </DropdownMenu>\n )}\n >\n {props.children}\n </ButtonGroup>\n );\n}\n\ninterface SearchResultStepperProps {\n total?: number;\n onStep: (newIndex: number) => void;\n selectedIndex?: number;\n size: \"large\" | \"small\";\n}\n\nfunction SearchResultStepper(props: SearchResultStepperProps) {\n const { selectedIndex = 1, total, onStep } = props;\n if (!total) {\n return null;\n }\n\n return (\n <>\n <span className=\"searchbox-stepping-count\">{`${selectedIndex}/${total}`}</span>\n <Divider orientation=\"vertical\" />\n <SearchBox.Button\n title={TreeWidget.translate(\"header.searchBox.previous\")}\n size={props.size}\n onClick={() => {\n if (selectedIndex > 1) {\n onStep(selectedIndex - 1);\n }\n }}\n >\n <SvgCaretUpSmall />\n </SearchBox.Button>\n <SearchBox.Button\n title={TreeWidget.translate(\"header.searchBox.next\")}\n size={props.size}\n onClick={() => {\n if (selectedIndex < total) {\n onStep(selectedIndex + 1);\n }\n }}\n >\n <SvgCaretDownSmall />\n </SearchBox.Button>\n </>\n );\n}\n"]}
1
+ {"version":3,"file":"TreeHeader.js","sourceRoot":"","sources":["../../../../src/components/tree-header/TreeHeader.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,mBAAmB,CAAC;AAC3B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACzF,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjG,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AA8BrF,gBAAgB;AAChB,MAAM,UAAU,UAAU,CAAC,KAAsB;IAC/C,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,WAAW,EAAE,aAAa,EAAE,iBAAiB,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,KAAK,CAAC;IAC5H,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAU,KAAK,CAAC,CAAC;IACjE,MAAM,EAAE,OAAO,EAAE,oBAAoB,EAAE,GAAG,0BAA0B,EAAE,CAAC;IACvE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,8BACE,eAAM,SAAS,EAAC,0BAA0B,YAAE,GAAG,aAAa,IAAI,KAAK,EAAE,GAAQ,EAC/E,KAAC,OAAO,IAAC,WAAW,EAAC,UAAU,GAAG,EAClC,KAAC,SAAS,CAAC,MAAM,IACf,KAAK,EAAE,UAAU,CAAC,SAAS,CAAC,2BAA2B,CAAC,EACxD,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,OAAO,EAAE,GAAG,EAAE;oBACZ,IAAI,aAAa,GAAG,CAAC,EAAE;wBACrB,MAAM,CAAC,aAAa,GAAG,CAAC,CAAC,CAAC;qBAC3B;gBACH,CAAC,YAED,KAAC,eAAe,KAAG,GACF,EACnB,KAAC,SAAS,CAAC,MAAM,IACf,KAAK,EAAE,UAAU,CAAC,SAAS,CAAC,uBAAuB,CAAC,EACpD,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,OAAO,EAAE,GAAG,EAAE;oBACZ,IAAI,aAAa,GAAG,KAAK,EAAE;wBACzB,MAAM,CAAC,aAAa,GAAG,CAAC,CAAC,CAAC;qBAC3B;gBACH,CAAC,YAED,KAAC,iBAAiB,KAAG,GACJ,IAClB,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 \"./TreeHeader.scss\";\nimport classnames from \"classnames\";\nimport { Children, useEffect, useRef, useState } from \"react\";\nimport { SvgCaretDownSmall, SvgCaretUpSmall, SvgMore } from \"@itwin/itwinui-icons-react\";\nimport { ButtonGroup, Divider, DropdownMenu, IconButton, SearchBox } from \"@itwin/itwinui-react\";\nimport { TreeWidget } from \"../../TreeWidget\";\nimport { useFocusedInstancesContext } from \"../trees/common/FocusedInstancesContext\";\n\nimport type { Viewport } from \"@itwin/core-frontend\";\nimport type { CommonProps } from \"@itwin/core-react\";\n\n/** @public */\nexport interface TreeHeaderButtonProps {\n viewport: Viewport;\n density?: \"default\" | \"enlarged\";\n onFeatureUsed?: (feature: string) => void;\n}\n\n/** @internal */\nexport interface TreeHeaderProps extends CommonProps {\n /** Filtering is cleared after everything's loaded */\n onFilterStart: (newFilter: string) => void;\n /** listens for onClick event for Clear (x) icon */\n onFilterClear: () => void;\n /** Total number of results/entries */\n resultCount?: number;\n /** Current selected result index */\n selectedIndex?: number;\n /** Callback to currently selected result/entry change */\n onSelectedChanged: (index: number) => void;\n /** Header buttons */\n children?: React.ReactNode;\n /** Modifies the density of tree header. `enlarged` header contains larger content */\n density?: \"default\" | \"enlarged\";\n}\n\n/** @internal */\nexport function TreeHeader(props: TreeHeaderProps) {\n const { onFilterStart, onFilterClear, resultCount, selectedIndex, onSelectedChanged, children, density, className } = props;\n const [isSearchOpen, setIsSearchOpen] = useState<boolean>(false);\n const { enabled: instanceFocusEnabled } = useFocusedInstancesContext();\n const size = density === \"enlarged\" ? \"large\" : \"small\";\n\n useEffect(() => {\n // istanbul ignore if\n if (instanceFocusEnabled) {\n onFilterClear();\n setIsSearchOpen(false);\n }\n }, [instanceFocusEnabled, onFilterClear]);\n\n return (\n <div className={classnames(\"tree-widget-tree-header\", className)}>\n <HeaderButtons contracted={isSearchOpen} size={size}>\n {children}\n </HeaderButtons>\n <DebouncedSearchBox\n isOpened={isSearchOpen}\n onOpen={() => setIsSearchOpen(true)}\n onClose={() => setIsSearchOpen(false)}\n onChange={(value) => (value ? onFilterStart(value) : onFilterClear())}\n delay={500}\n selectedResultIndex={selectedIndex}\n resultCount={resultCount}\n onSelectedResultChanged={onSelectedChanged}\n size={size}\n isDisabled={instanceFocusEnabled}\n />\n </div>\n );\n}\n\ninterface DebouncedSearchBoxProps {\n isOpened: boolean;\n onOpen: () => void;\n onClose: () => void;\n onChange: (value: string) => void;\n delay: number;\n selectedResultIndex?: number;\n resultCount?: number;\n onSelectedResultChanged: (index: number) => void;\n size: \"large\" | \"small\";\n isDisabled?: boolean;\n}\n\nfunction DebouncedSearchBox({\n isOpened,\n selectedResultIndex,\n resultCount,\n onSelectedResultChanged,\n onChange,\n onOpen,\n onClose,\n delay,\n size,\n isDisabled,\n}: DebouncedSearchBoxProps) {\n const [inputValue, setInputValue] = useState<string>(\"\");\n const onChangeRef = useRef(onChange);\n // save latest `onChange` reference into `useRef` to avoid restarting timeout when `onChange` reference changes.\n onChangeRef.current = onChange;\n\n useEffect(() => {\n if (!inputValue) {\n onChangeRef.current(\"\");\n return;\n }\n\n const timeoutId = setTimeout(() => {\n onChangeRef.current(inputValue);\n }, delay);\n\n return () => {\n clearTimeout(timeoutId);\n };\n }, [inputValue, delay]);\n\n return (\n <SearchBox\n expandable\n isExpanded={isOpened}\n onExpand={onOpen}\n onCollapse={onClose}\n size={size}\n className={classnames(\"tree-widget-search-box\", !isOpened && \"contracted\")}\n isDisabled={isDisabled}\n >\n <SearchBox.CollapsedState>\n <SearchBox.ExpandButton\n title={TreeWidget.translate(\"header.searchBox.searchForSomething\")}\n aria-label={TreeWidget.translate(\"header.searchBox.open\")}\n size={size}\n styleType=\"borderless\"\n />\n </SearchBox.CollapsedState>\n <SearchBox.ExpandedState>\n <SearchBox.Input placeholder={TreeWidget.translate(\"header.searchBox.search\")} onChange={(e) => setInputValue(e.currentTarget.value)} />\n <SearchResultStepper selectedIndex={selectedResultIndex} total={resultCount} onStep={onSelectedResultChanged} size={size} />\n <SearchBox.CollapseButton\n onClick={() => {\n setInputValue(\"\");\n onClose();\n }}\n size={size}\n aria-label={TreeWidget.translate(\"header.searchBox.close\")}\n />\n </SearchBox.ExpandedState>\n </SearchBox>\n );\n}\n\ninterface HeaderButtonsProps {\n contracted: boolean;\n children?: React.ReactNode;\n size: \"large\" | \"small\";\n}\n\nfunction HeaderButtons(props: HeaderButtonsProps) {\n const className = classnames(\"button-container\", props.contracted && \"contracted\");\n\n return (\n <ButtonGroup\n className={className}\n overflowButton={(overflowStart) => (\n <DropdownMenu\n menuItems={() =>\n Children.toArray(props.children)\n .slice(overflowStart)\n .map((btn, index) => (\n <li key={index} className=\"dropdown-item\" role=\"menuitem\">\n {btn}\n </li>\n ))\n }\n className=\"tree-header-button-dropdown-container\"\n >\n <IconButton title={TreeWidget.translate(\"header.dropdownMore\")} styleType=\"borderless\" size={props.size}>\n <SvgMore />\n </IconButton>\n </DropdownMenu>\n )}\n >\n {props.children}\n </ButtonGroup>\n );\n}\n\ninterface SearchResultStepperProps {\n total?: number;\n onStep: (newIndex: number) => void;\n selectedIndex?: number;\n size: \"large\" | \"small\";\n}\n\nfunction SearchResultStepper(props: SearchResultStepperProps) {\n const { selectedIndex = 1, total, onStep } = props;\n if (!total) {\n return null;\n }\n\n return (\n <>\n <span className=\"searchbox-stepping-count\">{`${selectedIndex}/${total}`}</span>\n <Divider orientation=\"vertical\" />\n <SearchBox.Button\n title={TreeWidget.translate(\"header.searchBox.previous\")}\n size={props.size}\n onClick={() => {\n if (selectedIndex > 1) {\n onStep(selectedIndex - 1);\n }\n }}\n >\n <SvgCaretUpSmall />\n </SearchBox.Button>\n <SearchBox.Button\n title={TreeWidget.translate(\"header.searchBox.next\")}\n size={props.size}\n onClick={() => {\n if (selectedIndex < total) {\n onStep(selectedIndex + 1);\n }\n }}\n >\n <SvgCaretDownSmall />\n </SearchBox.Button>\n </>\n );\n}\n"]}
@@ -2,6 +2,7 @@ import { VisibilityTree } from "../common/components/VisibilityTree";
2
2
  import type { CategoryInfo } from "../common/CategoriesVisibilityUtils";
3
3
  import type { ComponentPropsWithoutRef } from "react";
4
4
  import type { ViewManager, Viewport } from "@itwin/core-frontend";
5
+ /** @beta */
5
6
  interface CategoriesTreeOwnProps {
6
7
  filter: string;
7
8
  activeView: Viewport;
@@ -11,12 +12,12 @@ interface CategoriesTreeOwnProps {
11
12
  hierarchyLevelConfig?: {
12
13
  sizeLimit?: number;
13
14
  };
14
- onPerformanceMeasured?: (featureId: string, duration: number) => void;
15
- onFeatureUsed?: (feature: string) => void;
16
15
  }
16
+ /** @beta */
17
17
  type VisibilityTreeProps = ComponentPropsWithoutRef<typeof VisibilityTree>;
18
- type ModelsTreeProps = CategoriesTreeOwnProps & Pick<VisibilityTreeProps, "imodel" | "getSchemaContext" | "height" | "width" | "density" | "selectionMode">;
19
- /** @internal */
20
- export declare function CategoriesTree({ imodel, viewManager, categories, allViewports, getSchemaContext, height, width, activeView, filter, density, hierarchyLevelConfig, selectionMode, onPerformanceMeasured, onFeatureUsed, }: ModelsTreeProps): JSX.Element;
18
+ /** @beta */
19
+ type CategoriesTreeProps = CategoriesTreeOwnProps & Pick<VisibilityTreeProps, "imodel" | "getSchemaContext" | "selectionStorage" | "height" | "width" | "density" | "selectionMode">;
20
+ /** @beta */
21
+ export declare function CategoriesTree({ imodel, viewManager, categories, allViewports, getSchemaContext, selectionStorage, height, width, activeView, filter, density, hierarchyLevelConfig, selectionMode, }: CategoriesTreeProps): JSX.Element;
21
22
  export {};
22
23
  //# sourceMappingURL=CategoriesTree.d.ts.map
@@ -9,12 +9,13 @@ import { SvgLayers } from "@itwin/itwinui-icons-react";
9
9
  import { Text } from "@itwin/itwinui-react";
10
10
  import { TreeWidget } from "../../../TreeWidget";
11
11
  import { VisibilityTree } from "../common/components/VisibilityTree";
12
- import { useFeatureReporting } from "../common/UseFeatureReporting";
12
+ import { VisibilityTreeRenderer } from "../common/components/VisibilityTreeRenderer";
13
+ import { useTelemetryContext } from "../common/UseTelemetryContext";
13
14
  import { CategoriesTreeComponent } from "./CategoriesTreeComponent";
14
15
  import { CategoriesTreeDefinition } from "./CategoriesTreeDefinition";
15
16
  import { CategoriesVisibilityHandler } from "./CategoriesVisibilityHandler";
16
- /** @internal */
17
- export function CategoriesTree({ imodel, viewManager, categories, allViewports, getSchemaContext, height, width, activeView, filter, density, hierarchyLevelConfig, selectionMode, onPerformanceMeasured, onFeatureUsed, }) {
17
+ /** @beta */
18
+ export function CategoriesTree({ imodel, viewManager, categories, allViewports, getSchemaContext, selectionStorage, height, width, activeView, filter, density, hierarchyLevelConfig, selectionMode, }) {
18
19
  const [filteringError, setFilteringError] = useState();
19
20
  const visibilityHandlerFactory = useCallback(() => {
20
21
  const visibilityHandler = new CategoriesVisibilityHandler({
@@ -31,7 +32,7 @@ export function CategoriesTree({ imodel, viewManager, categories, allViewports,
31
32
  dispose: () => visibilityHandler.dispose(),
32
33
  };
33
34
  }, [activeView, allViewports, categories, imodel, viewManager]);
34
- const { reportUsage } = useFeatureReporting({ onFeatureUsed, treeIdentifier: CategoriesTreeComponent.id });
35
+ const { onFeatureUsed } = useTelemetryContext();
35
36
  const getDefinitionsProvider = useCallback((props) => {
36
37
  return new CategoriesTreeDefinition({ ...props, viewType: activeView.view.is2d() ? "2d" : "3d" });
37
38
  }, [activeView]);
@@ -41,7 +42,7 @@ export function CategoriesTree({ imodel, viewManager, categories, allViewports,
41
42
  return undefined;
42
43
  }
43
44
  return async ({ imodelAccess }) => {
44
- reportUsage?.({ featureId: "filtering", reportInteraction: true });
45
+ onFeatureUsed({ featureId: "filtering", reportInteraction: true });
45
46
  try {
46
47
  return await CategoriesTreeDefinition.createInstanceKeyPaths({ imodelAccess, label: filter, viewType: activeView.view.is2d() ? "2d" : "3d" });
47
48
  }
@@ -51,10 +52,8 @@ export function CategoriesTree({ imodel, viewManager, categories, allViewports,
51
52
  return [];
52
53
  }
53
54
  };
54
- }, [filter, activeView, reportUsage]);
55
- return (_jsx(VisibilityTree, { height: height, width: width, imodel: imodel, treeName: CategoriesTreeComponent.id, getSchemaContext: getSchemaContext, visibilityHandlerFactory: visibilityHandlerFactory, getHierarchyDefinition: getDefinitionsProvider, getFilteredPaths: getSearchFilteredPaths, hierarchyLevelSizeLimit: hierarchyLevelConfig?.sizeLimit, getSublabel: getSublabel, getIcon: getIcon, density: density, noDataMessage: getNoDataMessage(filter, filteringError), selectionMode: selectionMode ?? "none", onPerformanceMeasured: (action, duration) => {
56
- onPerformanceMeasured?.(`${CategoriesTreeComponent.id}-${action}`, duration);
57
- }, reportUsage: reportUsage, searchText: filter }));
55
+ }, [filter, activeView, onFeatureUsed]);
56
+ return (_jsx(VisibilityTree, { height: height, width: width, imodel: imodel, treeName: CategoriesTreeComponent.id, selectionStorage: selectionStorage, getSchemaContext: getSchemaContext, visibilityHandlerFactory: visibilityHandlerFactory, getHierarchyDefinition: getDefinitionsProvider, getFilteredPaths: getSearchFilteredPaths, hierarchyLevelSizeLimit: hierarchyLevelConfig?.sizeLimit, density: density, noDataMessage: getNoDataMessage(filter, filteringError), selectionMode: selectionMode ?? "none", highlight: filter === undefined ? undefined : { text: filter }, treeRenderer: (treeProps) => _jsx(VisibilityTreeRenderer, { ...treeProps, getIcon: getIcon, getSublabel: getSublabel }) }));
58
57
  }
59
58
  function getNoDataMessage(filter, error) {
60
59
  if (error) {
@@ -1 +1 @@
1
- {"version":3,"file":"CategoriesTree.js","sourceRoot":"","sources":["../../../../../src/components/trees/categories-tree/CategoriesTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AA6B5E,gBAAgB;AAChB,MAAM,UAAU,cAAc,CAAC,EAC7B,MAAM,EACN,WAAW,EACX,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,MAAM,EACN,KA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AAO,EAChB,aAAa,EAAE,gBAAgB,CAAC,MAAM,EAAE,cAAc,CAAC,EACvD,aAAa,EAAE,aAAa,IAAI,MAAM,EACtC,qBAAqB,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE;YAC1C,qBAAqB,EAAE,CAAC,GAAG,uBAAuB,CAAC,EAAE,IAAI,MAAM,EAAE,EAAE,QAAQ,CAAC,CAAC;QAC/E,CAAC,EACD,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,MAAM,GAClB,CACH,CAAC;AACJ,CAAC;AAED,SAAS,gBAAgB,CAAC,MAAc,EAAE,KAAoC;IAC5E,IAAI,KAAK,EAAE;QACT,OAAO,KAAC,IAAI,cAAE,UAAU,CAAC,SAAS,CAAC,4BAA4B,KAAK,EAAE,CAAC,GAAQ,CAAC;KACjF;IACD,IAAI,MAAM,EAAE;QACV,OAAO,KAAC,IAAI,cAAE,UAAU,CAAC,SAAS,CAAC,oCAAoC,EAAE,EAAE,MAAM,EAAE,CAAC,GAAQ,CAAC;KAC9F;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,OAAO;IACd,OAAO,KAAC,SAAS,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 { IModelApp } from \"@itwin/core-frontend\";\nimport { SvgLayers } from \"@itwin/itwinui-icons-react\";\nimport { Text } from \"@itwin/itwinui-react\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { VisibilityTree } from \"../common/components/VisibilityTree\";\nimport { useFeatureReporting } from \"../common/UseFeatureReporting\";\nimport { CategoriesTreeComponent } from \"./CategoriesTreeComponent\";\nimport { CategoriesTreeDefinition } from \"./CategoriesTreeDefinition\";\nimport { CategoriesVisibilityHandler } from \"./CategoriesVisibilityHandler\";\n\nimport type { CategoryInfo } from \"../common/CategoriesVisibilityUtils\";\nimport type { ComponentPropsWithoutRef } from \"react\";\nimport type { ViewManager, Viewport } from \"@itwin/core-frontend\";\nimport type { HierarchyNode } from \"@itwin/presentation-hierarchies\";\nimport type { PresentationHierarchyNode } from \"@itwin/presentation-hierarchies-react\";\n\ntype CategoriesTreeFilteringError = \"tooManyFilterMatches\" | \"unknownFilterError\";\n\ninterface CategoriesTreeOwnProps {\n filter: string;\n activeView: Viewport;\n categories: CategoryInfo[];\n viewManager?: ViewManager;\n allViewports?: boolean;\n hierarchyLevelConfig?: {\n sizeLimit?: number;\n };\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\"];\n\ntype ModelsTreeProps = CategoriesTreeOwnProps & Pick<VisibilityTreeProps, \"imodel\" | \"getSchemaContext\" | \"height\" | \"width\" | \"density\" | \"selectionMode\">;\n\n/** @internal */\nexport function CategoriesTree({\n imodel,\n viewManager,\n categories,\n allViewports,\n getSchemaContext,\n height,\n width,\n activeView,\n filter,\n density,\n hierarchyLevelConfig,\n selectionMode,\n onPerformanceMeasured,\n onFeatureUsed,\n}: ModelsTreeProps) {\n const [filteringError, setFilteringError] = useState<CategoriesTreeFilteringError | undefined>();\n const visibilityHandlerFactory = useCallback(() => {\n const visibilityHandler = new CategoriesVisibilityHandler({\n imodel,\n viewport: activeView,\n viewManager: viewManager ?? IModelApp.viewManager,\n categories,\n allViewports,\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, allViewports, categories, imodel, viewManager]);\n\n const { reportUsage } = useFeatureReporting({ onFeatureUsed, treeIdentifier: CategoriesTreeComponent.id });\n\n const getDefinitionsProvider = useCallback(\n (props: Parameters<GetHierarchyDefinitionCallback>[0]) => {\n return new CategoriesTreeDefinition({ ...props, viewType: activeView.view.is2d() ? \"2d\" : \"3d\" });\n },\n [activeView],\n );\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 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 setFilteringError(newError);\n return [];\n }\n };\n }, [filter, activeView, reportUsage]);\n\n return (\n <VisibilityTree\n height={height}\n width={width}\n imodel={imodel}\n treeName={CategoriesTreeComponent.id}\n getSchemaContext={getSchemaContext}\n visibilityHandlerFactory={visibilityHandlerFactory}\n getHierarchyDefinition={getDefinitionsProvider}\n getFilteredPaths={getSearchFilteredPaths}\n hierarchyLevelSizeLimit={hierarchyLevelConfig?.sizeLimit}\n getSublabel={getSublabel}\n getIcon={getIcon}\n density={density}\n noDataMessage={getNoDataMessage(filter, filteringError)}\n selectionMode={selectionMode ?? \"none\"}\n onPerformanceMeasured={(action, duration) => {\n onPerformanceMeasured?.(`${CategoriesTreeComponent.id}-${action}`, duration);\n }}\n reportUsage={reportUsage}\n searchText={filter}\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
+ {"version":3,"file":"CategoriesTree.js","sourceRoot":"","sources":["../../../../../src/components/trees/categories-tree/CategoriesTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6CAA6C,CAAC;AACrF,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AA6B5E,YAAY;AACZ,MAAM,UAAU,cAAc,CAAC,EAC7B,MAAM,EACN,WAAW,EACX,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,MAAM,EACN,KAAK,EACL,UAAU,EACV,MAAM,EACN,OAAO,EACP,oBAAoB,EACpB,aAAa,GACO;IACpB,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,EAA4C,CAAC;IACjG,MAAM,wBAAwB,GAAG,WAAW,CAAC,GAA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AE,OAAO,EAAE,WAAW,EAAE,WAAW,GAAI,GAClH,CACH,CAAC;AACJ,CAAC;AAED,SAAS,gBAAgB,CAAC,MAAc,EAAE,KAAoC;IAC5E,IAAI,KAAK,EAAE;QACT,OAAO,KAAC,IAAI,cAAE,UAAU,CAAC,SAAS,CAAC,4BAA4B,KAAK,EAAE,CAAC,GAAQ,CAAC;KACjF;IACD,IAAI,MAAM,EAAE;QACV,OAAO,KAAC,IAAI,cAAE,UAAU,CAAC,SAAS,CAAC,oCAAoC,EAAE,EAAE,MAAM,EAAE,CAAC,GAAQ,CAAC;KAC9F;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,OAAO;IACd,OAAO,KAAC,SAAS,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 { IModelApp } from \"@itwin/core-frontend\";\nimport { SvgLayers } from \"@itwin/itwinui-icons-react\";\nimport { Text } from \"@itwin/itwinui-react\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { VisibilityTree } from \"../common/components/VisibilityTree\";\nimport { VisibilityTreeRenderer } from \"../common/components/VisibilityTreeRenderer\";\nimport { useTelemetryContext } from \"../common/UseTelemetryContext\";\nimport { CategoriesTreeComponent } from \"./CategoriesTreeComponent\";\nimport { CategoriesTreeDefinition } from \"./CategoriesTreeDefinition\";\nimport { CategoriesVisibilityHandler } from \"./CategoriesVisibilityHandler\";\n\nimport type { CategoryInfo } from \"../common/CategoriesVisibilityUtils\";\nimport type { ComponentPropsWithoutRef } from \"react\";\nimport type { ViewManager, Viewport } from \"@itwin/core-frontend\";\nimport type { HierarchyNode } from \"@itwin/presentation-hierarchies\";\nimport type { PresentationHierarchyNode } from \"@itwin/presentation-hierarchies-react\";\n\ntype CategoriesTreeFilteringError = \"tooManyFilterMatches\" | \"unknownFilterError\";\n\n/** @beta */\ninterface CategoriesTreeOwnProps {\n filter: string;\n activeView: Viewport;\n categories: CategoryInfo[];\n viewManager?: ViewManager;\n allViewports?: boolean;\n hierarchyLevelConfig?: {\n sizeLimit?: number;\n };\n}\n\n/** @beta */\ntype VisibilityTreeProps = ComponentPropsWithoutRef<typeof VisibilityTree>;\n\n/** @beta */\ntype CategoriesTreeProps = CategoriesTreeOwnProps &\n Pick<VisibilityTreeProps, \"imodel\" | \"getSchemaContext\" | \"selectionStorage\" | \"height\" | \"width\" | \"density\" | \"selectionMode\">;\n\n/** @beta */\nexport function CategoriesTree({\n imodel,\n viewManager,\n categories,\n allViewports,\n getSchemaContext,\n selectionStorage,\n height,\n width,\n activeView,\n filter,\n density,\n hierarchyLevelConfig,\n selectionMode,\n}: CategoriesTreeProps) {\n const [filteringError, setFilteringError] = useState<CategoriesTreeFilteringError | undefined>();\n const visibilityHandlerFactory = useCallback(() => {\n const visibilityHandler = new CategoriesVisibilityHandler({\n imodel,\n viewport: activeView,\n viewManager: viewManager ?? IModelApp.viewManager,\n categories,\n allViewports,\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, allViewports, categories, imodel, viewManager]);\n const { onFeatureUsed } = useTelemetryContext();\n\n const getDefinitionsProvider = useCallback<VisibilityTreeProps[\"getHierarchyDefinition\"]>(\n (props) => {\n return new CategoriesTreeDefinition({ ...props, viewType: activeView.view.is2d() ? \"2d\" : \"3d\" });\n },\n [activeView],\n );\n\n const getSearchFilteredPaths = 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 setFilteringError(newError);\n return [];\n }\n };\n }, [filter, activeView, onFeatureUsed]);\n\n return (\n <VisibilityTree\n height={height}\n width={width}\n imodel={imodel}\n treeName={CategoriesTreeComponent.id}\n selectionStorage={selectionStorage}\n getSchemaContext={getSchemaContext}\n visibilityHandlerFactory={visibilityHandlerFactory}\n getHierarchyDefinition={getDefinitionsProvider}\n getFilteredPaths={getSearchFilteredPaths}\n hierarchyLevelSizeLimit={hierarchyLevelConfig?.sizeLimit}\n density={density}\n noDataMessage={getNoDataMessage(filter, filteringError)}\n selectionMode={selectionMode ?? \"none\"}\n highlight={filter === undefined ? undefined : { text: filter }}\n treeRenderer={(treeProps) => <VisibilityTreeRenderer {...treeProps} getIcon={getIcon} getSublabel={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"]}
@@ -12,10 +12,10 @@ export interface CategoriesTreeHeaderButtonProps extends TreeHeaderButtonProps {
12
12
  /** In case the tree is filtered, a list of filtered categories. */
13
13
  filteredCategories?: CategoryInfo[];
14
14
  }
15
- /** @internal */
15
+ /** @public */
16
16
  export declare function ShowAllButton(props: CategoriesTreeHeaderButtonProps): JSX.Element;
17
- /** @internal */
17
+ /** @public */
18
18
  export declare function HideAllButton(props: CategoriesTreeHeaderButtonProps): JSX.Element;
19
- /** @internal */
19
+ /** @public */
20
20
  export declare function InvertAllButton(props: CategoriesTreeHeaderButtonProps): JSX.Element;
21
21
  //# sourceMappingURL=CategoriesTreeButtons.d.ts.map
@@ -7,21 +7,21 @@ import { SvgVisibilityHalf, SvgVisibilityHide, SvgVisibilityShow } from "@itwin/
7
7
  import { IconButton } from "@itwin/itwinui-react";
8
8
  import { TreeWidget } from "../../../TreeWidget";
9
9
  import { hideAllCategories, invertAllCategories, showAllCategories } from "../common/CategoriesVisibilityUtils";
10
- /** @internal */
10
+ /** @public */
11
11
  export function ShowAllButton(props) {
12
12
  return (_jsx(IconButton, { size: props.density === "enlarged" ? "large" : "small", styleType: "borderless", title: TreeWidget.translate("categoriesTree.buttons.showAll.tooltip"), onClick: () => {
13
13
  props.onFeatureUsed?.(`categories-tree-showall`);
14
14
  void showAllCategories((props.filteredCategories ?? props.categories).map((category) => category.categoryId), props.viewport);
15
15
  }, children: _jsx(SvgVisibilityShow, {}) }));
16
16
  }
17
- /** @internal */
17
+ /** @public */
18
18
  export function HideAllButton(props) {
19
19
  return (_jsx(IconButton, { size: props.density === "enlarged" ? "large" : "small", styleType: "borderless", title: TreeWidget.translate("categoriesTree.buttons.hideAll.tooltip"), onClick: () => {
20
20
  props.onFeatureUsed?.(`categories-tree-hideall`);
21
21
  void hideAllCategories((props.filteredCategories ?? props.categories).map((category) => category.categoryId), props.viewport);
22
22
  }, children: _jsx(SvgVisibilityHide, {}) }));
23
23
  }
24
- /** @internal */
24
+ /** @public */
25
25
  export function InvertAllButton(props) {
26
26
  return (_jsx(IconButton, { title: TreeWidget.translate("categoriesTree.buttons.invert.tooltip"), size: props.density === "enlarged" ? "large" : "small", styleType: "borderless", onClick: () => {
27
27
  props.onFeatureUsed?.(`categories-tree-invert`);
@@ -1 +1 @@
1
- {"version":3,"file":"CategoriesTreeButtons.js","sourceRoot":"","sources":["../../../../../src/components/trees/categories-tree/CategoriesTreeButtons.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACrG,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAiBhH,gBAAgB;AAChB,MAAM,UAAU,aAAa,CAAC,KAAsC;IAClE,OAAO,CACL,KAAC,UAAU,IACT,IAAI,EAAE,KAAK,CAAC,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,EACtD,SAAS,EAAC,YAAY,EACtB,KAAK,EAAE,UAAU,CAAC,SAAS,CAAC,wCAAwC,CAAC,EACrE,OAAO,EAAE,GAAG,EAAE;YACZ,KAAK,CAAC,aAAa,EAAE,CAAC,yBAAyB,CAAC,CAAC;YACjD,KAAK,iBAAiB,CACpB,CAAC,KAAK,CAAC,kBAAkB,IAAI,KAAK,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,EACrF,KAAK,CAAC,QAAQ,CACf,CAAC;QACJ,CAAC,YAED,KAAC,iBAAiB,KAAG,GACV,CACd,CAAC;AACJ,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,aAAa,CAAC,KAAsC;IAClE,OAAO,CACL,KAAC,UAAU,IACT,IAAI,EAAE,KAAK,CAAC,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,EACtD,SAAS,EAAC,YAAY,EACtB,KAAK,EAAE,UAAU,CAAC,SAAS,CAAC,wCAAwC,CAAC,EACrE,OAAO,EAAE,GAAG,EAAE;YACZ,KAAK,CAAC,aAAa,EAAE,CAAC,yBAAyB,CAAC,CAAC;YACjD,KAAK,iBAAiB,CACpB,CAAC,KAAK,CAAC,kBAAkB,IAAI,KAAK,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,EACrF,KAAK,CAAC,QAAQ,CACf,CAAC;QACJ,CAAC,YAED,KAAC,iBAAiB,KAAG,GACV,CACd,CAAC;AACJ,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,eAAe,CAAC,KAAsC;IACpE,OAAO,CACL,KAAC,UAAU,IACT,KAAK,EAAE,UAAU,CAAC,SAAS,CAAC,uCAAuC,CAAC,EACpE,IAAI,EAAE,KAAK,CAAC,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,EACtD,SAAS,EAAC,YAAY,EACtB,OAAO,EAAE,GAAG,EAAE;YACZ,KAAK,CAAC,aAAa,EAAE,CAAC,wBAAwB,CAAC,CAAC;YAChD,KAAK,mBAAmB,CAAC,KAAK,CAAC,kBAAkB,IAAI,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;QACzF,CAAC,YAED,KAAC,iBAAiB,KAAG,GACV,CACd,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 { SvgVisibilityHalf, SvgVisibilityHide, SvgVisibilityShow } from \"@itwin/itwinui-icons-react\";\nimport { IconButton } from \"@itwin/itwinui-react\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { hideAllCategories, invertAllCategories, showAllCategories } from \"../common/CategoriesVisibilityUtils\";\n\nimport type { CategoryInfo } from \"../common/CategoriesVisibilityUtils\";\nimport type { TreeHeaderButtonProps } from \"../../tree-header/TreeHeader\";\n\n/**\n * Props that get passed to `CategoriesTreeComponent` header button renderer.\n * @see CategoriesTreeComponentProps.headerButtons\n * @public\n */\nexport interface CategoriesTreeHeaderButtonProps extends TreeHeaderButtonProps {\n /** A list of categories available in the iModel */\n categories: CategoryInfo[];\n /** In case the tree is filtered, a list of filtered categories. */\n filteredCategories?: CategoryInfo[];\n}\n\n/** @internal */\nexport function ShowAllButton(props: CategoriesTreeHeaderButtonProps) {\n return (\n <IconButton\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"categoriesTree.buttons.showAll.tooltip\")}\n onClick={() => {\n props.onFeatureUsed?.(`categories-tree-showall`);\n void showAllCategories(\n (props.filteredCategories ?? props.categories).map((category) => category.categoryId),\n props.viewport,\n );\n }}\n >\n <SvgVisibilityShow />\n </IconButton>\n );\n}\n\n/** @internal */\nexport function HideAllButton(props: CategoriesTreeHeaderButtonProps) {\n return (\n <IconButton\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"categoriesTree.buttons.hideAll.tooltip\")}\n onClick={() => {\n props.onFeatureUsed?.(`categories-tree-hideall`);\n void hideAllCategories(\n (props.filteredCategories ?? props.categories).map((category) => category.categoryId),\n props.viewport,\n );\n }}\n >\n <SvgVisibilityHide />\n </IconButton>\n );\n}\n\n/** @internal */\nexport function InvertAllButton(props: CategoriesTreeHeaderButtonProps) {\n return (\n <IconButton\n title={TreeWidget.translate(\"categoriesTree.buttons.invert.tooltip\")}\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n onClick={() => {\n props.onFeatureUsed?.(`categories-tree-invert`);\n void invertAllCategories(props.filteredCategories ?? props.categories, props.viewport);\n }}\n >\n <SvgVisibilityHalf />\n </IconButton>\n );\n}\n"]}
1
+ {"version":3,"file":"CategoriesTreeButtons.js","sourceRoot":"","sources":["../../../../../src/components/tr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EAAE,CAAC,yBAAyB,CAAC,CAAC;YACjD,KAAK,iBAAiB,CACpB,CAAC,KAAK,CAAC,kBAAkB,IAAI,KAAK,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,EACrF,KAAK,CAAC,QAAQ,CACf,CAAC;QACJ,CAAC,YAED,KAAC,iBAAiB,KAAG,GACV,CACd,CAAC;AACJ,CAAC;AAED,cAAc;AACd,MAAM,UAAU,eAAe,CAAC,KAAsC;IACpE,OAAO,CACL,KAAC,UAAU,IACT,KAAK,EAAE,UAAU,CAAC,SAAS,CAAC,uCAAuC,CAAC,EACpE,IAAI,EAAE,KAAK,CAAC,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,EACtD,SAAS,EAAC,YAAY,EACtB,OAAO,EAAE,GAAG,EAAE;YACZ,KAAK,CAAC,aAAa,EAAE,CAAC,wBAAwB,CAAC,CAAC;YAChD,KAAK,mBAAmB,CAAC,KAAK,CAAC,kBAAkB,IAAI,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;QACzF,CAAC,YAED,KAAC,iBAAiB,KAAG,GACV,CACd,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 { SvgVisibilityHalf, SvgVisibilityHide, SvgVisibilityShow } from \"@itwin/itwinui-icons-react\";\nimport { IconButton } from \"@itwin/itwinui-react\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { hideAllCategories, invertAllCategories, showAllCategories } from \"../common/CategoriesVisibilityUtils\";\n\nimport type { CategoryInfo } from \"../common/CategoriesVisibilityUtils\";\nimport type { TreeHeaderButtonProps } from \"../../tree-header/TreeHeader\";\n\n/**\n * Props that get passed to `CategoriesTreeComponent` header button renderer.\n * @see CategoriesTreeComponentProps.headerButtons\n * @public\n */\nexport interface CategoriesTreeHeaderButtonProps extends TreeHeaderButtonProps {\n /** A list of categories available in the iModel */\n categories: CategoryInfo[];\n /** In case the tree is filtered, a list of filtered categories. */\n filteredCategories?: CategoryInfo[];\n}\n\n/** @public */\nexport function ShowAllButton(props: CategoriesTreeHeaderButtonProps) {\n return (\n <IconButton\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"categoriesTree.buttons.showAll.tooltip\")}\n onClick={() => {\n props.onFeatureUsed?.(`categories-tree-showall`);\n void showAllCategories(\n (props.filteredCategories ?? props.categories).map((category) => category.categoryId),\n props.viewport,\n );\n }}\n >\n <SvgVisibilityShow />\n </IconButton>\n );\n}\n\n/** @public */\nexport function HideAllButton(props: CategoriesTreeHeaderButtonProps) {\n return (\n <IconButton\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"categoriesTree.buttons.hideAll.tooltip\")}\n onClick={() => {\n props.onFeatureUsed?.(`categories-tree-hideall`);\n void hideAllCategories(\n (props.filteredCategories ?? props.categories).map((category) => category.categoryId),\n props.viewport,\n );\n }}\n >\n <SvgVisibilityHide />\n </IconButton>\n );\n}\n\n/** @public */\nexport function InvertAllButton(props: CategoriesTreeHeaderButtonProps) {\n return (\n <IconButton\n title={TreeWidget.translate(\"categoriesTree.buttons.invert.tooltip\")}\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n onClick={() => {\n props.onFeatureUsed?.(`categories-tree-invert`);\n void invertAllCategories(props.filteredCategories ?? props.categories, props.viewport);\n }}\n >\n <SvgVisibilityHalf />\n </IconButton>\n );\n}\n"]}
@@ -2,10 +2,9 @@ import "../Tree.scss";
2
2
  import { CategoriesTree } from "./CategoriesTree";
3
3
  import { HideAllButton, InvertAllButton, ShowAllButton } from "./CategoriesTreeButtons";
4
4
  import type { ComponentPropsWithoutRef } from "react";
5
- import type { SelectionStorage } from "@itwin/presentation-hierarchies-react";
6
5
  import type { CategoriesTreeHeaderButtonProps } from "./CategoriesTreeButtons";
7
- type CategoriesTreeProps = ComponentPropsWithoutRef<typeof CategoriesTree>;
8
- interface CategoriesTreeComponentProps extends Pick<CategoriesTreeProps, "getSchemaContext" | "density" | "hierarchyLevelConfig" | "selectionMode" | "onPerformanceMeasured" | "onFeatureUsed"> {
6
+ /** @public */
7
+ interface CategoriesTreeComponentProps extends Pick<ComponentPropsWithoutRef<typeof CategoriesTree>, "getSchemaContext" | "selectionStorage" | "density" | "hierarchyLevelConfig" | "selectionMode"> {
9
8
  /**
10
9
  * Renderers of header buttons. Defaults to:
11
10
  * ```ts
@@ -17,7 +16,8 @@ interface CategoriesTreeComponentProps extends Pick<CategoriesTreeProps, "getSch
17
16
  * ```
18
17
  */
19
18
  headerButtons?: Array<(props: CategoriesTreeHeaderButtonProps) => React.ReactNode>;
20
- selectionStorage: SelectionStorage;
19
+ onPerformanceMeasured?: (featureId: string, duration: number) => void;
20
+ onFeatureUsed?: (feature: string) => void;
21
21
  }
22
22
  /**
23
23
  * A component that renders `CategoriesTree` and a header with filtering capabilities and header buttons.
@@ -8,11 +8,11 @@ import classNames from "classnames";
8
8
  import { Fragment } from "react";
9
9
  import { useActiveIModelConnection, useActiveViewport } from "@itwin/appui-react";
10
10
  import { IModelApp } from "@itwin/core-frontend";
11
- import { UnifiedSelectionProvider } from "@itwin/presentation-hierarchies-react";
12
11
  import { TreeWidget } from "../../../TreeWidget";
13
12
  import { TreeHeader } from "../../tree-header/TreeHeader";
14
13
  import { AutoSizer } from "../../utils/AutoSizer";
15
14
  import { useFiltering } from "../common/UseFiltering";
15
+ import { TelemetryContextProvider } from "../common/UseTelemetryContext";
16
16
  import { CategoriesTree } from "./CategoriesTree";
17
17
  import { HideAllButton, InvertAllButton, ShowAllButton } from "./CategoriesTreeButtons";
18
18
  import { useCategories } from "./UseCategories";
@@ -53,16 +53,16 @@ CategoriesTreeComponent.id = "categories-tree-v2";
53
53
  * @public
54
54
  */
55
55
  CategoriesTreeComponent.getLabel = () => TreeWidget.translate("categoriesTree.label");
56
- function CategoriesTreeComponentImpl({ iModel, viewport, headerButtons, selectionStorage, ...treeProps }) {
56
+ function CategoriesTreeComponentImpl({ iModel, viewport, headerButtons, onPerformanceMeasured, onFeatureUsed, ...treeProps }) {
57
57
  const categories = useCategories(IModelApp.viewManager, iModel, viewport);
58
58
  const { filter, applyFilter, clearFilter } = useFiltering();
59
59
  const density = treeProps.density;
60
- return (_jsx("div", { className: classNames("tw-tree-with-header", density === "enlarged" && "enlarge"), children: _jsxs(UnifiedSelectionProvider, { storage: selectionStorage, children: [_jsx(TreeHeader, { onFilterStart: applyFilter, onFilterClear: clearFilter, onSelectedChanged: () => { }, density: density, children: headerButtons
61
- ? headerButtons.map((btn, index) => _jsx(Fragment, { children: btn({ viewport, categories, onFeatureUsed: treeProps.onFeatureUsed }) }, index))
60
+ return (_jsx(TelemetryContextProvider, { componentIdentifier: CategoriesTreeComponent.id, onFeatureUsed: onFeatureUsed, onPerformanceMeasured: onPerformanceMeasured, children: _jsxs("div", { className: classNames("tw-tree-with-header", density === "enlarged" && "enlarge"), children: [_jsx(TreeHeader, { onFilterStart: applyFilter, onFilterClear: clearFilter, onSelectedChanged: () => { }, density: density, children: headerButtons
61
+ ? headerButtons.map((btn, index) => _jsx(Fragment, { children: btn({ viewport, categories, onFeatureUsed }) }, index))
62
62
  : [
63
- _jsx(ShowAllButton, { viewport: viewport, categories: categories, density: density, onFeatureUsed: treeProps.onFeatureUsed }, "show-all-btn"),
64
- _jsx(HideAllButton, { viewport: viewport, categories: categories, density: density, onFeatureUsed: treeProps.onFeatureUsed }, "hide-all-btn"),
65
- _jsx(InvertAllButton, { viewport: viewport, categories: categories, density: density, onFeatureUsed: treeProps.onFeatureUsed }, "invert-all-btn"),
63
+ _jsx(ShowAllButton, { viewport: viewport, categories: categories, density: density, onFeatureUsed: onFeatureUsed }, "show-all-btn"),
64
+ _jsx(HideAllButton, { viewport: viewport, categories: categories, density: density, onFeatureUsed: onFeatureUsed }, "hide-all-btn"),
65
+ _jsx(InvertAllButton, { viewport: viewport, categories: categories, density: density, onFeatureUsed: onFeatureUsed }, "invert-all-btn"),
66
66
  ] }), _jsx("div", { className: "tw-tree-content", children: _jsx(AutoSizer, { children: ({ width, height }) => (_jsx(CategoriesTree, { ...treeProps, imodel: iModel, categories: categories, activeView: viewport, width: width, height: height, filter: filter })) }) })] }) }));
67
67
  }
68
68
  //# sourceMappingURL=CategoriesTreeComponent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CategoriesTreeComponent.js","sourceRoot":"","sources":["../../../../../src/components/trees/categories-tree/CategoriesTreeComponent.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,cAAc,CAAC;AACtB,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAClF,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,uCAAuC,CAAC;AACjF,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxF,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAyBhD;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG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CAAC,EAAE,OAAO,EAAE,OAAO,YAC9G,aAAa;wBACZ,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,KAAC,QAAQ,cAAc,GAAG,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,CAAC,aAAa,EAAE,CAAC,IAA7E,KAAK,CAAoF,CAAC;wBAC7I,CAAC,CAAC;4BACE,KAAC,aAAa,IAAC,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAqB,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,SAAS,CAAC,aAAa,IAAvE,cAAc,CAA6D;4BAC1I,KAAC,aAAa,IAAC,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAqB,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,SAAS,CAAC,aAAa,IAAvE,cAAc,CAA6D;4BAC1I,KAAC,eAAe,IAAC,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAuB,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,SAAS,CAAC,aAAa,IAAzE,gBAAgB,CAA6D;yBAC/I,GACM,EACb,cAAK,SAAS,EAAC,iBAAiB,YAC9B,KAAC,SAAS,cACP,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CACtB,KAAC,cAAc,OAAK,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAI,CAC9I,GACS,GACR,IACmB,GACvB,CACP,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 \"../Tree.scss\";\nimport classNames from \"classnames\";\nimport { Fragment } from \"react\";\nimport { useActiveIModelConnection, useActiveViewport } from \"@itwin/appui-react\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { UnifiedSelectionProvider } from \"@itwin/presentation-hierarchies-react\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { TreeHeader } from \"../../tree-header/TreeHeader\";\nimport { AutoSizer } from \"../../utils/AutoSizer\";\nimport { useFiltering } from \"../common/UseFiltering\";\nimport { CategoriesTree } from \"./CategoriesTree\";\nimport { HideAllButton, InvertAllButton, ShowAllButton } from \"./CategoriesTreeButtons\";\nimport { useCategories } from \"./UseCategories\";\n\nimport type { ComponentPropsWithoutRef } from \"react\";\nimport type { IModelConnection, ScreenViewport } from \"@itwin/core-frontend\";\nimport type { SelectionStorage } from \"@itwin/presentation-hierarchies-react\";\nimport type { CategoriesTreeHeaderButtonProps } from \"./CategoriesTreeButtons\";\n\ntype CategoriesTreeProps = ComponentPropsWithoutRef<typeof CategoriesTree>;\n\ninterface CategoriesTreeComponentProps\n extends Pick<CategoriesTreeProps, \"getSchemaContext\" | \"density\" | \"hierarchyLevelConfig\" | \"selectionMode\" | \"onPerformanceMeasured\" | \"onFeatureUsed\"> {\n /**\n * Renderers of header buttons. Defaults to:\n * ```ts\n * [\n * CategoriesTreeComponent.ShowAllButton,\n * CategoriesTreeComponent.HideAllButton,\n * CategoriesTreeComponent.InvertAllButton,\n * ]\n * ```\n */\n headerButtons?: Array<(props: CategoriesTreeHeaderButtonProps) => React.ReactNode>;\n selectionStorage: SelectionStorage;\n}\n\n/**\n * A component that renders `CategoriesTree` and a header with filtering capabilities and header buttons.\n * @public\n */\nexport const CategoriesTreeComponent = (props: CategoriesTreeComponentProps) => {\n const iModel = useActiveIModelConnection();\n const viewport = useActiveViewport();\n\n if (!iModel || !viewport) {\n return null;\n }\n\n return <CategoriesTreeComponentImpl {...props} iModel={iModel} viewport={viewport} />;\n};\n\n/**\n * Renders a \"Show all\" button that enables display of all categories and their subcategories.\n * @public\n */\nCategoriesTreeComponent.ShowAllButton = ShowAllButton;\n\n/**\n * Renders a \"Hide all\" button that disables display of all categories.\n * @public\n */\nCategoriesTreeComponent.HideAllButton = HideAllButton;\n\n/**\n * Renders an \"Invert all\" button that inverts display of all categories.\n * @public\n */\nCategoriesTreeComponent.InvertAllButton = InvertAllButton;\n\n/**\n * Id of the component. May be used when a creating a `TreeDefinition` for `SelectableTree`.\n * @public\n */\nCategoriesTreeComponent.id = \"categories-tree-v2\";\n\n/**\n * Label of the component. May be used when a creating a `TreeDefinition` for `SelectableTree`.\n * @public\n */\nCategoriesTreeComponent.getLabel = () => TreeWidget.translate(\"categoriesTree.label\");\n\nfunction CategoriesTreeComponentImpl({\n iModel,\n viewport,\n headerButtons,\n selectionStorage,\n ...treeProps\n}: CategoriesTreeComponentProps & { iModel: IModelConnection; viewport: ScreenViewport }) {\n const categories = useCategories(IModelApp.viewManager, iModel, viewport);\n const { filter, applyFilter, clearFilter } = useFiltering();\n const density = treeProps.density;\n return (\n <div className={classNames(\"tw-tree-with-header\", density === \"enlarged\" && \"enlarge\")}>\n <UnifiedSelectionProvider storage={selectionStorage}>\n <TreeHeader onFilterStart={applyFilter} onFilterClear={clearFilter} onSelectedChanged={() => {}} density={density}>\n {headerButtons\n ? headerButtons.map((btn, index) => <Fragment key={index}>{btn({ viewport, categories, onFeatureUsed: treeProps.onFeatureUsed })}</Fragment>)\n : [\n <ShowAllButton viewport={viewport} categories={categories} key=\"show-all-btn\" density={density} onFeatureUsed={treeProps.onFeatureUsed} />,\n <HideAllButton viewport={viewport} categories={categories} key=\"hide-all-btn\" density={density} onFeatureUsed={treeProps.onFeatureUsed} />,\n <InvertAllButton viewport={viewport} categories={categories} key=\"invert-all-btn\" density={density} onFeatureUsed={treeProps.onFeatureUsed} />,\n ]}\n </TreeHeader>\n <div className=\"tw-tree-content\">\n <AutoSizer>\n {({ width, height }) => (\n <CategoriesTree {...treeProps} imodel={iModel} categories={categories} activeView={viewport} width={width} height={height} filter={filter} />\n )}\n </AutoSizer>\n </div>\n </UnifiedSelectionProvider>\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"CategoriesTreeComponent.js","sourceRoot":"","sources":["../../../../../src/components/trees/categories-tree/CategoriesTreeComponent.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,cAAc,CAAC;AACtB,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAClF,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxF,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AA2BhD;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,KAAmC,EAAE,EAAE;IAC7E,MAAM,MAAM,GAAG,yBAAyB,EAAE,CAAC;IAC3C,MAAM,QAAQ,GAAG,iBAAiB,EAAE,CAAC;IAErC,IAAI,CAAC,MAAM,IAAI,CAAC,QAAQ,EAAE;QACxB,OAAO,IAAI,CAAC;KACb;IAED,OAAO,KAAC,2BAA2B,OAAK,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAI,CAAC;AACxF,CAA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,CAAC;wBACpH,CAAC,CAAC;4BACE,KAAC,aAAa,IAAC,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAqB,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,IAA7D,cAAc,CAAmD;4BAChI,KAAC,aAAa,IAAC,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAqB,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,IAA7D,cAAc,CAAmD;4BAChI,KAAC,eAAe,IAAC,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAuB,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,IAA/D,gBAAgB,CAAmD;yBACrI,GACM,EACb,cAAK,SAAS,EAAC,iBAAiB,YAC9B,KAAC,SAAS,cACP,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CACtB,KAAC,cAAc,OAAK,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAI,CAC9I,GACS,GACR,IACF,GACmB,CAC5B,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport \"../Tree.scss\";\nimport classNames from \"classnames\";\nimport { Fragment } from \"react\";\nimport { useActiveIModelConnection, useActiveViewport } from \"@itwin/appui-react\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { TreeHeader } from \"../../tree-header/TreeHeader\";\nimport { AutoSizer } from \"../../utils/AutoSizer\";\nimport { useFiltering } from \"../common/UseFiltering\";\nimport { TelemetryContextProvider } from \"../common/UseTelemetryContext\";\nimport { CategoriesTree } from \"./CategoriesTree\";\nimport { HideAllButton, InvertAllButton, ShowAllButton } from \"./CategoriesTreeButtons\";\nimport { useCategories } from \"./UseCategories\";\n\nimport type { ComponentPropsWithoutRef } from \"react\";\nimport type { IModelConnection, ScreenViewport } from \"@itwin/core-frontend\";\nimport type { CategoriesTreeHeaderButtonProps } from \"./CategoriesTreeButtons\";\n\n/** @public */\ninterface CategoriesTreeComponentProps\n extends Pick<\n ComponentPropsWithoutRef<typeof CategoriesTree>,\n \"getSchemaContext\" | \"selectionStorage\" | \"density\" | \"hierarchyLevelConfig\" | \"selectionMode\"\n > {\n /**\n * Renderers of header buttons. Defaults to:\n * ```ts\n * [\n * CategoriesTreeComponent.ShowAllButton,\n * CategoriesTreeComponent.HideAllButton,\n * CategoriesTreeComponent.InvertAllButton,\n * ]\n * ```\n */\n headerButtons?: Array<(props: CategoriesTreeHeaderButtonProps) => React.ReactNode>;\n onPerformanceMeasured?: (featureId: string, duration: number) => void;\n onFeatureUsed?: (feature: string) => void;\n}\n\n/**\n * A component that renders `CategoriesTree` and a header with filtering capabilities and header buttons.\n * @public\n */\nexport const CategoriesTreeComponent = (props: CategoriesTreeComponentProps) => {\n const iModel = useActiveIModelConnection();\n const viewport = useActiveViewport();\n\n if (!iModel || !viewport) {\n return null;\n }\n\n return <CategoriesTreeComponentImpl {...props} iModel={iModel} viewport={viewport} />;\n};\n\n/**\n * Renders a \"Show all\" button that enables display of all categories and their subcategories.\n * @public\n */\nCategoriesTreeComponent.ShowAllButton = ShowAllButton;\n\n/**\n * Renders a \"Hide all\" button that disables display of all categories.\n * @public\n */\nCategoriesTreeComponent.HideAllButton = HideAllButton;\n\n/**\n * Renders an \"Invert all\" button that inverts display of all categories.\n * @public\n */\nCategoriesTreeComponent.InvertAllButton = InvertAllButton;\n\n/**\n * Id of the component. May be used when a creating a `TreeDefinition` for `SelectableTree`.\n * @public\n */\nCategoriesTreeComponent.id = \"categories-tree-v2\";\n\n/**\n * Label of the component. May be used when a creating a `TreeDefinition` for `SelectableTree`.\n * @public\n */\nCategoriesTreeComponent.getLabel = () => TreeWidget.translate(\"categoriesTree.label\");\n\nfunction CategoriesTreeComponentImpl({\n iModel,\n viewport,\n headerButtons,\n onPerformanceMeasured,\n onFeatureUsed,\n ...treeProps\n}: CategoriesTreeComponentProps & { iModel: IModelConnection; viewport: ScreenViewport }) {\n const categories = useCategories(IModelApp.viewManager, iModel, viewport);\n const { filter, applyFilter, clearFilter } = useFiltering();\n const density = treeProps.density;\n return (\n <TelemetryContextProvider componentIdentifier={CategoriesTreeComponent.id} onFeatureUsed={onFeatureUsed} onPerformanceMeasured={onPerformanceMeasured}>\n <div className={classNames(\"tw-tree-with-header\", density === \"enlarged\" && \"enlarge\")}>\n <TreeHeader onFilterStart={applyFilter} onFilterClear={clearFilter} onSelectedChanged={() => {}} density={density}>\n {headerButtons\n ? headerButtons.map((btn, index) => <Fragment key={index}>{btn({ viewport, categories, onFeatureUsed })}</Fragment>)\n : [\n <ShowAllButton viewport={viewport} categories={categories} key=\"show-all-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n <HideAllButton viewport={viewport} categories={categories} key=\"hide-all-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n <InvertAllButton viewport={viewport} categories={categories} key=\"invert-all-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n ]}\n </TreeHeader>\n <div className=\"tw-tree-content\">\n <AutoSizer>\n {({ width, height }) => (\n <CategoriesTree {...treeProps} imodel={iModel} categories={categories} activeView={viewport} width={width} height={height} filter={filter} />\n )}\n </AutoSizer>\n </div>\n </div>\n </TelemetryContextProvider>\n );\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import type { IModelConnection, ViewManager, 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,25 +9,20 @@ export interface CategoryInfo {
8
9
  }
9
10
  /**
10
11
  * Toggles visibility of categories to show or hide.
11
- * @internal
12
12
  */
13
13
  export declare function toggleAllCategories(viewManager: ViewManager, imodel: IModelConnection, display: boolean, viewport?: Viewport, forAllViewports?: boolean): Promise<void>;
14
14
  /**
15
15
  * Gets ids of all categories from specified imodel and viewport.
16
- * @internal
17
16
  */
18
17
  export declare function getCategories(imodel: IModelConnection, viewport?: Viewport): Promise<string[]>;
19
18
  /**
20
19
  * Changes category display in the viewport.
21
- * @internal
22
20
  */
23
21
  export declare function enableCategoryDisplay(viewManager: ViewManager, imodel: IModelConnection, ids: string[], enabled: boolean, forAllViewports: boolean, enableAllSubCategories?: boolean): Promise<void>;
24
22
  /**
25
23
  * Changes subcategory display in the viewport
26
- * @internal
27
24
  */
28
25
  export declare function enableSubCategoryDisplay(viewManager: ViewManager, key: string, enabled: boolean, forAllViewports?: boolean): void;
29
- /** @internal */
30
26
  export declare function loadCategoriesFromViewport(iModel?: IModelConnection, vp?: Viewport): Promise<CategoryInfo[]>;
31
27
  /**
32
28
  * Enable display of all given categories.
@@ -6,7 +6,6 @@ import { QueryRowFormat } from "@itwin/core-common";
6
6
  import { IModelApp, PerModelCategoryVisibility } from "@itwin/core-frontend";
7
7
  /**
8
8
  * Toggles visibility of categories to show or hide.
9
- * @internal
10
9
  */
11
10
  export async function toggleAllCategories(viewManager, imodel, display, viewport, forAllViewports) {
12
11
  // istanbul ignore next
@@ -20,7 +19,6 @@ export async function toggleAllCategories(viewManager, imodel, display, viewport
20
19
  }
21
20
  /**
22
21
  * Gets ids of all categories from specified imodel and viewport.
23
- * @internal
24
22
  */
25
23
  export async function getCategories(imodel, viewport) {
26
24
  const categories = await loadCategoriesFromViewport(imodel, viewport);
@@ -28,7 +26,6 @@ export async function getCategories(imodel, viewport) {
28
26
  }
29
27
  /**
30
28
  * Changes category display in the viewport.
31
- * @internal
32
29
  */
33
30
  export async function enableCategoryDisplay(viewManager, imodel, ids, enabled, forAllViewports, enableAllSubCategories = true) {
34
31
  if (!viewManager.selectedView) {
@@ -68,7 +65,6 @@ export async function enableCategoryDisplay(viewManager, imodel, ids, enabled, f
68
65
  }
69
66
  /**
70
67
  * Changes subcategory display in the viewport
71
- * @internal
72
68
  */
73
69
  export function enableSubCategoryDisplay(viewManager, key, enabled, forAllViewports) {
74
70
  if (!viewManager.selectedView) {
@@ -91,7 +87,6 @@ export function enableSubCategoryDisplay(viewManager, key, enabled, forAllViewpo
91
87
  updateViewport(viewManager.selectedView);
92
88
  }
93
89
  }
94
- /** @internal */
95
90
  export async function loadCategoriesFromViewport(iModel, vp) {
96
91
  if (!vp) {
97
92
  return EMPTY_CATEGORIES_ARRAY;
@@ -1 +1 @@
1
- {"version":3,"file":"CategoriesVisibilityUtils.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/CategoriesVisibilityUtils.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAY7E;;;GAGG;AACH,MAAM,CAAC,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;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,MAAwB,EAAE,QAAmB;IAC/E,MAAM,UAAU,GAAG,MAAM,0BAA0B,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AkB;IAClB,oBAAoB,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,wBAAwB,CAAC,SAAS,CAAC,WAAW,EAAE,WAAW,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;IAEzH,MAAM,qBAAqB,CAAC,SAAS,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,SAAS,CAAC,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IAEzH,MAAM,qBAAqB,CAAC,SAAS,CAAC,WAAW,EAAE,QAAQ,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAC5F,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 { 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,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAa7E;;GAEG;AACH,MAAM,CAAC,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,CAA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EAAE;YAC/F,KAAK,MAAM,WAAW,IAAI,QAAQ,CAAC,cAAc,EAAE;gBACjD,QAAQ,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,oBAAoB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,qBAAqB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;aAC/H;SACF;aAAM;YACL,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;SACnC;KACF;IAED,kBAAkB;IAClB,oBAAoB,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,wBAAwB,CAAC,SAAS,CAAC,WAAW,EAAE,WAAW,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;IAEzH,MAAM,qBAAqB,CAAC,SAAS,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,SAAS,CAAC,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IAEzH,MAAM,qBAAqB,CAAC,SAAS,CAAC,WAAW,EAAE,QAAQ,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAC5F,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 { 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 * @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(\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 */\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 */\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 */\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\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,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
@@ -3,9 +3,7 @@
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
  import { createContext, useContext } from "react";
6
- /** @internal */
7
6
  export const focusedInstancesContext = createContext({ enabled: false, toggle: () => { } });
8
- /** @internal */
9
7
  export function useFocusedInstancesContext() {
10
8
  return useContext(focusedInstancesContext);
11
9
  }
@@ -1 +1 @@
1
- {"version":3,"file":"FocusedInstancesContext.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/FocusedInstancesContext.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAYlD,gBAAgB;AAChB,MAAM,CAAC,MAAM,uBAAuB,GAAG,aAAa,CAA0B,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,CAAC,CAAC;AAEpH,gBAAgB;AAChB,MAAM,UAAU,0BAA0B;IACxC,OAAO,UAAU,CAAC,uBAAuB,CAAC,CAAC;AAC7C,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 { 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,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAWlD,MAAM,CAAC,MAAM,uBAAuB,GAAG,aAAa,CAA0B,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,CAAC,CAAC;AAEpH,MAAM,UAAU,0BAA0B;IACxC,OAAO,UAAU,CAAC,uBAAuB,CAAC,CAAC;AAC7C,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 { 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;
@@ -7,7 +7,6 @@ import { useEffect, useState } from "react";
7
7
  import { HierarchyNode } from "@itwin/presentation-hierarchies-react";
8
8
  import { Selectable, Selectables } from "@itwin/unified-selection";
9
9
  import { focusedInstancesContext } from "./FocusedInstancesContext";
10
- /** @internal */
11
10
  export function FocusedInstancesContextProvider({ selectionStorage, imodelKey, children, }) {
12
11
  const [state, setState] = useState({
13
12
  enabled: false,
@@ -1 +1 @@
1
- {"version":3,"file":"FocusedInstancesContextProvider.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/FocusedInstancesContextProvider.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAQpE,gBAAgB;AAChB,MAAM,UAAU,+BAA+B,CAAC,EAC9C,gBAAgB,EAChB,SAAS,EACT,QAAQ,GACqE;IAC7E,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAA0B;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,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,OAAO,EAAE;YACZ,QAAQ,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,gBAAgB,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;YAC/D,OAAO;SACR;QAED,MA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AAkB,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,KAAC,uBAAuB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAAoC,CAAC;AACvG,CAAC;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,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,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","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"]}