@itwin/tree-widget-react 1.0.0-dev.3 → 1.0.0-dev.4

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/README.md +2 -1
  2. package/lib/cjs/components/{TreeWidgetComponent.d.ts → SelectableTree.d.ts} +6 -6
  3. package/lib/cjs/components/{TreeWidgetComponent.js → SelectableTree.js} +8 -8
  4. package/lib/cjs/components/SelectableTree.js.map +1 -0
  5. package/lib/{esm/components/TreeWidgetComponent.scss → cjs/components/SelectableTree.scss} +1 -15
  6. package/lib/cjs/components/TreeWidgetUiItemsProvider.d.ts +3 -2
  7. package/lib/cjs/components/TreeWidgetUiItemsProvider.js +9 -3
  8. package/lib/cjs/components/TreeWidgetUiItemsProvider.js.map +1 -1
  9. package/lib/cjs/components/TreeWidgetUiItemsProvider.scss +9 -0
  10. package/lib/cjs/components/tree-header/TreeHeader.js +23 -1
  11. package/lib/cjs/components/tree-header/TreeHeader.js.map +1 -1
  12. package/lib/cjs/components/trees/Common.d.ts +27 -0
  13. package/lib/cjs/components/trees/Common.js.map +1 -1
  14. package/lib/cjs/components/trees/VisibilityTreeRenderer.d.ts +13 -5
  15. package/lib/cjs/components/trees/VisibilityTreeRenderer.js +11 -10
  16. package/lib/cjs/components/trees/VisibilityTreeRenderer.js.map +1 -1
  17. package/lib/cjs/components/trees/category-tree/Categories.json +4 -8
  18. package/lib/cjs/components/trees/category-tree/CategoriesTree.d.ts +3 -21
  19. package/lib/cjs/components/trees/category-tree/CategoriesTree.js +8 -2
  20. package/lib/cjs/components/trees/category-tree/CategoriesTree.js.map +1 -1
  21. package/lib/cjs/components/trees/category-tree/CategoriesTreeComponent.d.ts +2 -2
  22. package/lib/cjs/components/trees/category-tree/CategoriesTreeComponent.js +2 -2
  23. package/lib/cjs/components/trees/category-tree/CategoriesTreeComponent.js.map +1 -1
  24. package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.d.ts +2 -9
  25. package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.js +1 -1
  26. package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
  27. package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.d.ts +3 -13
  28. package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.js +2 -6
  29. package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
  30. package/lib/cjs/components/trees/imodel-content-tree/IModelContentTreeComponent.d.ts +2 -2
  31. package/lib/cjs/components/trees/imodel-content-tree/IModelContentTreeComponent.js +2 -2
  32. package/lib/cjs/components/trees/imodel-content-tree/IModelContentTreeComponent.js.map +1 -1
  33. package/lib/cjs/components/trees/models-tree/ModelsTree.d.ts +3 -29
  34. package/lib/cjs/components/trees/models-tree/ModelsTree.js +11 -2
  35. package/lib/cjs/components/trees/models-tree/ModelsTree.js.map +1 -1
  36. package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.d.ts +2 -2
  37. package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.js +2 -2
  38. package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
  39. package/lib/cjs/components/trees/models-tree/Utils.d.ts +4 -1
  40. package/lib/cjs/components/trees/models-tree/Utils.js +28 -36
  41. package/lib/cjs/components/trees/models-tree/Utils.js.map +1 -1
  42. package/lib/cjs/components/utils/UseTreeTransientState.d.ts +19 -0
  43. package/lib/cjs/components/utils/UseTreeTransientState.js +33 -0
  44. package/lib/cjs/components/utils/UseTreeTransientState.js.map +1 -0
  45. package/lib/cjs/tree-widget-react.d.ts +2 -1
  46. package/lib/cjs/tree-widget-react.js +2 -1
  47. package/lib/cjs/tree-widget-react.js.map +1 -1
  48. package/lib/esm/components/{TreeWidgetComponent.d.ts → SelectableTree.d.ts} +6 -6
  49. package/lib/esm/components/{TreeWidgetComponent.js → SelectableTree.js} +6 -6
  50. package/lib/esm/components/SelectableTree.js.map +1 -0
  51. package/lib/{cjs/components/TreeWidgetComponent.scss → esm/components/SelectableTree.scss} +1 -15
  52. package/lib/esm/components/TreeWidgetUiItemsProvider.d.ts +3 -2
  53. package/lib/esm/components/TreeWidgetUiItemsProvider.js +9 -3
  54. package/lib/esm/components/TreeWidgetUiItemsProvider.js.map +1 -1
  55. package/lib/esm/components/TreeWidgetUiItemsProvider.scss +9 -0
  56. package/lib/esm/components/tree-header/TreeHeader.js +24 -2
  57. package/lib/esm/components/tree-header/TreeHeader.js.map +1 -1
  58. package/lib/esm/components/trees/Common.d.ts +27 -0
  59. package/lib/esm/components/trees/Common.js.map +1 -1
  60. package/lib/esm/components/trees/VisibilityTreeRenderer.d.ts +13 -5
  61. package/lib/esm/components/trees/VisibilityTreeRenderer.js +10 -9
  62. package/lib/esm/components/trees/VisibilityTreeRenderer.js.map +1 -1
  63. package/lib/esm/components/trees/category-tree/Categories.json +4 -8
  64. package/lib/esm/components/trees/category-tree/CategoriesTree.d.ts +3 -21
  65. package/lib/esm/components/trees/category-tree/CategoriesTree.js +8 -2
  66. package/lib/esm/components/trees/category-tree/CategoriesTree.js.map +1 -1
  67. package/lib/esm/components/trees/category-tree/CategoriesTreeComponent.d.ts +2 -2
  68. package/lib/esm/components/trees/category-tree/CategoriesTreeComponent.js +2 -2
  69. package/lib/esm/components/trees/category-tree/CategoriesTreeComponent.js.map +1 -1
  70. package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.d.ts +2 -9
  71. package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.js +1 -1
  72. package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
  73. package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.d.ts +3 -13
  74. package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.js +2 -3
  75. package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
  76. package/lib/esm/components/trees/imodel-content-tree/IModelContentTreeComponent.d.ts +2 -2
  77. package/lib/esm/components/trees/imodel-content-tree/IModelContentTreeComponent.js +2 -2
  78. package/lib/esm/components/trees/imodel-content-tree/IModelContentTreeComponent.js.map +1 -1
  79. package/lib/esm/components/trees/models-tree/ModelsTree.d.ts +3 -29
  80. package/lib/esm/components/trees/models-tree/ModelsTree.js +12 -3
  81. package/lib/esm/components/trees/models-tree/ModelsTree.js.map +1 -1
  82. package/lib/esm/components/trees/models-tree/ModelsTreeComponent.d.ts +2 -2
  83. package/lib/esm/components/trees/models-tree/ModelsTreeComponent.js +2 -2
  84. package/lib/esm/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
  85. package/lib/esm/components/trees/models-tree/Utils.d.ts +4 -1
  86. package/lib/esm/components/trees/models-tree/Utils.js +26 -35
  87. package/lib/esm/components/trees/models-tree/Utils.js.map +1 -1
  88. package/lib/esm/components/utils/UseTreeTransientState.d.ts +19 -0
  89. package/lib/esm/components/utils/UseTreeTransientState.js +29 -0
  90. package/lib/esm/components/utils/UseTreeTransientState.js.map +1 -0
  91. package/lib/esm/tree-widget-react.d.ts +2 -1
  92. package/lib/esm/tree-widget-react.js +2 -1
  93. package/lib/esm/tree-widget-react.js.map +1 -1
  94. package/package.json +10 -10
  95. package/lib/cjs/components/TreeWidgetComponent.js.map +0 -1
  96. package/lib/esm/components/TreeWidgetComponent.js.map +0 -1
@@ -2,6 +2,7 @@
2
2
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
+ import { NodeKey } from "@itwin/presentation-common";
5
6
  /** @internal */
6
7
  export class CachingElementIdsContainer {
7
8
  constructor(_generator) {
@@ -55,6 +56,7 @@ export function createRuleset(props) {
55
56
  ruleType: "ExtendedData",
56
57
  items: {
57
58
  isSubject: "true",
59
+ icon: "\"icon-imodel-hollow-2\"",
58
60
  },
59
61
  },
60
62
  ],
@@ -109,6 +111,7 @@ export function createRuleset(props) {
109
111
  ruleType: "ExtendedData",
110
112
  items: {
111
113
  isSubject: "true",
114
+ icon: "\"icon-folder\"",
112
115
  },
113
116
  },
114
117
  ],
@@ -187,6 +190,7 @@ export function createRuleset(props) {
187
190
  ruleType: "ExtendedData",
188
191
  items: {
189
192
  isModel: "true",
193
+ icon: "\"icon-model\"",
190
194
  },
191
195
  },
192
196
  ],
@@ -217,6 +221,7 @@ export function createRuleset(props) {
217
221
  ruleType: "ExtendedData",
218
222
  items: {
219
223
  isModel: "true",
224
+ icon: "\"icon-model\"",
220
225
  },
221
226
  },
222
227
  ],
@@ -259,6 +264,7 @@ export function createRuleset(props) {
259
264
  items: {
260
265
  isCategory: "true",
261
266
  modelId: "ParentNode.InstanceId",
267
+ icon: "\"icon-layers\"",
262
268
  },
263
269
  },
264
270
  ],
@@ -290,6 +296,8 @@ export function createRuleset(props) {
290
296
  items: {
291
297
  modelId: "this.Model.Id",
292
298
  categoryId: "this.Category.Id",
299
+ icon: "\"icon-item\"",
300
+ groupIcon: "\"icon-ec-class\"",
293
301
  },
294
302
  },
295
303
  ],
@@ -320,6 +328,8 @@ export function createRuleset(props) {
320
328
  items: {
321
329
  modelId: "this.Model.Id",
322
330
  categoryId: "this.Category.Id",
331
+ icon: "\"icon-item\"",
332
+ groupIcon: "\"icon-ec-class\"",
323
333
  },
324
334
  },
325
335
  ],
@@ -350,31 +360,6 @@ export function createRuleset(props) {
350
360
  },
351
361
  ],
352
362
  },
