@itwin/tree-widget-react 4.0.0-alpha.1 → 4.0.0-alpha.11

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 (284) hide show
  1. package/CHANGELOG.md +84 -1
  2. package/README.md +5 -53
  3. package/lib/esm/tree-widget-react/TreeWidget.d.ts +7 -2
  4. package/lib/esm/tree-widget-react/TreeWidget.js +22 -2
  5. package/lib/esm/tree-widget-react/TreeWidget.js.map +1 -1
  6. package/lib/esm/tree-widget-react/components/{SelectableTree.scss → TreeWidgetComponentImpl.css} +0 -1
  7. package/lib/esm/tree-widget-react/components/{SelectableTree.d.ts → TreeWidgetComponentImpl.d.ts} +18 -14
  8. package/lib/esm/tree-widget-react/components/{SelectableTree.js → TreeWidgetComponentImpl.js} +28 -28
  9. package/lib/esm/tree-widget-react/components/TreeWidgetComponentImpl.js.map +1 -0
  10. package/lib/esm/tree-widget-react/components/TreeWidgetUiItemsProvider.d.ts +4 -6
  11. package/lib/esm/tree-widget-react/components/TreeWidgetUiItemsProvider.js +9 -10
  12. package/lib/esm/tree-widget-react/components/TreeWidgetUiItemsProvider.js.map +1 -1
  13. package/lib/esm/tree-widget-react/components/tree-header/ErrorState.d.ts +4 -0
  14. package/lib/esm/tree-widget-react/components/tree-header/ErrorState.js +14 -0
  15. package/lib/esm/tree-widget-react/components/tree-header/ErrorState.js.map +1 -0
  16. package/lib/esm/tree-widget-react/components/tree-header/SearchBox.d.ts +11 -0
  17. package/lib/esm/tree-widget-react/components/tree-header/SearchBox.js +33 -0
  18. package/lib/esm/tree-widget-react/components/tree-header/SearchBox.js.map +1 -0
  19. package/lib/esm/tree-widget-react/components/tree-header/{TreeWithHeader.scss → SelectableTree.css} +9 -8
  20. package/lib/esm/tree-widget-react/components/tree-header/SelectableTree.d.ts +16 -0
  21. package/lib/esm/tree-widget-react/components/tree-header/SelectableTree.js +14 -0
  22. package/lib/esm/tree-widget-react/components/tree-header/SelectableTree.js.map +1 -0
  23. package/lib/esm/tree-widget-react/components/{TreeSelector.scss → tree-header/WidgetHeader.css} +12 -5
  24. package/lib/esm/tree-widget-react/components/tree-header/WidgetHeader.d.ts +36 -0
  25. package/lib/esm/tree-widget-react/components/tree-header/WidgetHeader.js +31 -0
  26. package/lib/esm/tree-widget-react/components/tree-header/WidgetHeader.js.map +1 -0
  27. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTree.d.ts +3 -2
  28. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTree.js +4 -2
  29. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTree.js.map +1 -1
  30. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.d.ts +11 -5
  31. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.js +60 -14
  32. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.js.map +1 -1
  33. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeComponent.d.ts +1 -6
  34. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeComponent.js +4 -10
  35. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeComponent.js.map +1 -1
  36. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.d.ts +39 -4
  37. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js +658 -114
  38. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js.map +1 -1
  39. package/lib/esm/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.d.ts +19 -6
  40. package/lib/esm/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js +83 -82
  41. package/lib/esm/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js.map +1 -1
  42. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.d.ts +68 -0
  43. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js +442 -0
  44. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js.map +1 -0
  45. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeNode.d.ts +41 -0
  46. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeNode.js +50 -0
  47. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeNode.js.map +1 -0
  48. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeVisibilityHandler.d.ts +23 -0
  49. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeVisibilityHandler.js +708 -0
  50. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeVisibilityHandler.js.map +1 -0
  51. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/FilteredTree.d.ts +39 -0
  52. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/FilteredTree.js +221 -0
  53. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/FilteredTree.js.map +1 -0
  54. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/UseFilteredPaths.d.ts +25 -0
  55. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/UseFilteredPaths.js +133 -0
  56. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/UseFilteredPaths.js.map +1 -0
  57. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/UseIdsCache.d.ts +8 -0
  58. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/UseIdsCache.js +48 -0
  59. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/UseIdsCache.js.map +1 -0
  60. package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTree.d.ts +12 -0
  61. package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTree.js +14 -0
  62. package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTree.js.map +1 -0
  63. package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeComponent.d.ts +23 -0
  64. package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeComponent.js +47 -0
  65. package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeComponent.js.map +1 -0
  66. package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeDefinition.d.ts +38 -0
  67. package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeDefinition.js +353 -0
  68. package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeDefinition.js.map +1 -0
  69. package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeIcon.d.ts +6 -0
  70. package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeIcon.js +37 -0
  71. package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeIcon.js.map +1 -0
  72. package/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTree.d.ts +23 -0
  73. package/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTree.js +52 -0
  74. package/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTree.js.map +1 -0
  75. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeIdsCache.d.ts +38 -0
  76. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeIdsCache.js +269 -0
  77. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeIdsCache.js.map +1 -0
  78. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeNode.d.ts +20 -0
  79. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeNode.js +36 -0
  80. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeNode.js.map +1 -0
  81. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeVisibilityHandler.d.ts +19 -0
  82. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeVisibilityHandler.js +484 -0
  83. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeVisibilityHandler.js.map +1 -0
  84. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/UseIdsCache.d.ts +8 -0
  85. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/UseIdsCache.js +45 -0
  86. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/UseIdsCache.js.map +1 -0
  87. package/lib/esm/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.d.ts +5 -21
  88. package/lib/esm/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.js +5 -62
  89. package/lib/esm/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.js.map +1 -1
  90. package/lib/esm/tree-widget-react/components/trees/common/FocusedInstancesContext.d.ts +28 -4
  91. package/lib/esm/tree-widget-react/components/trees/common/FocusedInstancesContext.js +73 -2
  92. package/lib/esm/tree-widget-react/components/trees/common/FocusedInstancesContext.js.map +1 -1
  93. package/lib/esm/tree-widget-react/components/trees/common/TreeErrors.js +1 -0
  94. package/lib/esm/tree-widget-react/components/trees/common/TreeErrors.js.map +1 -1
  95. package/lib/esm/tree-widget-react/components/trees/common/UseHierarchyVisibility.d.ts +4 -4
  96. package/lib/esm/tree-widget-react/components/trees/common/UseHierarchyVisibility.js +12 -6
  97. package/lib/esm/tree-widget-react/components/trees/common/UseHierarchyVisibility.js.map +1 -1
  98. package/lib/esm/tree-widget-react/components/trees/common/UseNodeHighlighting.d.ts +3 -3
  99. package/lib/esm/tree-widget-react/components/trees/common/UseNodeHighlighting.js +13 -15
  100. package/lib/esm/tree-widget-react/components/trees/common/UseNodeHighlighting.js.map +1 -1
  101. package/lib/esm/tree-widget-react/components/trees/common/UseTelemetryContext.d.ts +1 -0
  102. package/lib/esm/tree-widget-react/components/trees/common/UseTelemetryContext.js +2 -1
  103. package/lib/esm/tree-widget-react/components/trees/common/UseTelemetryContext.js.map +1 -1
  104. package/lib/esm/tree-widget-react/components/trees/common/Utils.d.ts +38 -23
  105. package/lib/esm/tree-widget-react/components/trees/common/Utils.js +65 -47
  106. package/lib/esm/tree-widget-react/components/trees/common/Utils.js.map +1 -1
  107. package/lib/esm/tree-widget-react/components/trees/common/components/BaseTreeRenderer.d.ts +6 -0
  108. package/lib/esm/tree-widget-react/components/trees/common/components/BaseTreeRenderer.js +13 -0
  109. package/lib/esm/tree-widget-react/components/trees/common/components/BaseTreeRenderer.js.map +1 -0
  110. package/lib/esm/tree-widget-react/components/trees/common/components/Delayed.d.ts +1 -0
  111. package/lib/esm/tree-widget-react/components/trees/common/components/Delayed.js +1 -0
  112. package/lib/esm/tree-widget-react/components/trees/common/components/Delayed.js.map +1 -1
  113. package/lib/esm/tree-widget-react/components/trees/common/components/EmptyTree.css +25 -0
  114. package/lib/esm/tree-widget-react/components/trees/common/components/EmptyTree.d.ts +21 -0
  115. package/lib/esm/tree-widget-react/components/trees/common/components/EmptyTree.js +43 -0
  116. package/lib/esm/tree-widget-react/components/trees/common/components/EmptyTree.js.map +1 -0
  117. package/lib/esm/tree-widget-react/components/trees/common/components/ProgressOverlay.d.ts +2 -1
  118. package/lib/esm/tree-widget-react/components/trees/common/components/ProgressOverlay.js +5 -4
  119. package/lib/esm/tree-widget-react/components/trees/common/components/ProgressOverlay.js.map +1 -1
  120. package/lib/esm/tree-widget-react/components/trees/common/components/SkeletonTree.css +16 -0
  121. package/lib/esm/tree-widget-react/components/trees/common/components/SkeletonTree.d.ts +4 -0
  122. package/lib/esm/tree-widget-react/components/trees/common/components/SkeletonTree.js +16 -0
  123. package/lib/esm/tree-widget-react/components/trees/common/components/SkeletonTree.js.map +1 -0
  124. package/lib/esm/tree-widget-react/components/trees/common/components/Tree.css +11 -0
  125. package/lib/esm/tree-widget-react/components/trees/common/components/Tree.d.ts +9 -13
  126. package/lib/esm/tree-widget-react/components/trees/common/components/Tree.js +53 -36
  127. package/lib/esm/tree-widget-react/components/trees/common/components/Tree.js.map +1 -1
  128. package/lib/esm/tree-widget-react/components/trees/common/components/TreeNodeVisibilityButton.css +2 -1
  129. package/lib/esm/tree-widget-react/components/trees/common/components/TreeNodeVisibilityButton.d.ts +5 -10
  130. package/lib/esm/tree-widget-react/components/trees/common/components/TreeNodeVisibilityButton.js +14 -20
  131. package/lib/esm/tree-widget-react/components/trees/common/components/TreeNodeVisibilityButton.js.map +1 -1
  132. package/lib/esm/tree-widget-react/components/trees/common/components/TreeRenderer.d.ts +2 -8
  133. package/lib/esm/tree-widget-react/components/trees/common/components/TreeRenderer.js +11 -7
  134. package/lib/esm/tree-widget-react/components/trees/common/components/TreeRenderer.js.map +1 -1
  135. package/lib/esm/tree-widget-react/components/trees/common/components/UseVisibilityButtonHandler.d.ts +3 -2
  136. package/lib/esm/tree-widget-react/components/trees/common/components/UseVisibilityButtonHandler.js +7 -7
  137. package/lib/esm/tree-widget-react/components/trees/common/components/UseVisibilityButtonHandler.js.map +1 -1
  138. package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTree.d.ts +2 -2
  139. package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTree.js +10 -6
  140. package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTree.js.map +1 -1
  141. package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTreeRenderer.d.ts +3 -3
  142. package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTreeRenderer.js +13 -10
  143. package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTreeRenderer.js.map +1 -1
  144. package/lib/esm/tree-widget-react/components/trees/common/internal/AlwaysAndNeverDrawnElementInfo.d.ts +43 -0
  145. package/lib/esm/tree-widget-react/components/trees/{models-tree → common}/internal/AlwaysAndNeverDrawnElementInfo.js +91 -34
  146. package/lib/esm/tree-widget-react/components/trees/common/internal/AlwaysAndNeverDrawnElementInfo.js.map +1 -0
  147. package/lib/esm/tree-widget-react/components/trees/common/internal/ClassNameDefinitions.d.ts +43 -0
  148. package/lib/esm/tree-widget-react/components/trees/common/internal/ClassNameDefinitions.js +47 -0
  149. package/lib/esm/tree-widget-react/components/trees/common/internal/ClassNameDefinitions.js.map +1 -0
  150. package/lib/esm/tree-widget-react/components/trees/common/internal/ModelCategoryElementsCountCache.d.ts +15 -0
  151. package/lib/esm/tree-widget-react/components/trees/common/internal/ModelCategoryElementsCountCache.js +79 -0
  152. package/lib/esm/tree-widget-react/components/trees/common/internal/ModelCategoryElementsCountCache.js.map +1 -0
  153. package/lib/esm/tree-widget-react/components/trees/common/{Rxjs.d.ts → internal/Rxjs.d.ts} +9 -2
  154. package/lib/esm/tree-widget-react/components/trees/common/{Rxjs.js → internal/Rxjs.js} +10 -2
  155. package/lib/esm/tree-widget-react/components/trees/common/internal/Rxjs.js.map +1 -0
  156. package/lib/esm/tree-widget-react/components/trees/common/{Tooltip.d.ts → internal/Tooltip.d.ts} +4 -8
  157. package/lib/esm/tree-widget-react/components/trees/common/internal/Tooltip.js +18 -0
  158. package/lib/esm/tree-widget-react/components/trees/common/internal/Tooltip.js.map +1 -0
  159. package/lib/esm/tree-widget-react/components/trees/common/internal/Types.d.ts +14 -0
  160. package/lib/esm/tree-widget-react/components/trees/common/internal/Types.js +6 -0
  161. package/lib/esm/tree-widget-react/components/trees/common/internal/Types.js.map +1 -0
  162. package/lib/esm/tree-widget-react/components/trees/common/internal/UseActiveViewport.js.map +1 -0
  163. package/lib/esm/tree-widget-react/components/trees/common/{UseHierarchiesLocalization.d.ts → internal/UseHierarchiesLocalization.d.ts} +3 -2
  164. package/lib/esm/tree-widget-react/components/trees/common/{UseHierarchiesLocalization.js → internal/UseHierarchiesLocalization.js} +6 -2
  165. package/lib/esm/tree-widget-react/components/trees/common/internal/UseHierarchiesLocalization.js.map +1 -0
  166. package/lib/esm/tree-widget-react/components/trees/common/{UseHierarchyFiltering.d.ts → internal/UseHierarchyFiltering.d.ts} +1 -1
  167. package/lib/esm/tree-widget-react/components/trees/common/{UseHierarchyFiltering.js → internal/UseHierarchyFiltering.js} +5 -4
  168. package/lib/esm/tree-widget-react/components/trees/common/internal/UseHierarchyFiltering.js.map +1 -0
  169. package/lib/esm/tree-widget-react/components/trees/common/internal/UseIModelAccess.d.ts +17 -0
  170. package/lib/esm/tree-widget-react/components/trees/common/internal/UseIModelAccess.js +32 -0
  171. package/lib/esm/tree-widget-react/components/trees/common/internal/UseIModelAccess.js.map +1 -0
  172. package/lib/esm/tree-widget-react/components/trees/common/{UseIModelChangeListener.d.ts → internal/UseIModelChangeListener.d.ts} +1 -0
  173. package/lib/esm/tree-widget-react/components/trees/common/{UseIModelChangeListener.js → internal/UseIModelChangeListener.js} +1 -0
  174. package/lib/esm/tree-widget-react/components/trees/common/internal/UseIModelChangeListener.js.map +1 -0
  175. package/lib/esm/tree-widget-react/components/trees/common/internal/Utils.d.ts +46 -0
  176. package/lib/esm/tree-widget-react/components/trees/common/internal/Utils.js +101 -0
  177. package/lib/esm/tree-widget-react/components/trees/common/internal/Utils.js.map +1 -0
  178. package/lib/esm/tree-widget-react/components/trees/common/internal/VisibilityChangeEventListener.d.ts +19 -0
  179. package/lib/esm/tree-widget-react/components/trees/{models-tree → common}/internal/VisibilityChangeEventListener.js +17 -9
  180. package/lib/esm/tree-widget-react/components/trees/common/internal/VisibilityChangeEventListener.js.map +1 -0
  181. package/lib/esm/tree-widget-react/components/trees/common/internal/VisibilityUtils.d.ts +63 -0
  182. package/lib/esm/tree-widget-react/components/trees/common/internal/VisibilityUtils.js +205 -0
  183. package/lib/esm/tree-widget-react/components/trees/common/internal/VisibilityUtils.js.map +1 -0
  184. package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.d.ts +8 -2
  185. package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.js +26 -16
  186. package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
  187. package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeComponent.d.ts +1 -5
  188. package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js +2 -1
  189. package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js.map +1 -1
  190. package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeDefinition.d.ts +1 -0
  191. package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeDefinition.js +6 -0
  192. package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeDefinition.js.map +1 -1
  193. package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.d.ts +10 -2
  194. package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.js +46 -31
  195. package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
  196. package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeComponent.d.ts +1 -5
  197. package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeComponent.js +2 -1
  198. package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeComponent.js.map +1 -1
  199. package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeDefinition.d.ts +13 -1
  200. package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeDefinition.js +47 -76
  201. package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeDefinition.js.map +1 -1
  202. package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/internal/IModelContentTreeIdsCache.d.ts +5 -5
  203. package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/internal/IModelContentTreeIdsCache.js +29 -24
  204. package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/internal/IModelContentTreeIdsCache.js.map +1 -1
  205. package/lib/esm/tree-widget-react/components/trees/index.d.ts +11 -4
  206. package/lib/esm/tree-widget-react/components/trees/index.js +10 -4
  207. package/lib/esm/tree-widget-react/components/trees/index.js.map +1 -1
  208. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTree.d.ts +3 -2
  209. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTree.js +3 -2
  210. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTree.js.map +1 -1
  211. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.d.ts +4 -4
  212. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.js +38 -30
  213. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.js.map +1 -1
  214. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.d.ts +7 -7
  215. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.js +16 -19
  216. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
  217. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.d.ts +10 -3
  218. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js +91 -114
  219. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js.map +1 -1
  220. package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.d.ts +9 -3
  221. package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.js +70 -239
  222. package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.js.map +1 -1
  223. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/FilteredTree.d.ts +7 -9
  224. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/FilteredTree.js +7 -9
  225. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/FilteredTree.js.map +1 -1
  226. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.d.ts +10 -7
  227. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js +106 -104
  228. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js.map +1 -1
  229. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeNode.js.map +1 -1
  230. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.d.ts +3 -29
  231. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js +177 -333
  232. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js.map +1 -1
  233. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/UseFilteredPaths.d.ts +27 -0
  234. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/UseFilteredPaths.js +170 -0
  235. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/UseFilteredPaths.js.map +1 -0
  236. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/UseIdsCache.d.ts +8 -0
  237. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/UseIdsCache.js +47 -0
  238. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/UseIdsCache.js.map +1 -0
  239. package/lib/esm/tree-widget-react-internal.d.ts +11 -0
  240. package/lib/esm/tree-widget-react-internal.js +17 -0
  241. package/lib/esm/tree-widget-react-internal.js.map +1 -0
  242. package/lib/esm/tree-widget-react.d.ts +2 -2
  243. package/lib/esm/tree-widget-react.js +1 -2
  244. package/lib/esm/tree-widget-react.js.map +1 -1
  245. package/lib/public/locales/en/TreeWidget.json +36 -56
  246. package/package.json +75 -73
  247. package/lib/esm/tree-widget-react/components/SelectableTree.js.map +0 -1
  248. package/lib/esm/tree-widget-react/components/TreeSelector.d.ts +0 -30
  249. package/lib/esm/tree-widget-react/components/TreeSelector.js +0 -23
  250. package/lib/esm/tree-widget-react/components/TreeSelector.js.map +0 -1
  251. package/lib/esm/tree-widget-react/components/tree-header/TreeHeader.d.ts +0 -32
  252. package/lib/esm/tree-widget-react/components/tree-header/TreeHeader.js +0 -25
  253. package/lib/esm/tree-widget-react/components/tree-header/TreeHeader.js.map +0 -1
  254. package/lib/esm/tree-widget-react/components/tree-header/TreeHeader.scss +0 -56
  255. package/lib/esm/tree-widget-react/components/tree-header/TreeWithHeader.d.ts +0 -13
  256. package/lib/esm/tree-widget-react/components/tree-header/TreeWithHeader.js +0 -13
  257. package/lib/esm/tree-widget-react/components/tree-header/TreeWithHeader.js.map +0 -1
  258. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesVisibilityHandler.d.ts +0 -28
  259. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesVisibilityHandler.js +0 -87
  260. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesVisibilityHandler.js.map +0 -1
  261. package/lib/esm/tree-widget-react/components/trees/common/FocusedInstancesContextProvider.d.ts +0 -7
  262. package/lib/esm/tree-widget-react/components/trees/common/FocusedInstancesContextProvider.js +0 -66
  263. package/lib/esm/tree-widget-react/components/trees/common/FocusedInstancesContextProvider.js.map +0 -1
  264. package/lib/esm/tree-widget-react/components/trees/common/Rxjs.js.map +0 -1
  265. package/lib/esm/tree-widget-react/components/trees/common/Tooltip.js +0 -24
  266. package/lib/esm/tree-widget-react/components/trees/common/Tooltip.js.map +0 -1
  267. package/lib/esm/tree-widget-react/components/trees/common/UseActiveViewport.js.map +0 -1
  268. package/lib/esm/tree-widget-react/components/trees/common/UseFiltering.d.ts +0 -11
  269. package/lib/esm/tree-widget-react/components/trees/common/UseFiltering.js +0 -24
  270. package/lib/esm/tree-widget-react/components/trees/common/UseFiltering.js.map +0 -1
  271. package/lib/esm/tree-widget-react/components/trees/common/UseHierarchiesLocalization.js.map +0 -1
  272. package/lib/esm/tree-widget-react/components/trees/common/UseHierarchyFiltering.js.map +0 -1
  273. package/lib/esm/tree-widget-react/components/trees/common/UseIModelChangeListener.js.map +0 -1
  274. package/lib/esm/tree-widget-react/components/trees/models-tree/Utils.d.ts +0 -7
  275. package/lib/esm/tree-widget-react/components/trees/models-tree/Utils.js +0 -21
  276. package/lib/esm/tree-widget-react/components/trees/models-tree/Utils.js.map +0 -1
  277. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.d.ts +0 -29
  278. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.js.map +0 -1
  279. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/VisibilityChangeEventListener.d.ts +0 -12
  280. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/VisibilityChangeEventListener.js.map +0 -1
  281. /package/lib/esm/tree-widget-react/components/{TreeWidgetUiItemsProvider.scss → TreeWidgetUiItemsProvider.css} +0 -0
  282. /package/lib/esm/tree-widget-react/components/trees/common/components/{ProgressOverlay.scss → ProgressOverlay.css} +0 -0
  283. /package/lib/esm/tree-widget-react/components/trees/common/{UseActiveViewport.d.ts → internal/UseActiveViewport.d.ts} +0 -0
  284. /package/lib/esm/tree-widget-react/components/trees/common/{UseActiveViewport.js → internal/UseActiveViewport.js} +0 -0
