@itwin/tree-widget-react 1.0.0 → 1.1.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 (96) hide show
  1. package/CHANGELOG.md +42 -181
  2. package/lib/cjs/TreeWidget.d.ts +1 -0
  3. package/lib/cjs/TreeWidget.js +10 -3
  4. package/lib/cjs/TreeWidget.js.map +1 -1
  5. package/lib/cjs/components/SelectableTree.scss +0 -1
  6. package/lib/cjs/components/trees/VisibilityTreeBase.scss +55 -84
  7. package/lib/cjs/components/trees/VisibilityTreeRenderer.d.ts +4 -3
  8. package/lib/cjs/components/trees/VisibilityTreeRenderer.js +5 -4
  9. package/lib/cjs/components/trees/VisibilityTreeRenderer.js.map +1 -1
  10. package/lib/cjs/components/trees/category-tree/CategoriesTree.d.ts +1 -1
  11. package/lib/cjs/components/trees/category-tree/CategoriesTree.js +13 -1
  12. package/lib/cjs/components/trees/category-tree/CategoriesTree.js.map +1 -1
  13. package/lib/cjs/components/trees/category-tree/CategoryVisibilityHandler.d.ts +2 -2
  14. package/lib/cjs/components/trees/common/ContextMenu.d.ts +39 -0
  15. package/lib/cjs/components/trees/common/ContextMenu.js +44 -0
  16. package/lib/cjs/components/trees/common/ContextMenu.js.map +1 -0
  17. package/lib/cjs/components/trees/common/TreeNodeRenderer.d.ts +61 -0
  18. package/lib/cjs/components/trees/common/TreeNodeRenderer.js +50 -0
  19. package/lib/cjs/components/trees/common/TreeNodeRenderer.js.map +1 -0
  20. package/lib/cjs/components/trees/common/TreeRenderer.d.ts +26 -0
  21. package/lib/cjs/components/trees/common/TreeRenderer.js +41 -0
  22. package/lib/cjs/components/trees/common/TreeRenderer.js.map +1 -0
  23. package/lib/cjs/components/trees/common/TreeRenderer.scss +102 -0
  24. package/lib/cjs/components/trees/{Common.d.ts → common/Types.d.ts} +3 -2
  25. package/lib/cjs/components/trees/{Common.js → common/Types.js} +1 -1
  26. package/lib/cjs/components/trees/common/Types.js.map +1 -0
  27. package/lib/cjs/components/trees/common/Utils.d.ts +11 -0
  28. package/lib/cjs/components/trees/common/Utils.js +49 -0
  29. package/lib/cjs/components/trees/common/Utils.js.map +1 -0
  30. package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.d.ts +1 -1
  31. package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.js +9 -4
  32. package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
  33. package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTreeComponent.d.ts +7 -1
  34. package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js +1 -4
  35. package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js.map +1 -1
  36. package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.d.ts +1 -1
  37. package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.js +8 -2
  38. package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
  39. package/lib/cjs/components/trees/index.d.ts +4 -2
  40. package/lib/cjs/components/trees/index.js +4 -2
  41. package/lib/cjs/components/trees/index.js.map +1 -1
  42. package/lib/cjs/components/trees/models-tree/ModelsTree.d.ts +6 -4
  43. package/lib/cjs/components/trees/models-tree/ModelsTree.js +25 -10
  44. package/lib/cjs/components/trees/models-tree/ModelsTree.js.map +1 -1
  45. package/lib/cjs/components/trees/models-tree/Utils.d.ts +2 -2
  46. package/lib/cjs/components/trees/models-tree/Utils.js +269 -335
  47. package/lib/cjs/components/trees/models-tree/Utils.js.map +1 -1
  48. package/lib/esm/TreeWidget.d.ts +1 -0
  49. package/lib/esm/TreeWidget.js +10 -3
  50. package/lib/esm/TreeWidget.js.map +1 -1
  51. package/lib/esm/components/SelectableTree.scss +0 -1
  52. package/lib/esm/components/trees/VisibilityTreeBase.scss +55 -84
  53. package/lib/esm/components/trees/VisibilityTreeRenderer.d.ts +4 -3
  54. package/lib/esm/components/trees/VisibilityTreeRenderer.js +6 -5
  55. package/lib/esm/components/trees/VisibilityTreeRenderer.js.map +1 -1
  56. package/lib/esm/components/trees/category-tree/CategoriesTree.d.ts +1 -1
  57. package/lib/esm/components/trees/category-tree/CategoriesTree.js +10 -1
  58. package/lib/esm/components/trees/category-tree/CategoriesTree.js.map +1 -1
  59. package/lib/esm/components/trees/category-tree/CategoryVisibilityHandler.d.ts +2 -2
  60. package/lib/esm/components/trees/common/ContextMenu.d.ts +39 -0
  61. package/lib/esm/components/trees/common/ContextMenu.js +39 -0
  62. package/lib/esm/components/trees/common/ContextMenu.js.map +1 -0
  63. package/lib/esm/components/trees/common/TreeNodeRenderer.d.ts +61 -0
  64. package/lib/esm/components/trees/common/TreeNodeRenderer.js +44 -0
  65. package/lib/esm/components/trees/common/TreeNodeRenderer.js.map +1 -0
  66. package/lib/esm/components/trees/common/TreeRenderer.d.ts +26 -0
  67. package/lib/esm/components/trees/common/TreeRenderer.js +34 -0
  68. package/lib/esm/components/trees/common/TreeRenderer.js.map +1 -0
  69. package/lib/esm/components/trees/common/TreeRenderer.scss +102 -0
  70. package/lib/esm/components/trees/{Common.d.ts → common/Types.d.ts} +3 -2
  71. package/lib/esm/components/trees/{Common.js → common/Types.js} +1 -1
  72. package/lib/esm/components/trees/common/Types.js.map +1 -0
  73. package/lib/esm/components/trees/common/Utils.d.ts +11 -0
  74. package/lib/esm/components/trees/common/Utils.js +42 -0
  75. package/lib/esm/components/trees/common/Utils.js.map +1 -0
  76. package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.d.ts +1 -1
  77. package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.js +9 -4
  78. package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
  79. package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTreeComponent.d.ts +7 -1
  80. package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js +1 -4
  81. package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js.map +1 -1
  82. package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.d.ts +1 -1
  83. package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.js +8 -2
  84. package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
  85. package/lib/esm/components/trees/index.d.ts +4 -2
  86. package/lib/esm/components/trees/index.js +4 -2
  87. package/lib/esm/components/trees/index.js.map +1 -1
  88. package/lib/esm/components/trees/models-tree/ModelsTree.d.ts +6 -4
  89. package/lib/esm/components/trees/models-tree/ModelsTree.js +19 -7
  90. package/lib/esm/components/trees/models-tree/ModelsTree.js.map +1 -1
  91. package/lib/esm/components/trees/models-tree/Utils.d.ts +2 -2
  92. package/lib/esm/components/trees/models-tree/Utils.js +267 -333
  93. package/lib/esm/components/trees/models-tree/Utils.js.map +1 -1
  94. package/package.json +1 -2
  95. package/lib/cjs/components/trees/Common.js.map +0 -1
  96. package/lib/esm/components/trees/Common.js.map +0 -1
