@itwin/tree-widget-react 4.0.0-alpha.23 → 4.0.0-alpha.25

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 (111) hide show
  1. package/README.md +48 -37
  2. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTree.d.ts +3 -3
  3. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTree.js +4 -3
  4. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTree.js.map +1 -1
  5. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.js +43 -18
  6. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.js.map +1 -1
  7. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeComponent.d.ts +1 -1
  8. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeComponent.js.map +1 -1
  9. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.d.ts +2 -1
  10. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js +15 -2
  11. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js.map +1 -1
  12. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeNode.d.ts +84 -0
  13. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeNode.js +50 -0
  14. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeNode.js.map +1 -0
  15. package/lib/esm/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.d.ts +5 -4
  16. package/lib/esm/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js +8 -9
  17. package/lib/esm/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js.map +1 -1
  18. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js +8 -7
  19. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js.map +1 -1
  20. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/CategoriesTreeVisibilityHandler.d.ts +1 -3
  21. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/CategoriesTreeVisibilityHandler.js +22 -49
  22. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/visibility/CategoriesTreeVisibilityHandler.js.map +1 -1
  23. package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTree.d.ts +3 -3
  24. package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTree.js +4 -3
  25. package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTree.js.map +1 -1
  26. package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeComponent.d.ts +1 -1
  27. package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeComponent.js.map +1 -1
  28. package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeDefinition.js +3 -2
  29. package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeDefinition.js.map +1 -1
  30. package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeNode.d.ts +34 -0
  31. package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeNode.js +28 -0
  32. package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeNode.js.map +1 -0
  33. package/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTree.d.ts +5 -4
  34. package/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTree.js +6 -5
  35. package/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTree.js.map +1 -1
  36. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeIdsCache.js +6 -5
  37. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeIdsCache.js.map +1 -1
  38. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/ClassificationsTreeVisibilityHandler.d.ts +1 -1
  39. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/ClassificationsTreeVisibilityHandler.js +10 -15
  40. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/visibility/ClassificationsTreeVisibilityHandler.js.map +1 -1
  41. package/lib/esm/tree-widget-react/components/trees/common/UseHierarchyVisibility.js +14 -4
  42. package/lib/esm/tree-widget-react/components/trees/common/UseHierarchyVisibility.js.map +1 -1
  43. package/lib/esm/tree-widget-react/components/trees/common/Utils.js +3 -3
  44. package/lib/esm/tree-widget-react/components/trees/common/Utils.js.map +1 -1
  45. package/lib/esm/tree-widget-react/components/trees/common/components/Tree.d.ts +7 -1
  46. package/lib/esm/tree-widget-react/components/trees/common/components/Tree.js +3 -1
  47. package/lib/esm/tree-widget-react/components/trees/common/components/Tree.js.map +1 -1
  48. package/lib/esm/tree-widget-react/components/trees/common/components/TreeRenderer.d.ts +4 -4
  49. package/lib/esm/tree-widget-react/components/trees/common/components/TreeRenderer.js +5 -8
  50. package/lib/esm/tree-widget-react/components/trees/common/components/TreeRenderer.js.map +1 -1
  51. package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTreeRenderer.d.ts +4 -3
  52. package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTreeRenderer.js +5 -8
  53. package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTreeRenderer.js.map +1 -1
  54. package/lib/esm/tree-widget-react/components/trees/common/internal/AlwaysAndNeverDrawnElementInfo.js +2 -1
  55. package/lib/esm/tree-widget-react/components/trees/common/internal/AlwaysAndNeverDrawnElementInfo.js.map +1 -1
  56. package/lib/esm/tree-widget-react/components/trees/common/internal/ModelCategoryElementsCountCache.js +2 -1
  57. package/lib/esm/tree-widget-react/components/trees/common/internal/ModelCategoryElementsCountCache.js.map +1 -1
  58. package/lib/esm/tree-widget-react/components/trees/common/internal/UseErrorState.d.ts +15 -0
  59. package/lib/esm/tree-widget-react/components/trees/common/internal/UseErrorState.js +37 -0
  60. package/lib/esm/tree-widget-react/components/trees/common/internal/UseErrorState.js.map +1 -0
  61. package/lib/esm/tree-widget-react/components/trees/common/internal/VisibilityUtils.js +16 -6
  62. package/lib/esm/tree-widget-react/components/trees/common/internal/VisibilityUtils.js.map +1 -1
  63. package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.d.ts +3 -3
  64. package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.js +5 -2
  65. package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
  66. package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeComponent.d.ts +1 -1
  67. package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js.map +1 -1
  68. package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.d.ts +3 -3
  69. package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.js +5 -2
  70. package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
  71. package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeComponent.d.ts +1 -1
  72. package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeComponent.js.map +1 -1
  73. package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/internal/IModelContentTreeIdsCache.js +65 -43
  74. package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/internal/IModelContentTreeIdsCache.js.map +1 -1
  75. package/lib/esm/tree-widget-react/components/trees/index.d.ts +3 -0
  76. package/lib/esm/tree-widget-react/components/trees/index.js +3 -0
  77. package/lib/esm/tree-widget-react/components/trees/index.js.map +1 -1
  78. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTree.d.ts +3 -3
  79. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTree.js +4 -3
  80. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTree.js.map +1 -1
  81. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.js +1 -1
  82. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.js.map +1 -1
  83. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.d.ts +1 -1
  84. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
  85. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.d.ts +2 -1
  86. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js +17 -2
  87. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js.map +1 -1
  88. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeNode.d.ts +63 -0
  89. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeNode.js +56 -0
  90. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeNode.js.map +1 -0
  91. package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.d.ts +5 -4
  92. package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.js +8 -7
  93. package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.js.map +1 -1
  94. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js +6 -5
  95. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js.map +1 -1
  96. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/ModelsTreeVisibilityHandler.d.ts +1 -3
  97. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/ModelsTreeVisibilityHandler.js +20 -51
  98. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/visibility/ModelsTreeVisibilityHandler.js.map +1 -1
  99. package/lib/esm/tree-widget-react-internal.d.ts +0 -1
  100. package/lib/esm/tree-widget-react-internal.js +0 -1
  101. package/lib/esm/tree-widget-react-internal.js.map +1 -1
  102. package/package.json +3 -3
  103. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeNode.d.ts +0 -41
  104. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeNode.js +0 -50
  105. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeNode.js.map +0 -1
  106. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeNode.d.ts +0 -19
  107. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeNode.js +0 -32
  108. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeNode.js.map +0 -1
  109. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeNode.d.ts +0 -37
  110. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeNode.js +0 -54
  111. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeNode.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ModelCategoryElementsCountCache.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/internal/ModelCategoryElementsCountCache.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC5I,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAS3D,gBAAgB;AAChB,MAAM,OAAO,+BAA+B;IAC1C,MAAM,GAAG,IAAI,GAAG,EAAqC,CAAC;IACtD,eAAe,GAAG,IAAI,OAAO,EAAmD,CAAC;IACjF,aAAa,CAAe;IAC5B,cAAc,CAA6B;IAC3C,mBAAmB,CAAW;IAC9B,YAAY,CAAa;IAC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E,MAAM,QAAQ,GAAqB,GAAG,OAAO,IAAI,UAAU,EAAE,CAAC;QAC9D,IAAI,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACvC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QACpC,CAAC;QAED,MAAM,GAAG,IAAI,aAAa,CAAC,CAAC,CAAC,CAAC;QAC9B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAClC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC;QACnD,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IACpC,CAAC;CACF","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 { bufferCount, bufferTime, defer, filter, from, map, mergeAll, mergeMap, reduce, ReplaySubject, Subject, take, toArray } from \"rxjs\";\nimport { assert, Guid } from \"@itwin/core-bentley\";\nimport { releaseMainThreadOnItemsCount } from \"./Utils.js\";\n\nimport type { Observable, Subscription } from \"rxjs\";\nimport type { GuidString, Id64Set, Id64String } from \"@itwin/core-bentley\";\nimport type { LimitingECSqlQueryExecutor } from \"@itwin/presentation-hierarchies\";\nimport type { CategoryId, ModelId } from \"./Types.js\";\n\ntype ModelCategoryKey = `${ModelId}-${CategoryId}`;\n\n/** @internal */\nexport class ModelCategoryElementsCountCache implements Disposable {\n #cache = new Map<ModelCategoryKey, Subject<number>>();\n #requestsStream = new Subject<{ modelId: Id64String; categoryId: Id64String }>();\n #subscription: Subscription;\n #queryExecutor: LimitingECSqlQueryExecutor;\n #elementsClassNames: string[];\n #componentId: GuidString;\n #componentName: string;\n\n public constructor(queryExecutor: LimitingECSqlQueryExecutor, elementsClassNames: string[], componentId: GuidString) {\n this.#componentId = componentId;\n this.#queryExecutor = queryExecutor;\n this.#elementsClassNames = elementsClassNames;\n this.#componentName = \"ModelCategoryElementsCountCache\";\n this.#subscription = this.#requestsStream\n .pipe(\n bufferTime(20),\n filter((requests) => requests.length > 0),\n mergeMap((requests) => this.queryCategoryElementCounts(requests)),\n mergeAll(),\n )\n .subscribe({\n next: ({ modelId, categoryId, elementsCount }) => {\n const subject = this.#cache.get(`${modelId}-${categoryId}`);\n assert(!!subject);\n subject.next(elementsCount);\n },\n });\n }\n\n private queryCategoryElementCounts(\n input: Array<{ modelId: Id64String; categoryId: Id64String }>,\n ): Observable<Array<{ modelId: Id64String; categoryId: Id64String; elementsCount: number }>> {\n return from(input).pipe(\n reduce((acc, { modelId, categoryId }) => {\n const entry = acc.get(modelId);\n if (!entry) {\n acc.set(modelId, new Set([categoryId]));\n } else {\n entry.add(categoryId);\n }\n return acc;\n }, new Map<Id64String, Id64Set>()),\n mergeMap((modelCategoryMap) => modelCategoryMap.entries()),\n map(([modelId, categoryIds]) => `Model.Id = ${modelId} AND Category.Id IN (${[...categoryIds].join(\", \")})`),\n // we may have thousands of where clauses here, and sending a single query with all of them could take a\n // long time - instead, split it into smaller chunks\n bufferCount(100),\n mergeMap((whereClauses) =>\n defer(() =>\n this.#queryExecutor.createQueryReader(\n {\n ctes: this.#elementsClassNames.map(\n (elementsClassName, index) => `\n CategoryElements${index}(id, modelId, categoryId) AS (\n SELECT ECInstanceId, Model.Id, Category.Id\n FROM ${elementsClassName}\n WHERE\n Parent.Id IS NULL\n AND (\n ${whereClauses.join(\" OR \")}\n )\n\n UNION ALL\n\n SELECT c.ECInstanceId, p.modelId, p.categoryId\n FROM ${elementsClassName} c\n JOIN CategoryElements${index} p ON c.Parent.Id = p.id\n )\n `,\n ),\n ecsql: `\n SELECT modelId, categoryId, COUNT(id) elementsCount\n FROM (\n ${this.#elementsClassNames\n .map(\n (_, index) => `\n SELECT * FROM CategoryElements${index}\n `,\n )\n .join(\" UNION ALL \")}\n )\n GROUP BY modelId, categoryId\n `,\n },\n {\n rowFormat: \"ECSqlPropertyNames\",\n limit: \"unbounded\",\n restartToken: `${this.#componentName}/${this.#componentId}/category-element-counts/${Guid.createValue()}`,\n },\n ),\n ),\n ),\n releaseMainThreadOnItemsCount(500),\n reduce(\n ({ acc, createKey }, row) => {\n acc.set(createKey({ modelId: row.modelId, categoryId: row.categoryId }), {\n modelId: row.modelId,\n categoryId: row.categoryId,\n elementsCount: row.elementsCount,\n });\n return { acc, createKey };\n },\n {\n acc: new Map<string, { modelId: Id64String; categoryId: Id64String; elementsCount: number }>(),\n createKey: (keyProps: { modelId: Id64String; categoryId: Id64String }) => `${keyProps.modelId}-${keyProps.categoryId}`,\n },\n ),\n mergeMap(({ acc: result, createKey }) => {\n input.forEach(({ modelId, categoryId }) => {\n if (!result.has(createKey({ modelId, categoryId }))) {\n result.set(createKey({ modelId, categoryId }), { categoryId, modelId, elementsCount: 0 });\n }\n });\n\n return from(result.values());\n }),\n toArray(),\n );\n }\n\n public [Symbol.dispose]() {\n this.#subscription.unsubscribe();\n }\n\n public getCategoryElementsCount(modelId: Id64String, categoryId: Id64String): Observable<number> {\n const cacheKey: ModelCategoryKey = `${modelId}-${categoryId}`;\n let result = this.#cache.get(cacheKey);\n if (result !== undefined) {\n return from(result).pipe(take(1));\n }\n\n result = new ReplaySubject(1);\n this.#cache.set(cacheKey, result);\n this.#requestsStream.next({ modelId, categoryId });\n return from(result).pipe(take(1));\n }\n}\n"]}