@@ -3,40 +3,41 @@ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
3
3
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
4
  * See LICENSE.md in the project root for license terms and full copyright notice.
5
5
  *--------------------------------------------------------------------------------------------*/
6
- import { useCallback, useEffect, useRef, useState } from "react";
7
- import { isPresentationHierarchyNode } from "@itwin/presentation-hierarchies-react";
8
- import { useLatest } from "./Utils.js";
6
+ import { useCallback, useEffect, useState } from "react";
7
+ import { useLatest } from "./internal/Utils.js";
8
+ /** @internal */
9
9
  export function useNodeHighlighting({ rootNodes, highlight }) {
10
- const state = useRef({ nodeInfoMap: new Map(), totalMatches: 0 });
10
+ const [state, setState] = useState({ nodeInfoMap: new Map(), totalMatches: 0 });
11
11
  const [activeNodeId, setActiveNodeId] = useState();
12
12
  const activeMatchIndexRef = useLatest(highlight?.activeMatchIndex);
13
13
  const activeNodeIdRef = useLatest(activeNodeId);
14
14
  const onHighlightChangedRef = useLatest(highlight?.onHighlightChanged);
15
+ const prevStateRef = useLatest(state);
15
16
  const searchText = highlight?.text;
16
17
  useEffect(() => {
17
18
  const { state: newState, activeIndex } = rootNodes && searchText
18
- ? computeHighlightState(rootNodes, searchText, state.current, activeNodeIdRef.current, activeMatchIndexRef.current)
19
+ ? computeHighlightState(rootNodes, searchText, prevStateRef.current, activeNodeIdRef.current, activeMatchIndexRef.current)
19
20
  : { state: { nodeInfoMap: new Map(), totalMatches: 0 }, activeIndex: 0 };
20
- state.current = newState;
21
+ setState(newState);
21
22
  if (newState.totalMatches === 0) {
22
23
  setActiveNodeId(undefined);
23
24
  }
24
25
  onHighlightChangedRef.current?.(newState.totalMatches === 0 ? 0 : activeIndex, newState.totalMatches);
25
- }, [rootNodes, searchText, activeNodeIdRef, activeMatchIndexRef, onHighlightChangedRef]);
26
+ }, [rootNodes, searchText, activeNodeIdRef, activeMatchIndexRef, onHighlightChangedRef, prevStateRef]);
26
27
  useEffect(() => {
27
- for (const nodeId of state.current.nodeInfoMap.keys()) {
28
- if (getNodeChunkInfo(state.current, nodeId, highlight?.activeMatchIndex)?.activeChunkIndex !== undefined) {
28
+ for (const nodeId of state.nodeInfoMap.keys()) {
29
+ if (getNodeChunkInfo(state, nodeId, highlight?.activeMatchIndex)?.activeChunkIndex !== undefined) {
29
30
  setActiveNodeId(nodeId);
30
31
  }
31
32
  }
32
- }, [highlight?.activeMatchIndex]);
33
+ }, [state, highlight?.activeMatchIndex]);
33
34
  const getLabel = useCallback((node) => {
34
- const chunkInfo = getNodeChunkInfo(state.current, node.id, highlight?.activeMatchIndex);
35
+ const chunkInfo = getNodeChunkInfo(state, node.id, highlight?.activeMatchIndex);
35
36
  if (searchText && chunkInfo) {
36
37
  return _jsx(_Fragment, { children: markChunks(node.label, chunkInfo.chunks, chunkInfo.activeChunkIndex) });
37
38
  }
38
39
  return _jsx("span", { children: node.label });
39
- }, [searchText, highlight?.activeMatchIndex]);
40
+ }, [state, searchText, highlight?.activeMatchIndex]);
40
41
  return { activeNodeId, getLabel };
