@itwin/tree-widget-react 0.10.0-dev.1 → 1.0.0-dev.0

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 (194) hide show
  1. package/CHANGELOG.md +331 -0
  2. package/README.md +146 -29
  3. package/lib/cjs/TreeWidget.d.ts +0 -1
  4. package/lib/cjs/TreeWidget.js +1 -6
  5. package/lib/cjs/TreeWidget.js.map +1 -1
  6. package/lib/cjs/components/TreeFilteringState.d.ts +3 -1
  7. package/lib/cjs/components/TreeFilteringState.js +19 -40
  8. package/lib/cjs/components/TreeFilteringState.js.map +1 -1
  9. package/lib/cjs/components/TreeWidgetComponent.d.ts +29 -5
  10. package/lib/cjs/components/TreeWidgetComponent.js +85 -29
  11. package/lib/cjs/components/TreeWidgetComponent.js.map +1 -1
  12. package/lib/cjs/components/TreeWidgetComponent.scss +4 -24
  13. package/lib/cjs/components/TreeWidgetUiItemsProvider.d.ts +25 -2
  14. package/lib/cjs/components/TreeWidgetUiItemsProvider.js +31 -46
  15. package/lib/cjs/components/TreeWidgetUiItemsProvider.js.map +1 -1
  16. package/lib/cjs/components/tree-header/TreeHeader.d.ts +26 -0
  17. package/lib/cjs/components/tree-header/TreeHeader.js +43 -0
  18. package/lib/cjs/components/tree-header/TreeHeader.js.map +1 -0
  19. package/lib/cjs/components/tree-header/TreeHeader.scss +69 -0
  20. package/lib/cjs/components/trees/CategoriesVisibilityUtils.d.ts +12 -6
  21. package/lib/cjs/components/trees/CategoriesVisibilityUtils.js +10 -4
  22. package/lib/cjs/components/trees/CategoriesVisibilityUtils.js.map +1 -1
  23. package/lib/cjs/components/trees/Common.d.ts +2 -2
  24. package/lib/cjs/components/trees/Common.js +1 -1
  25. package/lib/cjs/components/trees/Common.js.map +1 -1
  26. package/lib/cjs/components/trees/VisibilityTreeBase.scss +66 -10
  27. package/lib/cjs/components/trees/VisibilityTreeEventHandler.d.ts +13 -12
  28. package/lib/cjs/components/trees/VisibilityTreeEventHandler.js +6 -17
  29. package/lib/cjs/components/trees/VisibilityTreeEventHandler.js.map +1 -1
  30. package/lib/cjs/components/trees/VisibilityTreeRenderer.d.ts +38 -14
  31. package/lib/cjs/components/trees/VisibilityTreeRenderer.js +35 -41
  32. package/lib/cjs/components/trees/VisibilityTreeRenderer.js.map +1 -1
  33. package/lib/cjs/components/trees/category-tree/CategoriesTree.d.ts +12 -11
  34. package/lib/cjs/components/trees/category-tree/CategoriesTree.js +17 -41
  35. package/lib/cjs/components/trees/category-tree/CategoriesTree.js.map +1 -1
  36. package/lib/cjs/components/trees/category-tree/CategoriesTreeComponent.d.ts +67 -6
  37. package/lib/cjs/components/trees/category-tree/CategoriesTreeComponent.js +61 -72
  38. package/lib/cjs/components/trees/category-tree/CategoriesTreeComponent.js.map +1 -1
  39. package/lib/cjs/components/trees/category-tree/CategoryVisibilityHandler.d.ts +30 -8
  40. package/lib/cjs/components/trees/category-tree/CategoryVisibilityHandler.js +61 -34
  41. package/lib/cjs/components/trees/category-tree/CategoryVisibilityHandler.js.map +1 -1
  42. package/lib/cjs/components/trees/external-sources-tree/ExternalSources.json +230 -0
  43. package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.d.ts +27 -0
  44. package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.js +61 -0
  45. package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -0
  46. package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTreeComponent.d.ts +20 -0
  47. package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js +39 -0
  48. package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js.map +1 -0
  49. package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.d.ts +30 -0
  50. package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.js +39 -0
  51. package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -0
  52. package/lib/cjs/components/trees/imodel-content-tree/IModelContentTreeComponent.d.ts +26 -0
  53. package/lib/cjs/components/trees/imodel-content-tree/IModelContentTreeComponent.js +35 -0
  54. package/lib/cjs/components/trees/imodel-content-tree/IModelContentTreeComponent.js.map +1 -0
  55. package/lib/cjs/components/trees/index.d.ts +5 -1
  56. package/lib/cjs/components/trees/index.js +10 -2
  57. package/lib/cjs/components/trees/index.js.map +1 -1
  58. package/lib/cjs/components/trees/models-tree/ModelsTree.d.ts +26 -18
  59. package/lib/cjs/components/trees/models-tree/ModelsTree.js +22 -50
  60. package/lib/cjs/components/trees/models-tree/ModelsTree.js.map +1 -1
  61. package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.d.ts +70 -2
  62. package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.js +68 -105
  63. package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
  64. package/lib/cjs/components/trees/models-tree/ModelsVisibilityHandler.d.ts +40 -12
  65. package/lib/cjs/components/trees/models-tree/ModelsVisibilityHandler.js +65 -5
  66. package/lib/cjs/components/trees/models-tree/ModelsVisibilityHandler.js.map +1 -1
  67. package/lib/cjs/components/trees/models-tree/Utils.d.ts +12 -0
  68. package/lib/cjs/components/trees/models-tree/Utils.js +625 -1
  69. package/lib/cjs/components/trees/models-tree/Utils.js.map +1 -1
  70. package/lib/cjs/components/utils/AutoSizer.d.ts +6 -3
  71. package/lib/cjs/components/utils/AutoSizer.js +9 -29
  72. package/lib/cjs/components/utils/AutoSizer.js.map +1 -1
  73. package/lib/cjs/components/utils/IsPromiseLike.d.ts +4 -1
  74. package/lib/cjs/components/utils/IsPromiseLike.js +6 -3
  75. package/lib/cjs/components/utils/IsPromiseLike.js.map +1 -1
  76. package/lib/cjs/tree-widget-react.d.ts +0 -1
  77. package/lib/cjs/tree-widget-react.js +5 -2
  78. package/lib/cjs/tree-widget-react.js.map +1 -1
  79. package/lib/esm/TreeWidget.d.ts +0 -1
  80. package/lib/esm/TreeWidget.js +2 -7
  81. package/lib/esm/TreeWidget.js.map +1 -1
  82. package/lib/esm/components/TreeFilteringState.d.ts +3 -1
  83. package/lib/esm/components/TreeFilteringState.js +17 -19
  84. package/lib/esm/components/TreeFilteringState.js.map +1 -1
  85. package/lib/esm/components/TreeWidgetComponent.d.ts +29 -5
  86. package/lib/esm/components/TreeWidgetComponent.js +82 -7
  87. package/lib/esm/components/TreeWidgetComponent.js.map +1 -1
  88. package/lib/esm/components/TreeWidgetComponent.scss +4 -24
  89. package/lib/esm/components/TreeWidgetUiItemsProvider.d.ts +25 -2
  90. package/lib/esm/components/TreeWidgetUiItemsProvider.js +29 -41
  91. package/lib/esm/components/TreeWidgetUiItemsProvider.js.map +1 -1
  92. package/lib/esm/components/tree-header/TreeHeader.d.ts +26 -0
  93. package/lib/esm/components/tree-header/TreeHeader.js +36 -0
  94. package/lib/esm/components/tree-header/TreeHeader.js.map +1 -0
  95. package/lib/esm/components/tree-header/TreeHeader.scss +69 -0
  96. package/lib/esm/components/trees/CategoriesVisibilityUtils.d.ts +12 -6
  97. package/lib/esm/components/trees/CategoriesVisibilityUtils.js +10 -4
  98. package/lib/esm/components/trees/CategoriesVisibilityUtils.js.map +1 -1
  99. package/lib/esm/components/trees/Common.d.ts +2 -2
  100. package/lib/esm/components/trees/Common.js +1 -1
  101. package/lib/esm/components/trees/Common.js.map +1 -1
  102. package/lib/esm/components/trees/VisibilityTreeBase.scss +66 -10
  103. package/lib/esm/components/trees/VisibilityTreeEventHandler.d.ts +13 -12
  104. package/lib/esm/components/trees/VisibilityTreeEventHandler.js +6 -17
  105. package/lib/esm/components/trees/VisibilityTreeEventHandler.js.map +1 -1
  106. package/lib/esm/components/trees/VisibilityTreeRenderer.d.ts +38 -14
  107. package/lib/esm/components/trees/VisibilityTreeRenderer.js +29 -19
  108. package/lib/esm/components/trees/VisibilityTreeRenderer.js.map +1 -1
  109. package/lib/esm/components/trees/category-tree/CategoriesTree.d.ts +12 -11
  110. package/lib/esm/components/trees/category-tree/CategoriesTree.js +16 -21
  111. package/lib/esm/components/trees/category-tree/CategoriesTree.js.map +1 -1
  112. package/lib/esm/components/trees/category-tree/CategoriesTreeComponent.d.ts +67 -6
  113. package/lib/esm/components/trees/category-tree/CategoriesTreeComponent.js +60 -52
  114. package/lib/esm/components/trees/category-tree/CategoriesTreeComponent.js.map +1 -1
  115. package/lib/esm/components/trees/category-tree/CategoryVisibilityHandler.d.ts +30 -8
  116. package/lib/esm/components/trees/category-tree/CategoryVisibilityHandler.js +57 -14
  117. package/lib/esm/components/trees/category-tree/CategoryVisibilityHandler.js.map +1 -1
  118. package/lib/esm/components/trees/external-sources-tree/ExternalSources.json +230 -0
  119. package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.d.ts +27 -0
  120. package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.js +34 -0
  121. package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -0
  122. package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTreeComponent.d.ts +20 -0
  123. package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js +35 -0
  124. package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js.map +1 -0
  125. package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.d.ts +30 -0
  126. package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.js +32 -0
  127. package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -0
  128. package/lib/esm/components/trees/imodel-content-tree/IModelContentTreeComponent.d.ts +26 -0
  129. package/lib/esm/components/trees/imodel-content-tree/IModelContentTreeComponent.js +31 -0
  130. package/lib/esm/components/trees/imodel-content-tree/IModelContentTreeComponent.js.map +1 -0
  131. package/lib/esm/components/trees/index.d.ts +5 -1
  132. package/lib/esm/components/trees/index.js +5 -1
  133. package/lib/esm/components/trees/index.js.map +1 -1
  134. package/lib/esm/components/trees/models-tree/ModelsTree.d.ts +26 -18
  135. package/lib/esm/components/trees/models-tree/ModelsTree.js +23 -32
  136. package/lib/esm/components/trees/models-tree/ModelsTree.js.map +1 -1
  137. package/lib/esm/components/trees/models-tree/ModelsTreeComponent.d.ts +70 -2
  138. package/lib/esm/components/trees/models-tree/ModelsTreeComponent.js +66 -84
  139. package/lib/esm/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
  140. package/lib/esm/components/trees/models-tree/ModelsVisibilityHandler.d.ts +40 -12
  141. package/lib/esm/components/trees/models-tree/ModelsVisibilityHandler.js +60 -5
  142. package/lib/esm/components/trees/models-tree/ModelsVisibilityHandler.js.map +1 -1
  143. package/lib/esm/components/trees/models-tree/Utils.d.ts +12 -0
  144. package/lib/esm/components/trees/models-tree/Utils.js +622 -0
  145. package/lib/esm/components/trees/models-tree/Utils.js.map +1 -1
  146. package/lib/esm/components/utils/AutoSizer.d.ts +6 -3
  147. package/lib/esm/components/utils/AutoSizer.js +9 -10
  148. package/lib/esm/components/utils/AutoSizer.js.map +1 -1
  149. package/lib/esm/components/utils/IsPromiseLike.d.ts +4 -1
  150. package/lib/esm/components/utils/IsPromiseLike.js +4 -1
  151. package/lib/esm/components/utils/IsPromiseLike.js.map +1 -1
  152. package/lib/esm/tree-widget-react.d.ts +0 -1
  153. package/lib/esm/tree-widget-react.js +0 -1
  154. package/lib/esm/tree-widget-react.js.map +1 -1
  155. package/lib/public/locales/en/TreeWidget.json +13 -4
  156. package/package.json +61 -66
  157. package/lib/cjs/components/rulesets/ClassificationSystems.json +0 -122
  158. package/lib/cjs/components/search-bar/SearchBar.d.ts +0 -48
  159. package/lib/cjs/components/search-bar/SearchBar.js +0 -86
  160. package/lib/cjs/components/search-bar/SearchBar.js.map +0 -1
  161. package/lib/cjs/components/search-bar/SearchBar.scss +0 -118
  162. package/lib/cjs/components/search-bar/SearchBox.d.ts +0 -70
  163. package/lib/cjs/components/search-bar/SearchBox.js +0 -186
  164. package/lib/cjs/components/search-bar/SearchBox.js.map +0 -1
  165. package/lib/cjs/components/search-bar/SearchBox.scss +0 -70
  166. package/lib/cjs/components/trees/IModelContentTree.d.ts +0 -4
  167. package/lib/cjs/components/trees/IModelContentTree.js +0 -50
  168. package/lib/cjs/components/trees/IModelContentTree.js.map +0 -1
  169. package/lib/cjs/components/trees/models-tree/Hierarchy.GroupedByClass.json +0 -391
  170. package/lib/cjs/components/trees/models-tree/Hierarchy.json +0 -386
  171. package/lib/cjs/components/trees/models-tree/ModelsTreeSearch.json +0 -239
  172. package/lib/cjs/types.d.ts +0 -44
  173. package/lib/cjs/types.js +0 -11
  174. package/lib/cjs/types.js.map +0 -1
  175. package/lib/esm/components/rulesets/ClassificationSystems.json +0 -122
  176. package/lib/esm/components/search-bar/SearchBar.d.ts +0 -48
  177. package/lib/esm/components/search-bar/SearchBar.js +0 -60
  178. package/lib/esm/components/search-bar/SearchBar.js.map +0 -1
  179. package/lib/esm/components/search-bar/SearchBar.scss +0 -118
  180. package/lib/esm/components/search-bar/SearchBox.d.ts +0 -70
  181. package/lib/esm/components/search-bar/SearchBox.js +0 -160
  182. package/lib/esm/components/search-bar/SearchBox.js.map +0 -1
  183. package/lib/esm/components/search-bar/SearchBox.scss +0 -70
  184. package/lib/esm/components/trees/IModelContentTree.d.ts +0 -4
  185. package/lib/esm/components/trees/IModelContentTree.js +0 -24
  186. package/lib/esm/components/trees/IModelContentTree.js.map +0 -1
  187. package/lib/esm/components/trees/models-tree/Hierarchy.GroupedByClass.json +0 -391
  188. package/lib/esm/components/trees/models-tree/Hierarchy.json +0 -386
  189. package/lib/esm/components/trees/models-tree/ModelsTreeSearch.json +0 -239
  190. package/lib/esm/types.d.ts +0 -44
  191. package/lib/esm/types.js +0 -8
  192. package/lib/esm/types.js.map +0 -1
  193. /package/lib/cjs/components/{rulesets → trees/imodel-content-tree}/IModelContent.json +0 -0
  194. /package/lib/esm/components/{rulesets → trees/imodel-content-tree}/IModelContent.json +0 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,331 @@