@@ -23,7 +23,11 @@ export class CachingElementIdsContainer {
23
23
  }
24
24
  /** @internal */
25
25
  export function createRuleset(props) {
26
- const elementClassSpecification = props.elementClassSpecification ?? { schemaName: "BisCore", className: "GeometricElement3d" };
26
+ const context = {
27
+ elementClassSpecification: props.elementClassSpecification ?? { schemaName: "BisCore", className: "GeometricElement3d" },
28
+ groupElements: !!props.enableElementsClassGrouping,
29
+ showEmptyModels: !!props.showEmptyModels,
30
+ };
27
31
  return {
28
32
  id: "tree-widget-react/ModelsTree",
29
33
  requiredSchemas: [
@@ -36,20 +40,7 @@ export function createRuleset(props) {
36
40
  ruleType: "RootNodes",
37
41
  autoExpand: true,
38
42
  specifications: [
39
- {
40
- specType: "InstanceNodesOfSpecificClasses",
41
- classes: [
42
- {
43
- schemaName: "BisCore",
44
- classNames: [
45
- "Subject",
46
- ],
47
- },
48
- ],
49
- instanceFilter: `this.Parent = NULL`,
50
- groupByClass: false,
51
- groupByLabel: false,
52
- },
43
+ createRootSubjectSpecification(),
53
44
  ],
54
45
  customizationRules: [
55
46
  {
@@ -65,46 +56,8 @@ export function createRuleset(props) {
65
56
  ruleType: "ChildNodes",
66
57
  condition: `ParentNode.IsOfClass("Subject", "BisCore")`,
67
58
  specifications: [
68
- {
69
- specType: "RelatedInstanceNodes",
70
- relationshipPaths: [
71
- {
72
- relationship: {
73
- schemaName: "BisCore",
74
- className: "SubjectOwnsSubjects",
75
- },
76
- direction: "Forward",
77
- targetClass: {
78
- schemaName: "BisCore",
79
- className: "Subject",
80
- },
81
- },
82
- ],
83
- instanceFilter: `json_extract(this.JsonProperties, "$.Subject.Job.Bridge") <> NULL OR ifnull(json_extract(this.JsonProperties, "$.Subject.Model.Type"), "") = "Hierarchy"`,
84
- hideNodesInHierarchy: true,
85
- groupByClass: false,
86
- groupByLabel: false,
87
- },
88
- {
89
- specType: "RelatedInstanceNodes",
90
- relationshipPaths: [
91
- {
92
- relationship: {
93
- schemaName: "BisCore",
94
- className: "SubjectOwnsSubjects",
95
- },
96
- direction: "Forward",
97
- targetClass: {
98
- schemaName: "BisCore",
99
- className: "Subject",
100
- },
101
- },
102
- ],
103
- instanceFilter: `json_extract(this.JsonProperties, "$.Subject.Job.Bridge") = NULL AND ifnull(json_extract(this.JsonProperties, "$.Subject.Model.Type"), "") <> "Hierarchy"`,
104
- hideIfNoChildren: true,
105
- groupByClass: false,
106
- groupByLabel: false,
107
- },
59
+ createRelatedHierarchySubjectSpecification(),
60
+ createRelatedNonHierarchySubjectSpecification(),
108
61
  ],
109
62
  customizationRules: [
110
63
  {
@@ -120,70 +73,8 @@ export function createRuleset(props) {
120
73
  ruleType: "ChildNodes",
121
74
  condition: `ParentNode.IsOfClass("Subject", "BisCore")`,
122
75
  specifications: [
123
- {
124
- specType: "InstanceNodesOfSpecificClasses",
125
- classes: {
126
- schemaName: "BisCore",
127
- classNames: [
128
- "GeometricModel3d",
129
- ],
130
- arePolymorphic: true,
131
- },
132
- relatedInstances: [
133
- {
134
- relationshipPath: {
135
- relationship: {
136
- schemaName: "BisCore",
137
- className: "ModelModelsElement",
138
- },
139
- direction: "Forward",
140
- targetClass: {
141
- schemaName: "BisCore",
142
- className: "InformationPartitionElement",
143
- },
144
- },
145
- alias: "partition",
146
- isRequired: true,
147
- },
148
- ],
149
- 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", "${elementClassSpecification.schemaName}:${elementClassSpecification.className}")`,
150
- hasChildren: "Always",
151
- hideIfNoChildren: true,
152
- groupByClass: false,
153
- groupByLabel: false,
154
- },
155
- {
156
- specType: "InstanceNodesOfSpecificClasses",
157
- classes: {
158
- schemaName: "BisCore",
159
- classNames: [
160
- "GeometricModel3d",
161
- ],
162
- arePolymorphic: true,
163
- },
164
- relatedInstances: [
165
- {
166
- relationshipPath: {
167
- relationship: {
168
- schemaName: "BisCore",
169
- className: "ModelModelsElement",
170
- },
171
- direction: "Forward",
172
- targetClass: {
173
- schemaName: "BisCore",
174
- className: "InformationPartitionElement",
175
- },
176
- },
177
- alias: "partition",
178
- isRequired: true,
179
- },
180
- ],
181
- 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", "${elementClassSpecification.schemaName}:${elementClassSpecification.className}")`,
182
- hasChildren: "Always",
183
- hideNodesInHierarchy: true,
184
- groupByClass: false,
185
- groupByLabel: false,
186
- },
76
+ createNonContentModelsSpecification(context),
77
+ createContentModelsSpecification(context),
187
78
  ],
188
79
  customizationRules: [
189
80
  {
@@ -199,22 +90,7 @@ export function createRuleset(props) {
199
90
  ruleType: "ChildNodes",
200
91
  condition: `ParentNode.IsOfClass("ISubModeledElement", "BisCore")`,
201
92
  specifications: [
202
- {
203
- specType: "RelatedInstanceNodes",
204
- relationshipPaths: [
205
- {
206
- relationship: {
207
- schemaName: "BisCore",
208
- className: "ModelModelsElement",
209
- },
210
- direction: "Backward",
211
- },
212
- ],
213
- instanceFilter: `NOT this.IsPrivate AND this.HasRelatedInstance("BisCore:ModelContainsElements", "Forward", "${elementClassSpecification.schemaName}:${elementClassSpecification.className}")`,
214
- hideNodesInHierarchy: true,
215
- groupByClass: false,
216
- groupByLabel: false,
217
- },
93
+ createElementModelSpecification(context),
218
94
  ],
219
95
  customizationRules: [
220
96
  {
@@ -230,33 +106,7 @@ export function createRuleset(props) {
230
106
  ruleType: "ChildNodes",
231
107
  condition: `ParentNode.IsOfClass("GeometricModel3d", "BisCore")`,
232
108
  specifications: [
233
- {
234
- specType: "RelatedInstanceNodes",
235
- relationshipPaths: [
236
- [
237
- {
238
- relationship: {
239
- schemaName: "BisCore",
240
- className: "ModelContainsElements",
241
- },
242
- direction: "Forward",
243
- targetClass: elementClassSpecification,
244
- },
245
- {
246
- relationship: {
247
- schemaName: "BisCore",
248
- className: "GeometricElement3dIsInCategory",
249
- },
250
- direction: "Forward",
251
- },
252
- ],
253
- ],
254
- instanceFilter: `NOT this.IsPrivate`,
255
- suppressSimilarAncestorsCheck: true,
256
- hideIfNoChildren: true,
257
- groupByClass: false,
258
- groupByLabel: false,
259
- },
109
+ createModelCategoriesSpecification(context),
260
110
  ],
261
111
  customizationRules: [
262
112
  {
@@ -273,22 +123,7 @@ export function createRuleset(props) {
273
123
  ruleType: "ChildNodes",
274
124
  condition: `ParentNode.IsOfClass("SpatialCategory", "BisCore")`,
275
125
  specifications: [
276
- {
277
- specType: "RelatedInstanceNodes",
278
- relationshipPaths: [
279
- {
280
- relationship: {
281
- schemaName: "BisCore",
282
- className: "GeometricElement3dIsInCategory",
283
- },
284
- direction: "Backward",
285
- targetClass: elementClassSpecification,
286
- },
287
- ],
288
- instanceFilter: `this.Model.Id = parent.parent.ECInstanceId ANDALSO this.Parent = NULL`,
289
- groupByClass: !!props.enableElementsClassGrouping,
290
- groupByLabel: false,
291
- },
126
+ createCategoryElementsSpecification(context),
292
127
  ],
293
128
  customizationRules: [
294
129
  {
@@ -306,21 +141,7 @@ export function createRuleset(props) {
306
141
  ruleType: "ChildNodes",
307
142
  condition: `ParentNode.IsOfClass("GeometricElement3d", "BisCore")`,
308
143
  specifications: [
309
- {
310
- specType: "RelatedInstanceNodes",
311
- relationshipPaths: [
312
- {
313
- relationship: {
314
- schemaName: "BisCore",
315
- className: "ElementOwnsChildElements",
316
- },
317
- direction: "Forward",
318
- targetClass: elementClassSpecification,
319
- },
320
- ],
321
- groupByClass: !!props.enableElementsClassGrouping,
322
- groupByLabel: false,
323
- },
144
+ createEementElementsSpecification(context),
324
145
  ],
325
146
  customizationRules: [
326
147
  {
@@ -387,28 +208,18 @@ export function createRuleset(props) {
387
208
  }
388
209
  /** @internal */
389
210
  export function createSearchRuleset(props) {
390
- const elementClassSpecification = props.elementClassSpecification ?? { schemaName: "BisCore", className: "GeometricElement3d" };
211
+ const context = {
212
+ elementClassSpecification: props.elementClassSpecification ?? { schemaName: "BisCore", className: "GeometricElement3d" },
213
+ groupElements: false,
214
+ showEmptyModels: !!props.showEmptyModels,
215
+ };
391
216
  return {
392
217
  id: "tree-widget-react/ModelsTreeSearch",
393
218
  rules: [
394
219
  {
395
220
  ruleType: "RootNodes",
396
221
  specifications: [
397
- {
398
- specType: "InstanceNodesOfSpecificClasses",
399
- classes: [
400
- {
401
- schemaName: "BisCore",
402
- classNames: [
403
- "Subject",
404
- ],
405
- },
406
- ],
407
- instanceFilter: "this.Parent = NULL",
408
- arePolymorphic: false,
409
- groupByClass: false,
410
- groupByLabel: false,
411
- },
222
+ createRootSubjectSpecification(),
412
223
  ],
413
224
  customizationRules: [
414
225
  {
@@ -424,45 +235,10 @@ export function createSearchRuleset(props) {
424
235
  ruleType: "ChildNodes",
425
236
  condition: `ParentNode.IsOfClass("Subject", "BisCore")`,
426
237
  specifications: [
238
+ createRelatedHierarchySubjectSpecification(),
427
239
  {
428
- specType: "RelatedInstanceNodes",
429
- relationshipPaths: [
430
- {
431
- relationship: {
432
- schemaName: "BisCore",
433
- className: "SubjectOwnsSubjects",
434
- },
435
- direction: "Forward",
436
- targetClass: {
437
- schemaName: "BisCore",
438
- className: "Subject",
439
- },
440
- },
441
- ],
442
- instanceFilter: `json_extract(this.JsonProperties, "$.Subject.Job.Bridge") <> NULL OR ifnull(json_extract(this.JsonProperties, "$.Subject.Model.Type"), "") = "Hierarchy"`,
443
- hideNodesInHierarchy: true,
444
- groupByClass: false,
445
- groupByLabel: false,
446
- },
447
- {
448
- specType: "RelatedInstanceNodes",
449
- relationshipPaths: [
450
- {
451
- relationship: {
452
- schemaName: "BisCore",
453
- className: "SubjectOwnsSubjects",
454
- },
455
- direction: "Forward",
456
- targetClass: {
457
- schemaName: "BisCore",
458
- className: "Subject",
459
- },
460
- },
461
- ],
462
- instanceFilter: `json_extract(this.JsonProperties, "$.Subject.Job.Bridge") = NULL AND ifnull(json_extract(this.JsonProperties, "$.Subject.Model.Type"), "") <> "Hierarchy"`,
240
+ ...createRelatedNonHierarchySubjectSpecification(),
463
241
  hideExpression: `NOT ThisNode.HasChildren ANDALSO NOT ThisNode.ChildrenArtifacts.AnyMatches(x => x.isContentModel)`,
464
- groupByClass: false,
465
- groupByLabel: false,
466
242
  },
467
243
  ],
468
244
  customizationRules: [
@@ -492,36 +268,7 @@ export function createSearchRuleset(props) {
492
268
  ruleType: "ChildNodes",
493
269
  condition: `ParentNode.IsOfClass("Subject", "BisCore")`,
494
270
  specifications: [
495
- {
496
- specType: "InstanceNodesOfSpecificClasses",
497
- classes: {
498
- schemaName: "BisCore",
499
- classNames: [
500
- "GeometricModel3d",
501
- ],
502
- },
503
- arePolymorphic: true,
504
- relatedInstances: [
505
- {
506
- relationshipPath: {
507
- relationship: {
508
- schemaName: "BisCore",
509
- className: "ModelModelsElement",
510
- },
511
- direction: "Forward",
512
- targetClass: {
513
- schemaName: "BisCore",
514
- className: "InformationPartitionElement",
515
- },
516
- },
517
- alias: "partition",
518
- isRequired: true,
519
- },
520
- ],
521
- 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", "${elementClassSpecification.schemaName}:${elementClassSpecification.className}")`,
522
- groupByClass: false,
523
- groupByLabel: false,
524
- },
271
+ createNonContentModelsSpecification(context),
525
272
  ],
526
273
  customizationRules: [
527
274
  {
@@ -537,37 +284,7 @@ export function createSearchRuleset(props) {
537
284
  ruleType: "ChildNodes",
538
285
  condition: `ParentNode.IsOfClass("Subject", "BisCore")`,
539
286
  specifications: [
540
- {
541
- specType: "InstanceNodesOfSpecificClasses",
542
- classes: {
543
- schemaName: "BisCore",
544
- classNames: [
545
- "GeometricModel3d",
546
- ],
547
- },
548
- arePolymorphic: true,
549
- relatedInstances: [
550
- {
551
- relationshipPath: {
552
- relationship: {
553
- schemaName: "BisCore",
554
- className: "ModelModelsElement",
555
- },
556
- direction: "Forward",
557
- targetClass: {
558
- schemaName: "BisCore",
559
- className: "InformationPartitionElement",
560
- },
561
- },
562
- alias: "partition",
563
- isRequired: true,
564
- },
565
- ],
566
- 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", "${elementClassSpecification.schemaName}:${elementClassSpecification.className}")`,
567
- hideNodesInHierarchy: true,
568
- groupByClass: false,
569
- groupByLabel: false,
570
- },
287
+ createContentModelsSpecification(context),
571
288
  ],
572
289
  customizationRules: [
573
290
  {
@@ -589,25 +306,7 @@ export function createSearchRuleset(props) {
589
306
  ruleType: "ChildNodes",
590
307
  condition: `ParentNode.IsOfClass("GeometricModel3d", "BisCore")`,
591
308
  specifications: [
592
- {
593
- specType: "RelatedInstanceNodes",
594
- relationshipPaths: [
595
- {
596
- relationship: {
597
- schemaName: "BisCore",
598
- className: "ModelOwnsSubModel",
599
- },
600
- direction: "Forward",
601
- targetClass: {
602
- schemaName: "BisCore",
603
- className: "GeometricModel3d",
604
- },
605
- },
606
- ],
607
- instanceFilter: `NOT this.IsPrivate AND this.HasRelatedInstance("BisCore:ModelContainsElements", "Forward", "${elementClassSpecification.schemaName}:${elementClassSpecification.className}")`,
608
- groupByClass: false,
609
- groupByLabel: false,
610
- },
309
+ createModelSubModelsSpecification(context),
611
310
  ],
612
311
  customizationRules: [
613
312
  {
@@ -622,14 +321,249 @@ export function createSearchRuleset(props) {
622
321
  ],
623
322
  };
624
323
  }
625
- /** @internal */
626
- export function customizeModelsTreeNodeItem(item, node) {
627
- item.isCheckboxVisible = true;
628
- item.isCheckboxDisabled = true;
629
- item.icon = getIcon(node);
324
+ function createRootSubjectSpecification() {
325
+ return {
326
+ specType: "InstanceNodesOfSpecificClasses",
327
+ classes: [
328
+ {
329
+ schemaName: "BisCore",
330
+ classNames: [
331
+ "Subject",
332
+ ],
333
+ },
334
+ ],
335
+ instanceFilter: `this.Parent = NULL`,
336
+ groupByClass: false,
337
+ groupByLabel: false,
338
+ };
339
+ }
340
+ function createRelatedHierarchySubjectSpecification() {
341
+ return {
342
+ specType: "RelatedInstanceNodes",
343
+ relationshipPaths: [
344
+ {
345
+ relationship: {
346
+ schemaName: "BisCore",
347
+ className: "SubjectOwnsSubjects",
348
+ },
349
+ direction: "Forward",
350
+ targetClass: {
351
+ schemaName: "BisCore",
352
+ className: "Subject",
353
+ },
354
+ },
355
+ ],
356
+ instanceFilter: `json_extract(this.JsonProperties, "$.Subject.Job.Bridge") <> NULL OR ifnull(json_extract(this.JsonProperties, "$.Subject.Model.Type"), "") = "Hierarchy"`,
357
+ hideNodesInHierarchy: true,
358
+ groupByClass: false,
359
+ groupByLabel: false,
360
+ };
361
+ }
362
+ function createRelatedNonHierarchySubjectSpecification() {
363
+ return {
364
+ specType: "RelatedInstanceNodes",
365
+ relationshipPaths: [
366
+ {
367
+ relationship: {
368
+ schemaName: "BisCore",
369
+ className: "SubjectOwnsSubjects",
370
+ },
371
+ direction: "Forward",
372
+ targetClass: {
373
+ schemaName: "BisCore",
374
+ className: "Subject",
375
+ },
376
+ },
377
+ ],
378
+ instanceFilter: `json_extract(this.JsonProperties, "$.Subject.Job.Bridge") = NULL AND ifnull(json_extract(this.JsonProperties, "$.Subject.Model.Type"), "") <> "Hierarchy"`,
379
+ hideIfNoChildren: true,
380
+ groupByClass: false,
381
+ groupByLabel: false,
382
+ };
630
383
  }
631
- function getIcon(node) {
632
- return node.key && NodeKey.isClassGroupingNodeKey(node.key)
384
+ function createNonContentModelsSpecification({ elementClassSpecification, showEmptyModels }) {
385
+ const partitionFilter = `parent.ECInstanceId = partition.Parent.Id OR json_extract(parent.JsonProperties, "$.Subject.Model.TargetPartition") = printf("0x%x", partition.ECInstanceId)`;
386
+ const modelHasElements = `this.HasRelatedInstance("BisCore:ModelContainsElements", "Forward", "${elementClassSpecification.schemaName}:${elementClassSpecification.className}")`;
387
+ const hasNoContent = `json_extract(partition.JsonProperties, "$.PhysicalPartition.Model.Content") = NULL AND json_extract(partition.JsonProperties, "$.GraphicalPartition3d.Model.Content") = NULL`;
388
+ const instanceFilter = `(${partitionFilter}) AND NOT this.IsPrivate AND ${hasNoContent}${showEmptyModels ? "" : ` AND ${modelHasElements}`}`;
389
+ return {
390
+ specType: "InstanceNodesOfSpecificClasses",
391
+ classes: {
392
+ schemaName: "BisCore",
393
+ classNames: [
394
+ "GeometricModel3d",
395
+ ],
396
+ arePolymorphic: true,
397
+ },
398
+ relatedInstances: [
399
+ {
400
+ relationshipPath: {
401
+ relationship: {
402
+ schemaName: "BisCore",
403
+ className: "ModelModelsElement",
404
+ },
405
+ direction: "Forward",
406
+ targetClass: {
407
+ schemaName: "BisCore",
408
+ className: "InformationPartitionElement",
409
+ },
410
+ },
411
+ alias: "partition",
412
+ isRequired: true,
413
+ },
414
+ ],
415
+ instanceFilter,
416
+ hasChildren: showEmptyModels ? "Unknown" : "Always",
417
+ groupByClass: false,
418
+ groupByLabel: false,
419
+ };
420
+ }
421
+ function createContentModelsSpecification({ elementClassSpecification, showEmptyModels }) {
422
+ const partitionFilter = `parent.ECInstanceId = partition.Parent.Id OR json_extract(parent.JsonProperties, "$.Subject.Model.TargetPartition") = printf("0x%x", partition.ECInstanceId)`;
423
+ const modelHasElements = `this.HasRelatedInstance("BisCore:ModelContainsElements", "Forward", "${elementClassSpecification.schemaName}:${elementClassSpecification.className}")`;
424
+ const hasContent = `json_extract(partition.JsonProperties, "$.PhysicalPartition.Model.Content") <> NULL OR json_extract(partition.JsonProperties, "$.GraphicalPartition3d.Model.Content") <> NULL`;
425
+ const instanceFilter = `(${partitionFilter}) AND NOT this.IsPrivate AND (${hasContent})${showEmptyModels ? "" : ` AND ${modelHasElements}`}`;
426
+ return {
427
+ specType: "InstanceNodesOfSpecificClasses",
428
+ classes: {
429
+ schemaName: "BisCore",
430
+ classNames: ["GeometricModel3d"],
431
+ arePolymorphic: true,
432
+ },
433
+ relatedInstances: [
434
+ {
435
+ relationshipPath: {
436
+ relationship: {
437
+ schemaName: "BisCore",
438
+ className: "ModelModelsElement",
439
+ },
440
+ direction: "Forward",
441
+ targetClass: {
442
+ schemaName: "BisCore",
443
+ className: "InformationPartitionElement",
444
+ },
445
+ },
446
+ alias: "partition",
447
+ isRequired: true,
448
+ },
449
+ ],
450
+ instanceFilter,
451
+ hasChildren: showEmptyModels ? "Unknown" : "Always",
452
+ hideNodesInHierarchy: true,
453
+ groupByClass: false,
454
+ groupByLabel: false,
455
+ };
456
+ }
457
+ function createElementModelSpecification({ elementClassSpecification, showEmptyModels }) {
458
+ const hasElements = `this.HasRelatedInstance("BisCore:ModelContainsElements", "Forward", "${elementClassSpecification.schemaName}:${elementClassSpecification.className}")`;
459
+ const instanceFilter = `NOT this.IsPrivate${showEmptyModels ? "" : ` AND ${hasElements}`}`;
460
+ return {
461
+ specType: "RelatedInstanceNodes",
462
+ relationshipPaths: [
463
+ {
464
+ relationship: {
465
+ schemaName: "BisCore",
466
+ className: "ModelModelsElement",
467
+ },
468
+ direction: "Backward",
469
+ },
470
+ ],
471
+ instanceFilter,
472
+ hideNodesInHierarchy: true,
473
+ groupByClass: false,
474
+ groupByLabel: false,
475
+ };
476
+ }
477
+ function createModelCategoriesSpecification({ elementClassSpecification }) {
478
+ return {
479
+ specType: "RelatedInstanceNodes",
480
+ relationshipPaths: [
481
+ [
482
+ {
483
+ relationship: {
484
+ schemaName: "BisCore",
485
+ className: "ModelContainsElements",
486
+ },
487
+ direction: "Forward",
488
+ targetClass: elementClassSpecification,
489
+ },
490
+ {
491
+ relationship: {
492
+ schemaName: "BisCore",
493
+ className: "GeometricElement3dIsInCategory",
494
+ },
495
+ direction: "Forward",
496
+ },
497
+ ],
498
+ ],
499
+ instanceFilter: `NOT this.IsPrivate`,
500
+ suppressSimilarAncestorsCheck: true,
501
+ hideIfNoChildren: true,
502
+ groupByClass: false,
503
+ groupByLabel: false,
504
+ };
505
+ }
506
+ function createCategoryElementsSpecification({ elementClassSpecification, groupElements }) {
507
+ return {
508
+ specType: "RelatedInstanceNodes",
509
+ relationshipPaths: [
510
+ {
511
+ relationship: {
512
+ schemaName: "BisCore",
513
+ className: "GeometricElement3dIsInCategory",
514
+ },
515
+ direction: "Backward",
516
+ targetClass: elementClassSpecification,
517
+ },
518
+ ],
519
+ instanceFilter: `this.Model.Id = parent.parent.ECInstanceId ANDALSO this.Parent = NULL`,
520
+ groupByClass: groupElements,
521
+ groupByLabel: false,
522
+ };
523
+ }
524
+ function createEementElementsSpecification({ elementClassSpecification, groupElements }) {
525
+ return {
526
+ specType: "RelatedInstanceNodes",
527
+ relationshipPaths: [
528
+ {
529
+ relationship: {
530
+ schemaName: "BisCore",
531
+ className: "ElementOwnsChildElements",
532
+ },
533
+ direction: "Forward",
534
+ targetClass: elementClassSpecification,
535
+ },
536
+ ],
537
+ groupByClass: groupElements,
538
+ groupByLabel: false,
539
+ };
540
+ }
541
+ function createModelSubModelsSpecification({ elementClassSpecification, showEmptyModels }) {
542
+ const hasElements = `this.HasRelatedInstance("BisCore:ModelContainsElements", "Forward", "${elementClassSpecification.schemaName}:${elementClassSpecification.className}")`;
543
+ const instanceFilter = `NOT this.IsPrivate${showEmptyModels ? "" : ` AND ${hasElements}`}`;
544
+ return {
545
+ specType: "RelatedInstanceNodes",
546
+ relationshipPaths: [
547
+ {
548
+ relationship: {
549
+ schemaName: "BisCore",
550
+ className: "ModelOwnsSubModel",
551
+ },
552
+ direction: "Forward",
553
+ targetClass: {
554
+ schemaName: "BisCore",
555
+ className: "GeometricModel3d",
556
+ },
557
+ },
558
+ ],
559
+ instanceFilter,
560
+ groupByClass: false,
561
+ groupByLabel: false,
562
+ };
563
+ }
564
+ /** @internal */
565
+ export function addModelsTreeNodeItemIcons(item, node) {
566
+ item.icon = node.key && NodeKey.isClassGroupingNodeKey(node.key)
633
567
  ? node.extendedData?.groupIcon
634
568
  : node.extendedData?.icon;
635
569
  }