353
- {
354
- ruleType: "ImageIdOverride",
355
- condition: `ThisNode.IsInstanceNode ANDALSO ThisNode.IsOfClass("Subject", "BisCore")`,
356
- imageIdExpression: `IIF(this.Parent.Id = NULL, "icon-imodel-hollow-2", "icon-folder")`,
357
- },
358
- {
359
- ruleType: "ImageIdOverride",
360
- condition: `ThisNode.IsInstanceNode ANDALSO ThisNode.IsOfClass("Model", "BisCore")`,
361
- imageIdExpression: `"icon-model"`,
362
- },
363
- {
364
- ruleType: "ImageIdOverride",
365
- condition: `ThisNode.IsInstanceNode ANDALSO ThisNode.IsOfClass("Category", "BisCore")`,
366
- imageIdExpression: `"icon-layers"`,
367
- },
368
- {
369
- ruleType: "ImageIdOverride",
370
- condition: `ThisNode.IsInstanceNode ANDALSO ThisNode.IsOfClass("Element", "BisCore")`,
371
- imageIdExpression: `"icon-item"`,
372
- },
373
- {
374
- ruleType: "ImageIdOverride",
375
- condition: `ThisNode.IsClassGroupingNode`,
376
- imageIdExpression: `"icon-ec-class"`,
377
- },
378
363
  {
379
364
  ruleType: "Content",
380
365
  condition: `ContentDisplayType = "AssemblyElementsRequest"`,
@@ -430,6 +415,7 @@ export function createSearchRuleset(props) {
430
415
  ruleType: "ExtendedData",
431
416
  items: {
432
417
  isSubject: "true",
418
+ icon: "\"icon-imodel-hollow-2\"",
433
419
  },
434
420
  },
435
421
  ],
@@ -484,6 +470,7 @@ export function createSearchRuleset(props) {
484
470
  ruleType: "ExtendedData",
485
471
  items: {
486
472
  isSubject: "true",
473
+ icon: "\"icon-folder\"",
487
474
  },
488
475
  },
489
476
  {
@@ -541,6 +528,7 @@ export function createSearchRuleset(props) {
541
528
  ruleType: "ExtendedData",
542
529
  items: {
543
530
  isModel: "true",
531
+ icon: "\"icon-model\"",
544
532
  },
545
533
  },
546
534
  ],
@@ -592,6 +580,7 @@ export function createSearchRuleset(props) {
592
580
  ruleType: "ExtendedData",
593
581
  items: {
594
582
  isModel: "true",
583
+ icon: "\"icon-model\"",
595
584
  },
596
585
  },
597
586
  ],
@@ -625,21 +614,23 @@ export function createSearchRuleset(props) {
625
614
  ruleType: "ExtendedData",
626
615
  items: {
627
616
  isModel: "true",
617
+ icon: "\"icon-model\"",
628
618
  },
629
619
  },
630
620
  ],
631
621
  },
632
- {
633
- ruleType: "ImageIdOverride",
634
- condition: `ThisNode.IsOfClass("Subject", "BisCore")`,
635
- imageIdExpression: `IIF(this.Parent.Id = NULL, "icon-imodel-hollow-2", "icon-folder")`,
636
- },
637
- {
638
- ruleType: "ImageIdOverride",
639
- condition: `ThisNode.IsOfClass("Model", "BisCore")`,
640
- imageIdExpression: `"icon-model"`,
641
- },
642
622
  ],
643
623
  };
644
624
  }