1
+ # Change Log - @itwin/tree-widget-react
2
+
3
+ This log was last generated on Tue, 23 May 2023 13:16:11 GMT and should not be manually modified.
4
+
5
+ ## 0.10.0
6
+ Tue, 23 May 2023 13:16:11 GMT
7
+
8
+ _Version update only_
9
+
10
+ ## 0.9.0
11
+ Tue, 02 May 2023 16:12:17 GMT
12
+
13
+ ### Minor changes
14
+
15
+ - Updated to AppUI 4.0 and Presentation 4.0
16
+
17
+ ## 0.8.0
18
+ Mon, 03 Apr 2023 15:34:07 GMT
19
+
20
+ ### Minor changes
21
+
22
+ - Removed `SpatialTree` and related components in favor of the ones in `@itwin/breakdown-trees-react`
23
+ - Updated dependencies (`itwinui@2`, `appui@4`, `presentation-components@4`, `itwinjs-core@3.7`)
24
+
25
+ ### Patches
26
+
27
+ - Use iTwin UI components instead of custom ones and CSS variables from `@itwin/itwinui-variables` instead of `@itwin/core-react`
28
+
29
+ ## 0.7.2
30
+ Fri, 24 Mar 2023 10:46:34 GMT
31
+
32
+ ### Patches
33
+
34
+ - Fixed tree filtering not being removed when search box is closed
35
+
36
+ ## 0.7.1
37
+ Thu, 23 Mar 2023 15:12:36 GMT
38
+
39
+ ### Patches
40
+
41
+ - 'ModelsTree': Restored 'HideAll' button behavior to hide only models
42
+
43
+ ## 0.7.0
44
+ Mon, 20 Mar 2023 14:48:35 GMT
45
+
46
+ ### Minor changes
47
+
48
+ - Add an option to control what buttons are available in tree toolbars.
49
+ - Upgrade `itwinjs-core` dependencies to `^3.6.0`
50
+ - Upgrade `typescript` to `~4.4.0`
51
+
52
+ ### Patches
53
+
54
+ - ModelsTree: ensure that the "Show all" button is going to show all elements when there are elements with an "exclusive" flag
55
+ - '2d' and '3d' buttons react to visibility changes in the viewport. The '2d' button will be disabled if no models with the PlanProjection flag are present in the model.
56
+
57
+ ## 0.6.2
58
+ Thu, 09 Mar 2023 20:08:53 GMT
59
+
60
+ ### Patches
61
+
62
+ - `ModelsTreeComponent`: ensure that the "show all" and "hide all" buttons affect all iModel content
63
+ - Models Tree: Remove unused feature of filtering the tree by element ids
64
+
65
+ ## 0.6.1
66
+ Thu, 19 Jan 2023 10:29:18 GMT
67
+
68
+ ### Patches
69
+
70
+ - CategoriesTree: Updated ruleset to not show private SubCategories
71
+ - Bug fix for changing visibility of multiple nodes at once
72
+
73
+ ## 0.6.0
74
+ Tue, 20 Dec 2022 15:12:29 GMT
75
+
76
+ ### Minor changes
77
+
78
+ - Moved core trees implementation from @itwin/appui-react package to @itwin/tree-widget-react
79
+
80
+ ## 0.5.0
81
+ Mon, 12 Sep 2022 19:50:36 GMT
82
+
83
+ ### Minor changes
84
+
85
+ - Add new `defaultTreeId` prop to specify default tree for TreeWidgetUiItemsProvider
86
+
87
+ ## 0.4.7
88
+ Mon, 30 May 2022 12:44:10 GMT
89
+
90
+ ### Patches
91
+
92
+ - Fix GeometricElement nodes not being shown in `IModelContentTree`.
93
+
94
+ ## 0.4.6
95
+ Thu, 26 May 2022 15:54:07 GMT
96
+
97
+ ### Patches
98
+
99
+ - Allow a caller to specify a default priority for Tree Widget item provider.
100
+
101
+ ## 0.4.5
102
+ Mon, 09 May 2022 18:04:58 GMT
103
+
104
+ ### Patches
105
+
106
+ - set restore transient state in tree widget ui items provider to restore state when remounted
107
+
108
+ ## 0.4.4
109
+ Thu, 05 May 2022 12:21:21 GMT
110
+
111
+ ### Patches
112
+
113
+ - set tree-widget-search-bar-button-container z-index to 1
114
+
115
+ ## 0.4.3
116
+ Thu, 21 Apr 2022 18:47:53 GMT
117
+
118
+ ### Patches
119
+
120
+ - Do not unmount children in AutoSizer when height or width is 0 to avoid losing children state
121
+
122
+ ## 0.4.2
123
+ Tue, 19 Apr 2022 14:15:57 GMT
124
+
125
+ ### Patches
126
+
127
+ - Fixed search bar container to take up entire width of widget when open.
128
+
129
+ ## 0.4.1
130
+ Wed, 06 Apr 2022 13:48:44 GMT
131
+
132
+ ### Patches
133
+
134
+ - Updates to allow specification of default panel location.
135
+ - Add transitive peers as dev deps
136
+ - added tree icon to tree widget tab
137
+
138
+ ## 0.4.0
139
+ Fri, 18 Mar 2022 13:31:19 GMT
140
+
141
+ ### Minor changes
142
+
143
+ - Remove deprecated WidgetControl, update UiItemsProvider init
144
+
145
+ ## 0.3.0
146
+ Wed, 02 Mar 2022 21:38:51 GMT
147
+
148
+ ### Minor changes
149
+
150
+ - Add `IModelContentTree`
151
+
152
+ ## 0.2.1
153
+ Fri, 04 Feb 2022 00:43:35 GMT
154
+
155
+ ### Patches
156
+
157
+ - Update scss to be pulled from cjs dir
158
+
159
+ ## 0.2.0
160
+ Mon, 24 Jan 2022 19:14:37 GMT
161
+
162
+ ### Minor changes
163
+
164
+ - Bump to official iTwin.js 3.0 release
165
+
166
+ ## 0.1.2
167
+ Wed, 19 Jan 2022 17:39:40 GMT
168
+
169
+ ### Patches
170
+
171
+ - updated to latest rc, dev-185, and updated deps
172
+
173
+ ## 0.1.1
174
+ Wed, 12 Jan 2022 13:59:35 GMT
175
+
176
+ ### Patches
177
+
178
+ - iTwin.js 3.0 first rc
179
+
180
+ ## 1.4.6
181
+ Tue, 11 Jan 2022 16:25:27 GMT
182
+
183
+ ### Patches
184
+
185
+ - Fix hide all button blocked by search bar
186
+
187
+ ## 1.4.5
188
+ Tue, 23 Nov 2021 21:19:42 GMT
189
+
190
+ ### Patches
191
+
192
+ - Fix an issue where ModelsTree Component could lose its state
193
+
194
+ ## 1.4.4
195
+ Thu, 16 Sep 2021 17:55:54 GMT
196
+
197
+ ### Patches
198
+
199
+ - Stop delivering psuedo-localized strings
200
+
201
+ ## 1.4.3
202
+ Thu, 26 Aug 2021 14:00:14 GMT
203
+
204
+ ### Patches
205
+
206
+ - Search bar was not sized correctly, and alignment was not centered.
207
+
208
+ ## 1.4.2
209
+ Mon, 09 Aug 2021 20:24:55 GMT
210
+
211
+ ### Patches
212
+
213
+ - Updated tree widget barrel file to include UiProvider
214
+
215
+ ## 1.4.1
216
+ Mon, 19 Jul 2021 18:07:24 GMT
217
+
218
+ ### Patches
219
+
220
+ - Model/Category tree was not resizing properly, missing flex=1.
221
+
222
+ ## 1.4.0
223
+ Tue, 13 Jul 2021 17:43:28 GMT
224
+
225
+ ### Minor changes
226
+
227
+ - Added a UiProvider that implements the existing tree widget
228
+
229
+ ## 1.3.1
230
+ Tue, 08 Jun 2021 21:23:59 GMT
231
+
232
+ ### Patches
233
+
234
+ - bump classnames dep
235
+
236
+ ## 1.3.0
237
+ Thu, 13 May 2021 21:15:14 GMT
238
+
239
+ ### Minor changes
240
+
241
+ - update imjs to 2.15.2 to resolve breaking change in usePResentationTreeNodeLoader
242
+
243
+ ## 1.2.8
244
+ Wed, 24 Mar 2021 21:09:25 GMT
245
+
246
+ ### Patches
247
+
248
+ - Avoid Nested ScrollBars in Tree View widget
249
+
250
+ ## 1.2.7
251
+ Tue, 23 Mar 2021 16:17:57 GMT
252
+
253
+ ### Patches
254
+
255
+ - Change .component-selectable-content to block to display to fix resize flicker.
256
+
257
+ ## 1.2.6
258
+ Fri, 26 Feb 2021 18:43:33 GMT
259
+
260
+ ### Patches
261
+
262
+ - Fixes for models tree not loading models when using show all, invert and other toggles
263
+
264
+ ## 1.2.5
265
+ Tue, 15 Dec 2020 13:51:37 GMT
266
+
267
+ ### Patches
268
+
269
+ - Fix styling issues in search bar
270
+
271
+ ## 1.2.4
272
+ Wed, 09 Dec 2020 19:09:13 GMT
273
+
274
+ ### Patches
275
+
276
+ - Fixing resizing issues with the SearchBox in Model tree
277
+
278
+ ## 1.2.3
279
+ Tue, 25 Aug 2020 16:57:36 GMT
280
+
281
+ ### Patches
282
+
283
+ - rm unecessary dep on react-scripts
284
+
285
+ ## 1.2.2
286
+ Mon, 24 Aug 2020 17:39:24 GMT
287
+
288
+ ### Patches
289
+
290
+ - alphabetize package.json
291
+
292
+ ## 1.2.1
293
+ Fri, 21 Aug 2020 21:17:48 GMT
294
+
295
+ ### Patches
296
+
297
+ - readme update
298
+ - support replacing model/category/spatial trees in TreeWidgetControl
299
+
300
+ ## 1.2.0
301
+ Tue, 11 Aug 2020 14:24:07 GMT
302
+
303
+ ### Minor changes
304
+
305
+ - Added 2D / 3D toggle to tree view header
306
+
307
+ ### Patches
308
+
309
+ - Decouple tree header for using in other widgets
310
+
311
+ ## 1.1.1
312
+ Tue, 28 Jul 2020 22:10:32 GMT
313
+
314
+ ### Patches
315
+
316
+ - Fixes for tree widgets consistency: Category tree invert functionality, tooltips on buttons and fix for iFrame height of tree not defined properly
317
+
318
+ ## 1.1.0
319
+ Tue, 14 Jul 2020 22:54:18 GMT
320
+
321
+ ### Minor changes
322
+
323
+ - "Add classifications tree."
324
+ - Added in tree-widget package
325
+ - Replacing ThemedSelect component with SelectableContent component
326
+
327
+ ### Patches
328
+
329
+ - Functional component.
330
+ - Model tree search box will now properly clear itself in addition to closing when its "X" icon is hit
331
+
package/README.md CHANGED
@@ -2,60 +2,177 @@
2
2
 