1
+ {"version":3,"file":"ModelCategoryElementsCountCache.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/internal/ModelCategoryElementsCountCache.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,KAA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AAE;gBACxC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC;oBACpD,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC,EAAE,CAAC,CAAC;gBAC5F,CAAC;YACH,CAAC,CAAC,CAAC;YAEH,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;QAC/B,CAAC,CAAC,EACF,OAAO,EAAE,CACV,CAAC;IACJ,CAAC;IAEM,CAAC,MAAM,CAAC,OAAO,CAAC;QACrB,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC;IACnC,CAAC;IAEM,wBAAwB,CAAC,OAAmB,EAAE,UAAsB;QACzE,MAAM,QAAQ,GAAqB,GAAG,OAAO,IAAI,UAAU,EAAE,CAAC;QAC9D,IAAI,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACvC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QACpC,CAAC;QAED,MAAM,GAAG,IAAI,aAAa,CAAC,CAAC,CAAC,CAAC;QAC9B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAClC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC;QACnD,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IACpC,CAAC;CACF","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 { bufferCount, bufferTime, defer, filter, from, map, mergeAll, mergeMap, reduce, ReplaySubject, Subject, take, toArray } from \"rxjs\";\nimport { assert, Guid } from \"@itwin/core-bentley\";\nimport { catchBeSQLiteInterrupts } from \"./UseErrorState.js\";\nimport { releaseMainThreadOnItemsCount } from \"./Utils.js\";\n\nimport type { Observable, Subscription } from \"rxjs\";\nimport type { GuidString, Id64Set, Id64String } from \"@itwin/core-bentley\";\nimport type { LimitingECSqlQueryExecutor } from \"@itwin/presentation-hierarchies\";\nimport type { CategoryId, ModelId } from \"./Types.js\";\n\ntype ModelCategoryKey = `${ModelId}-${CategoryId}`;\n\n/** @internal */\nexport class ModelCategoryElementsCountCache implements Disposable {\n #cache = new Map<ModelCategoryKey, Subject<number>>();\n #requestsStream = new Subject<{ modelId: Id64String; categoryId: Id64String }>();\n #subscription: Subscription;\n #queryExecutor: LimitingECSqlQueryExecutor;\n #elementsClassNames: string[];\n #componentId: GuidString;\n #componentName: string;\n\n public constructor(queryExecutor: LimitingECSqlQueryExecutor, elementsClassNames: string[], componentId: GuidString) {\n this.#componentId = componentId;\n this.#queryExecutor = queryExecutor;\n this.#elementsClassNames = elementsClassNames;\n this.#componentName = \"ModelCategoryElementsCountCache\";\n this.#subscription = this.#requestsStream\n .pipe(\n bufferTime(20),\n filter((requests) => requests.length > 0),\n mergeMap((requests) => this.queryCategoryElementCounts(requests)),\n mergeAll(),\n )\n .subscribe({\n next: ({ modelId, categoryId, elementsCount }) => {\n const subject = this.#cache.get(`${modelId}-${categoryId}`);\n assert(!!subject);\n subject.next(elementsCount);\n },\n });\n }\n\n private queryCategoryElementCounts(\n input: Array<{ modelId: Id64String; categoryId: Id64String }>,\n ): Observable<Array<{ modelId: Id64String; categoryId: Id64String; elementsCount: number }>> {\n return from(input).pipe(\n reduce((acc, { modelId, categoryId }) => {\n const entry = acc.get(modelId);\n if (!entry) {\n acc.set(modelId, new Set([categoryId]));\n } else {\n entry.add(categoryId);\n }\n return acc;\n }, new Map<Id64String, Id64Set>()),\n mergeMap((modelCategoryMap) => modelCategoryMap.entries()),\n map(([modelId, categoryIds]) => `Model.Id = ${modelId} AND Category.Id IN (${[...categoryIds].join(\", \")})`),\n // we may have thousands of where clauses here, and sending a single query with all of them could take a\n // long time - instead, split it into smaller chunks\n bufferCount(100),\n mergeMap((whereClauses) =>\n defer(() =>\n this.#queryExecutor.createQueryReader(\n {\n ctes: this.#elementsClassNames.map(\n (elementsClassName, index) => `\n CategoryElements${index}(id, modelId, categoryId) AS (\n SELECT ECInstanceId, Model.Id, Category.Id\n FROM ${elementsClassName}\n WHERE\n Parent.Id IS NULL\n AND (\n ${whereClauses.join(\" OR \")}\n )\n\n UNION ALL\n\n SELECT c.ECInstanceId, p.modelId, p.categoryId\n FROM ${elementsClassName} c\n JOIN CategoryElements${index} p ON c.Parent.Id = p.id\n )\n `,\n ),\n ecsql: `\n SELECT modelId, categoryId, COUNT(id) elementsCount\n FROM (\n ${this.#elementsClassNames\n .map(\n (_, index) => `\n SELECT * FROM CategoryElements${index}\n `,\n )\n .join(\" UNION ALL \")}\n )\n GROUP BY modelId, categoryId\n `,\n },\n {\n rowFormat: \"ECSqlPropertyNames\",\n limit: \"unbounded\",\n restartToken: `${this.#componentName}/${this.#componentId}/category-element-counts/${Guid.createValue()}`,\n },\n ),\n ).pipe(catchBeSQLiteInterrupts),\n ),\n releaseMainThreadOnItemsCount(500),\n reduce(\n ({ acc, createKey }, row) => {\n acc.set(createKey({ modelId: row.modelId, categoryId: row.categoryId }), {\n modelId: row.modelId,\n categoryId: row.categoryId,\n elementsCount: row.elementsCount,\n });\n return { acc, createKey };\n },\n {\n acc: new Map<string, { modelId: Id64String; categoryId: Id64String; elementsCount: number }>(),\n createKey: (keyProps: { modelId: Id64String; categoryId: Id64String }) => `${keyProps.modelId}-${keyProps.categoryId}`,\n },\n ),\n mergeMap(({ acc: result, createKey }) => {\n input.forEach(({ modelId, categoryId }) => {\n if (!result.has(createKey({ modelId, categoryId }))) {\n result.set(createKey({ modelId, categoryId }), { categoryId, modelId, elementsCount: 0 });\n }\n });\n\n return from(result.values());\n }),\n toArray(),\n );\n }\n\n public [Symbol.dispose]() {\n this.#subscription.unsubscribe();\n }\n\n public getCategoryElementsCount(modelId: Id64String, categoryId: Id64String): Observable<number> {\n const cacheKey: ModelCategoryKey = `${modelId}-${categoryId}`;\n let result = this.#cache.get(cacheKey);\n if (result !== undefined) {\n return from(result).pipe(take(1));\n }\n\n result = new ReplaySubject(1);\n this.#cache.set(cacheKey, result);\n this.#requestsStream.next({ modelId, categoryId });\n return from(result).pipe(take(1));\n }\n}\n"]}
@@ -0,0 +1,15 @@
1
+ import type { Observable } from "rxjs";
2
+ /**
3
+ * A hook that helps components throw errors in React's render loop so they can be captured by React error
4
+ * boundaries.
5
+ *
6
+ * Usage: simply call the returned function with an error and it will be re-thrown in React render loop.
7
+ *
8
+ * @internal
9
+ */
10
+ export declare function useErrorState(): (e: unknown) => void;
11
+ /** @internal */
12
+ export declare function isBeSqliteInterruptError(error: unknown): boolean;
13
+ /** @internal */
14
+ export declare function catchBeSQLiteInterrupts<T>(obs: Observable<T>): Observable<T>;
15
+ //# sourceMappingURL=UseErrorState.d.ts.map
@@ -0,0 +1,37 @@
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 { useCallback, useState } from "react";
6
+ import { catchError, EMPTY } from "rxjs";
7
+ /**
8
+ * A hook that helps components throw errors in React's render loop so they can be captured by React error
9
+ * boundaries.
10
+ *
11
+ * Usage: simply call the returned function with an error and it will be re-thrown in React render loop.
12
+ *
13
+ * @internal
14
+ */
15
+ export function useErrorState() {
16
+ const [_, setError] = useState(undefined);
17
+ const setErrorState = useCallback((e) => {
18
+ setError(() => {
19
+ throw e instanceof Error ? e : /* c8 ignore next */ new Error();
20
+ });
21
+ }, []);
22
+ return setErrorState;
23
+ }
24
+ /** @internal */
25
+ export function isBeSqliteInterruptError(error) {
26
+ return typeof error === "object" && !!error && "name" in error && error.name === "BE_SQLITE_INTERRUPT";
27
+ }
28
+ /** @internal */
29
+ export function catchBeSQLiteInterrupts(obs) {
30
+ return obs.pipe(catchError((error) => {
31
+ if (isBeSqliteInterruptError(error)) {
32
+ return EMPTY;
33
+ }
34
+ throw error;
35
+ }));
36
+ }
37
+ //# sourceMappingURL=UseErrorState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UseErrorState.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/internal/UseErrorState.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAIzC;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa;IAC3B,MAAM,CAAC,CAAC,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;IAC1C,MAAM,aAAa,GAAG,WAAW,CAAC,CAAC,CAAU,EAAE,EAAE;QAC/C,QAAQ,CAAC,GAAG,EAAE;YACZ,MAAM,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,oBAAoB,CAAC,IAAI,KAAK,EAAE,CAAC;QAClE,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,EAAE,CAAC,CAAC;IACP,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,wBAAwB,CAAC,KAAc;IACrD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,CAAC,KAAK,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,qBAAqB,CAAC;AACzG,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,uBAAuB,CAAI,GAAkB;IAC3D,OAAO,GAAG,CAAC,IAAI,CACb,UAAU,CAAC,CAAC,KAAK,EAAE,EAAE;QACnB,IAAI,wBAAwB,CAAC,KAAK,CAAC,EAAE,CAAC;YACpC,OAAO,KAAK,CAAC;QACf,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC,CAAC,CACH,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 { useCallback, useState } from \"react\";\nimport { catchError, EMPTY } from \"rxjs\";\n\nimport type { Observable } from \"rxjs\";\n\n/**\n * A hook that helps components throw errors in React's render loop so they can be captured by React error\n * boundaries.\n *\n * Usage: simply call the returned function with an error and it will be re-thrown in React render loop.\n *\n * @internal\n */\nexport function useErrorState() {\n const [_, setError] = useState(undefined);\n const setErrorState = useCallback((e: unknown) => {\n setError(() => {\n throw e instanceof Error ? e : /* c8 ignore next */ new Error();\n });\n }, []);\n return setErrorState;\n}\n\n/** @internal */\nexport function isBeSqliteInterruptError(error: unknown): boolean {\n return typeof error === \"object\" && !!error && \"name\" in error && error.name === \"BE_SQLITE_INTERRUPT\";\n}\n\n/** @internal */\nexport function catchBeSQLiteInterrupts<T>(obs: Observable<T>): Observable<T> {\n return obs.pipe(\n catchError((error) => {\n if (isBeSqliteInterruptError(error)) {\n return EMPTY;\n }\n throw error;\n }),\n );\n}\n"]}
@@ -7,6 +7,7 @@ import { Guid, Id64 } from "@itwin/core-bentley";
7
7
  import { QueryRowFormat } from "@itwin/core-common";
8
8
  import { reduceWhile, toVoidPromise } from "./Rxjs.js";
9
9
  import { createVisibilityStatus } from "./Tooltip.js";
10
+ import { isBeSqliteInterruptError } from "./UseErrorState.js";
10
11
  import { fromWithRelease, getClassesByView, getOptimalBatchSize, releaseMainThreadOnItemsCount } from "./Utils.js";