625
+ /** @internal */
626
+ export function customizeModelsTreeNodeItem(item, node) {
627
+ item.isCheckboxVisible = true;
628
+ item.isCheckboxDisabled = true;
629
+ item.icon = getIcon(node);
630
+ }
631
+ function getIcon(node) {
632
+ return node.key && NodeKey.isClassGroupingNodeKey(node.key)
633
+ ? node.extendedData?.groupIcon
634
+ : node.extendedData?.icon;
635
+ }
645
636
  //# sourceMappingURL=Utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../../../../src/components/trees/models-tree/Utils.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAM/F,gBAAgB;AAChB,MAAM,OAAO,0BAA0B;IAErC,YAAoB,UAAsC;QAAtC,eAAU,GAAV,UAAU,CAA4B;QADlD,SAAI,GAAG,IAAI,KAAK,EAAc,CAAC;IAEvC,CAAC;IAEO,KAAK,CAAC,IAAI,KAAK,OAAO,CAAC,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IAE9D,KAAK,CAAA,CAAE,aAAa;QACzB,KAAK,MAAM,EAAE,IAAI,IAAI,CAAC,IAAI,EAAE;YAC1B,MAAM,EAAE,CAAC;SACV;QAED,IAAI,MAAM,CAAC;QACX,OAAO,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,EAAE;YACjC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACvB,MAAM,MAAM,CAAC;SACd;IACH,CAAC;CACF;AAOD,gBAAgB;AAChB,MAAM,UAAU,aAAa,CAAC,KAAyB;IACrD,MAAM,yBAAyB,GAAG,KAAK,CAAC,yBAAyB,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,oBAAoB,EAAE,CAAC;IAChI,OAAO;QACL,EAAE,EAAE,8BAA8B;QAClC,eAAe,EAAE;YACf;gBACE,IAAI,EAAE,SA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AAQ,EAAE,cAAc;wBACxB,KAAK,EAAE;4BACL,OAAO,EAAE,MAAM;yBAChB;qBACF;iBACF;aACF;YACD;gBACE,QAAQ,EAAE,YAAY;gBACtB,SAAS,EAAE,qDAAqD;gBAChE,cAAc,EAAE;oBACd;wBACE,QAAQ,EAAE,sBAAsB;wBAChC,iBAAiB,EAAE;4BACjB;gCACE,YAAY,EAAE;oCACZ,UAAU,EAAE,SAAS;oCACrB,SAAS,EAAE,mBAAmB;iCAC/B;gCACD,SAAS,EAAE,SAAS;gCACpB,WAAW,EAAE;oCACX,UAAU,EAAE,SAAS;oCACrB,SAAS,EAAE,kBAAkB;iCAC9B;6BACF;yBACF;wBACD,cAAc,EAAE,+FAA+F,yBAAyB,CAAC,UAAU,IAAI,yBAAyB,CAAC,SAAS,IAAI;wBAC9L,YAAY,EAAE,KAAK;wBACnB,YAAY,EAAE,KAAK;qBACpB;iBACF;gBACD,kBAAkB,EAAE;oBAClB;wBACE,QAAQ,EAAE,cAAc;wBACxB,KAAK,EAAE;4BACL,OAAO,EAAE,MAAM;yBAChB;qBACF;iBACF;aACF;YACD;gBACE,QAAQ,EAAE,iBAAiB;gBAC3B,SAAS,EAAE,0CAA0C;gBACrD,iBAAiB,EAAE,mEAAmE;aACvF;YACD;gBACE,QAAQ,EAAE,iBAAiB;gBAC3B,SAAS,EAAE,wCAAwC;gBACnD,iBAAiB,EAAE,cAAc;aAClC;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport type { Id64String } from \"@itwin/core-bentley\";\nimport type { Ruleset } from \"@itwin/presentation-common\";\nimport type { ModelsTreeHierarchyConfiguration } from \"./ModelsTree\";\n\n/** @internal */\nexport class CachingElementIdsContainer {\n private _ids = new Array<Id64String>();\n constructor(private _generator: AsyncGenerator<Id64String>) {\n }\n\n private async next() { return (await this._generator.next()).value; }\n\n public async* getElementIds() {\n for (const id of this._ids) {\n yield id;\n }\n\n let nextId;\n while (nextId = await this.next()) {\n this._ids.push(nextId);\n yield nextId;\n }\n }\n}\n\n/** @internal */\nexport type CreateRulesetProps = Omit<ModelsTreeHierarchyConfiguration, \"enableElementsClassGrouping\"> & {\n enableElementsClassGrouping?: boolean;\n};\n\n/** @internal */\nexport function createRuleset(props: CreateRulesetProps): Ruleset {\n const elementClassSpecification = props.elementClassSpecification ?? { schemaName: \"BisCore\", className: \"GeometricElement3d\" };\n return {\n id: \"tree-widget-react/ModelsTree\",\n requiredSchemas: [\n {\n name: \"BisCore\",\n },\n ],\n rules: [\n {\n ruleType: \"RootNodes\",\n autoExpand: true,\n specifications: [\n {\n specType: \"InstanceNodesOfSpecificClasses\",\n classes: [\n {\n schemaName: \"BisCore\",\n classNames: [\n \"Subject\",\n ],\n },\n ],\n instanceFilter: `this.Parent = NULL`,\n groupByClass: false,\n groupByLabel: false,\n },\n ],\n customizationRules: [\n {\n ruleType: \"ExtendedData\",\n items: {\n isSubject: \"true\",\n },\n },\n ],\n },\n {\n ruleType: \"ChildNodes\",\n condition: `ParentNode.IsOfClass(\"Subject\", \"BisCore\")`,\n specifications: [\n {\n specType: \"RelatedInstanceNodes\",\n relationshipPaths: [\n {\n relationship: {\n schemaName: \"BisCore\",\n className: \"SubjectOwnsSubjects\",\n },\n direction: \"Forward\",\n targetClass: {\n schemaName: \"BisCore\",\n className: \"Subject\",\n },\n },\n ],\n instanceFilter: `json_extract(this.JsonProperties, \"$.Subject.Job.Bridge\") <> NULL OR ifnull(json_extract(this.JsonProperties, \"$.Subject.Model.Type\"), \"\") = \"Hierarchy\"`,\n hideNodesInHierarchy: true,\n groupByClass: false,\n groupByLabel: false,\n },\n {\n specType: \"RelatedInstanceNodes\",\n relationshipPaths: [\n {\n relationship: {\n schemaName: \"BisCore\",\n className: \"SubjectOwnsSubjects\",\n },\n direction: \"Forward\",\n targetClass: {\n schemaName: \"BisCore\",\n className: \"Subject\",\n },\n },\n ],\n instanceFilter: `json_extract(this.JsonProperties, \"$.Subject.Job.Bridge\") = NULL AND ifnull(json_extract(this.JsonProperties, \"$.Subject.Model.Type\"), \"\") <> \"Hierarchy\"`,\n hideIfNoChildren: true,\n groupByClass: false,\n groupByLabel: false,\n },\n ],\n customizationRules: [\n {\n ruleType: \"ExtendedData\",\n items: {\n isSubject: \"true\",\n },\n },\n ],\n },\n {\n ruleType: \"ChildNodes\",\n condition: `ParentNode.IsOfClass(\"Subject\", \"BisCore\")`,\n specifications: [\n {\n specType: \"InstanceNodesOfSpecificClasses\",\n classes: {\n schemaName: \"BisCore\",\n classNames: [\n \"GeometricModel3d\",\n ],\n arePolymorphic: true,\n },\n relatedInstances: [\n {\n relationshipPath: {\n relationship: {\n schemaName: \"BisCore\",\n className: \"ModelModelsElement\",\n },\n direction: \"Forward\",\n targetClass: {\n schemaName: \"BisCore\",\n className: \"InformationPartitionElement\",\n },\n },\n alias: \"partition\",\n isRequired: true,\n },\n ],\n 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}\")`,\n hasChildren: \"Always\",\n hideIfNoChildren: true,\n groupByClass: false,\n groupByLabel: false,\n },\n {\n specType: \"InstanceNodesOfSpecificClasses\",\n classes: {\n schemaName: \"BisCore\",\n classNames: [\n \"GeometricModel3d\",\n ],\n arePolymorphic: true,\n },\n relatedInstances: [\n {\n relationshipPath: {\n relationship: {\n schemaName: \"BisCore\",\n className: \"ModelModelsElement\",\n },\n direction: \"Forward\",\n targetClass: {\n schemaName: \"BisCore\",\n className: \"InformationPartitionElement\",\n },\n },\n alias: \"partition\",\n isRequired: true,\n },\n ],\n 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}\")`,\n hasChildren: \"Always\",\n hideNodesInHierarchy: true,\n groupByClass: false,\n groupByLabel: false,\n },\n ],\n customizationRules: [\n {\n ruleType: \"ExtendedData\",\n items: {\n isModel: \"true\",\n },\n },\n ],\n },\n {\n ruleType: \"ChildNodes\",\n condition: `ParentNode.IsOfClass(\"ISubModeledElement\", \"BisCore\")`,\n specifications: [\n {\n specType: \"RelatedInstanceNodes\",\n relationshipPaths: [\n {\n relationship: {\n schemaName: \"BisCore\",\n className: \"ModelModelsElement\",\n },\n direction: \"Backward\",\n },\n ],\n instanceFilter: `NOT this.IsPrivate AND this.HasRelatedInstance(\"BisCore:ModelContainsElements\", \"Forward\", \"${elementClassSpecification.schemaName}:${elementClassSpecification.className}\")`,\n hideNodesInHierarchy: true,\n groupByClass: false,\n groupByLabel: false,\n },\n ],\n customizationRules: [\n {\n ruleType: \"ExtendedData\",\n items: {\n isModel: \"true\",\n },\n },\n ],\n },\n {\n ruleType: \"ChildNodes\",\n condition: `ParentNode.IsOfClass(\"GeometricModel3d\", \"BisCore\")`,\n specifications: [\n {\n specType: \"RelatedInstanceNodes\",\n relationshipPaths: [\n [\n {\n relationship: {\n schemaName: \"BisCore\",\n className: \"ModelContainsElements\",\n },\n direction: \"Forward\",\n targetClass: elementClassSpecification,\n },\n {\n relationship: {\n schemaName: \"BisCore\",\n className: \"GeometricElement3dIsInCategory\",\n },\n direction: \"Forward\",\n },\n ],\n ],\n instanceFilter: `NOT this.IsPrivate`,\n suppressSimilarAncestorsCheck: true,\n hideIfNoChildren: true,\n groupByClass: false,\n groupByLabel: false,\n },\n ],\n customizationRules: [\n {\n ruleType: \"ExtendedData\",\n items: {\n isCategory: \"true\",\n modelId: \"ParentNode.InstanceId\",\n },\n },\n ],\n },\n {\n ruleType: \"ChildNodes\",\n condition: `ParentNode.IsOfClass(\"SpatialCategory\", \"BisCore\")`,\n specifications: [\n {\n specType: \"RelatedInstanceNodes\",\n relationshipPaths: [\n {\n relationship: {\n schemaName: \"BisCore\",\n className: \"GeometricElement3dIsInCategory\",\n },\n direction: \"Backward\",\n targetClass: elementClassSpecification,\n },\n ],\n instanceFilter: `this.Model.Id = parent.parent.ECInstanceId ANDALSO this.Parent = NULL`,\n groupByClass: !!props.enableElementsClassGrouping,\n groupByLabel: false,\n },\n ],\n customizationRules: [\n {\n ruleType: \"ExtendedData\",\n items: {\n modelId: \"this.Model.Id\",\n categoryId: \"this.Category.Id\",\n },\n },\n ],\n },\n {\n ruleType: \"ChildNodes\",\n condition: `ParentNode.IsOfClass(\"GeometricElement3d\", \"BisCore\")`,\n specifications: [\n {\n specType: \"RelatedInstanceNodes\",\n relationshipPaths: [\n {\n relationship: {\n schemaName: \"BisCore\",\n className: \"ElementOwnsChildElements\",\n },\n direction: \"Forward\",\n targetClass: elementClassSpecification,\n },\n ],\n groupByClass: !!props.enableElementsClassGrouping,\n groupByLabel: false,\n },\n ],\n customizationRules: [\n {\n ruleType: \"ExtendedData\",\n items: {\n modelId: \"this.Model.Id\",\n categoryId: \"this.Category.Id\",\n },\n },\n ],\n },\n {\n ruleType: \"Grouping\",\n class: {\n schemaName: \"BisCore\",\n className: \"Subject\",\n },\n groups: [\n {\n specType: \"SameLabelInstance\",\n applicationStage: \"PostProcess\",\n },\n ],\n },\n {\n ruleType: \"Grouping\",\n class: {\n schemaName: \"BisCore\",\n className: \"SpatialCategory\",\n },\n groups: [\n {\n specType: \"SameLabelInstance\",\n applicationStage: \"PostProcess\",\n },\n ],\n },\n {\n ruleType: \"ImageIdOverride\",\n condition: `ThisNode.IsInstanceNode ANDALSO ThisNode.IsOfClass(\"Subject\", \"BisCore\")`,\n imageIdExpression: `IIF(this.Parent.Id = NULL, \"icon-imodel-hollow-2\", \"icon-folder\")`,\n },\n {\n ruleType: \"ImageIdOverride\",\n condition: `ThisNode.IsInstanceNode ANDALSO ThisNode.IsOfClass(\"Model\", \"BisCore\")`,\n imageIdExpression: `\"icon-model\"`,\n },\n {\n ruleType: \"ImageIdOverride\",\n condition: `ThisNode.IsInstanceNode ANDALSO ThisNode.IsOfClass(\"Category\", \"BisCore\")`,\n imageIdExpression: `\"icon-layers\"`,\n },\n {\n ruleType: \"ImageIdOverride\",\n condition: `ThisNode.IsInstanceNode ANDALSO ThisNode.IsOfClass(\"Element\", \"BisCore\")`,\n imageIdExpression: `\"icon-item\"`,\n },\n {\n ruleType: \"ImageIdOverride\",\n condition: `ThisNode.IsClassGroupingNode`,\n imageIdExpression: `\"icon-ec-class\"`,\n },\n {\n ruleType: \"Content\",\n condition: `ContentDisplayType = \"AssemblyElementsRequest\"`,\n specifications: [\n {\n specType: \"SelectedNodeInstances\",\n },\n {\n specType: \"ContentRelatedInstances\",\n relationshipPaths: [\n {\n relationship: {\n schemaName: \"BisCore\",\n className: \"ElementOwnsChildElements\",\n },\n direction: \"Forward\",\n count: \"*\",\n },\n ],\n },\n ],\n },\n ],\n };\n}\n\n/** @internal */\nexport type CreateSearchRulesetProps = Omit<ModelsTreeHierarchyConfiguration, \"enableElementsClassGrouping\">;\n\n/** @internal */\nexport function createSearchRuleset(props: CreateSearchRulesetProps): Ruleset {\n const elementClassSpecification = props.elementClassSpecification ?? { schemaName: \"BisCore\", className: \"GeometricElement3d\" };\n return {\n id: \"tree-widget-react/ModelsTreeSearch\",\n rules: [\n {\n ruleType: \"RootNodes\",\n specifications: [\n {\n specType: \"InstanceNodesOfSpecificClasses\",\n classes: [\n {\n schemaName: \"BisCore\",\n classNames: [\n \"Subject\",\n ],\n },\n ],\n instanceFilter: \"this.Parent = NULL\",\n arePolymorphic: false,\n groupByClass: false,\n groupByLabel: false,\n },\n ],\n customizationRules: [\n {\n ruleType: \"ExtendedData\",\n items: {\n isSubject: \"true\",\n },\n },\n ],\n },\n {\n ruleType: \"ChildNodes\",\n condition: `ParentNode.IsOfClass(\"Subject\", \"BisCore\")`,\n specifications: [\n {\n specType: \"RelatedInstanceNodes\",\n relationshipPaths: [\n {\n relationship: {\n schemaName: \"BisCore\",\n className: \"SubjectOwnsSubjects\",\n },\n direction: \"Forward\",\n targetClass: {\n schemaName: \"BisCore\",\n className: \"Subject\",\n },\n },\n ],\n instanceFilter: `json_extract(this.JsonProperties, \"$.Subject.Job.Bridge\") <> NULL OR ifnull(json_extract(this.JsonProperties, \"$.Subject.Model.Type\"), \"\") = \"Hierarchy\"`,\n hideNodesInHierarchy: true,\n groupByClass: false,\n groupByLabel: false,\n },\n {\n specType: \"RelatedInstanceNodes\",\n relationshipPaths: [\n {\n relationship: {\n schemaName: \"BisCore\",\n className: \"SubjectOwnsSubjects\",\n },\n direction: \"Forward\",\n targetClass: {\n schemaName: \"BisCore\",\n className: \"Subject\",\n },\n },\n ],\n instanceFilter: `json_extract(this.JsonProperties, \"$.Subject.Job.Bridge\") = NULL AND ifnull(json_extract(this.JsonProperties, \"$.Subject.Model.Type\"), \"\") <> \"Hierarchy\"`,\n hideExpression: `NOT ThisNode.HasChildren ANDALSO NOT ThisNode.ChildrenArtifacts.AnyMatches(x => x.isContentModel)`,\n groupByClass: false,\n groupByLabel: false,\n },\n ],\n customizationRules: [\n {\n ruleType: \"ExtendedData\",\n items: {\n isSubject: \"true\",\n },\n },\n {\n ruleType: \"Grouping\",\n class: {\n schemaName: \"BisCore\",\n className: \"Subject\",\n },\n groups: [\n {\n specType: \"SameLabelInstance\",\n applicationStage: \"PostProcess\",\n },\n ],\n },\n ],\n },\n {\n ruleType: \"ChildNodes\",\n condition: `ParentNode.IsOfClass(\"Subject\", \"BisCore\")`,\n specifications: [\n {\n specType: \"InstanceNodesOfSpecificClasses\",\n classes: {\n schemaName: \"BisCore\",\n classNames: [\n \"GeometricModel3d\",\n ],\n },\n arePolymorphic: true,\n relatedInstances: [\n {\n relationshipPath: {\n relationship: {\n schemaName: \"BisCore\",\n className: \"ModelModelsElement\",\n },\n direction: \"Forward\",\n targetClass: {\n schemaName: \"BisCore\",\n className: \"InformationPartitionElement\",\n },\n },\n alias: \"partition\",\n isRequired: true,\n },\n ],\n 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}\")`,\n groupByClass: false,\n groupByLabel: false,\n },\n ],\n customizationRules: [\n {\n ruleType: \"ExtendedData\",\n items: {\n isModel: \"true\",\n },\n },\n ],\n },\n {\n ruleType: \"ChildNodes\",\n condition: `ParentNode.IsOfClass(\"Subject\", \"BisCore\")`,\n specifications: [\n {\n specType: \"InstanceNodesOfSpecificClasses\",\n classes: {\n schemaName: \"BisCore\",\n classNames: [\n \"GeometricModel3d\",\n ],\n },\n arePolymorphic: true,\n relatedInstances: [\n {\n relationshipPath: {\n relationship: {\n schemaName: \"BisCore\",\n className: \"ModelModelsElement\",\n },\n direction: \"Forward\",\n targetClass: {\n schemaName: \"BisCore\",\n className: \"InformationPartitionElement\",\n },\n },\n alias: \"partition\",\n isRequired: true,\n },\n ],\n 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}\")`,\n hideNodesInHierarchy: true,\n groupByClass: false,\n groupByLabel: false,\n },\n ],\n customizationRules: [\n {\n ruleType: \"NodeArtifacts\",\n items: {\n isContentModel: \"true\",\n },\n },\n {\n ruleType: \"ExtendedData\",\n items: {\n isModel: \"true\",\n },\n },\n ],\n },\n {\n ruleType: \"ChildNodes\",\n condition: `ParentNode.IsOfClass(\"GeometricModel3d\", \"BisCore\")`,\n specifications: [\n {\n specType: \"RelatedInstanceNodes\",\n relationshipPaths: [\n {\n relationship: {\n schemaName: \"BisCore\",\n className: \"ModelOwnsSubModel\",\n },\n direction: \"Forward\",\n targetClass: {\n schemaName: \"BisCore\",\n className: \"GeometricModel3d\",\n },\n },\n ],\n instanceFilter: `NOT this.IsPrivate AND this.HasRelatedInstance(\"BisCore:ModelContainsElements\", \"Forward\", \"${elementClassSpecification.schemaName}:${elementClassSpecification.className}\")`,\n groupByClass: false,\n groupByLabel: false,\n },\n ],\n customizationRules: [\n {\n ruleType: \"ExtendedData\",\n items: {\n isModel: \"true\",\n },\n },\n ],\n },\n {\n ruleType: \"ImageIdOverride\",\n condition: `ThisNode.IsOfClass(\"Subject\", \"BisCore\")`,\n imageIdExpression: `IIF(this.Parent.Id = NULL, \"icon-imodel-hollow-2\", \"icon-folder\")`,\n },\n {\n ruleType: \"ImageIdOverride\",\n condition: `ThisNode.IsOfClass(\"Model\", \"BisCore\")`,\n imageIdExpression: `\"icon-model\"`,\n },\n ],\n };\n}\n"]}