41
42
  }
42
43
  function getNodeChunkInfo(state, nodeId, activeIndex) {
@@ -55,9 +56,6 @@ function computeHighlightState(rootNodes, searchText, state, activeNodeId, activ
55
56
  let newActiveIndex = activeMatchIndex ?? 0;
56
57
  const computeHighlightStateRecursively = (nodes) => {
57
58
  nodes.forEach((node) => {
58
- if (!isPresentationHierarchyNode(node)) {
59
- return;
60
- }
61
59
  const matches = findChunks(node.label, searchText);
62
60
  newState.nodeInfoMap.set(node.id, { startIndex: newState.totalMatches, matches });
63
61
  newState.totalMatches += matches.length;
@@ -1 +1 @@
1
- {"version":3,"file":"UseNodeHighlighting.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/common/UseNodeHighlighting.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,EAAE,2BAA2B,EAAE,MAAM,uCAAuC,CAAC;AACpF,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AA2CvC,MAAM,UAAU,mBAAmB,CAAC,EAAE,SAAS,EAAE,SAAS,EAA4B;IACpF,MAAM,KAAK,GAAG,MAAM,CAAiB,EAAE,WAAW,EAAE,IAAI,GAAG,EAAE,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC,CAAC;IAClF,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,EAAsB,CAAC;IACvE,MAAM,mBAAmB,GAAG,SAAS,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC;IACnE,MAAM,eAAe,GAAG,SAAS,CAAC,YAAY,CAAC,CAAC;IAChD,MAAM,qBAAqB,GAAG,SAAS,CAAC,SAAS,EAAE,kBAAkB,CAAC,CAAC;IACvE,MAAM,UAAU,GAAG,SAAS,EAAE,IAAI,CAAC;IAEnC,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,GACpC,SAAS,IAAI,UAAU;YAC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C,MAAM,iBAAiB,GAAG,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACrE,iBAAiB,CAAC,MAAM,IAAI,UAAU,CAAC,IAAI,CAAC,yBAA2B,iBAAiB,IAAjC,aAAa,CAA4B,CAAC,CAAC;IAElG,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,SAAS,WAAW,CAAC,MAA0B,EAAE,WAAoB;IACnE,MAAM,YAAY,GAAuB,EAAE,CAAC;IAC5C,IAAI,SAAoE,CAAC;IACzE,IAAI,cAAkC,CAAC;IAEvC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACtC,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QACxB,MAAM,QAAQ,GAAG,CAAC,KAAK,WAAW,CAAC;QACnC,IAAI,SAAS,IAAI,SAAS,CAAC,IAAI,CAAC,GAAG,KAAK,KAAK,CAAC,KAAK,IAAI,CAAC,QAAQ,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE;YACvF,SAAS,CAAC,IAAI,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC;YAC/B,SAAS;SACV;QACD,QAAQ,IAAI,CAAC,cAAc,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;QACnD,MAAM,QAAQ,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC;QACxD,SAAS,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;QACzC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;KAC7B;IACD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC;AAC1C,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport { isPresentationHierarchyNode } from \"@itwin/presentation-hierarchies-react\";\nimport { useLatest } from \"./Utils.js\";\n\nimport type { PresentationHierarchyNode, PresentationTreeNode } from \"@itwin/presentation-hierarchies-react\";\n\n/** @beta */\nexport interface HighlightInfo {\n text: string;\n}\n\ninterface UseNodeHighlightingProps {\n rootNodes: PresentationTreeNode[] | undefined;\n // TODO: move activeMatchIndex and onHighlightChanged to HighlightInfo when it's implemented.\n highlight?: HighlightInfo & {\n activeMatchIndex?: number;\n onHighlightChanged?: (activeMatchIndex: number, matches: number) => void;\n };\n}\n\ninterface HighlightedChunk {\n start: number;\n end: number;\n}\n\ninterface NodeChunkInfo {\n chunks: HighlightedChunk[];\n activeChunkIndex?: number;\n}\n\ninterface NodeHighlightInfo {\n startIndex: number;\n matches: HighlightedChunk[];\n}\n\ninterface HighlightState {\n nodeInfoMap: Map<string, NodeHighlightInfo>;\n totalMatches: number;\n}\n\ninterface UseNodeHighlightingResult {\n activeNodeId?: string;\n getLabel: (node: PresentationHierarchyNode) => React.ReactElement;\n}\n\nexport function useNodeHighlighting({ rootNodes, highlight }: UseNodeHighlightingProps): UseNodeHighlightingResult {\n const state = useRef<HighlightState>({ nodeInfoMap: new Map(), totalMatches: 0 });\n const [activeNodeId, setActiveNodeId] = useState<string | undefined>();\n const activeMatchIndexRef = useLatest(highlight?.activeMatchIndex);\n const activeNodeIdRef = useLatest(activeNodeId);\n const onHighlightChangedRef = useLatest(highlight?.onHighlightChanged);\n const searchText = highlight?.text;\n\n useEffect(() => {\n const { state: newState, activeIndex } =\n rootNodes && searchText\n ? computeHighlightState(rootNodes, searchText, state.current, activeNodeIdRef.current, activeMatchIndexRef.current)\n : { state: { nodeInfoMap: new Map(), totalMatches: 0 }, activeIndex: 0 };\n\n state.current = newState;\n if (newState.totalMatches === 0) {\n setActiveNodeId(undefined);\n }\n onHighlightChangedRef.current?.(newState.totalMatches === 0 ? 0 : activeIndex, newState.totalMatches);\n }, [rootNodes, searchText, activeNodeIdRef, activeMatchIndexRef, onHighlightChangedRef]);\n\n useEffect(() => {\n for (const nodeId of state.current.nodeInfoMap.keys()) {\n if (getNodeChunkInfo(state.current, nodeId, highlight?.activeMatchIndex)?.activeChunkIndex !== undefined) {\n setActiveNodeId(nodeId);\n }\n }\n }, [highlight?.activeMatchIndex]);\n\n const getLabel = useCallback(\n (node: PresentationHierarchyNode) => {\n const chunkInfo = getNodeChunkInfo(state.current, node.id, highlight?.activeMatchIndex);\n if (searchText && chunkInfo) {\n return <>{markChunks(node.label, chunkInfo.chunks, chunkInfo.activeChunkIndex)}</>;\n }\n return <span>{node.label}</span>;\n },\n [searchText, highlight?.activeMatchIndex],\n );\n\n return { activeNodeId, getLabel };\n}\n\nfunction getNodeChunkInfo(state: HighlightState, nodeId: string, activeIndex?: number): NodeChunkInfo | undefined {\n const info = state.nodeInfoMap.get(nodeId);\n if (!info) {\n return undefined;\n }\n if (activeIndex === undefined) {\n return { chunks: info.matches };\n }\n const isActive = info && activeIndex >= info.startIndex && activeIndex < info.startIndex + info.matches.length;\n return isActive ? { activeChunkIndex: activeIndex - info.startIndex, chunks: info.matches } : { chunks: info.matches };\n}\n\nfunction computeHighlightState(rootNodes: PresentationTreeNode[], searchText: string, state: HighlightState, activeNodeId?: string, activeMatchIndex?: number) {\n const newState: HighlightState = { nodeInfoMap: new Map(), totalMatches: 0 };\n let newActiveIndex = activeMatchIndex ?? 0;\n\n const computeHighlightStateRecursively = (nodes: Array<PresentationTreeNode>) => {\n nodes.forEach((node) => {\n if (!isPresentationHierarchyNode(node)) {\n return;\n }\n\n const matches = findChunks(node.label, searchText);\n newState.nodeInfoMap.set(node.id, { startIndex: newState.totalMatches, matches });\n newState.totalMatches += matches.length;\n\n if (typeof node.children !== \"boolean\") {\n computeHighlightStateRecursively(node.children);\n }\n });\n };\n\n computeHighlightStateRecursively(rootNodes);\n\n // update active index to not cause active chunk jumps when hierarchy changes\n if (activeNodeId && newActiveIndex !== 0) {\n const activeNodeInfo = getNodeChunkInfo(state, activeNodeId, activeMatchIndex);\n const updatedInfo = newState.nodeInfoMap.get(activeNodeId);\n\n if (updatedInfo && activeNodeInfo?.activeChunkIndex !== undefined) {\n newActiveIndex = updatedInfo.startIndex + activeNodeInfo.activeChunkIndex;\n }\n }\n\n return { state: newState, activeIndex: newActiveIndex };\n}\n\nfunction findChunks(text: string, searchText: string): HighlightedChunk[] {\n const chunks: HighlightedChunk[] = [];\n\n const contentText = text.toLowerCase();\n const inputText = searchText.toLowerCase();\n let index = contentText.indexOf(inputText);\n\n while (index !== -1) {\n chunks.push({ start: index, end: index + inputText.length });\n index = contentText.indexOf(inputText, index + 1);\n }\n\n return chunks;\n}\n\nfunction markChunks(text: string, chunks: HighlightedChunk[], activeChunk?: number) {\n const markedText: React.ReactElement[] = [];\n let previousIndex = 0;\n\n const { mergedChunks, newActiveIndex } = mergeChunks(chunks, activeChunk);\n\n for (let i = 0; i < mergedChunks.length; i++) {\n const { start, end } = mergedChunks[i];\n\n // add unmarked text between previous chunk and current one\n const nonMarkedText = text.substring(previousIndex, start);\n nonMarkedText.length && markedText.push(<span key={previousIndex}>{nonMarkedText}</span>);\n\n // add marked chunk text\n markedText.push(\n <mark key={start} className={i === newActiveIndex ? \"tw-active-match-highlight\" : undefined}>\n {text.substring(start, end)}\n </mark>,\n );\n previousIndex = end;\n }\n\n // add unmarked text after last chunk\n const lastNonMarkedText = text.substring(previousIndex, text.length);\n lastNonMarkedText.length && markedText.push(<span key={previousIndex}>{lastNonMarkedText}</span>);\n\n return markedText;\n}\n\nfunction mergeChunks(chunks: HighlightedChunk[], activeChunk?: number) {\n const mergedChunks: HighlightedChunk[] = [];\n let lastChunk: { isActive: boolean; info: HighlightedChunk } | undefined;\n let newActiveIndex: number | undefined;\n\n for (let i = 0; i < chunks.length; i++) {\n const chunk = chunks[i];\n const isActive = i === activeChunk;\n if (lastChunk && lastChunk.info.end === chunk.start && !isActive && !lastChunk.isActive) {\n lastChunk.info.end = chunk.end;\n continue;\n }\n isActive && (newActiveIndex = mergedChunks.length);\n const newChunk = { start: chunk.start, end: chunk.end };\n lastChunk = { isActive, info: newChunk };\n mergedChunks.push(newChunk);\n }\n return { mergedChunks, newActiveIndex };\n}\n"]}
1
+ {"version":3,"file":"UseNodeHighlighting.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/common/UseNodeHighlighting.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AA2ChD,gBAAgB;AAChB,MAAM,UAAU,mBAAmB,CAAC,EAAE,SAAS,EAAE,SAAS,EAA4B;IACpF,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAiB,EAAE,WAAW,EAAE,IAAI,GAAG,EAAE,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC,CAAC;IAChG,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,EAAsB,CAAC;IACvE,MAAM,mBAAmB,GAAG,SAAS,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC;IACnE,MAAM,eAAe,GAAG,SAAS,CAAC,YAAY,CAAC,CAAC;IAChD,MAAM,qBAAqB,GAAG,SAAS,CAAC,SAAS,EAAE,kBAAkB,CAAC,CAAC;IACvE,MAAM,YAAY,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;IACtC,MAAM,UAAU,GAAG,SAAS,EAAE,IAAI,CAAC;IAEnC,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,GACpC,SAAS,IAAI,UAAU;YACrB,CAAC,CAAC,qBAAqB,CAAC,SAAS,EAAE,UAAU,EAAE,YAAY,CAAC,OAAO,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BAAiB,GAAG,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACrE,iBAAiB,CAAC,MAAM,IAAI,UAAU,CAAC,IAAI,CAAC,yBAA2B,iBAAiB,IAAjC,aAAa,CAA4B,CAAC,CAAC;IAElG,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,SAAS,WAAW,CAAC,MAA0B,EAAE,WAAoB;IACnE,MAAM,YAAY,GAAuB,EAAE,CAAC;IAC5C,IAAI,SAAoE,CAAC;IACzE,IAAI,cAAkC,CAAC;IAEvC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACvC,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QACxB,MAAM,QAAQ,GAAG,CAAC,KAAK,WAAW,CAAC;QACnC,IAAI,SAAS,IAAI,SAAS,CAAC,IAAI,CAAC,GAAG,KAAK,KAAK,CAAC,KAAK,IAAI,CAAC,QAAQ,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;YACxF,SAAS,CAAC,IAAI,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC;YAC/B,SAAS;QACX,CAAC;QACD,QAAQ,IAAI,CAAC,cAAc,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;QACnD,MAAM,QAAQ,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC;QACxD,SAAS,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;QACzC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC9B,CAAC;IACD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC;AAC1C,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useCallback, useEffect, useState } from \"react\";\nimport { useLatest } from \"./internal/Utils.js\";\n\nimport type { PresentationHierarchyNode } from \"@itwin/presentation-hierarchies-react\";\n\n/** @beta */\nexport interface HighlightInfo {\n text: string;\n}\n\ninterface UseNodeHighlightingProps {\n rootNodes: PresentationHierarchyNode[] | undefined;\n // TODO: move activeMatchIndex and onHighlightChanged to HighlightInfo when it's implemented.\n highlight?: HighlightInfo & {\n activeMatchIndex?: number;\n onHighlightChanged?: (activeMatchIndex: number, matches: number) => void;\n };\n}\n\ninterface HighlightedChunk {\n start: number;\n end: number;\n}\n\ninterface NodeChunkInfo {\n chunks: HighlightedChunk[];\n activeChunkIndex?: number;\n}\n\ninterface NodeHighlightInfo {\n startIndex: number;\n matches: HighlightedChunk[];\n}\n\ninterface HighlightState {\n nodeInfoMap: Map<string, NodeHighlightInfo>;\n totalMatches: number;\n}\n\ninterface UseNodeHighlightingResult {\n activeNodeId?: string;\n getLabel: (node: PresentationHierarchyNode) => React.ReactElement;\n}\n\n/** @internal */\nexport function useNodeHighlighting({ rootNodes, highlight }: UseNodeHighlightingProps): UseNodeHighlightingResult {\n const [state, setState] = useState<HighlightState>({ nodeInfoMap: new Map(), totalMatches: 0 });\n const [activeNodeId, setActiveNodeId] = useState<string | undefined>();\n const activeMatchIndexRef = useLatest(highlight?.activeMatchIndex);\n const activeNodeIdRef = useLatest(activeNodeId);\n const onHighlightChangedRef = useLatest(highlight?.onHighlightChanged);\n const prevStateRef = useLatest(state);\n const searchText = highlight?.text;\n\n useEffect(() => {\n const { state: newState, activeIndex } =\n rootNodes && searchText\n ? computeHighlightState(rootNodes, searchText, prevStateRef.current, activeNodeIdRef.current, activeMatchIndexRef.current)\n : { state: { nodeInfoMap: new Map(), totalMatches: 0 }, activeIndex: 0 };\n\n setState(newState);\n if (newState.totalMatches === 0) {\n setActiveNodeId(undefined);\n }\n onHighlightChangedRef.current?.(newState.totalMatches === 0 ? 0 : activeIndex, newState.totalMatches);\n }, [rootNodes, searchText, activeNodeIdRef, activeMatchIndexRef, onHighlightChangedRef, prevStateRef]);\n\n useEffect(() => {\n for (const nodeId of state.nodeInfoMap.keys()) {\n if (getNodeChunkInfo(state, nodeId, highlight?.activeMatchIndex)?.activeChunkIndex !== undefined) {\n setActiveNodeId(nodeId);\n }\n }\n }, [state, highlight?.activeMatchIndex]);\n\n const getLabel = useCallback(\n (node: PresentationHierarchyNode) => {\n const chunkInfo = getNodeChunkInfo(state, node.id, highlight?.activeMatchIndex);\n if (searchText && chunkInfo) {\n return <>{markChunks(node.label, chunkInfo.chunks, chunkInfo.activeChunkIndex)}</>;\n }\n return <span>{node.label}</span>;\n },\n [state, searchText, highlight?.activeMatchIndex],\n );\n\n return { activeNodeId, getLabel };\n}\n\nfunction getNodeChunkInfo(state: HighlightState, nodeId: string, activeIndex?: number): NodeChunkInfo | undefined {\n const info = state.nodeInfoMap.get(nodeId);\n if (!info) {\n return undefined;\n }\n if (activeIndex === undefined) {\n return { chunks: info.matches };\n }\n const isActive = info && activeIndex >= info.startIndex && activeIndex < info.startIndex + info.matches.length;\n return isActive ? { activeChunkIndex: activeIndex - info.startIndex, chunks: info.matches } : { chunks: info.matches };\n}\n\nfunction computeHighlightState(\n rootNodes: PresentationHierarchyNode[],\n searchText: string,\n state: HighlightState,\n activeNodeId?: string,\n activeMatchIndex?: number,\n) {\n const newState: HighlightState = { nodeInfoMap: new Map(), totalMatches: 0 };\n let newActiveIndex = activeMatchIndex ?? 0;\n\n const computeHighlightStateRecursively = (nodes: Array<PresentationHierarchyNode>) => {\n nodes.forEach((node) => {\n const matches = findChunks(node.label, searchText);\n newState.nodeInfoMap.set(node.id, { startIndex: newState.totalMatches, matches });\n newState.totalMatches += matches.length;\n\n if (typeof node.children !== \"boolean\") {\n computeHighlightStateRecursively(node.children);\n }\n });\n };\n\n computeHighlightStateRecursively(rootNodes);\n\n // update active index to not cause active chunk jumps when hierarchy changes\n if (activeNodeId && newActiveIndex !== 0) {\n const activeNodeInfo = getNodeChunkInfo(state, activeNodeId, activeMatchIndex);\n const updatedInfo = newState.nodeInfoMap.get(activeNodeId);\n\n if (updatedInfo && activeNodeInfo?.activeChunkIndex !== undefined) {\n newActiveIndex = updatedInfo.startIndex + activeNodeInfo.activeChunkIndex;\n }\n }\n\n return { state: newState, activeIndex: newActiveIndex };\n}\n\nfunction findChunks(text: string, searchText: string): HighlightedChunk[] {\n const chunks: HighlightedChunk[] = [];\n\n const contentText = text.toLowerCase();\n const inputText = searchText.toLowerCase();\n let index = contentText.indexOf(inputText);\n\n while (index !== -1) {\n chunks.push({ start: index, end: index + inputText.length });\n index = contentText.indexOf(inputText, index + 1);\n }\n\n return chunks;\n}\n\nfunction markChunks(text: string, chunks: HighlightedChunk[], activeChunk?: number) {\n const markedText: React.ReactElement[] = [];\n let previousIndex = 0;\n\n const { mergedChunks, newActiveIndex } = mergeChunks(chunks, activeChunk);\n\n for (let i = 0; i < mergedChunks.length; i++) {\n const { start, end } = mergedChunks[i];\n\n // add unmarked text between previous chunk and current one\n const nonMarkedText = text.substring(previousIndex, start);\n nonMarkedText.length && markedText.push(<span key={previousIndex}>{nonMarkedText}</span>);\n\n // add marked chunk text\n markedText.push(\n <mark key={start} className={i === newActiveIndex ? \"tw-active-match-highlight\" : undefined}>\n {text.substring(start, end)}\n </mark>,\n );\n previousIndex = end;\n }\n\n // add unmarked text after last chunk\n const lastNonMarkedText = text.substring(previousIndex, text.length);\n lastNonMarkedText.length && markedText.push(<span key={previousIndex}>{lastNonMarkedText}</span>);\n\n return markedText;\n}\n\nfunction mergeChunks(chunks: HighlightedChunk[], activeChunk?: number) {\n const mergedChunks: HighlightedChunk[] = [];\n let lastChunk: { isActive: boolean; info: HighlightedChunk } | undefined;\n let newActiveIndex: number | undefined;\n\n for (let i = 0; i < chunks.length; i++) {\n const chunk = chunks[i];\n const isActive = i === activeChunk;\n if (lastChunk && lastChunk.info.end === chunk.start && !isActive && !lastChunk.isActive) {\n lastChunk.info.end = chunk.end;\n continue;\n }\n isActive && (newActiveIndex = mergedChunks.length);\n const newChunk = { start: chunk.start, end: chunk.end };\n lastChunk = { isActive, info: newChunk };\n mergedChunks.push(newChunk);\n }\n return { mergedChunks, newActiveIndex };\n}\n"]}
@@ -18,6 +18,7 @@ export interface TelemetryContextProviderProps {
18
18
  }
19
19
  /** @beta */
20
20
  export declare function TelemetryContextProvider({ children, onPerformanceMeasured, onFeatureUsed, componentIdentifier, }: PropsWithChildren<TelemetryContextProviderProps>): import("react/jsx-runtime").JSX.Element;
21
+ /** @internal */
21
22
  export declare function useTelemetryContext(): TelemetryContext;
22
23
  interface UseReportingActionProps<TAction> {
23
24
  action: TAction;
@@ -4,7 +4,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
4
4
  * See LICENSE.md in the project root for license terms and full copyright notice.
5
5
  *--------------------------------------------------------------------------------------------*/
6
6
  import { createContext, useCallback, useContext, useMemo } from "react";
7
- import { useLatest } from "./Utils.js";
7
+ import { useLatest } from "./internal/Utils.js";
8
8
  const telemetryContext = createContext(undefined);
9
9
  /** @beta */
10
10
  export function TelemetryContextProvider({ children, onPerformanceMeasured, onFeatureUsed, componentIdentifier, }) {
@@ -29,6 +29,7 @@ const defaultContextValue = {
29
29
  onPerformanceMeasured: () => { },
30
30
  onFeatureUsed: () => { },
31
31
  };
32
+ /** @internal */
32
33
  export function useTelemetryContext() {
33
34
  return useContext(telemetryContext) ?? defaultContextValue;
34
35
  }
@@ -1 +1 @@
1
- {"version":3,"file":"UseTelemetryContext.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/common/UseTelemetryContext.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAkBvC,MAAM,gBAAgB,GA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BAAkB,CAA2C,EAAE,MAAM,EAAE,SAAS,EAAoC;IAClI,MAAM,EAAE,aAAa,EAAE,GAAG,mBAAmB,EAAE,CAAC;IAChD,OAAO,WAAW,CAChB,CAAC,GAAG,IAAI,EAAE,EAAE;QACV,aAAa,CAAC,EAAE,SAAS,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC;QACtD,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;IAClB,CAAC,EACD,CAAC,MAAM,EAAE,SAAS,EAAE,aAAa,CAAC,CACnC,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 { createContext, useCallback, useContext, useMemo } from \"react\";\nimport { useLatest } from \"./Utils.js\";\n\nimport type { PropsWithChildren } from \"react\";\n\ntype TrackedFeatures =\n | \"visibility-change\"\n | \"hierarchy-level-filtering\"\n | \"filtering\"\n | \"hierarchy-level-size-limit-hit\"\n | \"zoom-to-node\"\n | \"error-timeout\"\n | \"error-unknown\";\n\ninterface TelemetryContext {\n onPerformanceMeasured: (featureId: string, duration: number) => void;\n onFeatureUsed: (props: { featureId?: TrackedFeatures; reportInteraction: boolean }) => void;\n}\n\nconst telemetryContext = createContext<TelemetryContext | undefined>(undefined);\n\n/** @beta */\nexport interface TelemetryContextProviderProps {\n /** Callback that is invoked when performance of tracked feature is measured. */\n onPerformanceMeasured?: (featureId: string, duration: number) => void;\n /** Callback that is invoked when a tracked feature is used. */\n onFeatureUsed?: (featureId: string) => void;\n /** Unique identifier that is appended to feature id to help track which component used that feature. */\n componentIdentifier: string;\n}\n\n/** @beta */\nexport function TelemetryContextProvider({\n children,\n onPerformanceMeasured,\n onFeatureUsed,\n componentIdentifier,\n}: PropsWithChildren<TelemetryContextProviderProps>) {\n const onPerformanceMeasuredRef = useLatest(onPerformanceMeasured);\n const onFeatureUsedRef = useLatest(onFeatureUsed);\n\n const contextValue = useMemo<TelemetryContext>(() => {\n return {\n onPerformanceMeasured: (featureId, duration) => onPerformanceMeasuredRef.current?.(`${componentIdentifier}-${featureId}`, duration),\n onFeatureUsed: ({ featureId, reportInteraction }) => {\n if (reportInteraction !== false) {\n onFeatureUsedRef.current?.(`use-${componentIdentifier}`);\n }\n if (featureId) {\n onFeatureUsedRef.current?.(`${componentIdentifier}-${featureId}`);\n }\n },\n };\n }, [componentIdentifier, onPerformanceMeasuredRef, onFeatureUsedRef]);\n\n return <telemetryContext.Provider value={contextValue}>{children}</telemetryContext.Provider>;\n}\n\nconst defaultContextValue: TelemetryContext = {\n onPerformanceMeasured: () => {},\n onFeatureUsed: () => {},\n};\n\nexport function useTelemetryContext() {\n return useContext(telemetryContext) ?? defaultContextValue;\n}\n\ninterface UseReportingActionProps<TAction> {\n action: TAction;\n featureId?: TrackedFeatures;\n}\n\n/** @internal */\nexport function useReportingAction<TAction extends (...args: any[]) => void>({ action, featureId }: UseReportingActionProps<TAction>) {\n const { onFeatureUsed } = useTelemetryContext();\n return useCallback<(...args: Parameters<TAction>) => void>(\n (...args) => {\n onFeatureUsed({ featureId, reportInteraction: true });\n action(...args);\n },\n [action, featureId, onFeatureUsed],\n );\n}\n"]}
1
+ {"version":3,"file":"UseTelemetryContext.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/common/UseTelemetryContext.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAkBhD,MAAM,gBAAgB,GAAG,aAAa,CAA+B,SAAS,CAAC,CAAC;AAYhF,YAAY;AACZ,MAAM,UAAU,wBAAwB,CAAC,EACvC,QAAQ,EACR,qBAAqB,EACrB,aAAa,EACb,mBAAmB,GAC8B;IACjD,MAAM,wBAAw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CAChB,CAAC,GAAG,IAAI,EAAE,EAAE;QACV,aAAa,CAAC,EAAE,SAAS,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC;QACtD,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;IAClB,CAAC,EACD,CAAC,MAAM,EAAE,SAAS,EAAE,aAAa,CAAC,CACnC,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 { createContext, useCallback, useContext, useMemo } from \"react\";\nimport { useLatest } from \"./internal/Utils.js\";\n\nimport type { PropsWithChildren } from \"react\";\n\ntype TrackedFeatures =\n | \"visibility-change\"\n | \"hierarchy-level-filtering\"\n | \"filtering\"\n | \"hierarchy-level-size-limit-hit\"\n | \"zoom-to-node\"\n | \"error-timeout\"\n | \"error-unknown\";\n\ninterface TelemetryContext {\n onPerformanceMeasured: (featureId: string, duration: number) => void;\n onFeatureUsed: (props: { featureId?: TrackedFeatures; reportInteraction: boolean }) => void;\n}\n\nconst telemetryContext = createContext<TelemetryContext | undefined>(undefined);\n\n/** @beta */\nexport interface TelemetryContextProviderProps {\n /** Callback that is invoked when performance of tracked feature is measured. */\n onPerformanceMeasured?: (featureId: string, duration: number) => void;\n /** Callback that is invoked when a tracked feature is used. */\n onFeatureUsed?: (featureId: string) => void;\n /** Unique identifier that is appended to feature id to help track which component used that feature. */\n componentIdentifier: string;\n}\n\n/** @beta */\nexport function TelemetryContextProvider({\n children,\n onPerformanceMeasured,\n onFeatureUsed,\n componentIdentifier,\n}: PropsWithChildren<TelemetryContextProviderProps>) {\n const onPerformanceMeasuredRef = useLatest(onPerformanceMeasured);\n const onFeatureUsedRef = useLatest(onFeatureUsed);\n\n const contextValue = useMemo<TelemetryContext>(() => {\n return {\n onPerformanceMeasured: (featureId, duration) => onPerformanceMeasuredRef.current?.(`${componentIdentifier}-${featureId}`, duration),\n onFeatureUsed: ({ featureId, reportInteraction }) => {\n if (reportInteraction !== false) {\n onFeatureUsedRef.current?.(`use-${componentIdentifier}`);\n }\n if (featureId) {\n onFeatureUsedRef.current?.(`${componentIdentifier}-${featureId}`);\n }\n },\n };\n }, [componentIdentifier, onPerformanceMeasuredRef, onFeatureUsedRef]);\n\n return <telemetryContext.Provider value={contextValue}>{children}</telemetryContext.Provider>;\n}\n\nconst defaultContextValue: TelemetryContext = {\n onPerformanceMeasured: () => {},\n onFeatureUsed: () => {},\n};\n\n/** @internal */\nexport function useTelemetryContext() {\n return useContext(telemetryContext) ?? defaultContextValue;\n}\n\ninterface UseReportingActionProps<TAction> {\n action: TAction;\n featureId?: TrackedFeatures;\n}\n\n/** @internal */\nexport function useReportingAction<TAction extends (...args: any[]) => void>({ action, featureId }: UseReportingActionProps<TAction>) {\n const { onFeatureUsed } = useTelemetryContext();\n return useCallback<(...args: Parameters<TAction>) => void>(\n (...args) => {\n onFeatureUsed({ featureId, reportInteraction: true });\n action(...args);\n },\n [action, featureId, onFeatureUsed],\n );\n}\n"]}
@@ -1,27 +1,42 @@
1
- /// <reference types="react" />
1
+ import type { Viewport } from "@itwin/core-frontend";
2
2
  import type { Id64Array } from "@itwin/core-bentley";
3
- import type { IModelConnection } from "@itwin/core-frontend";
4
- import type { SchemaContext } from "@itwin/ecschema-metadata";
3
+ /**
4
+ * This is a logging namespace for public log messages that may be interesting to consumers.
5
+ * @internal
6
+ */
7
+ export declare const LOGGING_NAMESPACE = "TreeWidget";
5
8
  /** @beta */
6
9
  export type FunctionProps<THook extends (props: any) => any> = Parameters<THook>[0];
7
- /** @internal */
8
- export declare function createIdsSelector(ids: Id64Array): string;
9
- /** @internal */
10
- export declare function parseIdsSelectorResult(selectorResult: any): Id64Array;
11
- /** @internal */
12
- export declare function pushToMap<TKey, TValue>(targetMap: Map<TKey, Set<TValue>>, key: TKey, value: TValue): void;
13
- /** @internal */
14
- export declare function createIModelAccess({ imodel, getSchemaContext }: {
15
- imodel: IModelConnection;
16
- getSchemaContext: (imodel: IModelConnection) => SchemaContext;
17
- }): {
18
- createQueryReader(query: import("@itwin/presentation-shared").ECSqlQueryDef, config?: (import("@itwin/presentation-shared").ECSqlQueryReaderOptions & {
19
- limit?: number | "unbounded" | undefined;
20
- }) | undefined): AsyncIterableIterator<import("@itwin/presentation-shared").ECSqlQueryRow>;
21
- classDerivesFrom(derivedClassFullName: string, candidateBaseClassFullName: string): boolean | Promise<boolean>;
22
- getSchema(schemaName: string): Promise<import("@itwin/presentation-shared").EC.Schema | undefined>;
23
- imodelKey: string;
24
- };
25
- /** @internal */
26
- export declare function useLatest<T>(value: T): import("react").MutableRefObject<T>;
10
+ /**
11
+ * Disables display of all given models.
12
+ * @public
13
+ */
14
+ export declare function hideAllModels(models: string[], viewport: Viewport): Promise<void>;
15
+ /**
16
+ * Enables display of all given models. Also enables display of all categories and clears always and
17
+ * never drawn lists in the viewport.
18
+ * @public
19
+ */
20
+ export declare function showAll(props: {
21
+ /** ID's of models to enable */
22
+ models: Id64Array;
23
+ /** ID's of categories to enable, if set to undefined, all categories will be enabled */
24
+ categories?: Id64Array;
25
+ viewport: Viewport;
26
+ }): Promise<void>;
27
+ /**
28
+ * Inverts display of all given models.
29
+ * @public
30
+ */
31
+ export declare function invertAllModels(models: Id64Array, viewport: Viewport): Promise<void>;
32
+ /**
33
+ * Based on the value of `enable` argument, either enables or disables display of given models.
34
+ * @public
35
+ */
36
+ export declare function toggleModels(models: string[], enable: boolean, viewport: Viewport): Promise<void>;
37
+ /**
38
+ * Checks if all given models are displayed in given viewport.
39
+ * @public
40
+ */
41
+ export declare function areAllModelsVisible(models: string[], viewport: Viewport): boolean;
27
42
  //# sourceMappingURL=Utils.d.ts.map
@@ -2,57 +2,75 @@
2
2
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
- import { useEffect, useRef } from "react";
6
- import { createECSchemaProvider, createECSqlQueryExecutor } from "@itwin/presentation-core-interop";
7
- import { createLimitingECSqlQueryExecutor } from "@itwin/presentation-hierarchies";
8
- import { createCachingECClassHierarchyInspector } from "@itwin/presentation-shared";
9
- /** @internal */
10
- export function createIdsSelector(ids) {
11
- // Note: `json_array` function only accepts up to 127 arguments and we may have more `ids` than that. As a workaround,
12
- // we're creating an array of arrays
13
- const slices = new Array();
14
- for (let sliceStartIndex = 0; sliceStartIndex < ids.length; sliceStartIndex += 127) {
15
- let sliceEndIndex = sliceStartIndex + 127;
16
- if (sliceEndIndex > ids.length) {
17
- sliceEndIndex = undefined;
18
- }
19
- slices.push(ids.slice(sliceStartIndex, sliceEndIndex));
20
- }
21
- return `json_array(${slices.map((sliceIds) => `json_array(${sliceIds.map((id) => `'${id}'`).join(",")})`).join(",")})`;
5
+ import { showAllCategories } from "./CategoriesVisibilityUtils.js";
6
+ import { toggleAllCategories } from "./internal/VisibilityUtils.js";
7
+ /**
8
+ * This is a logging namespace for public log messages that may be interesting to consumers.
9
+ * @internal
10
+ */
11
+ export const LOGGING_NAMESPACE = "TreeWidget";
12
+ /**
13
+ * Disables display of all given models.
14
+ * @public
15
+ */
16
+ export async function hideAllModels(models, viewport) {
17
+ viewport.changeModelDisplay(models, false);
22
18
  }
23
- /** @internal */
24
- export function parseIdsSelectorResult(selectorResult) {
25
- if (!Array.isArray(selectorResult)) {
26
- return [];
19
+ /**
20
+ * Enables display of all given models. Also enables display of all categories and clears always and
21
+ * never drawn lists in the viewport.
22
+ * @public
23
+ */
24
+ export async function showAll(props) {
25
+ const { models, categories, viewport } = props;
26
+ await viewport.addViewedModels(models);
27
+ viewport.clearNeverDrawn();
28
+ viewport.clearAlwaysDrawn();
29
+ if (categories) {
30
+ await showAllCategories(categories, viewport);
27
31
  }
28
- return selectorResult.reduce((arr, ids) => [...arr, ...(Array.isArray(ids) ? ids : [ids])], new Array());
29
- }
30
- /** @internal */
31
- export function pushToMap(targetMap, key, value) {
32
- let set = targetMap.get(key);
33
- if (!set) {
34
- set = new Set();
35
- targetMap.set(key, set);
32
+ else {
33
+ await toggleAllCategories(viewport, true);
36
34
  }
37
- set.add(value);
38
35
  }
39
- /** @internal */
40
- export function createIModelAccess({ imodel, getSchemaContext }) {
41
- const schemas = getSchemaContext(imodel);
42
- const schemaProvider = createECSchemaProvider(schemas);
43
- return {
44
- imodelKey: imodel.key,
45
- ...schemaProvider,
46
- ...createCachingECClassHierarchyInspector({ schemaProvider, cacheSize: 100 }),
47
- ...createLimitingECSqlQueryExecutor(createECSqlQueryExecutor(imodel), 1000),
48
- };
36
+ /**
37
+ * Inverts display of all given models.
38
+ * @public
39
+ */
40
+ export async function invertAllModels(models, viewport) {
41
+ const notViewedModels = new Array();
42
+ const viewedModels = new Array();
43
+ models.forEach((modelId) => {
44
+ if (viewport.viewsModel(modelId)) {
45
+ viewedModels.push(modelId);
46
+ }
47
+ else {
48
+ notViewedModels.push(modelId);
49
+ }
50
+ });
51
+ await viewport.addViewedModels(notViewedModels);
52
+ viewport.changeModelDisplay(viewedModels, false);
53
+ }
54
+ /**
55
+ * Based on the value of `enable` argument, either enables or disables display of given models.
56
+ * @public
57
+ */
58
+ export async function toggleModels(models, enable, viewport) {
59
+ if (!models) {
60
+ return;
61
+ }
62
+ if (enable) {
63
+ viewport.changeModelDisplay(models, false);
64
+ }
65
+ else {
66
+ await viewport.addViewedModels(models);
67
+ }
49
68
  }
50
- /** @internal */
51
- export function useLatest(value) {
52
- const ref = useRef(value);
53
- useEffect(() => {
54
- ref.current = value;
55
- }, [value]);
56
- return ref;
69
+ /**
70
+ * Checks if all given models are displayed in given viewport.
71
+ * @public
72
+ */
73
+ export function areAllModelsVisible(models, viewport) {
74
+ return models.length !== 0 ? models.every((id) => viewport.viewsModel(id)) : false;
57
75
  }
58
76
  //# sourceMappingURL=Utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/tr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------------------------------------------------------\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, useRef } from \"react\";\nimport { createECSchemaProvider, createECSqlQueryExecutor } from \"@itwin/presentation-core-interop\";\nimport { createLimitingECSqlQueryExecutor } from \"@itwin/presentation-hierarchies\";\nimport { createCachingECClassHierarchyInspector } from \"@itwin/presentation-shared\";\n\nimport type { Id64Array, Id64String } from \"@itwin/core-bentley\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport type { SchemaContext } from \"@itwin/ecschema-metadata\";\n\n/** @beta */\nexport type FunctionProps<THook extends (props: any) => any> = Parameters<THook>[0];\n\n/** @internal */\nexport function createIdsSelector(ids: Id64Array): string {\n // Note: `json_array` function only accepts up to 127 arguments and we may have more `ids` than that. As a workaround,\n // we're creating an array of arrays\n const slices = new Array<Id64String[]>();\n for (let sliceStartIndex = 0; sliceStartIndex < ids.length; sliceStartIndex += 127) {\n let sliceEndIndex: number | undefined = sliceStartIndex + 127;\n if (sliceEndIndex > ids.length) {\n sliceEndIndex = undefined;\n }\n slices.push(ids.slice(sliceStartIndex, sliceEndIndex));\n }\n return `json_array(${slices.map((sliceIds) => `json_array(${sliceIds.map((id) => `'${id}'`).join(\",\")})`).join(\",\")})`;\n}\n\n/** @internal */\nexport function parseIdsSelectorResult(selectorResult: any): Id64Array {\n if (!Array.isArray(selectorResult)) {\n return [];\n }\n return selectorResult.reduce((arr, ids: Id64String | Id64String[]) => [...arr, ...(Array.isArray(ids) ? ids : [ids])], new Array<Id64String>());\n}\n\n/** @internal */\nexport function pushToMap<TKey, TValue>(targetMap: Map<TKey, Set<TValue>>, key: TKey, value: TValue) {\n let set = targetMap.get(key);\n if (!set) {\n set = new Set();\n targetMap.set(key, set);\n }\n set.add(value);\n}\n\n/** @internal */\nexport function createIModelAccess({ imodel, getSchemaContext }: { imodel: IModelConnection; getSchemaContext: (imodel: IModelConnection) => SchemaContext }) {\n const schemas = getSchemaContext(imodel);\n const schemaProvider = createECSchemaProvider(schemas);\n return {\n imodelKey: imodel.key,\n ...schemaProvider,\n ...createCachingECClassHierarchyInspector({ schemaProvider, cacheSize: 100 }),\n ...createLimitingECSqlQueryExecutor(createECSqlQueryExecutor(imodel), 1000),\n };\n}\n\n/** @internal */\nexport function useLatest<T>(value: T) {\n const ref = useRef(value);\n useEffect(() => {\n ref.current = value;\n }, [value]);\n return ref;\n}\n"]}
1
+ {"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/common/Utils.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAGhG,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAIpE;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,YAAY,CAAC;AAK9C;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,MAAgB,EAAE,QAAkB;IACtE,QAAQ,CAAC,kBAAkB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAC7C,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,KAM7B;IACC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAC/C,MAAM,QAAQ,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;IACvC,QAAQ,CAAC,eAAe,EAAE,CAAC;IAC3B,QAAQ,CAAC,gBAAgB,EAAE,CAAC;IAC5B,IAAI,UAAU,EAAE,CAAC;QACf,MAAM,iBAAiB,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IAChD,CAAC;SAAM,CAAC;QACN,MAAM,mBAAmB,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAC5C,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,MAAiB,EAAE,QAAkB;IACzE,MAAM,eAAe,GAAG,IAAI,KAAK,EAAc,CAAC;IAChD,MAAM,YAAY,GAAG,IAAI,KAAK,EAAc,CAAC;IAC7C,MAAM,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QACzB,IAAI,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;YACjC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC7B,CAAC;aAAM,CAAC;YACN,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAChC,CAAC;IACH,CAAC,CAAC,CAAC;IACH,MAAM,QAAQ,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC;IAChD,QAAQ,CAAC,kBAAkB,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;AACnD,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,MAAgB,EAAE,MAAe,EAAE,QAAkB;IACtF,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO;IACT,CAAC;IACD,IAAI,MAAM,EAAE,CAAC;QACX,QAAQ,CAAC,kBAAkB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC7C,CAAC;SAAM,CAAC;QACN,MAAM,QAAQ,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;IACzC,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAgB,EAAE,QAAkB;IACtE,OAAO,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AACrF,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 type { Viewport } from \"@itwin/core-frontend\";\nimport { showAllCategories } from \"./CategoriesVisibilityUtils.js\";\nimport { toggleAllCategories } from \"./internal/VisibilityUtils.js\";\n\nimport type { Id64Array, Id64String } from \"@itwin/core-bentley\";\n\n/**\n * This is a logging namespace for public log messages that may be interesting to consumers.\n * @internal\n */\nexport const LOGGING_NAMESPACE = \"TreeWidget\";\n\n/** @beta */\nexport type FunctionProps<THook extends (props: any) => any> = Parameters<THook>[0];\n\n/**\n * Disables display of all given models.\n * @public\n */\nexport async function hideAllModels(models: string[], viewport: Viewport) {\n viewport.changeModelDisplay(models, false);\n}\n\n/**\n * Enables display of all given models. Also enables display of all categories and clears always and\n * never drawn lists in the viewport.\n * @public\n */\nexport async function showAll(props: {\n /** ID's of models to enable */\n models: Id64Array;\n /** ID's of categories to enable, if set to undefined, all categories will be enabled */\n categories?: Id64Array;\n viewport: Viewport;\n}) {\n const { models, categories, viewport } = props;\n await viewport.addViewedModels(models);\n viewport.clearNeverDrawn();\n viewport.clearAlwaysDrawn();\n if (categories) {\n await showAllCategories(categories, viewport);\n } else {\n await toggleAllCategories(viewport, true);\n }\n}\n\n/**\n * Inverts display of all given models.\n * @public\n */\nexport async function invertAllModels(models: Id64Array, viewport: Viewport) {\n const notViewedModels = new Array<Id64String>();\n const viewedModels = new Array<Id64String>();\n models.forEach((modelId) => {\n if (viewport.viewsModel(modelId)) {\n viewedModels.push(modelId);\n } else {\n notViewedModels.push(modelId);\n }\n });\n await viewport.addViewedModels(notViewedModels);\n viewport.changeModelDisplay(viewedModels, false);\n}\n\n/**\n * Based on the value of `enable` argument, either enables or disables display of given models.\n * @public\n */\nexport async function toggleModels(models: string[], enable: boolean, viewport: Viewport) {\n if (!models) {\n return;\n }\n if (enable) {\n viewport.changeModelDisplay(models, false);\n } else {\n await viewport.addViewedModels(models);\n }\n}\n\n/**\n * Checks if all given models are displayed in given viewport.\n * @public\n */\nexport function areAllModelsVisible(models: string[], viewport: Viewport) {\n return models.length !== 0 ? models.every((id) => viewport.viewsModel(id)) : false;\n}\n"]}
@@ -0,0 +1,6 @@
1
+ import { StrataKitTreeRenderer as PresentationTree } from "@itwin/presentation-hierarchies-react";
2
+ /** @beta */
3
+ export type BaseTreeRendererProps = React.ComponentPropsWithoutRef<typeof PresentationTree>;
4
+ /** @internal */
5
+ export declare function BaseTreeRenderer({ rootNodes, expandNode, getActions, ...props }: BaseTreeRendererProps): import("react/jsx-runtime").JSX.Element;
6
+ //# sourceMappingURL=BaseTreeRenderer.d.ts.map
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ import { StrataKitTreeRenderer as PresentationTree } from "@itwin/presentation-hierarchies-react";
7
+ import { useHierarchiesLocalization } from "../internal/UseHierarchiesLocalization.js";
8
+ /** @internal */
9
+ export function BaseTreeRenderer({ rootNodes, expandNode, getActions, ...props }) {
10
+ const localizedStrings = useHierarchiesLocalization();
11
+ return _jsx(PresentationTree, { ...props, localizedStrings: localizedStrings, expandNode: expandNode, rootNodes: rootNodes, getActions: getActions });
12
+ }
13
+ //# sourceMappingURL=BaseTreeRenderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseTreeRenderer.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/components/BaseTreeRenderer.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,qBAAqB,IAAI,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AAClG,OAAO,EAAE,0BAA0B,EAAE,MAAM,2CAA2C,CAAC;AAKvF,gBAAgB;AAChB,MAAM,UAAU,gBAAgB,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,KAAK,EAAyB;IACrG,MAAM,gBAAgB,GAAG,0BAA0B,EAAE,CAAC;IACtD,OAAO,KAAC,gBAAgB,OAAK,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,GAAI,CAAC;AACnJ,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 { StrataKitTreeRenderer as PresentationTree } from \"@itwin/presentation-hierarchies-react\";\nimport { useHierarchiesLocalization } from \"../internal/UseHierarchiesLocalization.js\";\n\n/** @beta */\nexport type BaseTreeRendererProps = React.ComponentPropsWithoutRef<typeof PresentationTree>;\n\n/** @internal */\nexport function BaseTreeRenderer({ rootNodes, expandNode, getActions, ...props }: BaseTreeRendererProps) {\n const localizedStrings = useHierarchiesLocalization();\n return <PresentationTree {...props} localizedStrings={localizedStrings} expandNode={expandNode} rootNodes={rootNodes} getActions={getActions} />;\n}\n"]}
@@ -1,4 +1,5 @@
1
1
  import type { PropsWithChildren } from "react";
2
+ /** @internal */
2
3
  export declare function Delayed({ show, children }: PropsWithChildren<{
3
4
  show: boolean;
4
5
  }>): import("react/jsx-runtime").JSX.Element | null;
@@ -4,6 +4,7 @@ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
4
4
  * See LICENSE.md in the project root for license terms and full copyright notice.
5
5
  *--------------------------------------------------------------------------------------------*/
6
6
  import { useLayoutEffect, useState } from "react";
7
+ /** @internal */
7
8
  export function Delayed({ show, children }) {
8
9
  const [visible, setVisible] = useState(false);
9
10
  useLayoutEffect(() => {
@@ -1 +1 @@
1
- {"version":3,"file":"Delayed.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/components/Delayed.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAIlD,MAAM,UAAU,OAAO,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAwC;IAC9E,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE9C,eAAe,CAAC,GAAG,EAAE;QACnB,IAAI,CAAC,IAAI,EAAE;YACT,UAAU,CAAC,KAAK,CAAC,CAAC;YAClB,OAAO;SACR;QAED,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;YAC5B,UAAU,CAAC,IAAI,CAAC,CAAC;QACnB,CAAC,EAAE,GAAG,CAAC,CAAC;QACR,OAAO,GAAG,EAAE;YACV,YAAY,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAEX,IAAI,CAAC,OAAO,EAAE;QACZ,OAAO,IAAI,CAAC;KACb;IAED,OAAO,4BAAG,QAAQ,GAAI,CAAC;AACzB,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 { useLayoutEffect, useState } from \"react\";\n\nimport type { PropsWithChildren } from \"react\";\n\nexport function Delayed({ show, children }: PropsWithChildren<{ show: boolean }>) {\n const [visible, setVisible] = useState(false);\n\n useLayoutEffect(() => {\n if (!show) {\n setVisible(false);\n return;\n }\n\n const timer = setTimeout(() => {\n setVisible(show);\n }, 250);\n return () => {\n clearTimeout(timer);\n };\n }, [show]);\n\n if (!visible) {\n return null;\n }\n\n return <>{children}</>;\n}\n"]}
1
+ {"version":3,"file":"Delayed.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/components/Delayed.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAIlD,gBAAgB;AAChB,MAAM,UAAU,OAAO,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAwC;IAC9E,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE9C,eAAe,CAAC,GAAG,EAAE;QACnB,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,UAAU,CAAC,KAAK,CAAC,CAAC;YAClB,OAAO;QACT,CAAC;QAED,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;YAC5B,UAAU,CAAC,IAAI,CAAC,CAAC;QACnB,CAAC,EAAE,GAAG,CAAC,CAAC;QACR,OAAO,GAAG,EAAE;YACV,YAAY,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAEX,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,4BAAG,QAAQ,GAAI,CAAC;AACzB,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 { useLayoutEffect, useState } from \"react\";\n\nimport type { PropsWithChildren } from \"react\";\n\n/** @internal */\nexport function Delayed({ show, children }: PropsWithChildren<{ show: boolean }>) {\n const [visible, setVisible] = useState(false);\n\n useLayoutEffect(() => {\n if (!show) {\n setVisible(false);\n return;\n }\n\n const timer = setTimeout(() => {\n setVisible(show);\n }, 250);\n return () => {\n clearTimeout(timer);\n };\n }, [show]);\n\n if (!visible) {\n return null;\n }\n\n return <>{children}</>;\n}\n"]}
@@ -0,0 +1,25 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+
6
+ .tw-filter-empty-tree-container {
7
+ display: flex;
8
+ flex-direction: column;
9
+ gap: var(--iui-size-s);
10
+ text-align: center;
11
+ padding-right: var(--iui-size-xl);
12
+ padding-left: var(--iui-size-xl);
13
+ padding-top: var(--iui-size-xs);
14
+ }
15
+
16
+ .tw-empty-tree-container {
17
+ display: flex;
18
+ flex-direction: column;
19
+ justify-content: center;
20
+ align-items: center;
21
+ padding: var(--iui-size-s);
22
+ gap: var(--iui-size-xs);
23
+ width: 100%;
24
+ height: 100%;
25
+ }
@@ -0,0 +1,21 @@
1
+ import "./EmptyTree.css";
2
+ interface FilterEmptyTreeProps {
3
+ base: string;
4
+ }
5
+ /** @internal */
6
+ export declare function TooManyFilterMatches({ base }: FilterEmptyTreeProps): import("react/jsx-runtime").JSX.Element;
7
+ /** @internal */
8
+ export declare function NoFilterMatches({ base }: FilterEmptyTreeProps): import("react/jsx-runtime").JSX.Element;
9
+ /** @internal */
10
+ export declare function FilterUnknownError({ base }: FilterEmptyTreeProps): import("react/jsx-runtime").JSX.Element;
11
+ /** @internal */
12
+ export declare function TooManyInstancesFocused({ base }: FilterEmptyTreeProps): import("react/jsx-runtime").JSX.Element;
13
+ /** @internal */
14
+ export declare function UnknownInstanceFocusError({ base }: FilterEmptyTreeProps): import("react/jsx-runtime").JSX.Element;
15
+ interface EmptyTreeContentProps {
16
+ icon?: string;
17
+ }
18
+ /** @internal */
19
+ export declare function EmptyTreeContent({ icon }: EmptyTreeContentProps): import("react/jsx-runtime").JSX.Element;
20
+ export {};
21
+ //# sourceMappingURL=EmptyTree.d.ts.map
@@ -0,0 +1,43 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ import "./EmptyTree.css";
7
+ import { Anchor, Text } from "@stratakit/bricks";
8
+ import { Icon } from "@stratakit/foundations";
9
+ import { TreeWidget } from "../../../../TreeWidget.js";
10
+ import { useFocusedInstancesContext } from "../FocusedInstancesContext.js";
11
+ /** @internal */
12
+ export function TooManyFilterMatches({ base }) {
13
+ return (_jsxs("div", { className: "tw-filter-empty-tree-container", children: [_jsx(Text, { variant: "body-sm", children: TreeWidget.translate(`${base}.filtering.tooManyFilterMatches`) }), _jsx(Text, { variant: "body-sm", children: TreeWidget.translate(`${base}.filtering.tooManyFilterMatchesRetry`) })] }));
14
+ }
15
+ /** @internal */
16
+ export function NoFilterMatches({ base }) {
17
+ return (_jsxs("div", { className: "tw-filter-empty-tree-container", children: [_jsx(Text, { variant: "body-sm", children: TreeWidget.translate(`${base}.filtering.noMatches`) }), _jsx(Text, { variant: "body-sm", children: TreeWidget.translate(`${base}.filtering.noMatchesRetry`) })] }));
18
+ }
19
+ /** @internal */
20
+ export function FilterUnknownError({ base }) {
21
+ return (_jsx("div", { className: "tw-filter-empty-tree-container", children: _jsx(Text, { variant: "body-sm", children: TreeWidget.translate(`${base}.filtering.unknownFilterError`) }) }));
22
+ }
23
+ /** @internal */
24
+ export function TooManyInstancesFocused({ base }) {
25
+ const { toggle } = useFocusedInstancesContext();
26
+ return (_jsxs("div", { className: "tw-filter-empty-tree-container", children: [_jsx(Text, { variant: "body-sm", children: TreeWidget.translate(`${base}.filtering.tooManyInstancesFocused`) }), _jsx(Anchor, { style: { textDecoration: "underline" }, onClick: (e) => {
27
+ e.stopPropagation();
28
+ toggle();
29
+ }, children: TreeWidget.translate(`${base}.filtering.disableInstanceFocusMode`) })] }));
30
+ }
31
+ /** @internal */
32
+ export function UnknownInstanceFocusError({ base }) {
33
+ const { toggle } = useFocusedInstancesContext();
34
+ return (_jsxs("div", { className: "tw-filter-empty-tree-container", children: [_jsx(Text, { variant: "body-sm", children: TreeWidget.translate(`${base}.filtering.unknownInstanceFocusError`) }), _jsx(Anchor, { style: { textDecoration: "underline" }, onClick: (e) => {
35
+ e.stopPropagation();
36
+ toggle();
37
+ }, children: TreeWidget.translate(`${base}.filtering.disableInstanceFocusMode`) })] }));
38
+ }
39
+ /** @internal */
40
+ export function EmptyTreeContent({ icon }) {
41
+ return (_jsxs("div", { className: "tw-empty-tree-container", children: [icon ? _jsx(Icon, { size: "large", href: icon }) : null, _jsx(Text, { variant: "body-sm", style: { textAlign: "center" }, children: TreeWidget.translate("baseTree.dataIsNotAvailable") })] }));
42
+ }
43
+ //# sourceMappingURL=EmptyTree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmptyTree.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/components/EmptyTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,iBAAiB,CAAC;AACzB,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAM3E,gBAAgB;AAChB,MAAM,UAAU,oBAAoB,CAAC,EAAE,IAAI,EAAwB;IACjE,OAAO,CACL,eAAK,SAAS,EAAE,gCAAgC,aAC9C,KAAC,IAAI,IAAC,OAAO,EAAE,SAAS,YAAG,UAAU,CAAC,SAAS,CAAC,GAAG,IAAI,iCAAiC,CAAC,GAAQ,EACjG,KAAC,IAAI,IAAC,OAAO,EAAE,SAAS,YAAG,UAAU,CAAC,SAAS,CAAC,GAAG,IAAI,sCAAsC,CAAC,GAAQ,IAClG,CACP,CAAC;AACJ,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,eAAe,CAAC,EAAE,IAAI,EAAwB;IAC5D,OAAO,CACL,eAAK,SAAS,EAAE,gCAAgC,aAC9C,KAAC,IAAI,IAAC,OAAO,EAAE,SAAS,YAA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AI,sCAAsC,CAAC,GAAQ,EACtG,KAAC,MAAM,IACL,KAAK,EAAE,EAAE,cAAc,EAAE,WAAW,EAAE,EACtC,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;oBACb,CAAC,CAAC,eAAe,EAAE,CAAC;oBACpB,MAAM,EAAE,CAAC;gBACX,CAAC,YAEA,UAAU,CAAC,SAAS,CAAC,GAAG,IAAI,qCAAqC,CAAC,GAC5D,IACL,CACP,CAAC;AACJ,CAAC;AAQD,gBAAgB;AAChB,MAAM,UAAU,gBAAgB,CAAC,EAAE,IAAI,EAAyB;IAC9D,OAAO,CACL,eAAK,SAAS,EAAE,yBAAyB,aACtC,IAAI,CAAC,CAAC,CAAC,KAAC,IAAI,IAAC,IAAI,EAAC,OAAO,EAAC,IAAI,EAAE,IAAI,GAAI,CAAC,CAAC,CAAC,IAAI,EAChD,KAAC,IAAI,IAAC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,YACrD,UAAU,CAAC,SAAS,CAAC,6BAA6B,CAAC,GAC/C,IACH,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 \"./EmptyTree.css\";\nimport { Anchor, Text } from \"@stratakit/bricks\";\nimport { Icon } from \"@stratakit/foundations\";\nimport { TreeWidget } from \"../../../../TreeWidget.js\";\nimport { useFocusedInstancesContext } from \"../FocusedInstancesContext.js\";\n\ninterface FilterEmptyTreeProps {\n base: string;\n}\n\n/** @internal */\nexport function TooManyFilterMatches({ base }: FilterEmptyTreeProps) {\n return (\n <div className={\"tw-filter-empty-tree-container\"}>\n <Text variant={\"body-sm\"}>{TreeWidget.translate(`${base}.filtering.tooManyFilterMatches`)}</Text>\n <Text variant={\"body-sm\"}>{TreeWidget.translate(`${base}.filtering.tooManyFilterMatchesRetry`)}</Text>\n </div>\n );\n}\n\n/** @internal */\nexport function NoFilterMatches({ base }: FilterEmptyTreeProps) {\n return (\n <div className={\"tw-filter-empty-tree-container\"}>\n <Text variant={\"body-sm\"}>{TreeWidget.translate(`${base}.filtering.noMatches`)}</Text>\n <Text variant={\"body-sm\"}>{TreeWidget.translate(`${base}.filtering.noMatchesRetry`)}</Text>\n </div>\n );\n}\n\n/** @internal */\nexport function FilterUnknownError({ base }: FilterEmptyTreeProps) {\n return (\n <div className={\"tw-filter-empty-tree-container\"}>\n <Text variant={\"body-sm\"}>{TreeWidget.translate(`${base}.filtering.unknownFilterError`)}</Text>\n </div>\n );\n}\n\n/** @internal */\nexport function TooManyInstancesFocused({ base }: FilterEmptyTreeProps) {\n const { toggle } = useFocusedInstancesContext();\n return (\n <div className={\"tw-filter-empty-tree-container\"}>\n <Text variant={\"body-sm\"}>{TreeWidget.translate(`${base}.filtering.tooManyInstancesFocused`)}</Text>\n <Anchor\n style={{ textDecoration: \"underline\" }}\n onClick={(e) => {\n e.stopPropagation();\n toggle();\n }}\n >\n {TreeWidget.translate(`${base}.filtering.disableInstanceFocusMode`)}\n </Anchor>\n </div>\n );\n}\n\n/** @internal */\nexport function UnknownInstanceFocusError({ base }: FilterEmptyTreeProps) {\n const { toggle } = useFocusedInstancesContext();\n return (\n <div className={\"tw-filter-empty-tree-container\"}>\n <Text variant={\"body-sm\"}>{TreeWidget.translate(`${base}.filtering.unknownInstanceFocusError`)}</Text>\n <Anchor\n style={{ textDecoration: \"underline\" }}\n onClick={(e) => {\n e.stopPropagation();\n toggle();\n }}\n >\n {TreeWidget.translate(`${base}.filtering.disableInstanceFocusMode`)}\n </Anchor>\n </div>\n );\n}\n\n\n\ninterface EmptyTreeContentProps {\n icon?: string;\n}\n\n/** @internal */\nexport function EmptyTreeContent({ icon }: EmptyTreeContentProps) {\n return (\n <div className={\"tw-empty-tree-container\"}>\n {icon ? <Icon size=\"large\" href={icon} /> : null}\n <Text variant={\"body-sm\"} style={{ textAlign: \"center\" }}>\n {TreeWidget.translate(\"baseTree.dataIsNotAvailable\")}\n </Text>\n </div>\n );\n}\n"]}
@@ -1,3 +1,4 @@
1
- import "./ProgressOverlay.scss";
1
+ import "./ProgressOverlay.css";
2
+ /** @internal */
2
3
  export declare function ProgressOverlay(): import("react/jsx-runtime").JSX.Element;
3
4
  //# sourceMappingURL=ProgressOverlay.d.ts.map