@itwin/tree-widget-react 0.5.0 → 0.6.1

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 (114) hide show
  1. package/lib/cjs/TreeWidget.js +4 -2
  2. package/lib/cjs/TreeWidget.js.map +1 -1
  3. package/lib/cjs/components/TreeWidgetUiItemsProvider.js +6 -6
  4. package/lib/cjs/components/TreeWidgetUiItemsProvider.js.map +1 -1
  5. package/lib/cjs/components/rulesets/ClassificationSystems.json +122 -0
  6. package/lib/cjs/components/rulesets/IModelContent.json +407 -407
  7. package/lib/cjs/components/trees/Common.d.ts +21 -0
  8. package/lib/cjs/components/trees/Common.js +21 -0
  9. package/lib/cjs/components/trees/Common.js.map +1 -0
  10. package/lib/cjs/components/trees/VisibilityTreeBase.scss +53 -0
  11. package/lib/cjs/components/trees/VisibilityTreeEventHandler.d.ts +68 -0
  12. package/lib/cjs/components/trees/VisibilityTreeEventHandler.js +162 -0
  13. package/lib/cjs/components/trees/VisibilityTreeEventHandler.js.map +1 -0
  14. package/lib/cjs/components/trees/VisibilityTreeRenderer.d.ts +43 -0
  15. package/lib/cjs/components/trees/VisibilityTreeRenderer.js +81 -0
  16. package/lib/cjs/components/trees/VisibilityTreeRenderer.js.map +1 -0
  17. package/lib/cjs/components/trees/category-tree/Categories.json +103 -0
  18. package/lib/cjs/components/trees/category-tree/CategoriesTree.d.ts +65 -0
  19. package/lib/cjs/components/trees/category-tree/CategoriesTree.js +121 -0
  20. package/lib/cjs/components/trees/category-tree/CategoriesTree.js.map +1 -0
  21. package/lib/{esm/components/trees → cjs/components/trees/category-tree}/CategoriesTree.scss +5 -0
  22. package/lib/cjs/components/trees/{CategoriesTree.d.ts → category-tree/CategoriesTreeComponent.d.ts} +2 -2
  23. package/lib/cjs/components/trees/{CategoriesTree.js → category-tree/CategoriesTreeComponent.js} +14 -13
  24. package/lib/cjs/components/trees/category-tree/CategoriesTreeComponent.js.map +1 -0
  25. package/lib/cjs/components/trees/category-tree/CategoryVisibilityHandler.d.ts +54 -0
  26. package/lib/cjs/components/trees/category-tree/CategoryVisibilityHandler.js +213 -0
  27. package/lib/cjs/components/trees/category-tree/CategoryVisibilityHandler.js.map +1 -0
  28. package/lib/cjs/components/trees/index.d.ts +10 -3
  29. package/lib/cjs/components/trees/index.js +13 -6
  30. package/lib/cjs/components/trees/index.js.map +1 -1
  31. package/lib/cjs/components/trees/models-tree/Hierarchy.GroupedByClass.json +392 -0
  32. package/lib/cjs/components/trees/models-tree/Hierarchy.json +387 -0
  33. package/lib/cjs/components/trees/models-tree/ModelsTree.d.ts +82 -0
  34. package/lib/cjs/components/trees/models-tree/ModelsTree.js +144 -0
  35. package/lib/cjs/components/trees/models-tree/ModelsTree.js.map +1 -0
  36. package/lib/cjs/components/trees/{ModelsTree.scss → models-tree/ModelsTree.scss} +5 -1
  37. package/lib/{esm/components/trees/ModelsTree.d.ts → cjs/components/trees/models-tree/ModelsTreeComponent.d.ts} +2 -2
  38. package/lib/cjs/components/trees/{ModelsTree.js → models-tree/ModelsTreeComponent.js} +6 -5
  39. package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.js.map +1 -0
  40. package/lib/cjs/components/trees/models-tree/ModelsTreeSearch.json +239 -0
  41. package/lib/cjs/components/trees/models-tree/ModelsVisibilityHandler.d.ts +100 -0
  42. package/lib/cjs/components/trees/models-tree/ModelsVisibilityHandler.js +477 -0
  43. package/lib/cjs/components/trees/models-tree/ModelsVisibilityHandler.js.map +1 -0
  44. package/lib/cjs/components/trees/models-tree/Utils.d.ts +10 -0
  45. package/lib/cjs/components/trees/models-tree/Utils.js +27 -0
  46. package/lib/cjs/components/trees/models-tree/Utils.js.map +1 -0
  47. package/lib/cjs/components/trees/{SpatialTree.d.ts → spatial-tree/SpatialTreeComponent.d.ts} +2 -2
  48. package/lib/cjs/components/trees/{SpatialTree.js → spatial-tree/SpatialTreeComponent.js} +2 -2
  49. package/lib/cjs/components/trees/spatial-tree/SpatialTreeComponent.js.map +1 -0
  50. package/lib/cjs/tree-widget-react.js +3 -3
  51. package/lib/cjs/tree-widget-react.js.map +1 -1
  52. package/lib/cjs/types.d.ts +3 -1
  53. package/lib/cjs/types.js.map +1 -1
  54. package/lib/esm/TreeWidget.js +4 -2
  55. package/lib/esm/TreeWidget.js.map +1 -1
  56. package/lib/esm/components/TreeWidgetUiItemsProvider.js +3 -3
  57. package/lib/esm/components/TreeWidgetUiItemsProvider.js.map +1 -1
  58. package/lib/esm/components/rulesets/ClassificationSystems.json +122 -0
  59. package/lib/esm/components/rulesets/IModelContent.json +407 -407
  60. package/lib/esm/components/trees/Common.d.ts +21 -0
  61. package/lib/esm/components/trees/Common.js +18 -0
  62. package/lib/esm/components/trees/Common.js.map +1 -0
  63. package/lib/esm/components/trees/VisibilityTreeBase.scss +53 -0
  64. package/lib/esm/components/trees/VisibilityTreeEventHandler.d.ts +68 -0
  65. package/lib/esm/components/trees/VisibilityTreeEventHandler.js +158 -0
  66. package/lib/esm/components/trees/VisibilityTreeEventHandler.js.map +1 -0
  67. package/lib/esm/components/trees/VisibilityTreeRenderer.d.ts +43 -0
  68. package/lib/esm/components/trees/VisibilityTreeRenderer.js +54 -0
  69. package/lib/esm/components/trees/VisibilityTreeRenderer.js.map +1 -0
  70. package/lib/esm/components/trees/category-tree/Categories.json +103 -0
  71. package/lib/esm/components/trees/category-tree/CategoriesTree.d.ts +65 -0
  72. package/lib/esm/components/trees/category-tree/CategoriesTree.js +96 -0
  73. package/lib/esm/components/trees/category-tree/CategoriesTree.js.map +1 -0
  74. package/lib/{cjs/components/trees → esm/components/trees/category-tree}/CategoriesTree.scss +5 -0
  75. package/lib/esm/components/trees/{CategoriesTree.d.ts → category-tree/CategoriesTreeComponent.d.ts} +2 -2
  76. package/lib/esm/components/trees/{CategoriesTree.js → category-tree/CategoriesTreeComponent.js} +8 -7
  77. package/lib/esm/components/trees/category-tree/CategoriesTreeComponent.js.map +1 -0
  78. package/lib/esm/components/trees/category-tree/CategoryVisibilityHandler.d.ts +54 -0
  79. package/lib/esm/components/trees/category-tree/CategoryVisibilityHandler.js +188 -0
  80. package/lib/esm/components/trees/category-tree/CategoryVisibilityHandler.js.map +1 -0
  81. package/lib/esm/components/trees/index.d.ts +10 -3
  82. package/lib/esm/components/trees/index.js +13 -6
  83. package/lib/esm/components/trees/index.js.map +1 -1
  84. package/lib/esm/components/trees/models-tree/Hierarchy.GroupedByClass.json +392 -0
  85. package/lib/esm/components/trees/models-tree/Hierarchy.json +387 -0
  86. package/lib/esm/components/trees/models-tree/ModelsTree.d.ts +82 -0
  87. package/lib/esm/components/trees/models-tree/ModelsTree.js +121 -0
  88. package/lib/esm/components/trees/models-tree/ModelsTree.js.map +1 -0
  89. package/lib/esm/components/trees/{ModelsTree.scss → models-tree/ModelsTree.scss} +5 -1
  90. package/lib/{cjs/components/trees/ModelsTree.d.ts → esm/components/trees/models-tree/ModelsTreeComponent.d.ts} +2 -2
  91. package/lib/esm/components/trees/{ModelsTree.js → models-tree/ModelsTreeComponent.js} +6 -5
  92. package/lib/esm/components/trees/models-tree/ModelsTreeComponent.js.map +1 -0
  93. package/lib/esm/components/trees/models-tree/ModelsTreeSearch.json +239 -0
  94. package/lib/esm/components/trees/models-tree/ModelsVisibilityHandler.d.ts +100 -0
  95. package/lib/esm/components/trees/models-tree/ModelsVisibilityHandler.js +472 -0
  96. package/lib/esm/components/trees/models-tree/ModelsVisibilityHandler.js.map +1 -0
  97. package/lib/esm/components/trees/models-tree/Utils.d.ts +10 -0
  98. package/lib/esm/components/trees/models-tree/Utils.js +23 -0
  99. package/lib/esm/components/trees/models-tree/Utils.js.map +1 -0
  100. package/lib/esm/components/trees/{SpatialTree.d.ts → spatial-tree/SpatialTreeComponent.d.ts} +2 -2
  101. package/lib/esm/components/trees/{SpatialTree.js → spatial-tree/SpatialTreeComponent.js} +2 -2
  102. package/lib/esm/components/trees/spatial-tree/SpatialTreeComponent.js.map +1 -0
  103. package/lib/esm/tree-widget-react.js +3 -3
  104. package/lib/esm/tree-widget-react.js.map +1 -1
  105. package/lib/esm/types.d.ts +3 -1
  106. package/lib/esm/types.js.map +1 -1
  107. package/lib/public/locales/en/TreeWidget.json +38 -1
  108. package/package.json +54 -32
  109. package/lib/cjs/components/trees/CategoriesTree.js.map +0 -1
  110. package/lib/cjs/components/trees/ModelsTree.js.map +0 -1
  111. package/lib/cjs/components/trees/SpatialTree.js.map +0 -1
  112. package/lib/esm/components/trees/CategoriesTree.js.map +0 -1
  113. package/lib/esm/components/trees/ModelsTree.js.map +0 -1
  114. package/lib/esm/components/trees/SpatialTree.js.map +0 -1