1
+ {"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../../../../src/components/trees/models-tree/Utils.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,E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AC9L,YAAY,EAAE,KAAK;wBACnB,YAAY,EAAE,KAAK;qBACpB;iBACF;gBACD,kBAAkB,EAAE;oBAClB;wBACE,QAAQ,EAAE,cAAc;wBACxB,KAAK,EAAE;4BACL,OAAO,EAAE,MAAM;4BACf,IAAI,EAAE,gBAAgB;yBACvB;qBACF;iBACF;aACF;SACF;KACF,CAAC;AACJ,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,2BAA2B,CAAC,IAAsC,EAAE,IAAmB;IACrG,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;IAC9B,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC;IAC/B,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC;AAED,SAAS,OAAO,CAAC,IAAmB;IAClC,OAAO,IAAI,CAAC,GAAG,IAAI,OAAO,CAAC,sBAAsB,CAAC,IAAI,CAAC,GAAG,CAAC;QACzD,CAAC,CAAC,IAAI,CAAC,YAAY,EAAE,SAAS;QAC9B,CAAC,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC;AAC9B,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 { NodeKey } from \"@itwin/presentation-common\";\n\nimport type { Id64String } from \"@itwin/core-bentley\";\nimport type { DelayLoadedTreeNodeItem } from \"@itwin/components-react\";\nimport type { Node, Ruleset } from \"@itwin/presentation-common\";\nimport type { ModelsTreeHierarchyConfiguration } from \"./ModelsTree\";\n\n/** @internal */\nexport class CachingElementIdsContainer {\n private _ids = new Array<Id64String>();\n constructor(private _generator: AsyncGenerator<Id64String>) {\n }\n\n private async next() { return (await this._generator.next()).value; }\n\n public async* getElementIds() {\n for (const id of this._ids) {\n yield id;\n }\n\n let nextId;\n while (nextId = await this.next()) {\n this._ids.push(nextId);\n yield nextId;\n }\n }\n}\n\n/** @internal */\nexport type CreateRulesetProps = Omit<ModelsTreeHierarchyConfiguration, \"enableElementsClassGrouping\"> & {\n enableElementsClassGrouping?: boolean;\n};\n\n/** @internal */\nexport function createRuleset(props: CreateRulesetProps): Ruleset {\n const elementClassSpecification = props.elementClassSpecification ?? { schemaName: \"BisCore\", className: \"GeometricElement3d\" };\n return {\n id: \"tree-widget-react/ModelsTree\",\n requiredSchemas: [\n {\n name: \"BisCore\",\n },\n ],\n rules: [\n {\n ruleType: \"RootNodes\",\n autoExpand: true,\n specifications: [\n {\n specType: \"InstanceNodesOfSpecificClasses\",\n classes: [\n {\n schemaName: \"BisCore\",\n classNames: [\n \"Subject\",\n ],\n },\n ],\n instanceFilter: `this.Parent = NULL`,\n groupByClass: false,\n groupByLabel: false,\n },\n ],\n customizationRules: [\n {\n ruleType: \"ExtendedData\",\n items: {\n isSubject: \"true\",\n icon: \"\\\"icon-imodel-hollow-2\\\"\",\n },\n },\n ],\n },\n {\n ruleType: \"ChildNodes\",\n condition: `ParentNode.IsOfClass(\"Subject\", \"BisCore\")`,\n specifications: [\n {\n specType: \"RelatedInstanceNodes\",\n relationshipPaths: [\n {\n relationship: {\n schemaName: \"BisCore\",\n className: \"SubjectOwnsSubjects\",\n },\n direction: \"Forward\",\n targetClass: {\n schemaName: \"BisCore\",\n className: \"Subject\",\n },\n },\n ],\n instanceFilter: `json_extract(this.JsonProperties, \"$.Subject.Job.Bridge\") <> NULL OR ifnull(json_extract(this.JsonProperties, \"$.Subject.Model.Type\"), \"\") = \"Hierarchy\"`,\n hideNodesInHierarchy: true,\n groupByClass: false,\n groupByLabel: false,\n },\n {\n specType: \"RelatedInstanceNodes\",\n relationshipPaths: [\n {\n relationship: {\n schemaName: \"BisCore\",\n className: \"SubjectOwnsSubjects\",\n },\n direction: \"Forward\",\n targetClass: {\n schemaName: \"BisCore\",\n className: \"Subject\",\n },\n },\n ],\n instanceFilter: `json_extract(this.JsonProperties, \"$.Subject.Job.Bridge\") = NULL AND ifnull(json_extract(this.JsonProperties, \"$.Subject.Model.Type\"), \"\") <> \"Hierarchy\"`,\n hideIfNoChildren: true,\n groupByClass: false,\n groupByLabel: false,\n },\n ],\n customizationRules: [\n {\n ruleType: \"ExtendedData\",\n items: {\n isSubject: \"true\",\n icon: \"\\\"icon-folder\\\"\",\n },\n },\n ],\n },\n {\n ruleType: \"ChildNodes\",\n condition: `ParentNode.IsOfClass(\"Subject\", \"BisCore\")`,\n specifications: [\n {\n specType: \"InstanceNodesOfSpecificClasses\",\n classes: {\n schemaName: \"BisCore\",\n classNames: [\n \"GeometricModel3d\",\n ],\n arePolymorphic: true,\n },\n relatedInstances: [\n {\n relationshipPath: {\n relationship: {\n schemaName: \"BisCore\",\n className: \"ModelModelsElement\",\n },\n direction: \"Forward\",\n targetClass: {\n schemaName: \"BisCore\",\n className: \"InformationPartitionElement\",\n },\n },\n alias: \"partition\",\n isRequired: true,\n },\n ],\n 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}\")`,\n hasChildren: \"Always\",\n hideIfNoChildren: true,\n groupByClass: false,\n groupByLabel: false,\n },\n {\n specType: \"InstanceNodesOfSpecificClasses\",\n classes: {\n schemaName: \"BisCore\",\n classNames: [\n \"GeometricModel3d\",\n ],\n arePolymorphic: true,\n },\n relatedInstances: [\n {\n relationshipPath: {\n relationship: {\n schemaName: \"BisCore\",\n className: \"ModelModelsElement\",\n },\n direction: \"Forward\",\n targetClass: {\n schemaName: \"BisCore\",\n className: \"InformationPartitionElement\",\n },\n },\n alias: \"partition\",\n isRequired: true,\n },\n ],\n 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}\")`,\n hasChildren: \"Always\",\n hideNodesInHierarchy: true,\n groupByClass: false,\n groupByLabel: false,\n },\n ],\n customizationRules: [\n {\n ruleType: \"ExtendedData\",\n items: {\n isModel: \"true\",\n icon: \"\\\"icon-model\\\"\",\n },\n },\n ],\n },\n {\n ruleType: \"ChildNodes\",\n condition: `ParentNode.IsOfClass(\"ISubModeledElement\", \"BisCore\")`,\n specifications: [\n {\n specType: \"RelatedInstanceNodes\",\n relationshipPaths: [\n {\n relationship: {\n schemaName: \"BisCore\",\n className: \"ModelModelsElement\",\n },\n direction: \"Backward\",\n },\n ],\n instanceFilter: `NOT this.IsPrivate AND this.HasRelatedInstance(\"BisCore:ModelContainsElements\", \"Forward\", \"${elementClassSpecification.schemaName}:${elementClassSpecification.className}\")`,\n hideNodesInHierarchy: true,\n groupByClass: false,\n groupByLabel: false,\n },\n ],\n customizationRules: [\n {\n ruleType: \"ExtendedData\",\n items: {\n isModel: \"true\",\n icon: \"\\\"icon-model\\\"\",\n },\n },\n ],\n },\n {\n ruleType: \"ChildNodes\",\n condition: `ParentNode.IsOfClass(\"GeometricModel3d\", \"BisCore\")`,\n specifications: [\n {\n specType: \"RelatedInstanceNodes\",\n relationshipPaths: [\n [\n {\n relationship: {\n schemaName: \"BisCore\",\n className: \"ModelContainsElements\",\n },\n direction: \"Forward\",\n targetClass: elementClassSpecification,\n },\n {\n relationship: {\n schemaName: \"BisCore\",\n className: \"GeometricElement3dIsInCategory\",\n },\n direction: \"Forward\",\n },\n ],\n ],\n instanceFilter: `NOT this.IsPrivate`,\n suppressSimilarAncestorsCheck: true,\n hideIfNoChildren: true,\n groupByClass: false,\n groupByLabel: false,\n },\n ],\n customizationRules: [\n {\n ruleType: \"ExtendedData\",\n items: {\n isCategory: \"true\",\n modelId: \"ParentNode.InstanceId\",\n icon: \"\\\"icon-layers\\\"\",\n },\n },\n ],\n },\n {\n ruleType: \"ChildNodes\",\n condition: `ParentNode.IsOfClass(\"SpatialCategory\", \"BisCore\")`,\n specifications: [\n {\n specType: \"RelatedInstanceNodes\",\n relationshipPaths: [\n {\n relationship: {\n schemaName: \"BisCore\",\n className: \"GeometricElement3dIsInCategory\",\n },\n direction: \"Backward\",\n targetClass: elementClassSpecification,\n },\n ],\n instanceFilter: `this.Model.Id = parent.parent.ECInstanceId ANDALSO this.Parent = NULL`,\n groupByClass: !!props.enableElementsClassGrouping,\n groupByLabel: false,\n },\n ],\n customizationRules: [\n {\n ruleType: \"ExtendedData\",\n items: {\n modelId: \"this.Model.Id\",\n categoryId: \"this.Category.Id\",\n icon: \"\\\"icon-item\\\"\",\n groupIcon: \"\\\"icon-ec-class\\\"\",\n },\n },\n ],\n },\n {\n ruleType: \"ChildNodes\",\n condition: `ParentNode.IsOfClass(\"GeometricElement3d\", \"BisCore\")`,\n specifications: [\n {\n specType: \"RelatedInstanceNodes\",\n relationshipPaths: [\n {\n relationship: {\n schemaName: \"BisCore\",\n className: \"ElementOwnsChildElements\",\n },\n direction: \"Forward\",\n targetClass: elementClassSpecification,\n },\n ],\n groupByClass: !!props.enableElementsClassGrouping,\n groupByLabel: false,\n },\n ],\n customizationRules: [\n {\n ruleType: \"ExtendedData\",\n items: {\n modelId: \"this.Model.Id\",\n categoryId: \"this.Category.Id\",\n icon: \"\\\"icon-item\\\"\",\n groupIcon: \"\\\"icon-ec-class\\\"\",\n },\n },\n ],\n },\n {\n ruleType: \"Grouping\",\n class: {\n schemaName: \"BisCore\",\n className: \"Subject\",\n },\n groups: [\n {\n specType: \"SameLabelInstance\",\n applicationStage: \"PostProcess\",\n },\n ],\n },\n {\n ruleType: \"Grouping\",\n class: {\n schemaName: \"BisCore\",\n className: \"SpatialCategory\",\n },\n groups: [\n {\n specType: \"SameLabelInstance\",\n applicationStage: \"PostProcess\",\n },\n ],\n },\n {\n ruleType: \"Content\",\n condition: `ContentDisplayType = \"AssemblyElementsRequest\"`,\n specifications: [\n {\n specType: \"SelectedNodeInstances\",\n },\n {\n specType: \"ContentRelatedInstances\",\n relationshipPaths: [\n {\n relationship: {\n schemaName: \"BisCore\",\n className: \"ElementOwnsChildElements\",\n },\n direction: \"Forward\",\n count: \"*\",\n },\n ],\n },\n ],\n },\n ],\n };\n}\n\n/** @internal */\nexport type CreateSearchRulesetProps = Omit<ModelsTreeHierarchyConfiguration, \"enableElementsClassGrouping\">;\n\n/** @internal */\nexport function createSearchRuleset(props: CreateSearchRulesetProps): Ruleset {\n const elementClassSpecification = props.elementClassSpecification ?? { schemaName: \"BisCore\", className: \"GeometricElement3d\" };\n return {\n id: \"tree-widget-react/ModelsTreeSearch\",\n rules: [\n {\n ruleType: \"RootNodes\",\n specifications: [\n {\n specType: \"InstanceNodesOfSpecificClasses\",\n classes: [\n {\n schemaName: \"BisCore\",\n classNames: [\n \"Subject\",\n ],\n },\n ],\n instanceFilter: \"this.Parent = NULL\",\n arePolymorphic: false,\n groupByClass: false,\n groupByLabel: false,\n },\n ],\n customizationRules: [\n {\n ruleType: \"ExtendedData\",\n items: {\n isSubject: \"true\",\n icon: \"\\\"icon-imodel-hollow-2\\\"\",\n },\n },\n ],\n },\n {\n ruleType: \"ChildNodes\",\n condition: `ParentNode.IsOfClass(\"Subject\", \"BisCore\")`,\n specifications: [\n {\n specType: \"RelatedInstanceNodes\",\n relationshipPaths: [\n {\n relationship: {\n schemaName: \"BisCore\",\n className: \"SubjectOwnsSubjects\",\n },\n direction: \"Forward\",\n targetClass: {\n schemaName: \"BisCore\",\n className: \"Subject\",\n },\n },\n ],\n instanceFilter: `json_extract(this.JsonProperties, \"$.Subject.Job.Bridge\") <> NULL OR ifnull(json_extract(this.JsonProperties, \"$.Subject.Model.Type\"), \"\") = \"Hierarchy\"`,\n hideNodesInHierarchy: true,\n groupByClass: false,\n groupByLabel: false,\n },\n {\n specType: \"RelatedInstanceNodes\",\n relationshipPaths: [\n {\n relationship: {\n schemaName: \"BisCore\",\n className: \"SubjectOwnsSubjects\",\n },\n direction: \"Forward\",\n targetClass: {\n schemaName: \"BisCore\",\n className: \"Subject\",\n },\n },\n ],\n instanceFilter: `json_extract(this.JsonProperties, \"$.Subject.Job.Bridge\") = NULL AND ifnull(json_extract(this.JsonProperties, \"$.Subject.Model.Type\"), \"\") <> \"Hierarchy\"`,\n hideExpression: `NOT ThisNode.HasChildren ANDALSO NOT ThisNode.ChildrenArtifacts.AnyMatches(x => x.isContentModel)`,\n groupByClass: false,\n groupByLabel: false,\n },\n ],\n customizationRules: [\n {\n ruleType: \"ExtendedData\",\n items: {\n isSubject: \"true\",\n icon: \"\\\"icon-folder\\\"\",\n },\n },\n {\n ruleType: \"Grouping\",\n class: {\n schemaName: \"BisCore\",\n className: \"Subject\",\n },\n groups: [\n {\n specType: \"SameLabelInstance\",\n applicationStage: \"PostProcess\",\n },\n ],\n },\n ],\n },\n {\n ruleType: \"ChildNodes\",\n condition: `ParentNode.IsOfClass(\"Subject\", \"BisCore\")`,\n specifications: [\n {\n specType: \"InstanceNodesOfSpecificClasses\",\n classes: {\n schemaName: \"BisCore\",\n classNames: [\n \"GeometricModel3d\",\n ],\n },\n arePolymorphic: true,\n relatedInstances: [\n {\n relationshipPath: {\n relationship: {\n schemaName: \"BisCore\",\n className: \"ModelModelsElement\",\n },\n direction: \"Forward\",\n targetClass: {\n schemaName: \"BisCore\",\n className: \"InformationPartitionElement\",\n },\n },\n alias: \"partition\",\n isRequired: true,\n },\n ],\n 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}\")`,\n groupByClass: false,\n groupByLabel: false,\n },\n ],\n customizationRules: [\n {\n ruleType: \"ExtendedData\",\n items: {\n isModel: \"true\",\n icon: \"\\\"icon-model\\\"\",\n },\n },\n ],\n },\n {\n ruleType: \"ChildNodes\",\n condition: `ParentNode.IsOfClass(\"Subject\", \"BisCore\")`,\n specifications: [\n {\n specType: \"InstanceNodesOfSpecificClasses\",\n classes: {\n schemaName: \"BisCore\",\n classNames: [\n \"GeometricModel3d\",\n ],\n },\n arePolymorphic: true,\n relatedInstances: [\n {\n relationshipPath: {\n relationship: {\n schemaName: \"BisCore\",\n className: \"ModelModelsElement\",\n },\n direction: \"Forward\",\n targetClass: {\n schemaName: \"BisCore\",\n className: \"InformationPartitionElement\",\n },\n },\n alias: \"partition\",\n isRequired: true,\n },\n ],\n 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}\")`,\n hideNodesInHierarchy: true,\n groupByClass: false,\n groupByLabel: false,\n },\n ],\n customizationRules: [\n {\n ruleType: \"NodeArtifacts\",\n items: {\n isContentModel: \"true\",\n },\n },\n {\n ruleType: \"ExtendedData\",\n items: {\n isModel: \"true\",\n icon: \"\\\"icon-model\\\"\",\n },\n },\n ],\n },\n {\n ruleType: \"ChildNodes\",\n condition: `ParentNode.IsOfClass(\"GeometricModel3d\", \"BisCore\")`,\n specifications: [\n {\n specType: \"RelatedInstanceNodes\",\n relationshipPaths: [\n {\n relationship: {\n schemaName: \"BisCore\",\n className: \"ModelOwnsSubModel\",\n },\n direction: \"Forward\",\n targetClass: {\n schemaName: \"BisCore\",\n className: \"GeometricModel3d\",\n },\n },\n ],\n instanceFilter: `NOT this.IsPrivate AND this.HasRelatedInstance(\"BisCore:ModelContainsElements\", \"Forward\", \"${elementClassSpecification.schemaName}:${elementClassSpecification.className}\")`,\n groupByClass: false,\n groupByLabel: false,\n },\n ],\n customizationRules: [\n {\n ruleType: \"ExtendedData\",\n items: {\n isModel: \"true\",\n icon: \"\\\"icon-model\\\"\",\n },\n },\n ],\n },\n ],\n };\n}\n\n/** @internal */\nexport function customizeModelsTreeNodeItem(item: Partial<DelayLoadedTreeNodeItem>, node: Partial<Node>) {\n item.isCheckboxVisible = true;\n item.isCheckboxDisabled = true;\n item.icon = getIcon(node);\n}\n\nfunction getIcon(node: Partial<Node>) {\n return node.key && NodeKey.isClassGroupingNodeKey(node.key)\n ? node.extendedData?.groupIcon\n : node.extendedData?.icon;\n}\n"]}
@@ -0,0 +1,19 @@
1
+ /// <reference types="react" />
2
+ /**
3
+ * Allows to persist tree scroll position when tree is used in `@itwin/appui-react` Widgets.
4
+ * Returned `ref` should be passed to container element containing tree component.
5
+ *
6
+ * Example:
7
+ * ```typescript
8
+ * function ModelsTreeWidget() {
9
+ * const ref = useTreeTransientState<HTMLDivElement>();
10
+ * return <div ref={ref}>
11
+ * <ModelsTree />
12
+ * </div>
13
+ * }
14
+ * ```
15
+ *
16
+ * @public
17
+ */
18
+ export declare function useTreeTransientState<T extends Element>(): import("react").Ref<T>;
19
+ //# sourceMappingURL=UseTreeTransientState.d.ts.map
@@ -0,0 +1,29 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ import { useTransientState } from "@itwin/appui-react";
6
+ import { useControlledTreeLayoutStorage } from "@itwin/components-react";
7
+ // istanbul ignore file
8
+ /**
9
+ * Allows to persist tree scroll position when tree is used in `@itwin/appui-react` Widgets.
10
+ * Returned `ref` should be passed to container element containing tree component.
11
+ *
12
+ * Example:
13
+ * ```typescript
14
+ * function ModelsTreeWidget() {
15
+ * const ref = useTreeTransientState<HTMLDivElement>();
16
+ * return <div ref={ref}>
17
+ * <ModelsTree />
18
+ * </div>
19
+ * }
20
+ * ```
21
+ *
22
+ * @public
23
+ */
24
+ export function useTreeTransientState() {
25
+ const { ref, persist, restore } = useControlledTreeLayoutStorage();
26
+ useTransientState(persist, restore);
27
+ return ref;
28
+ }
29
+ //# sourceMappingURL=UseTreeTransientState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UseTreeTransientState.js","sourceRoot":"","sources":["../../../../src/components/utils/UseTreeTransientState.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,8BAA8B,EAAE,MAAM,yBAAyB,CAAC;AAEzE,uBAAuB;AAEvB;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,qBAAqB;IACnC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,8BAA8B,EAAK,CAAC;IACtE,iBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACpC,OAAO,GAAG,CAAC;AACb,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 { useTransientState } from \"@itwin/appui-react\";\nimport { useControlledTreeLayoutStorage } from \"@itwin/components-react\";\n\n// istanbul ignore file\n\n/**\n * Allows to persist tree scroll position when tree is used in `@itwin/appui-react` Widgets.\n * Returned `ref` should be passed to container element containing tree component.\n *\n * Example:\n * ```typescript\n * function ModelsTreeWidget() {\n * const ref = useTreeTransientState<HTMLDivElement>();\n * return <div ref={ref}>\n * <ModelsTree />\n * </div>\n * }\n * ```\n *\n * @public\n */\nexport function useTreeTransientState<T extends Element>() {\n const { ref, persist, restore } = useControlledTreeLayoutStorage<T>();\n useTransientState(persist, restore);\n return ref;\n}\n"]}
@@ -1,5 +1,6 @@
1
1
  export * from "./TreeWidget";