3
3
  Copyright © Bentley Systems, Incorporated. All rights reserved.
4
4
 
5
- The tree-widget-react package provides React components to access Models and Categories within an iModel via a UiProvider, `TreeWidgetUiItemsProvider`.
5
+ The `@itwin/tree-widget-react` package provides React components to build a widget with tree components' selector, along with all the building blocks that can be used individually.
6
6
 
7
- The package also provides the underlying component, `TreeWidgetComponent`, which you can wrap within your own custom UiProvider and pass in your own custom trees to display.
7
+ ![Widget example](./media/widget.png)
8
8
 
9
9
  ## Usage
10
10
 
11
- ### What to add in your iTwin AppUI based application
11
+ Typically, the package is used with an [AppUI](https://github.com/iTwin/appui/tree/master/ui/appui-react) based application, but the building blocks may as well be used with any other iTwin.js React app.
12
12
 
13
- With a few short lines, you can add the tree widget to your app.
14
-
15
- #### Call TreeWidget.initialize() **_before_** making use of the provided Tree Widget Provider
13
+ In any case, **before** using any APIs or components delivered with the package, it needs to be initialized:
16
14
 
17
15
  ```ts
16
+ import { IModelApp } from "@itwin/core-frontend";
18
17
  import { TreeWidget } from "@itwin/tree-widget-react";
19
18
  ...
20
19
  await TreeWidget.initialize(IModelApp.localization);
21
20
  ```
22
21
 
23
- #### Register Tree Widget Provider
22
+ In [AppUI](https://github.com/iTwin/appui/tree/master/ui/appui-react) based applications widgets are typically provided using `UiItemsProvider` implementations. The `@itwin/tree-widget-react` package delivers `TreeWidgetUiItemsProvider` that can be used to add the tree widget to UI:
24
23
 
25
24
  ```ts
26
- import { UiItemsManager } from "@itwin/appui-abstract";
25
+ import { UiItemsManager } from "@itwin/appui-react";
27
26
  import { TreeWidgetUiItemsProvider } from "@itwin/tree-widget-react";
28
27
  ...
29
28
  UiItemsManager.register(
30
- new TreeWidgetUiItemsProvider({ ...TreeWidgetOptions })
29
+ new TreeWidgetUiItemsProvider()
31
30
  );
32
31
  ```
33
32
 
34
- ### Additional trees avaialable
33
+ The above example uses default widget parameters and results in a component similar to the one visible at the top of this README. Customization is also possible:
34
+
35
+ ```ts
36
+ import { UiItemsManager } from "@itwin/appui-react";
37
+ import { TreeWidgetUiItemsProvider, ModelsTreeComponent } from "@itwin/tree-widget-react";
38
+ ...
39
+ UiItemsManager.register(
40
+ new TreeWidgetUiItemsProvider({
41
+ // defaults to `StagePanelLocation.Right`
42
+ defaultPanelLocation: StagePanelLocation.Left,
43
+ // defaults to `StagePanelSection.Start`
44
+ defaultPanelSection: StagePanelSection.End,
45
+ // defaults to whatever the default `Widget.priority` in AppUI is
46
+ defaultTreeWidgetPriority: 1000,
47
+ // defaults to `ModelsTreeComponent` and `CategoriesTreeComponent`
48
+ trees: [{
49
+ id: ModelsTreeComponent.id,
50
+ getLabel: ModelsTreeComponent.getLabel,
51
+ render: () => <ModelsTreeComponent />,
52
+ }, {
53
+ id: "my-tree-id",
54
+ getLabel: "My Custom Tree",
55
+ render: () => <>This is my custom tree.</>,
56
+ }];
57
+ })
58
+ );
59
+ ```
60
+
61
+ As seen in the above code snippet, `TreeWidgetUiItemsProvider` takes a list of trees that are displayed in the widget. This package delivers a number of tree components for everyone's use (see below), but providing custom trees is also an option.
62
+
63
+ ## Components
64
+
65
+ While we expect this package to be mostly used with [AppUI](https://github.com/iTwin/appui/tree/master/ui/appui-react) and widget created through `TreeWidgetUiItemsProvider`, the package delivers components used within the widget to meet other use cases:
66
+
67
+ - `TreeWidgetComponent` renders a tree selector and selected tree (based on the `trees` prop).
68
+
69
+ - Visibility tree components help you build trees that look and feel like [Models](#models-tree) and [Categories](#categories-tree) trees, letting you control display of elements in the hierarchy.
70
+
71
+ - `createVisibilityTreeRenderer` returns a tree renderer that renders nodes with "eye" checkboxes. Its building blocks:
72
+ - `createVisibilityTreeNodeRenderer`
73
+ - `VisibilityTreeNodeCheckbox`
74
+ - `useVisibilityTreeFiltering` is used to filter the hierarchy.
75
+ - `VisibilityTreeNoFilteredData` is used to render a "no results" when filtering.
76
+ - `VisibilityTreeEventHandler` is an extension of [UnifiedSelectionTreeEventHandler](https://www.itwinjs.org/reference/presentation-components/tree/unifiedselectiontreeeventhandler/), that additionally handles checkbox events and calls provided `IVisibilityHandler` to get/set display of the elements in the hierarchy.
77
+
78
+ ### Models tree
79
+
80
+ The component renders a tree that tries to replicate how a typical "Models" tree of the iModel would look like in the source application. There's also a header that renders models search box and various visibility control buttons.
81
+
82
+ ![Models tree example](./media/models-tree.png)
83
+
84
+ Typical usage:
85
+
86
+ ```tsx
87
+ import { ModelsTreeComponent, ClassGroupingOption } from "@itwin/tree-widget-react";
88
+ import { SelectionMode } from "@itwin/components-react";
89
+ ...
90
+ function MyWidget() {
91
+ return (
92
+ <ModelsTreeComponent
93
+ headerButtons={[
94
+ (props) => <ModelsTreeComponent.ShowAllButton {...props} />,
95
+ (props) => <ModelsTreeComponent.HideAllButton {...props} />,
96
+ (props) => <MyCustomButton />,
97
+ ]}
98
+ selectionMode={SelectionMode.Extended}
99
+ hierarchyConfig={{
100
+ enableElementsClassGrouping: ClassGroupingOption.Yes,
101
+ }}
102
+ />
103
+ );
104
+ }
105
+ ```
106
+
107
+ Available header buttons:
108
+
109
+ - `ModelsTreeComponent.ShowAllButton` makes everything in the iModel displayed.
110
+ - `ModelsTreeComponent.HideAllButton` makes everything in the iModel hidden by turning off all models.
111
+ - `ModelsTreeComponent.InvertButton` inverts display of all models.
112
+ - `ModelsTreeComponent.View2DButton` toggles plan projection models' display.
113
+ - `ModelsTreeComponent.View3DButton` toggles non-plan projection models' display.
114
+
115
+ `ModelsTreeComponent` building blocks:
116
+
117
+ - `ModelsTree` renders the tree without the header.
118
+ - `ModelsVisibilityHandler` knows how to get and control display of various concepts displayed in the Models tree: Subjects, Models, Categories, Elements.
119
+
120
+ ### Categories tree
121
+
122
+ The component, based on the active view, renders a hierarchy of either spatial (3d) or drawing (2d) categories. The hierarchy consists of two levels - the category (spatial or drawing) and its sub-categories. There's also a header that renders categories search box and various visibility control buttons.
123
+
124
+ ![Categories tree example](./media/categories-tree.png)
125
+
126
+ Typical usage:
127
+
128
+ ```tsx
129
+ import { CategoriesTreeComponent } from "@itwin/tree-widget-react";
130
+ ...
131
+ function MyWidget() {
132
+ return (
133
+ <CategoriesTreeComponent
134
+ headerButtons={[
135
+ (props) => <CategoriesTreeComponent.ShowAllButton {...props} />,
136
+ (props) => <CategoriesTreeComponent.HideAllButton {...props} />,
137
+ (props) => <MyCustomButton />,
138
+ ]}
139
+ />
140
+ );
141
+ }
142
+ ```
143
+
144
+ Available header buttons:
35
145
 
36
- #### IModelContentTree
146
+ - `ModelsTreeComponent.ShowAllButton` makes all categories and their subcategories displayed.
147
+ - `ModelsTreeComponent.HideAllButton` makes all categories hidden.
148
+ - `ModelsTreeComponent.InvertButton` inverts display of all categories.
37
149
 
38
- Component that displays a hierarchy with content of a given `IModelConnection`.
150
+ `CategoriesTreeComponent` building blocks:
39
151
 
40
- ##### Resulting hierarchy
152
+ - `CategoryTree` renders the tree without the header.
153
+ - `CategoryVisibilityHandler` knows how to get and control display of Categories and SubCategories.
41
154
 
42
- - Root Subject
43
- - Child Subjects
44
- - Target Model
45
- - Spatial Categories of top-assemblies in the Model (if model is a GeometricModel3d)
46
- - Top-assemblies in the model and category
47
- - Child elements of the assembly
48
- - Drawing Categories of top-assemblies in the Model (if model is a GeometricModel2d)
49
- - Top-assemblies in the model and category
50
- - Child elements of the assembly
51
- - Top-assemblies in the Model (if model is neither GeometricModel3d nor GeometricModel2d)
52
- - Child elements of the assembly
155
+ ### IModel content tree
53
156
 
54
- In addition, for every modeled element we show content of the model as children for the element's node.
157
+ The component renders a similar hierarchy to [Models tree](#models-tree), but with the following changes:
55
158
 
56
- More details about Subjects and Models can be found here:
159
+ - Only the hierarchy, without a header is rendered.
160
+ - Visibility control is not allowed.
161
+ - There's less hiding of `Subject` and `Model` nodes.
162
+ - Show not only geometric, but all Models.
57
163
 
58
- - <https://www.imodeljs.org/bis/intro/information-hierarchy/>
59
- - <https://www.imodeljs.org/bis/intro/organizing-models-and-elements/>
164
+ In general, the component is expected to be used by advanced users to inspect contents of the iModel.
60
165
 
61
- More details about the hierarchy can be found in the [presentation ruleset JSON file](./src/components/rulesets/IModelContent.json).
166
+ ![IModel content tree example](./media/imodel-content-tree.png)
167
+
168
+ Typical usage:
169
+
170
+ ```tsx
171
+ import { IModelContentTreeComponent } from "@itwin/tree-widget-react";
172
+ ...
173
+ function MyWidget() {
174
+ return (
175
+ <IModelContentTreeComponent />
176
+ );
177
+ }
178
+ ```
@@ -22,6 +22,5 @@ export declare class TreeWidget {
22
22
  /** Calls i18n.translateWithNamespace with the "TreeWidget" namespace. Do NOT include the namespace in the key.
23
23
  */
24
24
  static translate(key: string | string[], options?: LocalizationOptions): string;
25
- static loggerCategory(obj: any): string;
26
25
  }
27
26
  //# sourceMappingURL=TreeWidget.d.ts.map
@@ -33,7 +33,7 @@ class TreeWidget {
33
33
  /** The internationalization service created by the IModelApp. */
34
34
  static get i18n() {
35
35
  if (!TreeWidget._i18n)
36
- throw new appui_abstract_1.UiError(TreeWidget.loggerCategory(this), "TreeWidget not initialized");
36
+ throw new appui_abstract_1.UiError(TreeWidget.packageName, "TreeWidget not initialized");
37
37
  return TreeWidget._i18n;
38
38
  }
39
39
  /** The internationalization service namespace. */
@@ -49,11 +49,6 @@ class TreeWidget {
49
49
  const stringKey = `${TreeWidget.i18nNamespace}:${key}`;
50
50
  return TreeWidget.i18n.getLocalizedString(stringKey, options);
51
51
  }
52
- static loggerCategory(obj) {
53
- const className = (0, appui_abstract_1.getClassName)(obj);
54
- const category = TreeWidget.packageName + (className ? `.${className}` : "");
55
- return category;
56
- }
57
52
  }
58
53
  exports.TreeWidget = TreeWidget;
59
54
  //# sourceMappingURL=TreeWidget.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TreeWidget.js","sourceRoot":"","sources":["../../src/TreeWidget.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,0DAA8D;AAC9D,wDAAiD;AAIjD;;;GAGG;AACH,MAAa,UAAU;IAIrB;;;OAGG;IACI,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,IAAmB;QAChD,IAAI,IAAI,CAAC,YAAY;YAAE,OAAO;QAE9B,UAAU,CAAC,YAAY,GAAG,IAAI,CAAC;QAC/B,UAAU,CAAC,KAAK,GAAG,IAAI,IAAI,yBAAS,CAAC,YAAY,CAAC;QAElD,OAAO,UAAU,CAAC,KAAK,CAAC,iBAAiB,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IACtE,CAAC;IAED,wEAAwE;IACjE,MAAM,CAAC,SAAS;QACrB,IAAI,UAAU,CAAC,KAAK;YAClB,UAAU,CAAC,KAAK,CAAC,mBAAmB,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,yCAAyC;QAC3G,UAAU,CAAC,KAAK,GAAG,SAAS,CAAC;QAC7B,UAAU,CAAC,YAAY,GAAG,KAAK,CAAC;IAClC,CAAC;IAED,iEAAiE;IAC1D,MAAM,KAAK,IAAI;QACpB,IAAI,CAAC,UAAU,CAAC,KAAK;YACnB,MAAM,IAAI,wBAAO,CACf,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC,EAC/B,4BAA4B,CAC7B,CAAC;QACJ,OAAO,UAAU,CAAC,KAAK,CAAC;IAC1B,CAAC;IAED,kDAAkD;IAC3C,MAAM,KAAK,aAAa;QAC7B,OAAO,YAAY,CAAC;IACtB,CAAC;IAEM,MAAM,KAAK,WAAW;QAC3B,OAAO,mBAAmB,CAAC;IAC7B,CAAC;IAED;OACG;IACI,MAAM,CAAC,SAAS,CACrB,GAAsB,EACtB,OAA6B;QAE7B,MAAM,SAAS,GAAG,GAAG,UAAU,CAAC,aAAa,IAAI,GAAG,EAAE,CAAC;QACvD,OAAO,UAAU,CAAC,IAAI,CAAC,kBAAkB,CACvC,SAAS,EACT,OAAO,CACR,CAAC;IACJ,CAAC;IAEM,MAAM,CAAC,cAAc,CAAC,GAAQ;QACnC,MAAM,SAAS,GAAG,IAAA,6BAAY,EAAC,GAAG,CAAC,CAAC;QACpC,MAAM,QAAQ,GACZ,UAAU,CAAC,WAAW,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAC9D,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AA/DD,gCA+DC","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 { getClassName, UiError } from \"@itwin/appui-abstract\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport type { Localization } from \"@itwin/core-common\";\nimport type { LocalizationOptions } from \"@itwin/core-i18n\";\n\n/**\n * Entry point for static initialization required by various components used in the package.\n * @public\n */\nexport class TreeWidget {\n private static _i18n?: Localization;\n private static _initialized?: boolean;\n\n /**\n * Called by IModelApp to initialize the Tree Widget\n * @param i18n - The internationalization service created by the IModelApp.\n */\n public static async initialize(i18n?: Localization): Promise<void> {\n if (this._initialized) return;\n\n TreeWidget._initialized = true;\n TreeWidget._i18n = i18n ?? IModelApp.localization;\n\n return TreeWidget._i18n.registerNamespace(TreeWidget.i18nNamespace);\n }\n\n /** Unregisters the TreeWidget internationalization service namespace */\n public static terminate() {\n if (TreeWidget._i18n)\n TreeWidget._i18n.unregisterNamespace(TreeWidget.i18nNamespace); // eslint-disable-line @itwin/no-internal\n TreeWidget._i18n = undefined;\n TreeWidget._initialized = false;\n }\n\n /** The internationalization service created by the IModelApp. */\n public static get i18n(): Localization {\n if (!TreeWidget._i18n)\n throw new UiError(\n TreeWidget.loggerCategory(this),\n \"TreeWidget not initialized\"\n );\n return TreeWidget._i18n;\n }\n\n /** The internationalization service namespace. */\n public static get i18nNamespace(): string {\n return \"TreeWidget\";\n }\n\n public static get packageName(): string {\n return \"tree-widget-react\";\n }\n\n /** Calls i18n.translateWithNamespace with the \"TreeWidget\" namespace. Do NOT include the namespace in the key.\n */\n public static translate(\n key: string | string[],\n options?: LocalizationOptions\n ): string {\n const stringKey = `${TreeWidget.i18nNamespace}:${key}`;\n return TreeWidget.i18n.getLocalizedString(\n stringKey,\n options\n );\n }\n\n public static loggerCategory(obj: any): string {\n const className = getClassName(obj);\n const category =\n TreeWidget.packageName + (className ? `.${className}` : \"\");\n return category;\n }\n}\n"]}
1
+ {"version":3,"file":"TreeWidget.js","sourceRoot":"","sources":["../../src/TreeWidget.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,0DAAgD;AAChD,wDAAiD;AAKjD;;;GAGG;AACH,MAAa,UAAU;IAIrB;;;OAGG;IACI,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,IAAmB;QAChD,IAAI,IAAI,CAAC,YAAY;YAAE,OAAO;QAE9B,UAAU,CAAC,YAAY,GAAG,IAAI,CAAC;QAC/B,UAAU,CAAC,KAAK,GAAG,IAAI,IAAI,yBAAS,CAAC,YAAY,CAAC;QAElD,OAAO,UAAU,CAAC,KAAK,CAAC,iBAAiB,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IACtE,CAAC;IAED,wEAAwE;IACjE,MAAM,CAAC,SAAS;QACrB,IAAI,UAAU,CAAC,KAAK;YAClB,UAAU,CAAC,KAAK,CAAC,mBAAmB,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,yCAAyC;QAC3G,UAAU,CAAC,KAAK,GAAG,SAAS,CAAC;QAC7B,UAAU,CAAC,YAAY,GAAG,KAAK,CAAC;IAClC,CAAC;IAED,iEAAiE;IAC1D,MAAM,KAAK,IAAI;QACpB,IAAI,CAAC,UAAU,CAAC,KAAK;YACnB,MAAM,IAAI,wBAAO,CACf,UAAU,CAAC,WAAW,EACtB,4BAA4B,CAC7B,CAAC;QACJ,OAAO,UAAU,CAAC,KAAK,CAAC;IAC1B,CAAC;IAED,kDAAkD;IAC3C,MAAM,KAAK,aAAa;QAC7B,OAAO,YAAY,CAAC;IACtB,CAAC;IAEM,MAAM,KAAK,WAAW;QAC3B,OAAO,mBAAmB,CAAC;IAC7B,CAAC;IAED;OACG;IACI,MAAM,CAAC,SAAS,CACrB,GAAsB,EACtB,OAA6B;QAE7B,MAAM,SAAS,GAAG,GAAG,UAAU,CAAC,aAAa,IAAI,GAAG,EAAE,CAAC;QACvD,OAAO,UAAU,CAAC,IAAI,CAAC,kBAAkB,CACvC,SAAS,EACT,OAAO,CACR,CAAC;IACJ,CAAC;CACF;AAxDD,gCAwDC","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 { UiError } from \"@itwin/appui-abstract\";\nimport { IModelApp } from \"@itwin/core-frontend\";\n\nimport type { Localization } from \"@itwin/core-common\";\nimport type { LocalizationOptions } from \"@itwin/core-i18n\";\n\n/**\n * Entry point for static initialization required by various components used in the package.\n * @public\n */\nexport class TreeWidget {\n private static _i18n?: Localization;\n private static _initialized?: boolean;\n\n /**\n * Called by IModelApp to initialize the Tree Widget\n * @param i18n - The internationalization service created by the IModelApp.\n */\n public static async initialize(i18n?: Localization): Promise<void> {\n if (this._initialized) return;\n\n TreeWidget._initialized = true;\n TreeWidget._i18n = i18n ?? IModelApp.localization;\n\n return TreeWidget._i18n.registerNamespace(TreeWidget.i18nNamespace);\n }\n\n /** Unregisters the TreeWidget internationalization service namespace */\n public static terminate() {\n if (TreeWidget._i18n)\n TreeWidget._i18n.unregisterNamespace(TreeWidget.i18nNamespace); // eslint-disable-line @itwin/no-internal\n TreeWidget._i18n = undefined;\n TreeWidget._initialized = false;\n }\n\n /** The internationalization service created by the IModelApp. */\n public static get i18n(): Localization {\n if (!TreeWidget._i18n)\n throw new UiError(\n TreeWidget.packageName,\n \"TreeWidget not initialized\"\n );\n return TreeWidget._i18n;\n }\n\n /** The internationalization service namespace. */\n public static get i18nNamespace(): string {\n return \"TreeWidget\";\n }\n\n public static get packageName(): string {\n return \"tree-widget-react\";\n }\n\n /** Calls i18n.translateWithNamespace with the \"TreeWidget\" namespace. Do NOT include the namespace in the key.\n */\n public static translate(\n key: string | string[],\n options?: LocalizationOptions\n ): string {\n const stringKey = `${TreeWidget.i18nNamespace}:${key}`;\n return TreeWidget.i18n.getLocalizedString(\n stringKey,\n options\n );\n }\n}\n"]}
@@ -1,15 +1,17 @@
1
1
  import type { IPresentationTreeDataProvider } from "@itwin/presentation-components";
2
+ /** @internal */
2
3
  export interface SearchOptions {
3
4
  isFiltering: boolean;
4
5
  onFilterCancel: () => void;
5
6
  onFilterStart: (newFilter: string) => void;
6
7
  onResultSelectedChanged: (index: number) => void;
7
8
  matchedResultCount: number | undefined;
9
+ activeMatchIndex: number | undefined;
8
10
  }
11
+ /** @internal */
9
12
  export declare const useTreeFilteringState: () => {
10
13
  searchOptions: SearchOptions;
11
14
  filterString: string;
12
- activeMatchIndex: number | undefined;
13
15
  onFilterApplied: (provider: IPresentationTreeDataProvider, matches: number) => void;
14
16
  filteredProvider: IPresentationTreeDataProvider | undefined;
15
17
  };
@@ -1,51 +1,30 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.useTreeFilteringState = void 0;
23
2
  /*---------------------------------------------------------------------------------------------
24
3
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
25
4
  * See LICENSE.md in the project root for license terms and full copyright notice.
26
5
  *--------------------------------------------------------------------------------------------*/
27
- const react_1 = __importStar(require("react"));
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.useTreeFilteringState = void 0;
8
+ const react_1 = require("react");
9
+ /** @internal */
28
10
  const useTreeFilteringState = () => {
29
- const [filterString, setFilterString] = (0, react_1.useState)("");
30
- const [matchedResultCount, setMatchedResultCount] = (0, react_1.useState)();
31
- const [activeMatchIndex, setActiveMatchIndex] = (0, react_1.useState)();
32
- const [filteredProvider, setFilteredProvider] = (0, react_1.useState)();
33
- const onFilterCancel = react_1.default.useCallback(() => {
34
- setFilterString("");
35
- setMatchedResultCount(undefined);
36
- setFilteredProvider(undefined);
11
+ const [{ filterString, matchedResultCount, activeMatchIndex, filteredProvider }, setState] = (0, react_1.useState)({ filterString: "" });
12
+ const onFilterCancel = (0, react_1.useCallback)(() => {
13
+ setState({ filterString: "" });
37
14
  }, []);
38
- const onFilterStart = react_1.default.useCallback((newFilter) => {
39
- setFilterString(newFilter);
40
- setMatchedResultCount(undefined);
41
- setFilteredProvider(undefined);
15
+ const onFilterStart = (0, react_1.useCallback)((newFilter) => {
16
+ setState({ filterString: newFilter });
42
17
  }, []);
43
- const onResultSelectedChanged = react_1.default.useCallback((index) => {
44
- setActiveMatchIndex(index);
18
+ const onResultSelectedChanged = (0, react_1.useCallback)((index) => {
19
+ setState((prev) => ({ ...prev, activeMatchIndex: index }));
45
20
  }, []);
46
- const onFilterApplied = react_1.default.useCallback((provider, matches) => {
47
- setFilteredProvider(provider);
48
- setMatchedResultCount(matches);
21
+ const onFilterApplied = (0, react_1.useCallback)((provider, matches) => {
22
+ setState((prev) => ({
23
+ ...prev,
24
+ activeMatchIndex: prev.activeMatchIndex === undefined ? 1 : Math.min(prev.activeMatchIndex, matches),
25
+ matchedResultCount: matches,
26
+ filteredProvider: provider,
27
+ }));
49
28
  }, []);
50
29
  const isFiltering = !!filterString && matchedResultCount === undefined;
51
30
  const searchOptions = {
@@ -54,11 +33,11 @@ const useTreeFilteringState = () => {
54
33
  onFilterStart,
55
34
  onResultSelectedChanged,
56
35
  matchedResultCount,
36
+ activeMatchIndex,
57
37
  };
58
38
  return {
59
39
  searchOptions,
60
40
  filterString,
61
- activeMatchIndex,
62
41
  onFilterApplied,
63
42
  filteredProvider,
64
43
  };