@@ -0,0 +1,387 @@
1
+ {
2
+ "$schema": "../../../../node_modules/@itwin/presentation-common/Ruleset.schema.json",
3
+ "id": "tree-widget-react/ModelsTree",
4
+ "requiredSchemas": [
5
+ {
6
+ "name": "BisCore"
7
+ }
8
+ ],
9
+ "rules": [
10
+ {
11
+ "ruleType": "RootNodes",
12
+ "autoExpand": true,
13
+ "specifications": [
14
+ {
15
+ "specType": "InstanceNodesOfSpecificClasses",
16
+ "classes": [
17
+ {
18
+ "schemaName": "BisCore",
19
+ "classNames": [
20
+ "Subject"
21
+ ]
22
+ }
23
+ ],
24
+ "instanceFilter": "this.Parent = NULL",
25
+ "arePolymorphic": false,
26
+ "groupByClass": false,
27
+ "groupByLabel": false
28
+ }
29
+ ],
30
+ "customizationRules": [
31
+ {
32
+ "ruleType": "ExtendedData",
33
+ "items": {
34
+ "isSubject": "true"
35
+ }
36
+ }
37
+ ]
38
+ },
39
+ {
40
+ "ruleType": "ChildNodes",
41
+ "condition": "ParentNode.IsOfClass(\"Subject\", \"BisCore\")",
42
+ "specifications": [
43
+ {
44
+ "specType": "RelatedInstanceNodes",
45
+ "relationshipPaths": [
46
+ {
47
+ "relationship": {
48
+ "schemaName": "BisCore",
49
+ "className": "SubjectOwnsSubjects"
50
+ },
51
+ "direction": "Forward",
52
+ "targetClass": {
53
+ "schemaName": "BisCore",
54
+ "className": "Subject"
55
+ }
56
+ }
57
+ ],
58
+ "instanceFilter": "json_extract(this.JsonProperties, \"$.Subject.Job.Bridge\") <> NULL OR ifnull(json_extract(this.JsonProperties, \"$.Subject.Model.Type\"), \"\") = \"Hierarchy\"",
59
+ "hideNodesInHierarchy": true,
60
+ "groupByClass": false,
61
+ "groupByLabel": false
62
+ },
63
+ {
64
+ "specType": "RelatedInstanceNodes",
65
+ "relationshipPaths": [
66
+ {
67
+ "relationship": {
68
+ "schemaName": "BisCore",
69
+ "className": "SubjectOwnsSubjects"
70
+ },
71
+ "direction": "Forward",
72
+ "targetClass": {
73
+ "schemaName": "BisCore",
74
+ "className": "Subject"
75
+ }
76
+ }
77
+ ],
78
+ "instanceFilter": "json_extract(this.JsonProperties, \"$.Subject.Job.Bridge\") = NULL AND ifnull(json_extract(this.JsonProperties, \"$.Subject.Model.Type\"), \"\") <> \"Hierarchy\"",
79
+ "hideIfNoChildren": true,
80
+ "groupByClass": false,
81
+ "groupByLabel": false
82
+ }
83
+ ],
84
+ "customizationRules": [
85
+ {
86
+ "ruleType": "ExtendedData",
87
+ "items": {
88
+ "isSubject": "true"
89
+ }
90
+ }
91
+ ]
92
+ },
93
+ {
94
+ "ruleType": "ChildNodes",
95
+ "condition": "ParentNode.IsOfClass(\"Subject\", \"BisCore\")",
96
+ "specifications": [
97
+ {
98
+ "specType": "InstanceNodesOfSpecificClasses",
99
+ "classes": {
100
+ "schemaName": "BisCore",
101
+ "classNames": [
102
+ "GeometricModel3d"
103
+ ]
104
+ },
105
+ "arePolymorphic": true,
106
+ "relatedInstances": [
107
+ {
108
+ "relationshipPath": {
109
+ "relationship": {
110
+ "schemaName": "BisCore",
111
+ "className": "ModelModelsElement"
112
+ },
113
+ "direction": "Forward",
114
+ "targetClass": {
115
+ "schemaName": "BisCore",
116
+ "className": "InformationPartitionElement"
117
+ }
118
+ },
119
+ "alias": "partition",
120
+ "isRequired": true
121
+ }
122
+ ],
123
+ "instanceFilter": "(parent.ECInstanceId = partition.Parent.Id OR json_extract(parent.JsonProperties, \"$.Subject.Model.TargetPartition\") = printf(\"0x%x\", partition.ECInstanceId)) AND NOT this.IsPrivate AND json_extract(partition.JsonProperties, \"$.PhysicalPartition.Model.Content\") = NULL AND json_extract(partition.JsonProperties, \"$.GraphicalPartition3d.Model.Content\") = NULL AND this.HasRelatedInstance(\"BisCore:ModelContainsElements\", \"Forward\", \"BisCore:GeometricElement3d\")",
124
+ "hasChildren": "Always",
125
+ "hideIfNoChildren": true,
126
+ "groupByClass": false,
127
+ "groupByLabel": false
128
+ },
129
+ {
130
+ "specType": "InstanceNodesOfSpecificClasses",
131
+ "classes": {
132
+ "schemaName": "BisCore",
133
+ "classNames": [
134
+ "GeometricModel3d"
135
+ ]
136
+ },
137
+ "arePolymorphic": true,
138
+ "relatedInstances": [
139
+ {
140
+ "relationshipPath": {
141
+ "relationship": {
142
+ "schemaName": "BisCore",
143
+ "className": "ModelModelsElement"
144
+ },
145
+ "direction": "Forward",
146
+ "targetClass": {
147
+ "schemaName": "BisCore",
148
+ "className": "InformationPartitionElement"
149
+ }
150
+ },
151
+ "alias": "partition",
152
+ "isRequired": true
153
+ }
154
+ ],
155
+ "instanceFilter": "(parent.ECInstanceId = partition.Parent.Id OR json_extract(parent.JsonProperties, \"$.Subject.Model.TargetPartition\") = printf(\"0x%x\", partition.ECInstanceId)) AND NOT this.IsPrivate AND (json_extract(partition.JsonProperties, \"$.PhysicalPartition.Model.Content\") <> NULL OR json_extract(partition.JsonProperties, \"$.GraphicalPartition3d.Model.Content\") <> NULL) AND this.HasRelatedInstance(\"BisCore:ModelContainsElements\", \"Forward\", \"BisCore:GeometricElement3d\")",
156
+ "hasChildren": "Always",
157
+ "hideNodesInHierarchy": true,
158
+ "groupByClass": false,
159
+ "groupByLabel": false
160
+ }
161
+ ],
162
+ "customizationRules": [
163
+ {
164
+ "ruleType": "ExtendedData",
165
+ "items": {
166
+ "isModel": "true"
167
+ }
168
+ }
169
+ ]
170
+ },
171
+ {
172
+ "ruleType": "ChildNodes",
173
+ "condition": "ParentNode.IsOfClass(\"ISubModeledElement\", \"BisCore\")",
174
+ "specifications": [
175
+ {
176
+ "specType": "RelatedInstanceNodes",
177
+ "relationshipPaths": [
178
+ {
179
+ "relationship": {
180
+ "schemaName": "BisCore",
181
+ "className": "ModelModelsElement"
182
+ },
183
+ "direction": "Backward"
184
+ }
185
+ ],
186
+ "instanceFilter": "NOT this.IsPrivate AND this.HasRelatedInstance(\"BisCore:ModelContainsElements\", \"Forward\", \"BisCore:GeometricElement3d\")",
187
+ "hideNodesInHierarchy": true,
188
+ "groupByClass": false,
189
+ "groupByLabel": false
190
+ }
191
+ ],
192
+ "customizationRules": [
193
+ {
194
+ "ruleType": "ExtendedData",
195
+ "items": {
196
+ "isModel": "true"
197
+ }
198
+ }
199
+ ]
200
+ },
201
+ {
202
+ "ruleType": "ChildNodes",
203
+ "condition": "ParentNode.IsOfClass(\"GeometricModel3d\", \"BisCore\")",
204
+ "specifications": [
205
+ {
206
+ "specType": "RelatedInstanceNodes",
207
+ "relationshipPaths": [
208
+ [
209
+ {
210
+ "relationship": {
211
+ "schemaName": "BisCore",
212
+ "className": "ModelContainsElements"
213
+ },
214
+ "direction": "Forward",
215
+ "targetClass": {
216
+ "schemaName": "BisCore",
217
+ "className": "GeometricElement3d"
218
+ }
219
+ },
220
+ {
221
+ "relationship": {
222
+ "schemaName": "BisCore",
223
+ "className": "GeometricElement3dIsInCategory"
224
+ },
225
+ "direction": "Forward",
226
+ "targetClass": {
227
+ "schemaName": "BisCore",
228
+ "className": "SpatialCategory"
229
+ }
230
+ }
231
+ ]
232
+ ],
233
+ "instanceFilter": "NOT this.IsPrivate",
234
+ "suppressSimilarAncestorsCheck": true,
235
+ "hideIfNoChildren": true,
236
+ "groupByClass": false,
237
+ "groupByLabel": false
238
+ }
239
+ ],
240
+ "customizationRules": [
241
+ {
242
+ "ruleType": "ExtendedData",
243
+ "items": {
244
+ "isCategory": "true",
245
+ "modelId": "ParentNode.InstanceId"
246
+ }
247
+ }
248
+ ]
249
+ },
250
+ {
251
+ "ruleType": "ChildNodes",
252
+ "condition": "ParentNode.IsOfClass(\"SpatialCategory\", \"BisCore\")",
253
+ "specifications": [
254
+ {
255
+ "specType": "RelatedInstanceNodes",
256
+ "relationshipPaths": [
257
+ {
258
+ "relationship": {
259
+ "schemaName": "BisCore",
260
+ "className": "GeometricElement3dIsInCategory"
261
+ },
262
+ "direction": "Backward",
263
+ "targetClass": {
264
+ "schemaName": "BisCore",
265
+ "className": "GeometricElement3d"
266
+ }
267
+ }
268
+ ],
269
+ "instanceFilter": "this.Model.Id = parent.parent.ECInstanceId ANDALSO this.Parent = NULL ANDALSO (NOT HasVariable(\"filtered-element-ids\") OR GetVariableIntValues(\"filtered-element-ids\").AnyMatch(id => id = this.ECInstanceId))",
270
+ "groupByClass": false,
271
+ "groupByLabel": false
272
+ }
273
+ ],
274
+ "customizationRules": [
275
+ {
276
+ "ruleType": "ExtendedData",
277
+ "items": {
278
+ "modelId": "this.Model.Id",
279
+ "categoryId": "this.Category.Id"
280
+ }
281
+ }
282
+ ]
283
+ },
284
+ {
285
+ "ruleType": "ChildNodes",
286
+ "condition": "ParentNode.IsOfClass(\"GeometricElement3d\", \"BisCore\")",
287
+ "specifications": [
288
+ {
289
+ "specType": "RelatedInstanceNodes",
290
+ "relationshipPaths": [
291
+ {
292
+ "relationship": {
293
+ "schemaName": "BisCore",
294
+ "className": "ElementOwnsChildElements"
295
+ },
296
+ "direction": "Forward",
297
+ "targetClass": {
298
+ "schemaName": "BisCore",
299
+ "className": "GeometricElement3d"
300
+ }
301
+ }
302
+ ],
303
+ "instanceFilter": "NOT HasVariable(\"filtered-element-ids\") OR GetVariableIntValues(\"filtered-element-ids\").AnyMatch(id => id = this.ECInstanceId)",
304
+ "groupByClass": false,
305
+ "groupByLabel": false
306
+ }
307
+ ],
308
+ "customizationRules": [
309
+ {
310
+ "ruleType": "ExtendedData",
311
+ "items": {
312
+ "modelId": "this.Model.Id",
313
+ "categoryId": "this.Category.Id"
314
+ }
315
+ }
316
+ ]
317
+ },
318
+ {
319
+ "ruleType": "Grouping",
320
+ "class": {
321
+ "schemaName": "BisCore",
322
+ "className": "Subject"
323
+ },
324
+ "groups": [
325
+ {
326
+ "specType": "SameLabelInstance",
327
+ "applicationStage": "PostProcess"
328
+ }
329
+ ]
330
+ },
331
+ {
332
+ "ruleType": "Grouping",
333
+ "class": {
334
+ "schemaName": "BisCore",
335
+ "className": "SpatialCategory"
336
+ },
337
+ "groups": [
338
+ {
339
+ "specType": "SameLabelInstance",
340
+ "applicationStage": "PostProcess"
341
+ }
342
+ ]
343
+ },
344
+ {
345
+ "ruleType": "ImageIdOverride",
346
+ "condition": "ThisNode.IsInstanceNode ANDALSO ThisNode.IsOfClass(\"Subject\", \"BisCore\")",
347
+ "imageIdExpression": "IIF(this.Parent.Id = NULL, \"icon-imodel-hollow-2\", \"icon-folder\")"
348
+ },
349
+ {
350
+ "ruleType": "ImageIdOverride",
351
+ "condition": "ThisNode.IsInstanceNode ANDALSO ThisNode.IsOfClass(\"Model\", \"BisCore\")",
352
+ "imageIdExpression": "\"icon-model\""
353
+ },
354
+ {
355
+ "ruleType": "ImageIdOverride",
356
+ "condition": "ThisNode.IsInstanceNode ANDALSO ThisNode.IsOfClass(\"Category\", \"BisCore\")",
357
+ "imageIdExpression": "\"icon-layers\""
358
+ },
359
+ {
360
+ "ruleType": "ImageIdOverride",
361
+ "condition": "ThisNode.IsInstanceNode ANDALSO ThisNode.IsOfClass(\"Element\", \"BisCore\")",
362
+ "imageIdExpression": "\"icon-item\""
363
+ },
364
+ {
365
+ "ruleType": "Content",
366
+ "condition": "ContentDisplayType = \"AssemblyElementsRequest\"",
367
+ "specifications": [
368
+ {
369
+ "specType": "SelectedNodeInstances"
370
+ },
371
+ {
372
+ "specType": "ContentRelatedInstances",
373
+ "relationshipPaths": [
374
+ {
375
+ "relationship": {
376
+ "schemaName": "BisCore",
377
+ "className": "ElementOwnsChildElements"
378
+ },
379
+ "direction": "Forward",
380
+ "count": "*"
381
+ }
382
+ ]
383
+ }
384
+ ]
385
+ }
386
+ ]
387
+ }
@@ -0,0 +1,82 @@
1
+ import "./ModelsTree.scss";
2
+ import * as React from "react";
3
+ import { SelectionMode } from "@itwin/components-react";
4
+ import { ClassGroupingOption } from "../Common";
5
+ import { ModelsVisibilityHandler } from "./ModelsVisibilityHandler";
6
+ import type { VisibilityTreeFilterInfo } from "../Common";
7
+ import type { ModelsTreeSelectionPredicate } from "./ModelsVisibilityHandler";
8
+ import type { Id64Array } from "@itwin/core-bentley";
9
+ import type { IModelConnection, Viewport } from "@itwin/core-frontend";
10
+ import type { Ruleset } from "@itwin/presentation-common";
11
+ import type { IPresentationTreeDataProvider } from "@itwin/presentation-components";
12
+ /** @internal */
13
+ export declare const RULESET_MODELS: Ruleset;
14
+ /** @internal */
15
+ export declare const RULESET_MODELS_GROUPED_BY_CLASS: Ruleset;
16
+ /** Props for [[ModelsTree]] component
17
+ * @public
18
+ */
19
+ export interface ModelsTreeProps {
20
+ /**
21
+ * An IModel to pull data from
22
+ */
23
+ iModel: IModelConnection;
24
+ /** Width of the component */
25
+ width: number;
26
+ /** Height of the component */
27
+ height: number;
28
+ /**
29
+ * Selection mode in the tree
30
+ */
31
+ selectionMode?: SelectionMode;
32
+ /**
33
+ * Predicate which indicates whether node can be selected or no
34
+ * @alpha
35
+ */
36
+ selectionPredicate?: ModelsTreeSelectionPredicate;
37
+ /**
38
+ * Active view used to determine and control visibility
39
+ */
40
+ activeView?: Viewport;
41
+ /**
42
+ * Ref to the root HTML element used by this component
43
+ */
44
+ rootElementRef?: React.Ref<HTMLDivElement>;
45
+ /**
46
+ * Information for tree filtering.
47
+ * @alpha
48
+ */
49
+ filterInfo?: VisibilityTreeFilterInfo;
50
+ /**
51
+ * Filter the hierarchy by given element IDs.
52
+ * @alpha
53
+ */
54
+ filteredElementIds?: Id64Array;
55
+ /**
56
+ * Callback invoked when tree is filtered.
57
+ */
58
+ onFilterApplied?: (filteredDataProvider: IPresentationTreeDataProvider, matchesCount: number) => void;
59
+ /**
60
+ * Should the tree group displayed element nodes by class.
61
+ * @beta
62
+ */
63
+ enableElementsClassGrouping?: ClassGroupingOption;
64
+ /**
65
+ * Auto-update the hierarchy when data in the iModel changes.
66
+ * @alpha
67
+ */
68
+ enableHierarchyAutoUpdate?: boolean;
69
+ /**
70
+ * Custom visibility handler.
71
+ * @alpha
72
+ */
73
+ modelsVisibilityHandler?: ModelsVisibilityHandler;
74
+ }
75
+ /**
76
+ * A tree component that shows a subject - model - category - element
77
+ * hierarchy along with checkboxes that represent and allow changing
78
+ * the display of those instances.
79
+ * @public
80
+ */
81
+ export declare function ModelsTree(props: ModelsTreeProps): JSX.Element;
82
+ //# sourceMappingURL=ModelsTree.d.ts.map
@@ -0,0 +1,144 @@
1
+ "use strict";
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
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.ModelsTree = exports.RULESET_MODELS_GROUPED_BY_CLASS = exports.RULESET_MODELS = void 0;
27
+ require("./ModelsTree.scss");
28
+ const React = __importStar(require("react"));
29
+ const components_react_1 = require("@itwin/components-react");
30
+ const core_react_1 = require("@itwin/core-react");
31
+ const presentation_components_1 = require("@itwin/presentation-components");
32
+ const presentation_frontend_1 = require("@itwin/presentation-frontend");
33
+ const TreeWidget_1 = require("../../../TreeWidget");
34
+ const Common_1 = require("../Common");
35
+ const VisibilityTreeEventHandler_1 = require("../VisibilityTreeEventHandler");
36
+ const VisibilityTreeRenderer_1 = require("../VisibilityTreeRenderer");
37
+ const ModelsVisibilityHandler_1 = require("./ModelsVisibilityHandler");
38
+ const PAGING_SIZE = 20;
39
+ /** @internal */
40
+ exports.RULESET_MODELS = require("./Hierarchy.json"); // eslint-disable-line @typescript-eslint/no-var-requires
41
+ /** @internal */
42
+ exports.RULESET_MODELS_GROUPED_BY_CLASS = require("./Hierarchy.GroupedByClass.json"); // eslint-disable-line @typescript-eslint/no-var-requires
43
+ const RULESET_MODELS_SEARCH = require("./ModelsTreeSearch.json"); // eslint-disable-line @typescript-eslint/no-var-requires
44
+ /**
45
+ * A tree component that shows a subject - model - category - element
46
+ * hierarchy along with checkboxes that represent and allow changing
47
+ * the display of those instances.
48
+ * @public
49
+ */
50
+ function ModelsTree(props) {
51
+ const { nodeLoader, onItemsRendered } = useModelsTreeNodeLoader(props);
52
+ const { filteredNodeLoader, isFiltering, nodeHighlightingProps } = VisibilityTreeRenderer_1.useVisibilityTreeFiltering(nodeLoader, props.filterInfo, props.onFilterApplied);
53
+ const filterApplied = filteredNodeLoader !== nodeLoader;
54
+ const { activeView, modelsVisibilityHandler, selectionPredicate } = props;
55
+ const nodeSelectionPredicate = React.useCallback((key, node) => {
56
+ return !selectionPredicate ? true : selectionPredicate(key, ModelsVisibilityHandler_1.ModelsVisibilityHandler.getNodeType(node, nodeLoader.dataProvider));
57
+ }, [selectionPredicate, nodeLoader.dataProvider]);
58
+ const visibilityHandler = useVisibilityHandler(nodeLoader.dataProvider.rulesetId, props.iModel, activeView, modelsVisibilityHandler, getFilteredDataProvider(filteredNodeLoader.dataProvider), props.enableHierarchyAutoUpdate);
59
+ const eventHandler = core_react_1.useDisposable(React.useCallback(() => new VisibilityTreeEventHandler_1.VisibilityTreeEventHandler({
60
+ nodeLoader: filteredNodeLoader,
61
+ visibilityHandler,
62
+ collapsedChildrenDisposalEnabled: true,
63
+ selectionPredicate: nodeSelectionPredicate,
64
+ }), [filteredNodeLoader, visibilityHandler, nodeSelectionPredicate]));
65
+ const treeModel = components_react_1.useTreeModel(filteredNodeLoader.modelSource);
66
+ const treeRenderer = VisibilityTreeRenderer_1.useVisibilityTreeRenderer(true, false);
67
+ const overlay = isFiltering ? React.createElement("div", { className: "filteredTreeOverlay" }) : undefined;
68
+ // istanbul ignore next
69
+ const noFilteredDataRenderer = React.useCallback(() => {
70
+ return React.createElement(VisibilityTreeRenderer_1.VisibilityTreeNoFilteredData, { title: TreeWidget_1.TreeWidget.translate("modelTree.noModelFound"), message: TreeWidget_1.TreeWidget.translate("modelTree.noMatchingModelNames") });
71
+ }, []);
72
+ return (React.createElement("div", { className: "tree-widget-models-tree", ref: props.rootElementRef },
73
+ React.createElement(components_react_1.ControlledTree, { nodeLoader: filteredNodeLoader, model: treeModel, selectionMode: props.selectionMode || components_react_1.SelectionMode.None, eventsHandler: eventHandler, treeRenderer: treeRenderer, nodeHighlightingProps: nodeHighlightingProps, noDataRenderer: filterApplied ? noFilteredDataRenderer : undefined, onItemsRendered: onItemsRendered, width: props.width, height: props.height }),
74
+ overlay));
75
+ }
76
+ exports.ModelsTree = ModelsTree;
77
+ function useModelsTreeNodeLoader(props) {
78
+ var _a, _b;
79
+ // note: this is a temporary workaround for auto-update not working on ruleset variable changes - instead
80
+ // of auto-updating we just re-create the node loader by re-creating the ruleset
81
+ const rulesets = React.useMemo(() => {
82
+ return {
83
+ general: (!props.enableElementsClassGrouping) ? { ...exports.RULESET_MODELS } : /* istanbul ignore next */ { ...exports.RULESET_MODELS_GROUPED_BY_CLASS },
84
+ search: { ...RULESET_MODELS_SEARCH },
85
+ };
86
+ }, [props.filteredElementIds]); // eslint-disable-line react-hooks/exhaustive-deps
87
+ // const rulesets = {
88
+ // general: (!props.enableElementsClassGrouping) ? RULESET_MODELS : /* istanbul ignore next */ RULESET_MODELS_GROUPED_BY_CLASS,
89
+ // search: RULESET_MODELS_SEARCH,
90
+ // };
91
+ const { nodeLoader, onItemsRendered } = presentation_components_1.usePresentationTreeNodeLoader({
92
+ imodel: props.iModel,
93
+ ruleset: rulesets.general,
94
+ appendChildrenCountForGroupingNodes: (props.enableElementsClassGrouping === Common_1.ClassGroupingOption.YesWithCounts),
95
+ pagingSize: PAGING_SIZE,
96
+ enableHierarchyAutoUpdate: props.enableHierarchyAutoUpdate,
97
+ });
98
+ const { nodeLoader: searchNodeLoader, onItemsRendered: onSearchItemsRendered } = presentation_components_1.usePresentationTreeNodeLoader({
99
+ imodel: props.iModel,
100
+ ruleset: rulesets.search,
101
+ pagingSize: PAGING_SIZE,
102
+ enableHierarchyAutoUpdate: props.enableHierarchyAutoUpdate,
103
+ });
104
+ const activeNodeLoader = ((_a = props.filterInfo) === null || _a === void 0 ? void 0 : _a.filter) ? searchNodeLoader : nodeLoader;
105
+ const activeItemsRenderedCallback = ((_b = props.filterInfo) === null || _b === void 0 ? void 0 : _b.filter) ? onSearchItemsRendered : onItemsRendered;
106
+ const vars = presentation_frontend_1.Presentation.presentation.vars(activeNodeLoader.dataProvider.rulesetId);
107
+ if (props.filteredElementIds) {
108
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
109
+ vars.setId64s("filtered-element-ids", props.filteredElementIds);
110
+ }
111
+ else {
112
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
113
+ vars.unset("filtered-element-ids");
114
+ }
115
+ return {
116
+ nodeLoader: activeNodeLoader,
117
+ onItemsRendered: activeItemsRenderedCallback,
118
+ };
119
+ }
120
+ function useVisibilityHandler(rulesetId, iModel, activeView, visibilityHandler, filteredDataProvider, hierarchyAutoUpdateEnabled) {
121
+ const subjectModelIdsCache = React.useMemo(() => new ModelsVisibilityHandler_1.SubjectModelIdsCache(iModel), [iModel]);
122
+ const defaultVisibilityHandler = core_react_1.useOptionalDisposable(React.useCallback(() => {
123
+ if (activeView)
124
+ return createVisibilityHandler(rulesetId, activeView, subjectModelIdsCache, hierarchyAutoUpdateEnabled);
125
+ return undefined;
126
+ }, [rulesetId, activeView, subjectModelIdsCache, hierarchyAutoUpdateEnabled]));
127
+ const handler = visibilityHandler !== null && visibilityHandler !== void 0 ? visibilityHandler : defaultVisibilityHandler;
128
+ React.useEffect(() => {
129
+ handler && handler.setFilteredDataProvider(filteredDataProvider);
130
+ }, [handler, filteredDataProvider]);
131
+ return handler;
132
+ }
133
+ const createVisibilityHandler = (rulesetId, activeView, subjectModelIdsCache, hierarchyAutoUpdateEnabled) => {
134
+ // istanbul ignore next
135
+ return new ModelsVisibilityHandler_1.ModelsVisibilityHandler({ rulesetId, viewport: activeView, hierarchyAutoUpdateEnabled, subjectModelIdsCache });
136
+ };
137
+ const isFilteredDataProvider = (dataProvider) => {
138
+ const filteredProvider = dataProvider;
139
+ return filteredProvider.nodeMatchesFilter !== undefined && filteredProvider.getActiveMatch !== undefined && filteredProvider.countFilteringResults !== undefined;
140
+ };
141
+ const getFilteredDataProvider = (dataProvider) => {
142
+ return isFilteredDataProvider(dataProvider) ? dataProvider : undefined;
143
+ };
144
+ //# sourceMappingURL=ModelsTree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModelsTree.js","sourceRoot":"","sources":["../../../../../src/components/trees/models-tree/ModelsTree.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;;;;;;;;;;;;;;;;;;;;;;AAE/F,6BAA2B;AAC3B,6CAA+B;AAC/B,8DAAsF;AACtF,kDAAyE;AACzE,4EAA+E;AAC/E,wEAA4D;AAC5D,oDAAiD;AACjD,sCAAgD;AAChD,8EAA2E;AAC3E,sEAAgI;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AS,CAAC,GAAG,EAAE;QACnB,OAAO,IAAI,OAAO,CAAC,uBAAuB,CAAC,oBAAoB,CAAC,CAAC;IACnE,CAAC,EAAE,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAAC,CAAC;IAEpC,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,uBAAuB,GAAG,CAAC,SAAiB,EAAE,UAAoB,EAAE,oBAA0C,EAAE,0BAAoC,EAAuC,EAAE;IACjM,uBAAuB;IACvB,OAAO,IAAI,iDAAuB,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,CAAC,CAAC;AAC5H,CAAC,CAAC;AAEF,MAAM,sBAAsB,GAAG,CAAC,YAAmF,EAAyD,EAAE;IAC5K,MAAM,gBAAgB,GAAG,YAAqD,CAAC;IAC/E,OAAO,gBAAgB,CAAC,iBAAiB,KAAK,SAAS,IAAI,gBAAgB,CAAC,cAAc,KAAK,SAAS,IAAI,gBAAgB,CAAC,qBAAqB,KAAK,SAAS,CAAC;AACnK,CAAC,CAAC;AAEF,MAAM,uBAAuB,GAAG,CAAC,YAAmF,EAAqD,EAAE;IACzK,OAAO,sBAAsB,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC;AACzE,CAAC,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 \"./ModelsTree.scss\";\nimport * as React from \"react\";\nimport { ControlledTree, SelectionMode, useTreeModel } from \"@itwin/components-react\";\nimport { useDisposable, useOptionalDisposable } from \"@itwin/core-react\";\nimport { usePresentationTreeNodeLoader } from \"@itwin/presentation-components\";\nimport { Presentation } from \"@itwin/presentation-frontend\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { ClassGroupingOption } from \"../Common\";\nimport { VisibilityTreeEventHandler } from \"../VisibilityTreeEventHandler\";\nimport { useVisibilityTreeFiltering, useVisibilityTreeRenderer, VisibilityTreeNoFilteredData } from \"../VisibilityTreeRenderer\";\nimport { ModelsVisibilityHandler, SubjectModelIdsCache } from \"./ModelsVisibilityHandler\";\nimport type { VisibilityTreeFilterInfo } from \"../Common\";\nimport type { ModelsTreeSelectionPredicate } from \"./ModelsVisibilityHandler\";\nimport type { TreeNodeItem } from \"@itwin/components-react\";\nimport type { Id64Array } from \"@itwin/core-bentley\";\nimport type { IModelConnection, Viewport } from \"@itwin/core-frontend\";\nimport type { NodeKey, Ruleset } from \"@itwin/presentation-common\";\nimport type { IFilteredPresentationTreeDataProvider, IPresentationTreeDataProvider } from \"@itwin/presentation-components\";\n\nconst PAGING_SIZE = 20;\n\n/** @internal */\nexport const RULESET_MODELS: Ruleset = require(\"./Hierarchy.json\"); // eslint-disable-line @typescript-eslint/no-var-requires\n/** @internal */\nexport const RULESET_MODELS_GROUPED_BY_CLASS: Ruleset = require(\"./Hierarchy.GroupedByClass.json\"); // eslint-disable-line @typescript-eslint/no-var-requires\n\nconst RULESET_MODELS_SEARCH: Ruleset = require(\"./ModelsTreeSearch.json\"); // eslint-disable-line @typescript-eslint/no-var-requires\n\n/** Props for [[ModelsTree]] component\n * @public\n */\nexport interface ModelsTreeProps {\n /**\n * An IModel to pull data from\n */\n iModel: IModelConnection;\n /** Width of the component */\n width: number;\n /** Height of the component */\n height: number;\n /**\n * Selection mode in the tree\n */\n selectionMode?: SelectionMode;\n /**\n * Predicate which indicates whether node can be selected or no\n * @alpha\n */\n selectionPredicate?: ModelsTreeSelectionPredicate;\n /**\n * Active view used to determine and control visibility\n */\n activeView?: Viewport;\n /**\n * Ref to the root HTML element used by this component\n */\n rootElementRef?: React.Ref<HTMLDivElement>;\n /**\n * Information for tree filtering.\n * @alpha\n */\n filterInfo?: VisibilityTreeFilterInfo;\n /**\n * Filter the hierarchy by given element IDs.\n * @alpha\n */\n filteredElementIds?: Id64Array;\n /**\n * Callback invoked when tree is filtered.\n */\n onFilterApplied?: (filteredDataProvider: IPresentationTreeDataProvider, matchesCount: number) => void;\n /**\n * Should the tree group displayed element nodes by class.\n * @beta\n */\n enableElementsClassGrouping?: ClassGroupingOption;\n /**\n * Auto-update the hierarchy when data in the iModel changes.\n * @alpha\n */\n enableHierarchyAutoUpdate?: boolean;\n /**\n * Custom visibility handler.\n * @alpha\n */\n modelsVisibilityHandler?: ModelsVisibilityHandler;\n}\n\n/**\n * A tree component that shows a subject - model - category - element\n * hierarchy along with checkboxes that represent and allow changing\n * the display of those instances.\n * @public\n */\nexport function ModelsTree(props: ModelsTreeProps) {\n const { nodeLoader, onItemsRendered } = useModelsTreeNodeLoader(props);\n const { filteredNodeLoader, isFiltering, nodeHighlightingProps } = useVisibilityTreeFiltering(nodeLoader, props.filterInfo, props.onFilterApplied);\n const filterApplied = filteredNodeLoader !== nodeLoader;\n\n const { activeView, modelsVisibilityHandler, selectionPredicate } = props;\n const nodeSelectionPredicate = React.useCallback((key: NodeKey, node: TreeNodeItem) => {\n return !selectionPredicate ? true : selectionPredicate(key, ModelsVisibilityHandler.getNodeType(node, nodeLoader.dataProvider));\n }, [selectionPredicate, nodeLoader.dataProvider]);\n\n const visibilityHandler = useVisibilityHandler(\n nodeLoader.dataProvider.rulesetId,\n props.iModel,\n activeView,\n modelsVisibilityHandler,\n getFilteredDataProvider(filteredNodeLoader.dataProvider),\n props.enableHierarchyAutoUpdate);\n const eventHandler = useDisposable(React.useCallback(() => new VisibilityTreeEventHandler({\n nodeLoader: filteredNodeLoader,\n visibilityHandler,\n collapsedChildrenDisposalEnabled: true,\n selectionPredicate: nodeSelectionPredicate,\n }), [filteredNodeLoader, visibilityHandler, nodeSelectionPredicate]));\n\n const treeModel = useTreeModel(filteredNodeLoader.modelSource);\n const treeRenderer = useVisibilityTreeRenderer(true, false);\n\n const overlay = isFiltering ? <div className=\"filteredTreeOverlay\" /> : undefined;\n\n // istanbul ignore next\n const noFilteredDataRenderer = React.useCallback(() => {\n return <VisibilityTreeNoFilteredData\n title={TreeWidget.translate(\"modelTree.noModelFound\")}\n message={TreeWidget.translate(\"modelTree.noMatchingModelNames\")}\n />;\n }, []);\n\n return (\n <div className=\"tree-widget-models-tree\" ref={props.rootElementRef}>\n <ControlledTree\n nodeLoader={filteredNodeLoader}\n model={treeModel}\n selectionMode={props.selectionMode || SelectionMode.None}\n eventsHandler={eventHandler}\n treeRenderer={treeRenderer}\n nodeHighlightingProps={nodeHighlightingProps}\n noDataRenderer={filterApplied ? noFilteredDataRenderer : undefined}\n onItemsRendered={onItemsRendered}\n width={props.width}\n height={props.height}\n />\n {overlay}\n </div>\n );\n}\n\nfunction useModelsTreeNodeLoader(props: ModelsTreeProps) {\n // note: this is a temporary workaround for auto-update not working on ruleset variable changes - instead\n // of auto-updating we just re-create the node loader by re-creating the ruleset\n const rulesets = React.useMemo(() => {\n return {\n general: (!props.enableElementsClassGrouping) ? { ...RULESET_MODELS } : /* istanbul ignore next */ { ...RULESET_MODELS_GROUPED_BY_CLASS },\n search: { ...RULESET_MODELS_SEARCH },\n };\n }, [props.filteredElementIds]); // eslint-disable-line react-hooks/exhaustive-deps\n // const rulesets = {\n // general: (!props.enableElementsClassGrouping) ? RULESET_MODELS : /* istanbul ignore next */ RULESET_MODELS_GROUPED_BY_CLASS,\n // search: RULESET_MODELS_SEARCH,\n // };\n\n const { nodeLoader, onItemsRendered } = usePresentationTreeNodeLoader({\n imodel: props.iModel,\n ruleset: rulesets.general,\n appendChildrenCountForGroupingNodes: (props.enableElementsClassGrouping === ClassGroupingOption.YesWithCounts),\n pagingSize: PAGING_SIZE,\n enableHierarchyAutoUpdate: props.enableHierarchyAutoUpdate,\n });\n const { nodeLoader: searchNodeLoader, onItemsRendered: onSearchItemsRendered } = usePresentationTreeNodeLoader({\n imodel: props.iModel,\n ruleset: rulesets.search,\n pagingSize: PAGING_SIZE,\n enableHierarchyAutoUpdate: props.enableHierarchyAutoUpdate,\n });\n\n const activeNodeLoader = props.filterInfo?.filter ? searchNodeLoader : nodeLoader;\n const activeItemsRenderedCallback = props.filterInfo?.filter ? onSearchItemsRendered : onItemsRendered;\n\n const vars = Presentation.presentation.vars(activeNodeLoader.dataProvider.rulesetId);\n if (props.filteredElementIds) {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n vars.setId64s(\"filtered-element-ids\", props.filteredElementIds);\n } else {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n vars.unset(\"filtered-element-ids\");\n }\n\n return {\n nodeLoader: activeNodeLoader,\n onItemsRendered: activeItemsRenderedCallback,\n };\n}\n\nfunction useVisibilityHandler(\n rulesetId: string,\n iModel: IModelConnection,\n activeView?: Viewport,\n visibilityHandler?: ModelsVisibilityHandler,\n filteredDataProvider?: IFilteredPresentationTreeDataProvider,\n hierarchyAutoUpdateEnabled?: boolean,\n) {\n const subjectModelIdsCache = React.useMemo(() => new SubjectModelIdsCache(iModel), [iModel]);\n const defaultVisibilityHandler = useOptionalDisposable(React.useCallback(() => {\n if (activeView)\n return createVisibilityHandler(rulesetId, activeView, subjectModelIdsCache, hierarchyAutoUpdateEnabled);\n return undefined;\n }, [rulesetId, activeView, subjectModelIdsCache, hierarchyAutoUpdateEnabled]));\n\n const handler = visibilityHandler ?? defaultVisibilityHandler;\n\n React.useEffect(() => {\n handler && handler.setFilteredDataProvider(filteredDataProvider);\n }, [handler, filteredDataProvider]);\n\n return handler;\n}\n\nconst createVisibilityHandler = (rulesetId: string, activeView: Viewport, subjectModelIdsCache: SubjectModelIdsCache, hierarchyAutoUpdateEnabled?: boolean): ModelsVisibilityHandler | undefined => {\n // istanbul ignore next\n return new ModelsVisibilityHandler({ rulesetId, viewport: activeView, hierarchyAutoUpdateEnabled, subjectModelIdsCache });\n};\n\nconst isFilteredDataProvider = (dataProvider: IPresentationTreeDataProvider | IFilteredPresentationTreeDataProvider): dataProvider is IFilteredPresentationTreeDataProvider => {\n const filteredProvider = dataProvider as IFilteredPresentationTreeDataProvider;\n return filteredProvider.nodeMatchesFilter !== undefined && filteredProvider.getActiveMatch !== undefined && filteredProvider.countFilteringResults !== undefined;\n};\n\nconst getFilteredDataProvider = (dataProvider: IPresentationTreeDataProvider | IFilteredPresentationTreeDataProvider): IFilteredPresentationTreeDataProvider | undefined => {\n return isFilteredDataProvider(dataProvider) ? dataProvider : undefined;\n};\n"]}
@@ -2,8 +2,12 @@
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
-
6
5
  @import "~@itwin/core-react/lib/cjs/core-react/index";
6
+ @import "../VisibilityTreeBase";
7
+
8
+ .tree-widget-models-tree {
9
+ @include tree-widget-visibility-tree-base;
10
+ }
7
11
 
8
12
  .tree-widget-models-tree-container {
9
13
  flex: 1;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
2
  import "./ModelsTree.scss";
3
- import type { ModelTreeProps } from "../../types";
3
+ import type { ModelTreeProps } from "../../../types";
4
4
  export declare const ModelsTreeComponent: (props: ModelTreeProps) => JSX.Element;
5
- //# sourceMappingURL=ModelsTree.d.ts.map
5
+ //# sourceMappingURL=ModelsTreeComponent.d.ts.map