2
- export * from "./components/TreeWidgetComponent";
2
+ export * from "./components/SelectableTree";
3
3
  export * from "./components/trees";
4
4
  export * from "./components/TreeWidgetUiItemsProvider";
5
+ export * from "./components/utils/UseTreeTransientState";
5
6
  //# sourceMappingURL=tree-widget-react.d.ts.map
@@ -3,7 +3,8 @@
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
  export * from "./TreeWidget";
6
- export * from "./components/TreeWidgetComponent";
6
+ export * from "./components/SelectableTree";
7
7
  export * from "./components/trees";
8
8
  export * from "./components/TreeWidgetUiItemsProvider";
9
+ export * from "./components/utils/UseTreeTransientState";
9
10
  //# sourceMappingURL=tree-widget-react.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tree-widget-react.js","sourceRoot":"","sources":["../../src/tree-widget-react.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,cAAc,cAAc,CAAC;AAC7B,cAAc,kCAAkC,CAAC;AACjD,cAAc,oBAAoB,CAAC;AACnC,cAAc,wCAAwC,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\nexport * from \"./TreeWidget\";\nexport * from \"./components/TreeWidgetComponent\";\nexport * from \"./components/trees\";\nexport * from \"./components/TreeWidgetUiItemsProvider\";\n"]}