11
12
  function mergeVisibilities(obs) {
12
13
  return obs.pipe(reduceWhile((x) => x.allVisible || x.allHidden, (acc, val) => {
@@ -137,13 +138,22 @@ export async function loadCategoriesFromViewport(vp, componentId) {
137
138
  const categories = [];
138
139
  const rows = await (async () => {
139
140
  const result = new Array();
140
- for await (const row of vp.iModel.createQueryReader(ecsql, undefined, {
141
- rowFormat: QueryRowFormat.UseJsPropertyNames,
142
- restartToken: `CategoriesVisibilityUtils/${componentId ?? Guid.createValue()}/categories`,
143
- })) {
144
- result.push(row.id);
141
+ try {
142
+ for await (const row of vp.iModel.createQueryReader(ecsql, undefined, {
143
+ rowFormat: QueryRowFormat.UseJsPropertyNames,
144
+ restartToken: `CategoriesVisibilityUtils/${componentId ?? Guid.createValue()}/categories`,
145
+ })) {
146
+ result.push(row.id);
147
+ }
148
+ return result;
149
+ // This can happen when query is cancelled
150
+ }
151
+ catch (error) {
152
+ if (isBeSqliteInterruptError(error)) {
153
+ return [];
154
+ }
155
+ throw error;
145
156
  }
146
- return result;
147
157
  })();
148
158
  (await vp.iModel.categories.getCategoryInfo(rows)).forEach((val) => {
149
159
  categories.push({ categoryId: val.id, subCategoryIds: val.subCategories.size ? [...val.subCategories.keys()] : undefined });
@@ -1 +1 @@
1
- {"version":3,"file":"VisibilityUtils.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/internal/VisibilityUtils.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EA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AAC,gBAAgB;;GAErD,CAAC;IAEF,MAAM,UAAU,GAAmB,EAAE,CAAC;IACtC,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,IAAI,EAAE;QAC7B,MAAM,MAAM,GAAG,IAAI,KAAK,EAAc,CAAC;QACvC,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,EAAE,CAAC,MAAM,CAAC,iBAAiB,CAAC,KAAK,EAAE,SAAS,EAAE;YACpE,SAAS,EAAE,cAAc,CAAC,kBAAkB;YAC5C,YAAY,EAAE,6BAA6B,WAAW,IAAI,IAAI,CAAC,WAAW,EAAE,aAAa;SAC1F,CAAC,EAAE,CAAC;YACH,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACtB,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC,EAAE,CAAC;IACL,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;QACjE,UAAU,CAAC,IAAI,CAAC,EAAE,UAAU,EAAE,GAAG,CAAC,EAAE,EAAE,cAAc,EAAE,GAAG,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC;IAC9H,CAAC,CAAC,CAAC;IACH,OAAO,UAAU,CAAC;AACpB,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 { bufferCount, map, mergeMap, reduce } from \"rxjs\";\nimport { Guid, Id64 } from \"@itwin/core-bentley\";\nimport { QueryRowFormat } from \"@itwin/core-common\";\nimport { reduceWhile, toVoidPromise } from \"./Rxjs.js\";\nimport { createVisibilityStatus } from \"./Tooltip.js\";\nimport { fromWithRelease, getClassesByView, getOptimalBatchSize, releaseMainThreadOnItemsCount } from \"./Utils.js\";\n\nimport type { Observable, OperatorFunction } from \"rxjs\";\nimport type { GuidString, Id64Arg, Id64Array, Id64String } from \"@itwin/core-bentley\";\nimport type { CategoryInfo } from \"../CategoriesVisibilityUtils.js\";\nimport type { TreeWidgetViewport } from \"../TreeWidgetViewport.js\";\nimport type { VisibilityStatus } from \"../UseHierarchyVisibility.js\";\nimport type { Visibility } from \"./Tooltip.js\";\nimport type { ElementId } from \"./Types.js\";\n\nfunction mergeVisibilities(obs: Observable<Visibility>): Observable<Visibility | \"empty\"> {\n return obs.pipe(\n reduceWhile(\n (x) => x.allVisible || x.allHidden,\n (acc, val) => {\n acc.allVisible &&= val === \"visible\";\n acc.allHidden &&= val === \"hidden\";\n return acc;\n },\n { allVisible: true, allHidden: true },\n ),\n map((x) => {\n if (!x) {\n return \"empty\";\n }\n return x.allVisible ? \"visible\" : x.allHidden ? \"hidden\" : \"partial\";\n }),\n );\n}\n\n/** @internal */\nexport function mergeVisibilityStatuses(obs: Observable<VisibilityStatus>): Observable<VisibilityStatus> {\n return obs.pipe(\n map((visibilityStatus) => visibilityStatus.state),\n mergeVisibilities,\n map((visibility) => createVisibilityStatus(visibility === \"empty\" ? \"disabled\" : visibility)),\n );\n}\n\n/** @internal */\nexport function changeElementStateNoChildrenOperator(props: {\n on: boolean;\n isDisplayedByDefault: boolean;\n viewport: TreeWidgetViewport;\n}): OperatorFunction<string, void> {\n return (elementIds: Observable<Id64String>) => {\n const { on, isDisplayedByDefault } = props;\n const isAlwaysDrawnExclusive = props.viewport.isAlwaysDrawnExclusive;\n return elementIds.pipe(\n releaseMainThreadOnItemsCount(500),\n reduce<\n string,\n { changedNeverDrawn: boolean; changedAlwaysDrawn: boolean; neverDrawn: Set<ElementId> | undefined; alwaysDrawn: Set<ElementId> | undefined }\n >(\n (acc, elementId) => {\n if (acc.alwaysDrawn === undefined || acc.neverDrawn === undefined) {\n acc.alwaysDrawn = new Set(props.viewport.alwaysDrawn || []);\n acc.neverDrawn = new Set(props.viewport.neverDrawn || []);\n }\n if (on) {\n const wasRemoved = acc.neverDrawn.delete(elementId);\n acc.changedNeverDrawn ||= wasRemoved;\n // If exclusive mode is enabled, we must add the element to the always drawn list.\n if ((!isDisplayedByDefault || isAlwaysDrawnExclusive) && !acc.alwaysDrawn.has(elementId)) {\n acc.alwaysDrawn.add(elementId);\n acc.changedAlwaysDrawn = true;\n }\n } else {\n const wasRemoved = acc.alwaysDrawn.delete(elementId);\n acc.changedAlwaysDrawn ||= wasRemoved;\n // If exclusive mode is not enabled, we have to add the element to the never drawn list.\n if (isDisplayedByDefault && !isAlwaysDrawnExclusive && !acc.neverDrawn.has(elementId)) {\n acc.neverDrawn.add(elementId);\n acc.changedNeverDrawn = true;\n }\n }\n return acc;\n },\n {\n changedNeverDrawn: false,\n changedAlwaysDrawn: false,\n neverDrawn: undefined,\n alwaysDrawn: undefined,\n },\n ),\n map((state) => {\n state.changedNeverDrawn && state.neverDrawn && props.viewport.setNeverDrawn({ elementIds: state.neverDrawn });\n state.changedAlwaysDrawn &&\n state.alwaysDrawn &&\n props.viewport.setAlwaysDrawn({ elementIds: state.alwaysDrawn, exclusive: props.viewport.isAlwaysDrawnExclusive });\n }),\n );\n };\n}\n\n/** @internal */\nexport function getVisibilityFromAlwaysAndNeverDrawnElementsImpl(\n props: {\n alwaysDrawn: Set<ElementId> | undefined;\n neverDrawn: Set<ElementId> | undefined;\n totalCount: number;\n viewport: TreeWidgetViewport;\n } & GetVisibilityFromAlwaysAndNeverDrawnElementsProps,\n): VisibilityStatus {\n const { alwaysDrawn, neverDrawn, totalCount, viewport } = props;\n if (totalCount === 0) {\n return props.defaultStatus();\n }\n if (neverDrawn?.size === totalCount) {\n return createVisibilityStatus(\"hidden\");\n }\n\n if (alwaysDrawn?.size === totalCount) {\n return createVisibilityStatus(\"visible\");\n }\n\n if (viewport.isAlwaysDrawnExclusive) {\n return createVisibilityStatus(alwaysDrawn?.size ? \"partial\" : \"hidden\");\n }\n\n const status = props.defaultStatus();\n if ((status.state === \"visible\" && neverDrawn?.size) || (status.state === \"hidden\" && alwaysDrawn?.size)) {\n return createVisibilityStatus(\"partial\");\n }\n return status;\n}\n\n/** @internal */\nexport interface GetVisibilityFromAlwaysAndNeverDrawnElementsProps {\n /** Status when always/never lists are empty and exclusive mode is off */\n defaultStatus: (categoryId?: string) => VisibilityStatus;\n}\n\n/**\n * Changes category display in the viewport.\n * @internal\n */\nexport async function enableCategoryDisplay(viewport: TreeWidgetViewport, categoryIds: Id64Arg, enabled: boolean, enableAllSubCategories = true) {\n const removeOverrides = (bufferedCategories: Id64Array) => {\n const modelsContainingOverrides: string[] = [];\n for (const ovr of viewport.perModelCategoryOverrides) {\n if (Id64.has(bufferedCategories, ovr.categoryId)) {\n modelsContainingOverrides.push(ovr.modelId);\n }\n }\n viewport.setPerModelCategoryOverride({ modelIds: modelsContainingOverrides, categoryIds: bufferedCategories, override: \"none\" });\n };\n const disableSubCategories = async (bufferedCategories: Id64Array) => {\n // changeCategoryDisplay only enables subcategories, it does not disabled them. So we must do that ourselves.\n (await viewport.iModel.categories.getCategoryInfo(bufferedCategories)).forEach((categoryInfo) => {\n categoryInfo.subCategories.forEach((value) => viewport.changeSubCategoryDisplay({ subCategoryId: value.id, display: false }));\n });\n };\n return toVoidPromise(\n fromWithRelease({ source: categoryIds, releaseOnCount: 500 }).pipe(\n bufferCount(getOptimalBatchSize({ totalSize: Id64.sizeOf(categoryIds), maximumBatchSize: 500 })),\n mergeMap(async (bufferedCategories) => {\n viewport.changeCategoryDisplay({ categoryIds: bufferedCategories, display: enabled, enableAllSubCategories });\n removeOverrides(bufferedCategories);\n if (!enabled) {\n await disableSubCategories(bufferedCategories);\n }\n }),\n ),\n );\n}\n\n/** @internal */\nexport async function loadCategoriesFromViewport(vp: TreeWidgetViewport, componentId?: GuidString) {\n // Query categories and add them to state\n if (vp.viewType === \"other\") {\n return [];\n }\n const { categoryClass, elementClass } = getClassesByView(vp.viewType);\n const ecsql = `\n SELECT ECInstanceId as id\n FROM ${categoryClass}\n WHERE\n ECInstanceId IN (\n SELECT DISTINCT Category.Id\n FROM ${elementClass}\n WHERE\n Category.Id IN (SELECT ECInstanceId FROM ${categoryClass})\n ${vp.viewType !== \"2d\" ? \"\" : \"AND Model.Id=?\"}\n )\n `;\n\n const categories: CategoryInfo[] = [];\n const rows = await (async () => {\n const result = new Array<Id64String>();\n for await (const row of vp.iModel.createQueryReader(ecsql, undefined, {\n rowFormat: QueryRowFormat.UseJsPropertyNames,\n restartToken: `CategoriesVisibilityUtils/${componentId ?? Guid.createValue()}/categories`,\n })) {\n result.push(row.id);\n }\n return result;\n })();\n (await vp.iModel.categories.getCategoryInfo(rows)).forEach((val) => {\n categories.push({ categoryId: val.id, subCategoryIds: val.subCategories.size ? [...val.subCategories.keys()] : undefined });\n });\n return categories;\n}\n"]}
1
+ {"version":3,"file":"VisibilityUtils.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/common/internal/VisibilityUtils.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAUnH,SAAS,iBAAiB,CAAC,GAA2B;IACpD,OAAO,GAAG,CAAC,IA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AAG,IAAI,KAAK,EAAc,CAAC;QACvC,IAAI,CAAC;YACH,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,EAAE,CAAC,MAAM,CAAC,iBAAiB,CAAC,KAAK,EAAE,SAAS,EAAE;gBACpE,SAAS,EAAE,cAAc,CAAC,kBAAkB;gBAC5C,YAAY,EAAE,6BAA6B,WAAW,IAAI,IAAI,CAAC,WAAW,EAAE,aAAa;aAC1F,CAAC,EAAE,CAAC;gBACH,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACtB,CAAC;YACD,OAAO,MAAM,CAAC;YACd,0CAA0C;QAC5C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,wBAAwB,CAAC,KAAK,CAAC,EAAE,CAAC;gBACpC,OAAO,EAAE,CAAC;YACZ,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC,CAAC,EAAE,CAAC;IACL,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;QACjE,UAAU,CAAC,IAAI,CAAC,EAAE,UAAU,EAAE,GAAG,CAAC,EAAE,EAAE,cAAc,EAAE,GAAG,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC;IAC9H,CAAC,CAAC,CAAC;IACH,OAAO,UAAU,CAAC;AACpB,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 { bufferCount, map, mergeMap, reduce } from \"rxjs\";\nimport { Guid, Id64 } from \"@itwin/core-bentley\";\nimport { QueryRowFormat } from \"@itwin/core-common\";\nimport { reduceWhile, toVoidPromise } from \"./Rxjs.js\";\nimport { createVisibilityStatus } from \"./Tooltip.js\";\nimport { isBeSqliteInterruptError } from \"./UseErrorState.js\";\nimport { fromWithRelease, getClassesByView, getOptimalBatchSize, releaseMainThreadOnItemsCount } from \"./Utils.js\";\n\nimport type { Observable, OperatorFunction } from \"rxjs\";\nimport type { GuidString, Id64Arg, Id64Array, Id64String } from \"@itwin/core-bentley\";\nimport type { CategoryInfo } from \"../CategoriesVisibilityUtils.js\";\nimport type { TreeWidgetViewport } from \"../TreeWidgetViewport.js\";\nimport type { VisibilityStatus } from \"../UseHierarchyVisibility.js\";\nimport type { Visibility } from \"./Tooltip.js\";\nimport type { ElementId } from \"./Types.js\";\n\nfunction mergeVisibilities(obs: Observable<Visibility>): Observable<Visibility | \"empty\"> {\n return obs.pipe(\n reduceWhile(\n (x) => x.allVisible || x.allHidden,\n (acc, val) => {\n acc.allVisible &&= val === \"visible\";\n acc.allHidden &&= val === \"hidden\";\n return acc;\n },\n { allVisible: true, allHidden: true },\n ),\n map((x) => {\n if (!x) {\n return \"empty\";\n }\n return x.allVisible ? \"visible\" : x.allHidden ? \"hidden\" : \"partial\";\n }),\n );\n}\n\n/** @internal */\nexport function mergeVisibilityStatuses(obs: Observable<VisibilityStatus>): Observable<VisibilityStatus> {\n return obs.pipe(\n map((visibilityStatus) => visibilityStatus.state),\n mergeVisibilities,\n map((visibility) => createVisibilityStatus(visibility === \"empty\" ? \"disabled\" : visibility)),\n );\n}\n\n/** @internal */\nexport function changeElementStateNoChildrenOperator(props: {\n on: boolean;\n isDisplayedByDefault: boolean;\n viewport: TreeWidgetViewport;\n}): OperatorFunction<string, void> {\n return (elementIds: Observable<Id64String>) => {\n const { on, isDisplayedByDefault } = props;\n const isAlwaysDrawnExclusive = props.viewport.isAlwaysDrawnExclusive;\n return elementIds.pipe(\n releaseMainThreadOnItemsCount(500),\n reduce<\n string,\n { changedNeverDrawn: boolean; changedAlwaysDrawn: boolean; neverDrawn: Set<ElementId> | undefined; alwaysDrawn: Set<ElementId> | undefined }\n >(\n (acc, elementId) => {\n if (acc.alwaysDrawn === undefined || acc.neverDrawn === undefined) {\n acc.alwaysDrawn = new Set(props.viewport.alwaysDrawn || []);\n acc.neverDrawn = new Set(props.viewport.neverDrawn || []);\n }\n if (on) {\n const wasRemoved = acc.neverDrawn.delete(elementId);\n acc.changedNeverDrawn ||= wasRemoved;\n // If exclusive mode is enabled, we must add the element to the always drawn list.\n if ((!isDisplayedByDefault || isAlwaysDrawnExclusive) && !acc.alwaysDrawn.has(elementId)) {\n acc.alwaysDrawn.add(elementId);\n acc.changedAlwaysDrawn = true;\n }\n } else {\n const wasRemoved = acc.alwaysDrawn.delete(elementId);\n acc.changedAlwaysDrawn ||= wasRemoved;\n // If exclusive mode is not enabled, we have to add the element to the never drawn list.\n if (isDisplayedByDefault && !isAlwaysDrawnExclusive && !acc.neverDrawn.has(elementId)) {\n acc.neverDrawn.add(elementId);\n acc.changedNeverDrawn = true;\n }\n }\n return acc;\n },\n {\n changedNeverDrawn: false,\n changedAlwaysDrawn: false,\n neverDrawn: undefined,\n alwaysDrawn: undefined,\n },\n ),\n map((state) => {\n state.changedNeverDrawn && state.neverDrawn && props.viewport.setNeverDrawn({ elementIds: state.neverDrawn });\n state.changedAlwaysDrawn &&\n state.alwaysDrawn &&\n props.viewport.setAlwaysDrawn({ elementIds: state.alwaysDrawn, exclusive: props.viewport.isAlwaysDrawnExclusive });\n }),\n );\n };\n}\n\n/** @internal */\nexport function getVisibilityFromAlwaysAndNeverDrawnElementsImpl(\n props: {\n alwaysDrawn: Set<ElementId> | undefined;\n neverDrawn: Set<ElementId> | undefined;\n totalCount: number;\n viewport: TreeWidgetViewport;\n } & GetVisibilityFromAlwaysAndNeverDrawnElementsProps,\n): VisibilityStatus {\n const { alwaysDrawn, neverDrawn, totalCount, viewport } = props;\n if (totalCount === 0) {\n return props.defaultStatus();\n }\n if (neverDrawn?.size === totalCount) {\n return createVisibilityStatus(\"hidden\");\n }\n\n if (alwaysDrawn?.size === totalCount) {\n return createVisibilityStatus(\"visible\");\n }\n\n if (viewport.isAlwaysDrawnExclusive) {\n return createVisibilityStatus(alwaysDrawn?.size ? \"partial\" : \"hidden\");\n }\n\n const status = props.defaultStatus();\n if ((status.state === \"visible\" && neverDrawn?.size) || (status.state === \"hidden\" && alwaysDrawn?.size)) {\n return createVisibilityStatus(\"partial\");\n }\n return status;\n}\n\n/** @internal */\nexport interface GetVisibilityFromAlwaysAndNeverDrawnElementsProps {\n /** Status when always/never lists are empty and exclusive mode is off */\n defaultStatus: (categoryId?: string) => VisibilityStatus;\n}\n\n/**\n * Changes category display in the viewport.\n * @internal\n */\nexport async function enableCategoryDisplay(viewport: TreeWidgetViewport, categoryIds: Id64Arg, enabled: boolean, enableAllSubCategories = true) {\n const removeOverrides = (bufferedCategories: Id64Array) => {\n const modelsContainingOverrides: string[] = [];\n for (const ovr of viewport.perModelCategoryOverrides) {\n if (Id64.has(bufferedCategories, ovr.categoryId)) {\n modelsContainingOverrides.push(ovr.modelId);\n }\n }\n viewport.setPerModelCategoryOverride({ modelIds: modelsContainingOverrides, categoryIds: bufferedCategories, override: \"none\" });\n };\n const disableSubCategories = async (bufferedCategories: Id64Array) => {\n // changeCategoryDisplay only enables subcategories, it does not disabled them. So we must do that ourselves.\n (await viewport.iModel.categories.getCategoryInfo(bufferedCategories)).forEach((categoryInfo) => {\n categoryInfo.subCategories.forEach((value) => viewport.changeSubCategoryDisplay({ subCategoryId: value.id, display: false }));\n });\n };\n return toVoidPromise(\n fromWithRelease({ source: categoryIds, releaseOnCount: 500 }).pipe(\n bufferCount(getOptimalBatchSize({ totalSize: Id64.sizeOf(categoryIds), maximumBatchSize: 500 })),\n mergeMap(async (bufferedCategories) => {\n viewport.changeCategoryDisplay({ categoryIds: bufferedCategories, display: enabled, enableAllSubCategories });\n removeOverrides(bufferedCategories);\n if (!enabled) {\n await disableSubCategories(bufferedCategories);\n }\n }),\n ),\n );\n}\n\n/** @internal */\nexport async function loadCategoriesFromViewport(vp: TreeWidgetViewport, componentId?: GuidString) {\n // Query categories and add them to state\n if (vp.viewType === \"other\") {\n return [];\n }\n const { categoryClass, elementClass } = getClassesByView(vp.viewType);\n const ecsql = `\n SELECT ECInstanceId as id\n FROM ${categoryClass}\n WHERE\n ECInstanceId IN (\n SELECT DISTINCT Category.Id\n FROM ${elementClass}\n WHERE\n Category.Id IN (SELECT ECInstanceId FROM ${categoryClass})\n ${vp.viewType !== \"2d\" ? \"\" : \"AND Model.Id=?\"}\n )\n `;\n\n const categories: CategoryInfo[] = [];\n const rows = await (async () => {\n const result = new Array<Id64String>();\n try {\n for await (const row of vp.iModel.createQueryReader(ecsql, undefined, {\n rowFormat: QueryRowFormat.UseJsPropertyNames,\n restartToken: `CategoriesVisibilityUtils/${componentId ?? Guid.createValue()}/categories`,\n })) {\n result.push(row.id);\n }\n return result;\n // This can happen when query is cancelled\n } catch (error) {\n if (isBeSqliteInterruptError(error)) {\n return [];\n }\n throw error;\n }\n })();\n (await vp.iModel.categories.getCategoryInfo(rows)).forEach((val) => {\n categories.push({ categoryId: val.id, subCategoryIds: val.subCategories.size ? [...val.subCategories.keys()] : undefined });\n });\n return categories;\n}\n"]}
@@ -1,14 +1,14 @@
1
1
  import type { PresentationHierarchyNode } from "@itwin/presentation-hierarchies-react";
2
- import type { BaseTreeRendererProps } from "../common/components/BaseTreeRenderer.js";
3
2
  import type { TreeProps } from "../common/components/Tree.js";
3
+ import type { ExtendedTreeRendererProps } from "../common/components/TreeRenderer.js";
4
4
  /** @beta */
5
- export type ExternalSourcesTreeProps = Pick<TreeProps, "imodel" | "selectionStorage" | "selectionMode" | "emptyTreeContent"> & Pick<BaseTreeRendererProps, "getInlineActions" | "getMenuActions" | "getContextMenuActions" | "getDecorations" | "treeLabel"> & {
5
+ export type ExternalSourcesTreeProps = Pick<ExtendedTreeRendererProps, "getInlineActions" | "getMenuActions" | "getContextMenuActions" | "getTreeItemProps" | "treeLabel"> & Pick<TreeProps, "imodel" | "selectionStorage" | "selectionMode" | "emptyTreeContent"> & {
6
6
  hierarchyLevelConfig?: {
7
7
  sizeLimit?: number;
8
8
  };
9
9
  };
10
10
  /** @beta */
11
- export declare function ExternalSourcesTree({ getInlineActions, getMenuActions, getContextMenuActions, getDecorations, selectionMode, treeLabel, ...rest }: ExternalSourcesTreeProps): import("react/jsx-runtime").JSX.Element;
11
+ export declare function ExternalSourcesTree({ getInlineActions, getMenuActions, getContextMenuActions, getTreeItemProps, selectionMode, treeLabel, ...rest }: ExternalSourcesTreeProps): import("react/jsx-runtime").JSX.Element;
12
12
  /** @beta */
13
13
  export declare function ExternalSourcesTreeIcon({ node }: {
14
14
  node: PresentationHierarchyNode;
@@ -16,9 +16,12 @@ import { useGuid } from "../common/internal/useGuid.js";
16
16
  import { ExternalSourcesTreeComponent } from "./ExternalSourcesTreeComponent.js";
17
17
  import { ExternalSourcesTreeDefinition } from "./ExternalSourcesTreeDefinition.js";
18
18
  /** @beta */
19
- export function ExternalSourcesTree({ getInlineActions, getMenuActions, getContextMenuActions, getDecorations, selectionMode, treeLabel, ...rest }) {
19
+ export function ExternalSourcesTree({ getInlineActions, getMenuActions, getContextMenuActions, getTreeItemProps, selectionMode, treeLabel, ...rest }) {
20
20
  const componentId = useGuid();
21
- return (_jsx(Tree, { emptyTreeContent: _jsx(EmptyTreeContent, { icon: documentSvg }), ...rest, treeName: ExternalSourcesTreeComponent.id, getHierarchyDefinition: useCallback((definitionProps) => getDefinitionsProvider({ ...definitionProps, componentId }), [componentId]), selectionMode: selectionMode ?? "none", treeRenderer: (treeProps) => (_jsx(TreeRenderer, { ...treeProps, treeLabel: treeLabel, getInlineActions: getInlineActions, getMenuActions: getMenuActions, getContextMenuActions: getContextMenuActions, getDecorations: getDecorations ?? ((node) => _jsx(ExternalSourcesTreeIcon, { node: node })) })) }));
21
+ return (_jsx(Tree, { emptyTreeContent: _jsx(EmptyTreeContent, { icon: documentSvg }), ...rest, treeName: ExternalSourcesTreeComponent.id, getHierarchyDefinition: useCallback((definitionProps) => getDefinitionsProvider({ ...definitionProps, componentId }), [componentId]), selectionMode: selectionMode ?? "none", treeRenderer: (treeProps) => (_jsx(TreeRenderer, { ...treeProps, treeLabel: treeLabel, getInlineActions: getInlineActions ? (node) => getInlineActions(node, treeProps) : undefined, getMenuActions: getMenuActions ? (node) => getMenuActions(node, treeProps) : undefined, getContextMenuActions: getContextMenuActions ? (node) => getContextMenuActions(node, treeProps) : undefined, getTreeItemProps: (node) => ({
22
+ decorations: _jsx(ExternalSourcesTreeIcon, { node: node }),
23
+ ...(getTreeItemProps ? getTreeItemProps(node, treeProps) : {}),
24
+ }) })) }));
22
25
  }
23
26
  const getDefinitionsProvider = (props) => {
24
27
  return new ExternalSourcesTreeDefinition(props);
@@ -1 +1 @@
1
- {"version":3,"file":"ExternalSourcesTree.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,QAAQ,MAAM,gCAAgC,CAAC;AACtD,OAAO,UAAU,MAAM,kCAAkC,CAAC;AAC1D,OAAO,WAAW,MAAM,+BAA+B,CAAC;AACxD,OAAO,WAAW,MAAM,yCAAyC,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AACjF,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AAgBnF,YAAY;AACZ,MAAM,UAAU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,KAAK,WAAW;gBACd,OAAO,UAAU,CAAC;YACpB,KAAK,eAAe;gBAClB,OAAO,QAAQ,CAAC;YAClB,KAAK,eAAe;gBAClB,OAAO,WAAW,CAAC;YACrB,KAAK,gBAAgB;gBACnB,OAAO,WAAW,CAAC;YACrB;gBACE,OAAO,SAAS,CAAC;QACrB,CAAC;IACH,CAAC,CAAC;IAEF,OAAO,KAAC,IAAI,IAAC,IAAI,EAAE,OAAO,EAAE,GAAI,CAAC;AACnC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useCallback } from \"react\";\nimport { Icon } from \"@stratakit/foundations\";\nimport classSvg from \"@stratakit/icons/bis-class.svg\";\nimport elementSvg from \"@stratakit/icons/bis-element.svg\";\nimport documentSvg from \"@stratakit/icons/document.svg\";\nimport ecSchemaSvg from \"@stratakit/icons/selection-children.svg\";\nimport { EmptyTreeContent } from \"../common/components/EmptyTree.js\";\nimport { Tree } from \"../common/components/Tree.js\";\nimport { TreeRenderer } from \"../common/components/TreeRenderer.js\";\nimport { useGuid } from \"../common/internal/useGuid.js\";\nimport { ExternalSourcesTreeComponent } from \"./ExternalSourcesTreeComponent.js\";\nimport { ExternalSourcesTreeDefinition } from \"./ExternalSourcesTreeDefinition.js\";\n\nimport type { GuidString } from \"@itwin/core-bentley\";\nimport type { PresentationHierarchyNode } from \"@itwin/presentation-hierarchies-react\";\nimport type { Props } from \"@itwin/presentation-shared\";\nimport type { BaseTreeRendererProps } from \"../common/components/BaseTreeRenderer.js\";\nimport type { TreeProps } from \"../common/components/Tree.js\";\n\n/** @beta */\nexport type ExternalSourcesTreeProps = Pick<TreeProps, \"imodel\" | \"selectionStorage\" | \"selectionMode\" | \"emptyTreeContent\"> &\n Pick<BaseTreeRendererProps, \"getInlineActions\" | \"getMenuActions\" | \"getContextMenuActions\" | \"getDecorations\" | \"treeLabel\"> & {\n hierarchyLevelConfig?: {\n sizeLimit?: number;\n };\n };\n\n/** @beta */\nexport function ExternalSourcesTree({\n getInlineActions,\n getMenuActions,\n getContextMenuActions,\n getDecorations,\n selectionMode,\n treeLabel,\n ...rest\n}: ExternalSourcesTreeProps) {\n const componentId = useGuid();\n return (\n <Tree\n emptyTreeContent={<EmptyTreeContent icon={documentSvg} />}\n {...rest}\n treeName={ExternalSourcesTreeComponent.id}\n getHierarchyDefinition={useCallback((definitionProps) => getDefinitionsProvider({ ...definitionProps, componentId }), [componentId])}\n selectionMode={selectionMode ?? \"none\"}\n treeRenderer={(treeProps) => (\n <TreeRenderer\n {...treeProps}\n treeLabel={treeLabel}\n getInlineActions={getInlineActions}\n getMenuActions={getMenuActions}\n getContextMenuActions={getContextMenuActions}\n getDecorations={getDecorations ?? ((node) => <ExternalSourcesTreeIcon node={node} />)}\n />\n )}\n />\n );\n}\n\nconst getDefinitionsProvider = (props: Props<TreeProps[\"getHierarchyDefinition\"]> & { componentId: GuidString }) => {\n return new ExternalSourcesTreeDefinition(props);\n};\n\n/** @beta */\nexport function ExternalSourcesTreeIcon({ node }: { node: PresentationHierarchyNode }) {\n if (node.nodeData.extendedData?.imageId === undefined) {\n return undefined;\n }\n const getIcon = () => {\n switch (node.nodeData.extendedData!.imageId) {\n case \"icon-item\":\n return elementSvg;\n case \"icon-ec-class\":\n return classSvg;\n case \"icon-document\":\n return documentSvg;\n case \"icon-ec-schema\":\n return ecSchemaSvg;\n default:\n return undefined;\n }\n };\n\n return <Icon href={getIcon()} />;\n}\n"]}
1
+ {"version":3,"file":"ExternalSourcesTree.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,QAA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AAI,CAAC;AACnC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useCallback } from \"react\";\nimport { Icon } from \"@stratakit/foundations\";\nimport classSvg from \"@stratakit/icons/bis-class.svg\";\nimport elementSvg from \"@stratakit/icons/bis-element.svg\";\nimport documentSvg from \"@stratakit/icons/document.svg\";\nimport ecSchemaSvg from \"@stratakit/icons/selection-children.svg\";\nimport { EmptyTreeContent } from \"../common/components/EmptyTree.js\";\nimport { Tree } from \"../common/components/Tree.js\";\nimport { TreeRenderer } from \"../common/components/TreeRenderer.js\";\nimport { useGuid } from \"../common/internal/useGuid.js\";\nimport { ExternalSourcesTreeComponent } from \"./ExternalSourcesTreeComponent.js\";\nimport { ExternalSourcesTreeDefinition } from \"./ExternalSourcesTreeDefinition.js\";\n\nimport type { GuidString } from \"@itwin/core-bentley\";\nimport type { PresentationHierarchyNode } from \"@itwin/presentation-hierarchies-react\";\nimport type { Props } from \"@itwin/presentation-shared\";\nimport type { TreeProps } from \"../common/components/Tree.js\";\nimport type { ExtendedTreeRendererProps } from \"../common/components/TreeRenderer.js\";\n\n/** @beta */\nexport type ExternalSourcesTreeProps = Pick<\n ExtendedTreeRendererProps,\n \"getInlineActions\" | \"getMenuActions\" | \"getContextMenuActions\" | \"getTreeItemProps\" | \"treeLabel\"\n> &\n Pick<TreeProps, \"imodel\" | \"selectionStorage\" | \"selectionMode\" | \"emptyTreeContent\"> & {\n hierarchyLevelConfig?: {\n sizeLimit?: number;\n };\n };\n\n/** @beta */\nexport function ExternalSourcesTree({\n getInlineActions,\n getMenuActions,\n getContextMenuActions,\n getTreeItemProps,\n selectionMode,\n treeLabel,\n ...rest\n}: ExternalSourcesTreeProps) {\n const componentId = useGuid();\n return (\n <Tree\n emptyTreeContent={<EmptyTreeContent icon={documentSvg} />}\n {...rest}\n treeName={ExternalSourcesTreeComponent.id}\n getHierarchyDefinition={useCallback((definitionProps) => getDefinitionsProvider({ ...definitionProps, componentId }), [componentId])}\n selectionMode={selectionMode ?? \"none\"}\n treeRenderer={(treeProps) => (\n <TreeRenderer\n {...treeProps}\n treeLabel={treeLabel}\n getInlineActions={getInlineActions ? (node) => getInlineActions(node, treeProps) : undefined}\n getMenuActions={getMenuActions ? (node) => getMenuActions(node, treeProps) : undefined}\n getContextMenuActions={getContextMenuActions ? (node) => getContextMenuActions(node, treeProps) : undefined}\n getTreeItemProps={(node) => ({\n decorations: <ExternalSourcesTreeIcon node={node} />,\n ...(getTreeItemProps ? getTreeItemProps(node, treeProps) : {}),\n })}\n />\n )}\n />\n );\n}\n\nconst getDefinitionsProvider = (props: Props<TreeProps[\"getHierarchyDefinition\"]> & { componentId: GuidString }) => {\n return new ExternalSourcesTreeDefinition(props);\n};\n\n/** @beta */\nexport function ExternalSourcesTreeIcon({ node }: { node: PresentationHierarchyNode }) {\n if (node.nodeData.extendedData?.imageId === undefined) {\n return undefined;\n }\n const getIcon = () => {\n switch (node.nodeData.extendedData!.imageId) {\n case \"icon-item\":\n return elementSvg;\n case \"icon-ec-class\":\n return classSvg;\n case \"icon-document\":\n return documentSvg;\n case \"icon-ec-schema\":\n return ecSchemaSvg;\n default:\n return undefined;\n }\n };\n\n return <Icon href={getIcon()} />;\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import type { ExternalSourcesTreeProps } from "./ExternalSourcesTree.js";
2
2
  /** @beta */
3
- interface ExternalSourcesTreeComponentProps extends Pick<ExternalSourcesTreeProps, "selectionStorage" | "selectionMode" | "hierarchyLevelConfig" | "selectionMode" | "emptyTreeContent" | "getInlineActions" | "getMenuActions" | "getContextMenuActions" | "getDecorations" | "treeLabel"> {
3
+ interface ExternalSourcesTreeComponentProps extends Pick<ExternalSourcesTreeProps, "selectionStorage" | "selectionMode" | "hierarchyLevelConfig" | "selectionMode" | "emptyTreeContent" | "getInlineActions" | "getMenuActions" | "getContextMenuActions" | "getTreeItemProps" | "treeLabel"> {
4
4
  onPerformanceMeasured?: (featureId: string, duration: number) => void;
5
5
  onFeatureUsed?: (feature: string) => void;
6
6
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ExternalSourcesTreeComponent.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeComponent.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAuB/D;;;GAGG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,EAAE,aAAa,EAAE,qBAAqB,EAAE,SAAS,EAAE,GAAG,KAAK,EAAqC,EAAE,EAAE;IAC/I,MAAM,MAAM,GAAG,yBAAyB,EAAE,CAAC;IAE3C,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,CACL,KAAC,wBAAwB,IAAC,mBAAmB,EAAE,4BAA4B,CAAC,EAAE,EAAE,aAAa,EAAE,aAAa,EAAE,qBAAqB,EAAE,qBAAqB,YACxJ,KAAC,cAAc,cACb,KAAC,mBAAmB,OAAK,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,GAAI,GACzD,GACQ,CAC5B,CAAC;AACJ,CAAC,CAAC;AAEF;;;GAGG;AACH,4BAA4B,CAAC,EAAE,GAAG,0BAA0B,CAAC;AAE7D;;;GAGG;AACH,4BAA4B,CAAC,QAAQ,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,2BAA2B,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport { TreeWidget } from \"../../../TreeWidget.js\";\nimport { SelectableTree } from \"../../tree-header/SelectableTree.js\";\nimport { TelemetryContextProvider } from \"../common/UseTelemetryContext.js\";\nimport { ExternalSourcesTree } from \"./ExternalSourcesTree.js\";\n\nimport type { ExternalSourcesTreeProps } from \"./ExternalSourcesTree.js\";\n\n/** @beta */\ninterface ExternalSourcesTreeComponentProps\n extends Pick<\n ExternalSourcesTreeProps,\n | \"selectionStorage\"\n | \"selectionMode\"\n | \"hierarchyLevelConfig\"\n | \"selectionMode\"\n | \"emptyTreeContent\"\n | \"getInlineActions\"\n | \"getMenuActions\"\n | \"getContextMenuActions\"\n | \"getDecorations\"\n | \"treeLabel\"\n > {\n onPerformanceMeasured?: (featureId: string, duration: number) => void;\n onFeatureUsed?: (feature: string) => void;\n}\n\n/**\n * A component that renders `ExternalSourcesTree`.\n * @beta\n */\nexport const ExternalSourcesTreeComponent = ({ onFeatureUsed, onPerformanceMeasured, treeLabel, ...props }: ExternalSourcesTreeComponentProps) => {\n const imodel = useActiveIModelConnection();\n\n if (!imodel) {\n return null;\n }\n\n return (\n <TelemetryContextProvider componentIdentifier={ExternalSourcesTreeComponent.id} onFeatureUsed={onFeatureUsed} onPerformanceMeasured={onPerformanceMeasured}>\n <SelectableTree>\n <ExternalSourcesTree {...props} imodel={imodel} treeLabel={treeLabel} />\n </SelectableTree>\n </TelemetryContextProvider>\n );\n};\n\n/**\n * Id of the component. May be used when a creating a `TreeDefinition` for `SelectableTree`.\n * @beta\n */\nExternalSourcesTreeComponent.id = \"external-sources-tree-v2\";\n\n/**\n * Label of the component. May be used when a creating a `TreeDefinition` for `SelectableTree`.\n * @beta\n */\nExternalSourcesTreeComponent.getLabel = () => TreeWidget.translate(\"externalSourcesTree.label\");\n"]}
1
+ {"version":3,"file":"ExternalSourcesTreeComponent.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeComponent.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAuB/D;;;GAGG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,EAAE,aAAa,EAAE,qBAAqB,EAAE,SAAS,EAAE,GAAG,KAAK,EAAqC,EAAE,EAAE;IAC/I,MAAM,MAAM,GAAG,yBAAyB,EAAE,CAAC;IAE3C,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,CACL,KAAC,wBAAwB,IAAC,mBAAmB,EAAE,4BAA4B,CAAC,EAAE,EAAE,aAAa,EAAE,aAAa,EAAE,qBAAqB,EAAE,qBAAqB,YACxJ,KAAC,cAAc,cACb,KAAC,mBAAmB,OAAK,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,GAAI,GACzD,GACQ,CAC5B,CAAC;AACJ,CAAC,CAAC;AAEF;;;GAGG;AACH,4BAA4B,CAAC,EAAE,GAAG,0BAA0B,CAAC;AAE7D;;;GAGG;AACH,4BAA4B,CAAC,QAAQ,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,2BAA2B,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport { TreeWidget } from \"../../../TreeWidget.js\";\nimport { SelectableTree } from \"../../tree-header/SelectableTree.js\";\nimport { TelemetryContextProvider } from \"../common/UseTelemetryContext.js\";\nimport { ExternalSourcesTree } from \"./ExternalSourcesTree.js\";\n\nimport type { ExternalSourcesTreeProps } from \"./ExternalSourcesTree.js\";\n\n/** @beta */\ninterface ExternalSourcesTreeComponentProps\n extends Pick<\n ExternalSourcesTreeProps,\n | \"selectionStorage\"\n | \"selectionMode\"\n | \"hierarchyLevelConfig\"\n | \"selectionMode\"\n | \"emptyTreeContent\"\n | \"getInlineActions\"\n | \"getMenuActions\"\n | \"getContextMenuActions\"\n | \"getTreeItemProps\"\n | \"treeLabel\"\n > {\n onPerformanceMeasured?: (featureId: string, duration: number) => void;\n onFeatureUsed?: (feature: string) => void;\n}\n\n/**\n * A component that renders `ExternalSourcesTree`.\n * @beta\n */\nexport const ExternalSourcesTreeComponent = ({ onFeatureUsed, onPerformanceMeasured, treeLabel, ...props }: ExternalSourcesTreeComponentProps) => {\n const imodel = useActiveIModelConnection();\n\n if (!imodel) {\n return null;\n }\n\n return (\n <TelemetryContextProvider componentIdentifier={ExternalSourcesTreeComponent.id} onFeatureUsed={onFeatureUsed} onPerformanceMeasured={onPerformanceMeasured}>\n <SelectableTree>\n <ExternalSourcesTree {...props} imodel={imodel} treeLabel={treeLabel} />\n </SelectableTree>\n </TelemetryContextProvider>\n );\n};\n\n/**\n * Id of the component. May be used when a creating a `TreeDefinition` for `SelectableTree`.\n * @beta\n */\nExternalSourcesTreeComponent.id = \"external-sources-tree-v2\";\n\n/**\n * Label of the component. May be used when a creating a `TreeDefinition` for `SelectableTree`.\n * @beta\n */\nExternalSourcesTreeComponent.getLabel = () => TreeWidget.translate(\"externalSourcesTree.label\");\n"]}
@@ -1,16 +1,16 @@
1
1
  import type { PresentationHierarchyNode } from "@itwin/presentation-hierarchies-react";
2
- import type { BaseTreeRendererProps } from "../common/components/BaseTreeRenderer.js";
3
2
  import type { TreeProps } from "../common/components/Tree.js";
3
+ import type { ExtendedTreeRendererProps } from "../common/components/TreeRenderer.js";
4
4
  import type { IModelContentTreeHierarchyConfiguration } from "./IModelContentTreeDefinition.js";
5
5
  /** @beta */
6
- export type IModelContentTreeProps = Pick<TreeProps, "imodel" | "selectionStorage" | "selectionMode" | "emptyTreeContent"> & Pick<BaseTreeRendererProps, "getInlineActions" | "getMenuActions" | "getContextMenuActions" | "getDecorations" | "treeLabel"> & {
6
+ export type IModelContentTreeProps = Pick<ExtendedTreeRendererProps, "getInlineActions" | "getMenuActions" | "getContextMenuActions" | "getTreeItemProps" | "treeLabel"> & Pick<TreeProps, "imodel" | "selectionStorage" | "selectionMode" | "emptyTreeContent"> & {
7
7
  hierarchyLevelConfig?: {
8
8
  sizeLimit?: number;
9
9
  };
10
10
  hierarchyConfig?: Partial<IModelContentTreeHierarchyConfiguration>;
11
11
  };
12
12
  /** @beta */
13
- export declare function IModelContentTree({ getInlineActions, getMenuActions, getContextMenuActions, getDecorations, selectionMode, treeLabel, hierarchyConfig: hierarchyConfigProp, ...rest }: IModelContentTreeProps): import("react/jsx-runtime").JSX.Element;
13
+ export declare function IModelContentTree({ getInlineActions, getMenuActions, getContextMenuActions, getTreeItemProps, selectionMode, treeLabel, hierarchyConfig: hierarchyConfigProp, ...rest }: IModelContentTreeProps): import("react/jsx-runtime").JSX.Element;
14
14
  /** @beta */
15
15
  export declare function IModelContentTreeIcon({ node }: {
16
16
  node: PresentationHierarchyNode;
@@ -20,7 +20,7 @@ import { IModelContentTreeComponent } from "./IModelContentTreeComponent.js";
20
20
  import { defaultHierarchyConfiguration, IModelContentTreeDefinition } from "./IModelContentTreeDefinition.js";
21
21
  import { IModelContentTreeIdsCache } from "./internal/IModelContentTreeIdsCache.js";
22
22
  /** @beta */
23
- export function IModelContentTree({ getInlineActions, getMenuActions, getContextMenuActions, getDecorations, selectionMode, treeLabel, hierarchyConfig: hierarchyConfigProp, ...rest }) {
23
+ export function IModelContentTree({ getInlineActions, getMenuActions, getContextMenuActions, getTreeItemProps, selectionMode, treeLabel, hierarchyConfig: hierarchyConfigProp, ...rest }) {
24
24
  const componentId = useGuid();
25
25
  const getHierarchyDefinition = useCallback(({ imodelAccess }) => {
26
26
  const hierarchyConfig = {
@@ -31,7 +31,10 @@ export function IModelContentTree({ getInlineActions, getMenuActions, getContext
31
31
  },
32
32
  // eslint-disable-next-line react-hooks/exhaustive-deps
33
33
  Object.values({ ...(hierarchyConfigProp ?? {}), componentId }));
34
- return (_jsx(Tree, { emptyTreeContent: _jsx(EmptyTreeContent, { icon: modelSvg }), ...rest, treeName: IModelContentTreeComponent.id, getHierarchyDefinition: getHierarchyDefinition, selectionMode: selectionMode ?? "extended", treeRenderer: (treeProps) => (_jsx(TreeRenderer, { ...treeProps, treeLabel: treeLabel, getInlineActions: getInlineActions, getMenuActions: getMenuActions, getContextMenuActions: getContextMenuActions, getDecorations: getDecorations ?? ((node) => _jsx(IModelContentTreeIcon, { node: node })) })) }));
34
+ return (_jsx(Tree, { emptyTreeContent: _jsx(EmptyTreeContent, { icon: modelSvg }), ...rest, treeName: IModelContentTreeComponent.id, getHierarchyDefinition: getHierarchyDefinition, selectionMode: selectionMode ?? "extended", treeRenderer: (treeProps) => (_jsx(TreeRenderer, { ...treeProps, treeLabel: treeLabel, getInlineActions: getInlineActions ? (node) => getInlineActions(node, treeProps) : undefined, getMenuActions: getMenuActions ? (node) => getMenuActions(node, treeProps) : undefined, getContextMenuActions: getContextMenuActions ? (node) => getContextMenuActions(node, treeProps) : undefined, getTreeItemProps: (node) => ({
35
+ decorations: _jsx(IModelContentTreeIcon, { node: node }),
36
+ ...(getTreeItemProps ? getTreeItemProps(node, treeProps) : {}),
37
+ }) })) }));
35
38
  }
36
39
  /** @beta */
37
40
  export function IModelContentTreeIcon({ node }) {
@@ -1 +1 @@
1
- {"version":3,"file":"IModelContentTree.js","sourceRoot":"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,aAAa;gBAChB,OAAO,UAAU,CAAC;YACpB,KAAK,YAAY;gBACf,OAAO,QAAQ,CAAC;YAClB,KAAK,qBAAqB;gBACxB,OAAO,gBAAgB,CAAC;YAC1B,KAAK,YAAY;gBACf,OAAO,QAAQ,CAAC;YAClB;gBACE,OAAO,SAAS,CAAC;QACrB,CAAC;IACH,CAAC,CAAC;IAEF,OAAO,KAAC,IAAI,IAAC,IAAI,EAAE,OAAO,EAAE,GAAI,CAAC;AACnC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useCallback } from \"react\";\nimport { Icon } from \"@stratakit/foundations\";\nimport categorySvg from \"@stratakit/icons/bis-category-3d.svg\";\nimport classSvg from \"@stratakit/icons/bis-class.svg\";\nimport elementSvg from \"@stratakit/icons/bis-element.svg\";\nimport subjectSvg from \"@stratakit/icons/bis-subject.svg\";\nimport groupSvg from \"@stratakit/icons/group.svg\";\nimport modelSvg from \"@stratakit/icons/model-cube.svg\";\nimport hierarchyTreeSvg from \"@stratakit/icons/selection-children.svg\";\nimport { EmptyTreeContent } from \"../common/components/EmptyTree.js\";\nimport { Tree } from \"../common/components/Tree.js\";\nimport { TreeRenderer } from \"../common/components/TreeRenderer.js\";\nimport { useGuid } from \"../common/internal/useGuid.js\";\nimport { IModelContentTreeComponent } from \"./IModelContentTreeComponent.js\";\nimport { defaultHierarchyConfiguration, IModelContentTreeDefinition } from \"./IModelContentTreeDefinition.js\";\nimport { IModelContentTreeIdsCache } from \"./internal/IModelContentTreeIdsCache.js\";\n\nimport type { PresentationHierarchyNode } from \"@itwin/presentation-hierarchies-react\";\nimport type { BaseTreeRendererProps } from \"../common/components/BaseTreeRenderer.js\";\nimport type { TreeProps } from \"../common/components/Tree.js\";\nimport type { IModelContentTreeHierarchyConfiguration } from \"./IModelContentTreeDefinition.js\";\n\n/** @beta */\nexport type IModelContentTreeProps = Pick<TreeProps, \"imodel\" | \"selectionStorage\" | \"selectionMode\" | \"emptyTreeContent\"> &\n Pick<BaseTreeRendererProps, \"getInlineActions\" | \"getMenuActions\" | \"getContextMenuActions\" | \"getDecorations\" | \"treeLabel\"> & {\n hierarchyLevelConfig?: {\n sizeLimit?: number;\n };\n hierarchyConfig?: Partial<IModelContentTreeHierarchyConfiguration>;\n };\n\n/** @beta */\nexport function IModelContentTree({\n getInlineActions,\n getMenuActions,\n getContextMenuActions,\n getDecorations,\n selectionMode,\n treeLabel,\n hierarchyConfig: hierarchyConfigProp,\n ...rest\n}: IModelContentTreeProps) {\n const componentId = useGuid();\n const getHierarchyDefinition = useCallback<TreeProps[\"getHierarchyDefinition\"]>(\n ({ imodelAccess }) => {\n const hierarchyConfig = {\n ...defaultHierarchyConfiguration,\n ...hierarchyConfigProp,\n };\n return new IModelContentTreeDefinition({ imodelAccess, idsCache: new IModelContentTreeIdsCache(imodelAccess, componentId), hierarchyConfig });\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n Object.values({ ...(hierarchyConfigProp ?? {}), componentId }),\n );\n\n return (\n <Tree\n emptyTreeContent={<EmptyTreeContent icon={modelSvg} />}\n {...rest}\n treeName={IModelContentTreeComponent.id}\n getHierarchyDefinition={getHierarchyDefinition}\n selectionMode={selectionMode ?? \"extended\"}\n treeRenderer={(treeProps) => (\n <TreeRenderer\n {...treeProps}\n treeLabel={treeLabel}\n getInlineActions={getInlineActions}\n getMenuActions={getMenuActions}\n getContextMenuActions={getContextMenuActions}\n getDecorations={getDecorations ?? ((node) => <IModelContentTreeIcon node={node} />)}\n />\n )}\n />\n );\n}\n\n/** @beta */\nexport function IModelContentTreeIcon({ node }: { node: PresentationHierarchyNode }) {\n if (node.nodeData.extendedData?.imageId === undefined) {\n return undefined;\n }\n\n const getIcon = () => {\n switch (node.nodeData.extendedData!.imageId) {\n case \"icon-layers\":\n return categorySvg;\n case \"icon-item\":\n return elementSvg;\n case \"icon-ec-class\":\n return classSvg;\n case \"icon-folder\":\n return subjectSvg;\n case \"icon-model\":\n return modelSvg;\n case \"icon-hierarchy-tree\":\n return hierarchyTreeSvg;\n case \"icon-group\":\n return groupSvg;\n default:\n return undefined;\n }\n };\n\n return <Icon href={getIcon()} />;\n}\n"]}
1
+ {"version":3,"file":"IModelContentTree.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,WAAW,MAAM,sCAAsC,CAAC;AAC/D,OAAO,QAAQ,MAAM,gCAAgC,CAAC;AACtD,OAAO,UAAU,MAAM,kCAAkC,CAAC;AAC1D,OAAO,UAAU,MAAM,kCAAkC,CAAC;AAC1D,OAAO,QAAQ,MAAM,4BAA4B,CAAC;AAClD,OAAO,QAAQ,MAAM,iCAAiC,CAAC;AACvD,OAAO,gBAAgB,MAAM,yCAAyC,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,6BAA6B,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC9G,OAAO,EAAE,yBAAyB,EAAE,MAAM,yCAAyC,CAAC;AAmBpF,YAAY;AACZ,MAAM,UAAU,iBAAiB,CAAC,EAChC,gBAAgB,EAChB,cAAc,EACd,qBAAqB,EACrB,gBAAgB,EAChB,aAAa,EACb,SAAS,EACT,eAAe,EAAE,mBAAmB,EACp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EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;gBAC3B,WAAW,EAAE,KAAC,qBAAqB,IAAC,IAAI,EAAE,IAAI,GAAI;gBAClD,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC,gBAAgB,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;aAC/D,CAAC,GACF,CACH,GACD,CACH,CAAC;AACJ,CAAC;AAED,YAAY;AACZ,MAAM,UAAU,qBAAqB,CAAC,EAAE,IAAI,EAAuC;IACjF,IAAI,IAAI,CAAC,QAAQ,CAAC,YAAY,EAAE,OAAO,KAAK,SAAS,EAAE,CAAC;QACtD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,OAAO,GAAG,GAAG,EAAE;QACnB,QAAQ,IAAI,CAAC,QAAQ,CAAC,YAAa,CAAC,OAAO,EAAE,CAAC;YAC5C,KAAK,aAAa;gBAChB,OAAO,WAAW,CAAC;YACrB,KAAK,WAAW;gBACd,OAAO,UAAU,CAAC;YACpB,KAAK,eAAe;gBAClB,OAAO,QAAQ,CAAC;YAClB,KAAK,aAAa;gBAChB,OAAO,UAAU,CAAC;YACpB,KAAK,YAAY;gBACf,OAAO,QAAQ,CAAC;YAClB,KAAK,qBAAqB;gBACxB,OAAO,gBAAgB,CAAC;YAC1B,KAAK,YAAY;gBACf,OAAO,QAAQ,CAAC;YAClB;gBACE,OAAO,SAAS,CAAC;QACrB,CAAC;IACH,CAAC,CAAC;IAEF,OAAO,KAAC,IAAI,IAAC,IAAI,EAAE,OAAO,EAAE,GAAI,CAAC;AACnC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useCallback } from \"react\";\nimport { Icon } from \"@stratakit/foundations\";\nimport categorySvg from \"@stratakit/icons/bis-category-3d.svg\";\nimport classSvg from \"@stratakit/icons/bis-class.svg\";\nimport elementSvg from \"@stratakit/icons/bis-element.svg\";\nimport subjectSvg from \"@stratakit/icons/bis-subject.svg\";\nimport groupSvg from \"@stratakit/icons/group.svg\";\nimport modelSvg from \"@stratakit/icons/model-cube.svg\";\nimport hierarchyTreeSvg from \"@stratakit/icons/selection-children.svg\";\nimport { EmptyTreeContent } from \"../common/components/EmptyTree.js\";\nimport { Tree } from \"../common/components/Tree.js\";\nimport { TreeRenderer } from \"../common/components/TreeRenderer.js\";\nimport { useGuid } from \"../common/internal/useGuid.js\";\nimport { IModelContentTreeComponent } from \"./IModelContentTreeComponent.js\";\nimport { defaultHierarchyConfiguration, IModelContentTreeDefinition } from \"./IModelContentTreeDefinition.js\";\nimport { IModelContentTreeIdsCache } from \"./internal/IModelContentTreeIdsCache.js\";\n\nimport type { PresentationHierarchyNode } from \"@itwin/presentation-hierarchies-react\";\nimport type { TreeProps } from \"../common/components/Tree.js\";\nimport type { ExtendedTreeRendererProps } from \"../common/components/TreeRenderer.js\";\nimport type { IModelContentTreeHierarchyConfiguration } from \"./IModelContentTreeDefinition.js\";\n\n/** @beta */\nexport type IModelContentTreeProps = Pick<\n ExtendedTreeRendererProps,\n \"getInlineActions\" | \"getMenuActions\" | \"getContextMenuActions\" | \"getTreeItemProps\" | \"treeLabel\"\n> &\n Pick<TreeProps, \"imodel\" | \"selectionStorage\" | \"selectionMode\" | \"emptyTreeContent\"> & {\n hierarchyLevelConfig?: {\n sizeLimit?: number;\n };\n hierarchyConfig?: Partial<IModelContentTreeHierarchyConfiguration>;\n };\n\n/** @beta */\nexport function IModelContentTree({\n getInlineActions,\n getMenuActions,\n getContextMenuActions,\n getTreeItemProps,\n selectionMode,\n treeLabel,\n hierarchyConfig: hierarchyConfigProp,\n ...rest\n}: IModelContentTreeProps) {\n const componentId = useGuid();\n const getHierarchyDefinition = useCallback<TreeProps[\"getHierarchyDefinition\"]>(\n ({ imodelAccess }) => {\n const hierarchyConfig = {\n ...defaultHierarchyConfiguration,\n ...hierarchyConfigProp,\n };\n return new IModelContentTreeDefinition({ imodelAccess, idsCache: new IModelContentTreeIdsCache(imodelAccess, componentId), hierarchyConfig });\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n Object.values({ ...(hierarchyConfigProp ?? {}), componentId }),\n );\n\n return (\n <Tree\n emptyTreeContent={<EmptyTreeContent icon={modelSvg} />}\n {...rest}\n treeName={IModelContentTreeComponent.id}\n getHierarchyDefinition={getHierarchyDefinition}\n selectionMode={selectionMode ?? \"extended\"}\n treeRenderer={(treeProps) => (\n <TreeRenderer\n {...treeProps}\n treeLabel={treeLabel}\n getInlineActions={getInlineActions ? (node) => getInlineActions(node, treeProps) : undefined}\n getMenuActions={getMenuActions ? (node) => getMenuActions(node, treeProps) : undefined}\n getContextMenuActions={getContextMenuActions ? (node) => getContextMenuActions(node, treeProps) : undefined}\n getTreeItemProps={(node) => ({\n decorations: <IModelContentTreeIcon node={node} />,\n ...(getTreeItemProps ? getTreeItemProps(node, treeProps) : {}),\n })}\n />\n )}\n />\n );\n}\n\n/** @beta */\nexport function IModelContentTreeIcon({ node }: { node: PresentationHierarchyNode }) {\n if (node.nodeData.extendedData?.imageId === undefined) {\n return undefined;\n }\n\n const getIcon = () => {\n switch (node.nodeData.extendedData!.imageId) {\n case \"icon-layers\":\n return categorySvg;\n case \"icon-item\":\n return elementSvg;\n case \"icon-ec-class\":\n return classSvg;\n case \"icon-folder\":\n return subjectSvg;\n case \"icon-model\":\n return modelSvg;\n case \"icon-hierarchy-tree\":\n return hierarchyTreeSvg;\n case \"icon-group\":\n return groupSvg;\n default:\n return undefined;\n }\n };\n\n return <Icon href={getIcon()} />;\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import type { IModelContentTreeProps } from "./IModelContentTree.js";
2
2
  /** @beta */
3
- interface IModelContentTreeComponentProps extends Pick<IModelContentTreeProps, "selectionStorage" | "hierarchyConfig" | "hierarchyLevelConfig" | "selectionMode" | "emptyTreeContent" | "getInlineActions" | "getMenuActions" | "getContextMenuActions" | "getDecorations" | "treeLabel"> {
3
+ interface IModelContentTreeComponentProps extends Pick<IModelContentTreeProps, "selectionStorage" | "hierarchyConfig" | "hierarchyLevelConfig" | "selectionMode" | "emptyTreeContent" | "getInlineActions" | "getMenuActions" | "getContextMenuActions" | "getTreeItemProps" | "treeLabel"> {
4
4
  onPerformanceMeasured?: (featureId: string, duration: number) => void;
5
5
  onFeatureUsed?: (feature: string) => void;
6
6
  }
@@ -1 +1 @@
1
- {"version":3,"file":"IModelContentTreeComponent.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeComponent.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAuB3D;;;GAGG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,EAAE,aAAa,EAAE,qBAAqB,EAAE,SAAS,EAAE,GAAG,KAAK,EAAmC,EAAE,EAAE;IAC3I,MAAM,MAAM,GAAG,yBAAyB,EAAE,CAAC;IAE3C,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,CACL,KAAC,wBAAwB,IAAC,mBAAmB,EAAE,0BAA0B,CAAC,EAAE,EAAE,aAAa,EAAE,aAAa,EAAE,qBAAqB,EAAE,qBAAqB,YACtJ,KAAC,cAAc,cACb,KAAC,iBAAiB,OAAK,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,GAAI,GACvD,GACQ,CAC5B,CAAC;AACJ,CAAC,CAAC;AAEF;;;GAGG;AACH,0BAA0B,CAAC,EAAE,GAAG,wBAAwB,CAAC;AAEzD;;;GAGG;AACH,0BAA0B,CAAC,QAAQ,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,yBAAyB,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport { TreeWidget } from \"../../../TreeWidget.js\";\nimport { SelectableTree } from \"../../tree-header/SelectableTree.js\";\nimport { TelemetryContextProvider } from \"../common/UseTelemetryContext.js\";\nimport { IModelContentTree } from \"./IModelContentTree.js\";\n\nimport type { IModelContentTreeProps } from \"./IModelContentTree.js\";\n\n/** @beta */\ninterface IModelContentTreeComponentProps\n extends Pick<\n IModelContentTreeProps,\n | \"selectionStorage\"\n | \"hierarchyConfig\"\n | \"hierarchyLevelConfig\"\n | \"selectionMode\"\n | \"emptyTreeContent\"\n | \"getInlineActions\"\n | \"getMenuActions\"\n | \"getContextMenuActions\"\n | \"getDecorations\"\n | \"treeLabel\"\n > {\n onPerformanceMeasured?: (featureId: string, duration: number) => void;\n onFeatureUsed?: (feature: string) => void;\n}\n\n/**\n * A component that renders `IModelContentTree`.\n * @beta\n */\nexport const IModelContentTreeComponent = ({ onFeatureUsed, onPerformanceMeasured, treeLabel, ...props }: IModelContentTreeComponentProps) => {\n const imodel = useActiveIModelConnection();\n\n if (!imodel) {\n return null;\n }\n\n return (\n <TelemetryContextProvider componentIdentifier={IModelContentTreeComponent.id} onFeatureUsed={onFeatureUsed} onPerformanceMeasured={onPerformanceMeasured}>\n <SelectableTree>\n <IModelContentTree {...props} imodel={imodel} treeLabel={treeLabel} />\n </SelectableTree>\n </TelemetryContextProvider>\n );\n};\n\n/**\n * Id of the component. May be used when a creating a `TreeDefinition` for `SelectableTree`.\n * @beta\n */\nIModelContentTreeComponent.id = \"imodel-content-tree-v2\";\n\n/**\n * Label of the component. May be used when a creating a `TreeDefinition` for `SelectableTree`.\n * @beta\n */\nIModelContentTreeComponent.getLabel = () => TreeWidget.translate(\"imodelContentTree.label\");\n"]}
1
+ {"version":3,"file":"IModelContentTreeComponent.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeComponent.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAuB3D;;;GAGG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,EAAE,aAAa,EAAE,qBAAqB,EAAE,SAAS,EAAE,GAAG,KAAK,EAAmC,EAAE,EAAE;IAC3I,MAAM,MAAM,GAAG,yBAAyB,EAAE,CAAC;IAE3C,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,CACL,KAAC,wBAAwB,IAAC,mBAAmB,EAAE,0BAA0B,CAAC,EAAE,EAAE,aAAa,EAAE,aAAa,EAAE,qBAAqB,EAAE,qBAAqB,YACtJ,KAAC,cAAc,cACb,KAAC,iBAAiB,OAAK,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,GAAI,GACvD,GACQ,CAC5B,CAAC;AACJ,CAAC,CAAC;AAEF;;;GAGG;AACH,0BAA0B,CAAC,EAAE,GAAG,wBAAwB,CAAC;AAEzD;;;GAGG;AACH,0BAA0B,CAAC,QAAQ,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,yBAAyB,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport { TreeWidget } from \"../../../TreeWidget.js\";\nimport { SelectableTree } from \"../../tree-header/SelectableTree.js\";\nimport { TelemetryContextProvider } from \"../common/UseTelemetryContext.js\";\nimport { IModelContentTree } from \"./IModelContentTree.js\";\n\nimport type { IModelContentTreeProps } from \"./IModelContentTree.js\";\n\n/** @beta */\ninterface IModelContentTreeComponentProps\n extends Pick<\n IModelContentTreeProps,\n | \"selectionStorage\"\n | \"hierarchyConfig\"\n | \"hierarchyLevelConfig\"\n | \"selectionMode\"\n | \"emptyTreeContent\"\n | \"getInlineActions\"\n | \"getMenuActions\"\n | \"getContextMenuActions\"\n | \"getTreeItemProps\"\n | \"treeLabel\"\n > {\n onPerformanceMeasured?: (featureId: string, duration: number) => void;\n onFeatureUsed?: (feature: string) => void;\n}\n\n/**\n * A component that renders `IModelContentTree`.\n * @beta\n */\nexport const IModelContentTreeComponent = ({ onFeatureUsed, onPerformanceMeasured, treeLabel, ...props }: IModelContentTreeComponentProps) => {\n const imodel = useActiveIModelConnection();\n\n if (!imodel) {\n return null;\n }\n\n return (\n <TelemetryContextProvider componentIdentifier={IModelContentTreeComponent.id} onFeatureUsed={onFeatureUsed} onPerformanceMeasured={onPerformanceMeasured}>\n <SelectableTree>\n <IModelContentTree {...props} imodel={imodel} treeLabel={treeLabel} />\n </SelectableTree>\n </TelemetryContextProvider>\n );\n};\n\n/**\n * Id of the component. May be used when a creating a `TreeDefinition` for `SelectableTree`.\n * @beta\n */\nIModelContentTreeComponent.id = \"imodel-content-tree-v2\";\n\n/**\n * Label of the component. May be used when a creating a `TreeDefinition` for `SelectableTree`.\n * @beta\n */\nIModelContentTreeComponent.getLabel = () => TreeWidget.translate(\"imodelContentTree.label\");\n"]}
@@ -4,6 +4,7 @@
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
  import { assert, Guid } from "@itwin/core-bentley";
6
6
  import { CLASS_NAME_GeometricElement2d, CLASS_NAME_GeometricElement3d, CLASS_NAME_InformationPartitionElement, CLASS_NAME_Model, CLASS_NAME_Subject, } from "../../common/internal/ClassNameDefinitions.js";
7
+ import { isBeSqliteInterruptError } from "../../common/internal/UseErrorState.js";
7
8
  import { pushToMap } from "../../common/internal/Utils.js";
8
9
  /** @internal */
9
10
  export class IModelContentTreeIdsCache {
@@ -19,39 +20,53 @@ export class IModelContentTreeIdsCache {
19
20
  this.#componentName = "IModelContentTreeIdsCache";
20
21
  }
21
22
  async *querySubjects() {
22
- const subjectsQuery = `
23
- SELECT
24
- s.ECInstanceId id,
25
- s.Parent.Id parentId,
26
- (
27
- SELECT m.ECInstanceId
28
- FROM ${CLASS_NAME_Model} m
29
- WHERE
30
- m.ECInstanceId = HexToId(json_extract(s.JsonProperties, '$.Subject.Model.TargetPartition'))
31
- AND NOT m.IsPrivate
32
- ) targetPartitionId,
33
- CASE
34
- WHEN (
35
- json_extract(s.JsonProperties, '$.Subject.Job.Bridge') IS NOT NULL
36
- OR json_extract(s.JsonProperties, '$.Subject.Model.Type') = 'Hierarchy'
37
- ) THEN 1
38
- ELSE 0
39
- END hideInHierarchy
40
- FROM ${CLASS_NAME_Subject} s
41
- `;
42
- for await (const row of this.#queryExecutor.createQueryReader({ ecsql: subjectsQuery }, { rowFormat: "ECSqlPropertyNames", limit: "unbounded", restartToken: `${this.#componentName}/${this.#componentId}/subjects` })) {
43
- yield { id: row.id, parentId: row.parentId, targetPartitionId: row.targetPartitionId, hideInHierarchy: !!row.hideInHierarchy };
23
+ try {
24
+ const subjectsQuery = `
25
+ SELECT
26
+ s.ECInstanceId id,
27
+ s.Parent.Id parentId,
28
+ (
29
+ SELECT m.ECInstanceId
30
+ FROM ${CLASS_NAME_Model} m
31
+ WHERE
32
+ m.ECInstanceId = HexToId(json_extract(s.JsonProperties, '$.Subject.Model.TargetPartition'))
33
+ AND NOT m.IsPrivate
34
+ ) targetPartitionId,
35
+ CASE
36
+ WHEN (
37
+ json_extract(s.JsonProperties, '$.Subject.Job.Bridge') IS NOT NULL
38
+ OR json_extract(s.JsonProperties, '$.Subject.Model.Type') = 'Hierarchy'
39
+ ) THEN 1
40
+ ELSE 0
41
+ END hideInHierarchy
42
+ FROM ${CLASS_NAME_Subject} s
43
+ `;
44
+ for await (const row of this.#queryExecutor.createQueryReader({ ecsql: subjectsQuery }, { rowFormat: "ECSqlPropertyNames", limit: "unbounded", restartToken: `${this.#componentName}/${this.#componentId}/subjects` })) {
45
+ yield { id: row.id, parentId: row.parentId, targetPartitionId: row.targetPartitionId, hideInHierarchy: !!row.hideInHierarchy };
46
+ }
47
+ }
48
+ catch (error) {
49
+ if (!isBeSqliteInterruptError(error)) {
50
+ throw error;
51
+ }
44
52
  }
45
53
  }
46
54
  async *queryModels() {
47
- const modelsQuery = `
48
- SELECT p.ECInstanceId id, p.Parent.Id parentId
49
- FROM ${CLASS_NAME_InformationPartitionElement} p
50
- INNER JOIN ${CLASS_NAME_Model} m ON m.ModeledElement.Id = p.ECInstanceId
51
- WHERE NOT m.IsPrivate
52
- `;
53
- for await (const row of this.#queryExecutor.createQueryReader({ ecsql: modelsQuery }, { rowFormat: "ECSqlPropertyNames", limit: "unbounded", restartToken: `${this.#componentName}/${this.#componentId}/models` })) {
54
- yield { id: row.id, parentId: row.parentId };
55
+ try {
56
+ const modelsQuery = `
57
+ SELECT p.ECInstanceId id, p.Parent.Id parentId
58
+ FROM ${CLASS_NAME_InformationPartitionElement} p
59
+ INNER JOIN ${CLASS_NAME_Model} m ON m.ModeledElement.Id = p.ECInstanceId
60
+ WHERE NOT m.IsPrivate
61
+ `;
62
+ for await (const row of this.#queryExecutor.createQueryReader({ ecsql: modelsQuery }, { rowFormat: "ECSqlPropertyNames", limit: "unbounded", restartToken: `${this.#componentName}/${this.#componentId}/models` })) {
63
+ yield { id: row.id, parentId: row.parentId };
64
+ }
65
+ }
66
+ catch (error) {
67
+ if (!isBeSqliteInterruptError(error)) {
68
+ throw error;
69
+ }
55
70
  }
56
71
  }
57
72
  async getSubjectInfos() {
@@ -158,19 +173,26 @@ export class IModelContentTreeIdsCache {
158
173
  return modelIds;
159
174
  }
160
175
  async *queryModelCategories() {
161
- const query = `
162
- SELECT Model.Id modelId, Category.Id categoryId
163
- FROM ${CLASS_NAME_GeometricElement3d}
164
- WHERE Parent.Id IS NULL
165
- GROUP BY Model.Id, Category.Id
166
- UNION ALL
167
- SELECT Model.Id modelId, Category.Id categoryId
168
- FROM ${CLASS_NAME_GeometricElement2d}
169
- WHERE Parent.Id IS NULL
170
- GROUP BY Model.Id, Category.Id
171
- `;
172
- for await (const row of this.#queryExecutor.createQueryReader({ ecsql: query }, { rowFormat: "ECSqlPropertyNames", limit: "unbounded", restartToken: `${this.#componentName}/${this.#componentId}/model-categories` })) {
173
- yield { modelId: row.modelId, categoryId: row.categoryId };
176
+ try {
177
+ const query = `
178
+ SELECT Model.Id modelId, Category.Id categoryId
179
+ FROM ${CLASS_NAME_GeometricElement3d}
180
+ WHERE Parent.Id IS NULL
181
+ GROUP BY Model.Id, Category.Id
182
+ UNION ALL
183
+ SELECT Model.Id modelId, Category.Id categoryId
184
+ FROM ${CLASS_NAME_GeometricElement2d}
185
+ WHERE Parent.Id IS NULL
186
+ GROUP BY Model.Id, Category.Id
187
+ `;
188
+ for await (const row of this.#queryExecutor.createQueryReader({ ecsql: query }, { rowFormat: "ECSqlPropertyNames", limit: "unbounded", restartToken: `${this.#componentName}/${this.#componentId}/model-categories` })) {
189
+ yield { modelId: row.modelId, categoryId: row.categoryId };
190
+ }
191
+ }
192
+ catch (error) {
193
+ if (!isBeSqliteInterruptError(error)) {
194
+ throw error;
195
+ }
174
196
  }
175
197
  }
176
198
  async getModelInfos() {