1
+ {"version":3,"file":"tree-widget-react.js","sourceRoot":"","sources":["../../src/tree-widget-react.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,cAAc,cAAc,CAAC;AAC7B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oBAAoB,CAAC;AACnC,cAAc,wCAAwC,CAAC;AACvD,cAAc,0CAA0C,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\nexport * from \"./TreeWidget\";\nexport * from \"./components/SelectableTree\";\nexport * from \"./components/trees\";\nexport * from \"./components/TreeWidgetUiItemsProvider\";\nexport * from \"./components/utils/UseTreeTransientState\";\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/tree-widget-react",
3
- "version": "1.0.0-dev.3",
3
+ "version": "1.0.0-dev.4",
4
4
  "description": "Tree Widget React",
5
5
  "keywords": [
6
6
  "Bentley",
@@ -31,10 +31,10 @@
31
31
  },
32
32
  "devDependencies": {
33
33
  "@itwin/appui-abstract": "^4.0.0",
34
- "@itwin/appui-layout-react": "^4.1.0",
35
- "@itwin/appui-react": "^4.1.0",
34
+ "@itwin/appui-layout-react": "^4.3.0",
35
+ "@itwin/appui-react": "^4.3.0",
36
36
  "@itwin/build-tools": "^4.0.0",
37
- "@itwin/components-react": "^4.1.0",
37
+ "@itwin/components-react": "^4.3.0",
38
38
  "@itwin/core-backend": "^4.0.0",
39
39
  "@itwin/core-bentley": "^4.0.0",
40
40
  "@itwin/core-common": "^4.0.0",
@@ -44,11 +44,11 @@
44
44
  "@itwin/core-markup": "^4.0.0",
45
45
  "@itwin/core-orbitgt": "^4.0.0",
46
46
  "@itwin/core-quantity": "^4.0.0",
47
- "@itwin/core-react": "^4.1.0",
47
+ "@itwin/core-react": "^4.3.0",
48
48
  "@itwin/core-telemetry": "^4.0.0",
49
49
  "@itwin/ecschema-metadata": "^4.0.0",
50
50
  "@itwin/eslint-plugin": "^4.0.0-dev.38",
51
- "@itwin/imodel-components-react": "^4.1.0",
51
+ "@itwin/imodel-components-react": "^4.3.0",
52
52
  "@itwin/presentation-backend": "^4.0.0",
53
53
  "@itwin/presentation-common": "^4.0.0",
54
54
  "@itwin/presentation-components": "^4.0.0",
@@ -98,10 +98,10 @@
98
98
  },
99
99
  "peerDependencies": {
100
100
  "@itwin/appui-abstract": "^4.0.0",
101
- "@itwin/appui-react": "^4.0.0",
102
- "@itwin/components-react": "^4.0.0",
101
+ "@itwin/appui-react": "^4.3.0",
102
+ "@itwin/components-react": "^4.3.0",
103
103
  "@itwin/core-frontend": "^4.0.0",
104
- "@itwin/core-react": "^4.0.0",
104
+ "@itwin/core-react": "^4.3.0",
105
105
  "@itwin/presentation-components": "^4.0.0",
106
106
  "react": "^17.0.0",
107
107
  "react-dom": "^17.0.0"
@@ -129,5 +129,5 @@
129
129
  "clean": "rimraf lib .rush/temp/package-deps*.json",
130
130
  "rebuild": "npm run clean && npm run build"
131
131
  },
132
- "readme": "# @itwin/tree-widget-react\n\nCopyright © Bentley Systems, Incorporated. All rights reserved.\n\nThe `@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.\n\n![Widget example](./media/widget.png)\n\n## Usage\n\nTypically, 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.\n\nIn any case, **before** using any APIs or components delivered with the package, it needs to be initialized:\n\n```ts\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { TreeWidget } from \"@itwin/tree-widget-react\";\n...\nawait TreeWidget.initialize(IModelApp.localization);\n```\n\nIn [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:\n\n```ts\nimport { UiItemsManager } from \"@itwin/appui-react\";\nimport { TreeWidgetUiItemsProvider } from \"@itwin/tree-widget-react\";\n...\nUiItemsManager.register(\n new TreeWidgetUiItemsProvider()\n);\n```\n\nThe 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:\n\n```ts\nimport { UiItemsManager } from \"@itwin/appui-react\";\nimport { TreeWidgetUiItemsProvider, ModelsTreeComponent } from \"@itwin/tree-widget-react\";\n...\nUiItemsManager.register(\n new TreeWidgetUiItemsProvider({\n // defaults to `StagePanelLocation.Right`\n defaultPanelLocation: StagePanelLocation.Left,\n // defaults to `StagePanelSection.Start`\n defaultPanelSection: StagePanelSection.End,\n // defaults to whatever the default `Widget.priority` in AppUI is\n defaultTreeWidgetPriority: 1000,\n // defaults to `ModelsTreeComponent` and `CategoriesTreeComponent`\n trees: [{\n id: ModelsTreeComponent.id,\n getLabel: ModelsTreeComponent.getLabel,\n render: () => <ModelsTreeComponent />,\n }, {\n id: \"my-tree-id\",\n getLabel: \"My Custom Tree\",\n render: () => <>This is my custom tree.</>,\n }];\n })\n);\n```\n\nAs 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.\n\n## Components\n\nWhile 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:\n\n- `TreeWidgetComponent` renders a tree selector and selected tree (based on the `trees` prop).\n\n- 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.\n\n - `createVisibilityTreeRenderer` returns a tree renderer that renders nodes with \"eye\" checkboxes. Its building blocks:\n - `createVisibilityTreeNodeRenderer`\n - `VisibilityTreeNodeCheckbox`\n - `useVisibilityTreeFiltering` is used to filter the hierarchy.\n - `VisibilityTreeNoFilteredData` is used to render a \"no results\" when filtering.\n - `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.\n\n### Models tree\n\nThe 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.\n\n![Models tree example](./media/models-tree.png)\n\nTypical usage:\n\n```tsx\nimport { ModelsTreeComponent, ClassGroupingOption } from \"@itwin/tree-widget-react\";\nimport { SelectionMode } from \"@itwin/components-react\";\n...\nfunction MyWidget() {\n return (\n <ModelsTreeComponent\n headerButtons={[\n (props) => <ModelsTreeComponent.ShowAllButton {...props} />,\n (props) => <ModelsTreeComponent.HideAllButton {...props} />,\n (props) => <MyCustomButton />,\n ]}\n selectionMode={SelectionMode.Extended}\n hierarchyConfig={{\n enableElementsClassGrouping: ClassGroupingOption.Yes,\n }}\n />\n );\n}\n```\n\nAvailable header buttons:\n\n- `ModelsTreeComponent.ShowAllButton` makes everything in the iModel displayed.\n- `ModelsTreeComponent.HideAllButton` makes everything in the iModel hidden by turning off all models.\n- `ModelsTreeComponent.InvertButton` inverts display of all models.\n- `ModelsTreeComponent.View2DButton` toggles plan projection models' display.\n- `ModelsTreeComponent.View3DButton` toggles non-plan projection models' display.\n\n`ModelsTreeComponent` building blocks:\n\n- `ModelsTree` renders the tree without the header.\n- `ModelsVisibilityHandler` knows how to get and control display of various concepts displayed in the Models tree: Subjects, Models, Categories, Elements.\n\n### Categories tree\n\nThe 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.\n\n![Categories tree example](./media/categories-tree.png)\n\nTypical usage:\n\n```tsx\nimport { CategoriesTreeComponent } from \"@itwin/tree-widget-react\";\n...\nfunction MyWidget() {\n return (\n <CategoriesTreeComponent\n headerButtons={[\n (props) => <CategoriesTreeComponent.ShowAllButton {...props} />,\n (props) => <CategoriesTreeComponent.HideAllButton {...props} />,\n (props) => <MyCustomButton />,\n ]}\n />\n );\n}\n```\n\nAvailable header buttons:\n\n- `ModelsTreeComponent.ShowAllButton` makes all categories and their subcategories displayed.\n- `ModelsTreeComponent.HideAllButton` makes all categories hidden.\n- `ModelsTreeComponent.InvertButton` inverts display of all categories.\n\n`CategoriesTreeComponent` building blocks:\n\n- `CategoryTree` renders the tree without the header.\n- `CategoryVisibilityHandler` knows how to get and control display of Categories and SubCategories.\n\n### IModel content tree\n\nThe component renders a similar hierarchy to [Models tree](#models-tree), but with the following changes:\n\n- Only the hierarchy, without a header is rendered.\n- Visibility control is not allowed.\n- There's less hiding of `Subject` and `Model` nodes.\n- Show not only geometric, but all Models.\n\nIn general, the component is expected to be used by advanced users to inspect contents of the iModel.\n\n![IModel content tree example](./media/imodel-content-tree.png)\n\nTypical usage:\n\n```tsx\nimport { IModelContentTreeComponent } from \"@itwin/tree-widget-react\";\n...\nfunction MyWidget() {\n return (\n <IModelContentTreeComponent />\n );\n}\n```\n"
132
+ "readme": "# @itwin/tree-widget-react\n\nCopyright © Bentley Systems, Incorporated. All rights reserved.\n\nThe `@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.\n\n![Widget example](./media/widget.png)\n\n## Usage\n\nTypically, 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.\n\nIn any case, **before** using any APIs or components delivered with the package, it needs to be initialized:\n\n```ts\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { TreeWidget } from \"@itwin/tree-widget-react\";\n...\nawait TreeWidget.initialize(IModelApp.localization);\n```\n\nIn [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:\n\n```ts\nimport { UiItemsManager } from \"@itwin/appui-react\";\nimport { TreeWidgetUiItemsProvider } from \"@itwin/tree-widget-react\";\n...\nUiItemsManager.register(\n new TreeWidgetUiItemsProvider()\n);\n```\n\nThe 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:\n\n```ts\nimport { UiItemsManager } from \"@itwin/appui-react\";\nimport { TreeWidgetUiItemsProvider, ModelsTreeComponent } from \"@itwin/tree-widget-react\";\n...\nUiItemsManager.register(\n new TreeWidgetUiItemsProvider({\n // defaults to `StagePanelLocation.Right`\n defaultPanelLocation: StagePanelLocation.Left,\n // defaults to `StagePanelSection.Start`\n defaultPanelSection: StagePanelSection.End,\n // defaults to whatever the default `Widget.priority` in AppUI is\n defaultTreeWidgetPriority: 1000,\n // defaults to `ModelsTreeComponent` and `CategoriesTreeComponent`\n trees: [{\n id: ModelsTreeComponent.id,\n getLabel: ModelsTreeComponent.getLabel,\n render: () => <ModelsTreeComponent />,\n }, {\n id: \"my-tree-id\",\n getLabel: \"My Custom Tree\",\n render: () => <>This is my custom tree.</>,\n }];\n })\n);\n```\n\nAs 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.\n\n## Components\n\nWhile 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:\n\n- `SelectableTree` renders a tree selector and selected tree (based on the `trees` prop).\n\n- 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.\n\n - `createVisibilityTreeRenderer` returns a tree renderer that renders nodes with \"eye\" checkboxes. Its building blocks:\n - `createVisibilityTreeNodeRenderer`\n - `VisibilityTreeNodeCheckbox`\n - `useVisibilityTreeFiltering` is used to filter the hierarchy.\n - `VisibilityTreeNoFilteredData` is used to render a \"no results\" when filtering.\n - `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.\n - `useTreeTransientState` is used to persist tree scroll position when tree is used in [AppUI](https://github.com/iTwin/appui/tree/master/ui/appui-react) widget.\n\n### Models tree\n\nThe 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.\n\n![Models tree example](./media/models-tree.png)\n\nTypical usage:\n\n```tsx\nimport { ModelsTreeComponent, ClassGroupingOption } from \"@itwin/tree-widget-react\";\nimport { SelectionMode } from \"@itwin/components-react\";\n...\nfunction MyWidget() {\n return (\n <ModelsTreeComponent\n headerButtons={[\n (props) => <ModelsTreeComponent.ShowAllButton {...props} />,\n (props) => <ModelsTreeComponent.HideAllButton {...props} />,\n (props) => <MyCustomButton />,\n ]}\n selectionMode={SelectionMode.Extended}\n hierarchyConfig={{\n enableElementsClassGrouping: ClassGroupingOption.Yes,\n }}\n />\n );\n}\n```\n\nAvailable header buttons:\n\n- `ModelsTreeComponent.ShowAllButton` makes everything in the iModel displayed.\n- `ModelsTreeComponent.HideAllButton` makes everything in the iModel hidden by turning off all models.\n- `ModelsTreeComponent.InvertButton` inverts display of all models.\n- `ModelsTreeComponent.View2DButton` toggles plan projection models' display.\n- `ModelsTreeComponent.View3DButton` toggles non-plan projection models' display.\n\n`ModelsTreeComponent` building blocks:\n\n- `ModelsTree` renders the tree without the header.\n- `ModelsVisibilityHandler` knows how to get and control display of various concepts displayed in the Models tree: Subjects, Models, Categories, Elements.\n\n### Categories tree\n\nThe 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.\n\n![Categories tree example](./media/categories-tree.png)\n\nTypical usage:\n\n```tsx\nimport { CategoriesTreeComponent } from \"@itwin/tree-widget-react\";\n...\nfunction MyWidget() {\n return (\n <CategoriesTreeComponent\n headerButtons={[\n (props) => <CategoriesTreeComponent.ShowAllButton {...props} />,\n (props) => <CategoriesTreeComponent.HideAllButton {...props} />,\n (props) => <MyCustomButton />,\n ]}\n />\n );\n}\n```\n\nAvailable header buttons:\n\n- `ModelsTreeComponent.ShowAllButton` makes all categories and their subcategories displayed.\n- `ModelsTreeComponent.HideAllButton` makes all categories hidden.\n- `ModelsTreeComponent.InvertButton` inverts display of all categories.\n\n`CategoriesTreeComponent` building blocks:\n\n- `CategoryTree` renders the tree without the header.\n- `CategoryVisibilityHandler` knows how to get and control display of Categories and SubCategories.\n\n### IModel content tree\n\nThe component renders a similar hierarchy to [Models tree](#models-tree), but with the following changes:\n\n- Only the hierarchy, without a header is rendered.\n- Visibility control is not allowed.\n- There's less hiding of `Subject` and `Model` nodes.\n- Show not only geometric, but all Models.\n\nIn general, the component is expected to be used by advanced users to inspect contents of the iModel.\n\n![IModel content tree example](./media/imodel-content-tree.png)\n\nTypical usage:\n\n```tsx\nimport { IModelContentTreeComponent } from \"@itwin/tree-widget-react\";\n...\nfunction MyWidget() {\n return (\n <IModelContentTreeComponent />\n );\n}\n```\n"
133
133
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"TreeWidgetComponent.js","sourceRoot":"","sources":["../../../src/components/TreeWidgetComponent.tsx"],"names":[],"mappings":";;;;AAAA;;;+FAG+F;AAE/F,sCAAoC;AACpC,iCAA4C;AAC5C,oDAA+D;AAC/D,8DAA4D;AAC5D,kDAAiD;AACjD,wDAAsD;AACtD,8CAA2C;AAgC3C;;;GAGG;AACH,SAAgB,mBAAmB,CAAC,KAA+B;IACjE,MAAM,MAAM,GAAG,IAAA,uCAAyB,GAAE,CAAC;IAE3C,IAAI,CAAC,MAAM;QACT,OAAO,IAAI,CAAC;IAEd,OAAO,uBAAC,0BAA0B,OAAK,KAAK,EAAE,MAAM,EAAE,MAAM,GAAI,CAAC;AACnE,CAAC;AAPD,kDAOC;AAED,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,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;QACvD,OAAO,GAAG,EAAE,GAAG,YAAY,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACrC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,IAAI,CAAC;KACb;IAED,OAAO,2DAAG,QAAQ,GAAI,CAAC;AACzB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport \"./TreeWidgetComponent.scss\";\nimport { useEffect, useState } from \"react\";\nimport { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport { SelectableContent } from \"@itwin/components-react\";\nimport { FillCentered } from \"@itwin/core-react\";\nimport { ProgressLinear } from \"@itwin/itwinui-react\";\nimport { TreeWidget } from \"../TreeWidget\";\n\nimport type { PropsWithChildren } from \"react\";\nimport type { SelectableContentDefinition, SelectableContentProps } from \"@itwin/components-react\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\n\n/**\n * Definition of a tree component displayed in [[TreeWidgetComponent]]\n * @public\n */\nexport interface TreeDefinition {\n /** Id of the tree */\n id: string;\n /** Callback that is used to get tree label */\n getLabel: () => string;\n /** Callback that is used to render tree component */\n render: () => React.ReactNode;\n /**\n * Callback that is used to determine if tree should be shown for current active iModel connection.\n * If callback is `undefined` tree is shown for all iModel connections.\n */\n shouldShow?: (imodel: IModelConnection) => Promise<boolean>;\n}\n\n/**\n * Props for [[TreeWidgetComponent]]\n * @public\n */\nexport interface TreeWidgetComponentProps {\n trees: TreeDefinition[];\n}\n\n/**\n * A component that renders a tree (combo box) selector and the selected tree component.\n * @public\n */\nexport function TreeWidgetComponent(props: TreeWidgetComponentProps) {\n const imodel = useActiveIModelConnection();\n\n if (!imodel)\n return null;\n\n return <TreeWidgetComponentContent {...props} imodel={imodel} />;\n}\n\nfunction TreeWidgetComponentContent(props: TreeWidgetComponentProps & { imodel: IModelConnection}) {\n const { trees: treeDefinitions, imodel } = props;\n const trees = useActiveTrees(treeDefinitions, imodel);\n\n return (\n <div className=\"tree-widget-visibility-widget\">\n <SelectableContent {...getSelectableContentProps(trees)} />\n </div>\n );\n}\n\nfunction useActiveTrees(treeDefinitions: TreeDefinition[], imodel: IModelConnection) {\n const [trees, setTrees] = useState<SelectableContentDefinition[]>();\n\n useEffect(() => {\n let disposed = false;\n (async () => {\n const visibleTrees = await getActiveTrees(treeDefinitions, imodel);\n // istanbul ignore else\n if (!disposed) {\n setTrees(visibleTrees);\n }\n })();\n\n return () => { disposed = true; };\n }, [treeDefinitions, imodel]);\n\n return trees;\n}\n\nasync function getActiveTrees(treeDefinitions: TreeDefinition[], imodel: IModelConnection): Promise<SelectableContentDefinition[]> {\n const handleDefinition = async (treeDef: TreeDefinition) => {\n if (treeDef.shouldShow !== undefined && !(await treeDef.shouldShow(imodel))) {\n return undefined;\n }\n return {\n id: treeDef.id,\n label: treeDef.getLabel(),\n render: treeDef.render,\n };\n };\n\n return (await Promise.all(treeDefinitions.map(handleDefinition))).filter((tree) => tree !== undefined) as SelectableContentDefinition[];\n}\n\nfunction getSelectableContentProps(trees?: SelectableContentDefinition[]): SelectableContentProps {\n if (trees === undefined) {\n return {\n defaultSelectedContentId: \"loading\",\n children: [{\n id: \"loading\",\n label: \"\",\n render: () => (\n <Delayed>\n <ProgressLinear indeterminate={true} />\n </Delayed>\n ),\n }],\n };\n }\n\n if (trees.length === 0) {\n return {\n defaultSelectedContentId: \"no-trees\",\n children: [{\n id: \"no-trees\",\n label: \"\",\n render: () => (\n <FillCentered>\n {TreeWidget.translate(\"noTrees\")}\n </FillCentered>\n ),\n }],\n };\n }\n\n return {\n defaultSelectedContentId: trees[0].id,\n children: trees,\n };\n}\n\nfunction Delayed({ delay = 200, children }: PropsWithChildren<{ delay?: number }>) {\n const [show, setShow] = useState(false);\n\n useEffect(() => {\n const id = setTimeout(() => { setShow(true); }, delay);\n return () => { clearTimeout(id); };\n }, [delay]);\n\n if (!show) {\n return null;\n }\n\n return <>{children}</>;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"TreeWidgetComponent.js","sourceRoot":"","sources":["../../../src/components/TreeWidgetComponent.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAE/F,OAAO,4BAA4B,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAgC3C;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAA+B;IACjE,MAAM,MAAM,GAAG,yBAAyB,EAAE,CAAC;IAE3C,IAAI,CAAC,MAAM;QACT,OAAO,IAAI,CAAC;IAEd,OAAO,KAAC,0BAA0B,OAAK,KAAK,EAAE,MAAM,EAAE,MAAM,GAAI,CAAC;AACnE,CAAC;AAED,SAAS,0BAA0B,CAAC,KAA6D;IAC/F,MAAM,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;IACjD,MAAM,KAAK,GAAG,cAAc,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;IAEtD,OAAO,CACL,cAAK,SAAS,EAAC,+BAA+B,YAC5C,KAAC,iBAAiB,OAAK,yBAAyB,CAAC,KAAK,CAAC,GAAI,GACvD,CACP,CAAC;AACJ,CAAC;AAED,SAAS,cAAc,CAAC,eAAiC,EAAE,MAAwB;IACjF,MAAM,CAAC,KAAK,EAAE,QAA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,EAAE,SAAS;oBACb,KAAK,EAAE,EAAE;oBACT,MAAM,EAAE,GAAG,EAAE,CAAC,CACZ,KAAC,OAAO,cACN,KAAC,cAAc,IAAC,aAAa,EAAE,IAAI,GAAI,GAC/B,CACX;iBACF,CAAC;SACH,CAAC;KACH;IAED,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;QACtB,OAAO;YACL,wBAAwB,EAAE,UAAU;YACpC,QAAQ,EAAE,CAAC;oBACT,EAAE,EAAE,UAAU;oBACd,KAAK,EAAE,EAAE;oBACT,MAAM,EAAE,GAAG,EAAE,CAAC,CACZ,KAAC,YAAY,cACV,UAAU,CAAC,SAAS,CAAC,SAAS,CAAC,GACnB,CAChB;iBACF,CAAC;SACH,CAAC;KACH;IAED,OAAO;QACL,wBAAwB,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE;QACrC,QAAQ,EAAE,KAAK;KAChB,CAAC;AACJ,CAAC;AAED,SAAS,OAAO,CAAC,EAAE,KAAK,GAAG,GAAG,EAAE,QAAQ,EAAyC;IAC/E,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAExC,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;QACvD,OAAO,GAAG,EAAE,GAAG,YAAY,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACrC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,IAAI,CAAC;KACb;IAED,OAAO,4BAAG,QAAQ,GAAI,CAAC;AACzB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport \"./TreeWidgetComponent.scss\";\nimport { useEffect, useState } from \"react\";\nimport { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport { SelectableContent } from \"@itwin/components-react\";\nimport { FillCentered } from \"@itwin/core-react\";\nimport { ProgressLinear } from \"@itwin/itwinui-react\";\nimport { TreeWidget } from \"../TreeWidget\";\n\nimport type { PropsWithChildren } from \"react\";\nimport type { SelectableContentDefinition, SelectableContentProps } from \"@itwin/components-react\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\n\n/**\n * Definition of a tree component displayed in [[TreeWidgetComponent]]\n * @public\n */\nexport interface TreeDefinition {\n /** Id of the tree */\n id: string;\n /** Callback that is used to get tree label */\n getLabel: () => string;\n /** Callback that is used to render tree component */\n render: () => React.ReactNode;\n /**\n * Callback that is used to determine if tree should be shown for current active iModel connection.\n * If callback is `undefined` tree is shown for all iModel connections.\n */\n shouldShow?: (imodel: IModelConnection) => Promise<boolean>;\n}\n\n/**\n * Props for [[TreeWidgetComponent]]\n * @public\n */\nexport interface TreeWidgetComponentProps {\n trees: TreeDefinition[];\n}\n\n/**\n * A component that renders a tree (combo box) selector and the selected tree component.\n * @public\n */\nexport function TreeWidgetComponent(props: TreeWidgetComponentProps) {\n const imodel = useActiveIModelConnection();\n\n if (!imodel)\n return null;\n\n return <TreeWidgetComponentContent {...props} imodel={imodel} />;\n}\n\nfunction TreeWidgetComponentContent(props: TreeWidgetComponentProps & { imodel: IModelConnection}) {\n const { trees: treeDefinitions, imodel } = props;\n const trees = useActiveTrees(treeDefinitions, imodel);\n\n return (\n <div className=\"tree-widget-visibility-widget\">\n <SelectableContent {...getSelectableContentProps(trees)} />\n </div>\n );\n}\n\nfunction useActiveTrees(treeDefinitions: TreeDefinition[], imodel: IModelConnection) {\n const [trees, setTrees] = useState<SelectableContentDefinition[]>();\n\n useEffect(() => {\n let disposed = false;\n (async () => {\n const visibleTrees = await getActiveTrees(treeDefinitions, imodel);\n // istanbul ignore else\n if (!disposed) {\n setTrees(visibleTrees);\n }\n })();\n\n return () => { disposed = true; };\n }, [treeDefinitions, imodel]);\n\n return trees;\n}\n\nasync function getActiveTrees(treeDefinitions: TreeDefinition[], imodel: IModelConnection): Promise<SelectableContentDefinition[]> {\n const handleDefinition = async (treeDef: TreeDefinition) => {\n if (treeDef.shouldShow !== undefined && !(await treeDef.shouldShow(imodel))) {\n return undefined;\n }\n return {\n id: treeDef.id,\n label: treeDef.getLabel(),\n render: treeDef.render,\n };\n };\n\n return (await Promise.all(treeDefinitions.map(handleDefinition))).filter((tree) => tree !== undefined) as SelectableContentDefinition[];\n}\n\nfunction getSelectableContentProps(trees?: SelectableContentDefinition[]): SelectableContentProps {\n if (trees === undefined) {\n return {\n defaultSelectedContentId: \"loading\",\n children: [{\n id: \"loading\",\n label: \"\",\n render: () => (\n <Delayed>\n <ProgressLinear indeterminate={true} />\n </Delayed>\n ),\n }],\n };\n }\n\n if (trees.length === 0) {\n return {\n defaultSelectedContentId: \"no-trees\",\n children: [{\n id: \"no-trees\",\n label: \"\",\n render: () => (\n <FillCentered>\n {TreeWidget.translate(\"noTrees\")}\n </FillCentered>\n ),\n }],\n };\n }\n\n return {\n defaultSelectedContentId: trees[0].id,\n children: trees,\n };\n}\n\nfunction Delayed({ delay = 200, children }: PropsWithChildren<{ delay?: number }>) {\n const [show, setShow] = useState(false);\n\n useEffect(() => {\n const id = setTimeout(() => { setShow(true); }, delay);\n return () => { clearTimeout(id); };\n }, [delay]);\n\n if (!show) {\n return null;\n }\n\n return <>{children}</>;\n}\n"]}