@itwin/tree-widget-react 3.0.0-dev.4 → 3.0.0-dev.5

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 (82) hide show
  1. package/README.md +27 -0
  2. package/lib/cjs/components/SelectableTree.js +1 -2
  3. package/lib/cjs/components/SelectableTree.js.map +1 -1
  4. package/lib/cjs/components/SelectableTree.scss +5 -0
  5. package/lib/cjs/components/tree-header/TreeHeader.d.ts +3 -2
  6. package/lib/cjs/components/tree-header/TreeHeader.js +1 -1
  7. package/lib/cjs/components/tree-header/TreeHeader.js.map +1 -1
  8. package/lib/cjs/components/trees/categories-tree/CategoriesTreeComponent.js +2 -1
  9. package/lib/cjs/components/trees/categories-tree/CategoriesTreeComponent.js.map +1 -1
  10. package/lib/cjs/components/trees/categories-tree/CategoriesTreeDefinition.d.ts +2 -2
  11. package/lib/cjs/components/trees/categories-tree/CategoriesTreeDefinition.js +5 -4
  12. package/lib/cjs/components/trees/categories-tree/CategoriesTreeDefinition.js.map +1 -1
  13. package/lib/cjs/components/trees/categories-tree/UseCategoriesTree.js +2 -1
  14. package/lib/cjs/components/trees/categories-tree/UseCategoriesTree.js.map +1 -1
  15. package/lib/cjs/components/trees/common/FocusedInstancesContext.d.ts +1 -1
  16. package/lib/cjs/components/trees/common/FocusedInstancesContext.js.map +1 -1
  17. package/lib/cjs/components/trees/common/FocusedInstancesContextProvider.js +4 -4
  18. package/lib/cjs/components/trees/common/FocusedInstancesContextProvider.js.map +1 -1
  19. package/lib/cjs/components/trees/common/TreeErrors.d.ts +9 -0
  20. package/lib/cjs/components/trees/common/TreeErrors.js +19 -0
  21. package/lib/cjs/components/trees/common/TreeErrors.js.map +1 -0
  22. package/lib/cjs/components/trees/common/UseActiveViewport.d.ts +7 -0
  23. package/lib/cjs/components/trees/common/UseActiveViewport.js +25 -0
  24. package/lib/cjs/components/trees/common/UseActiveViewport.js.map +1 -0
  25. package/lib/cjs/components/trees/index.d.ts +1 -0
  26. package/lib/cjs/components/trees/index.js +3 -1
  27. package/lib/cjs/components/trees/index.js.map +1 -1
  28. package/lib/cjs/components/trees/models-tree/ModelsTree.d.ts +6 -11
  29. package/lib/cjs/components/trees/models-tree/ModelsTree.js +2 -2
  30. package/lib/cjs/components/trees/models-tree/ModelsTree.js.map +1 -1
  31. package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.d.ts +1 -1
  32. package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.js +3 -2
  33. package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
  34. package/lib/cjs/components/trees/models-tree/ModelsTreeDefinition.d.ts +10 -6
  35. package/lib/cjs/components/trees/models-tree/ModelsTreeDefinition.js +63 -43
  36. package/lib/cjs/components/trees/models-tree/ModelsTreeDefinition.js.map +1 -1
  37. package/lib/cjs/components/trees/models-tree/UseModelsTree.d.ts +11 -2
  38. package/lib/cjs/components/trees/models-tree/UseModelsTree.js +51 -31
  39. package/lib/cjs/components/trees/models-tree/UseModelsTree.js.map +1 -1
  40. package/lib/cjs/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js +4 -3
  41. package/lib/cjs/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js.map +1 -1
  42. package/lib/esm/components/SelectableTree.js +2 -3
  43. package/lib/esm/components/SelectableTree.js.map +1 -1
  44. package/lib/esm/components/SelectableTree.scss +5 -0
  45. package/lib/esm/components/tree-header/TreeHeader.d.ts +3 -2
  46. package/lib/esm/components/tree-header/TreeHeader.js +1 -1
  47. package/lib/esm/components/tree-header/TreeHeader.js.map +1 -1
  48. package/lib/esm/components/trees/categories-tree/CategoriesTreeComponent.js +2 -1
  49. package/lib/esm/components/trees/categories-tree/CategoriesTreeComponent.js.map +1 -1
  50. package/lib/esm/components/trees/categories-tree/CategoriesTreeDefinition.d.ts +2 -2
  51. package/lib/esm/components/trees/categories-tree/CategoriesTreeDefinition.js +5 -4
  52. package/lib/esm/components/trees/categories-tree/CategoriesTreeDefinition.js.map +1 -1
  53. package/lib/esm/components/trees/categories-tree/UseCategoriesTree.js +2 -1
  54. package/lib/esm/components/trees/categories-tree/UseCategoriesTree.js.map +1 -1
  55. package/lib/esm/components/trees/common/FocusedInstancesContext.d.ts +1 -1
  56. package/lib/esm/components/trees/common/FocusedInstancesContext.js.map +1 -1
  57. package/lib/esm/components/trees/common/FocusedInstancesContextProvider.js +4 -4
  58. package/lib/esm/components/trees/common/FocusedInstancesContextProvider.js.map +1 -1
  59. package/lib/esm/components/trees/common/TreeErrors.d.ts +9 -0
  60. package/lib/esm/components/trees/common/TreeErrors.js +15 -0
  61. package/lib/esm/components/trees/common/TreeErrors.js.map +1 -0
  62. package/lib/esm/components/trees/common/UseActiveViewport.d.ts +7 -0
  63. package/lib/esm/components/trees/common/UseActiveViewport.js +21 -0
  64. package/lib/esm/components/trees/common/UseActiveViewport.js.map +1 -0
  65. package/lib/esm/components/trees/index.d.ts +1 -0
  66. package/lib/esm/components/trees/index.js +1 -0
  67. package/lib/esm/components/trees/index.js.map +1 -1
  68. package/lib/esm/components/trees/models-tree/ModelsTree.d.ts +6 -11
  69. package/lib/esm/components/trees/models-tree/ModelsTree.js +2 -2
  70. package/lib/esm/components/trees/models-tree/ModelsTree.js.map +1 -1
  71. package/lib/esm/components/trees/models-tree/ModelsTreeComponent.d.ts +1 -1
  72. package/lib/esm/components/trees/models-tree/ModelsTreeComponent.js +3 -2
  73. package/lib/esm/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
  74. package/lib/esm/components/trees/models-tree/ModelsTreeDefinition.d.ts +10 -6
  75. package/lib/esm/components/trees/models-tree/ModelsTreeDefinition.js +63 -43
  76. package/lib/esm/components/trees/models-tree/ModelsTreeDefinition.js.map +1 -1
  77. package/lib/esm/components/trees/models-tree/UseModelsTree.d.ts +11 -2
  78. package/lib/esm/components/trees/models-tree/UseModelsTree.js +51 -31
  79. package/lib/esm/components/trees/models-tree/UseModelsTree.js.map +1 -1
  80. package/lib/esm/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js +4 -3
  81. package/lib/esm/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js.map +1 -1
  82. package/package.json +28 -28
@@ -1 +1 @@
1
- {"version":3,"file":"ModelsTreeDefinition.js","sourceRoot":"","sources":["../../../../../src/components/trees/models-tree/ModelsTreeDefinition.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,+BAA0E;AAC1E,8EAEyC;AACzC,oEAA8F;AAC9F,yCAAyC;AACzC,2CAA4E;AA0B5E,MAAM,gCAAgC,GAAG,GAAG,CAAC;AAehC,QAAA,6BAA6B,GAAqC;IAC7E,oBAAoB,EAAE,QAAQ;IAC9B,yBAAyB,EAAE,4BAA4B;IACvD,eAAe,EAAE,KAAK;CACvB,CAAC;AAsCF,2DAA2D;AAC3D,IAAiB,+BAA+B,CAI/C;AAJD,WAAiB,+BAA+B;IAC9C,SAAgB,YAAY,CAAC,KAAsC;QACjE,OAAO,CAAC,CAAE,KAA0D,CAAC,KAAK,CAAC;IAC7E,CAAC;IAFe,4CAAY,eAE3B,CAAA;AACH,CAAC,EAJgB,+BAA+B,GAA/B,uCAA+B,KAA/B,uCAA+B,QAI/C;AAED,MAAa,oBAAoB;IAS/B,YAAmB,KAAgC;QACjD,IAAI,CAAC,KAAK,GAAG,IAAA,8DAAmC,EAAC;YAC/C,uBAAuB,EAAE,KAAK,CAAC,YAAY;YAC3C,SAAS,EAAE;gBACT,SAAS,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,CAAC,IAAI,CAAC,kCAAkC,CAAC,YAAY,CAAC;gBACxF,UAAU,EAAE;oBACV;wBACE,mBAAmB,EAAE,iBAAiB;wBACtC,WAAW,EAAE,KAAK,EAAE,YAAwD,EAAE,EAAE,CAAC,IAAI,CAAC,0BAA0B,CAAC,YAAY,CAAC;qBAC/H;oBACD;wBACE,mBAAmB,EAAE,4BAA4B;wBACjD,WAAW,EAAE,KAAK,EAAE,YAAwD,EAAE,EAAE,CA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AAwB;IAC/D,MAAM,eAAe,GAAG,IAAI,KAAK,CAAC,KAAK,eAAe,CAAC;IACvD,MAAM,qBAAqB,GAAG,YAAY,KAAK,CAAC,KAAK,mBAAmB,CAAC;IACzE,OAAO,yCAAyC,eAAe,mBAAmB,qBAAqB,GAAG,CAAC;AAC7G,CAAC;AAGD,SAAS,OAAO,CAAI,MAA8B;IAChD,OAAO,MAAM,CAAC,MAAM,CAAM,CAAC,IAAI,EAAE,IAAI,EAAO,EAAE;QAC5C,OAAO,CAAC,GAAG,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACtE,CAAC,EAAE,IAAI,KAAK,EAAK,CAAC,CAAC;AACrB,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 { defer, EMPTY, from, map, merge, mergeAll, mergeMap } from \"rxjs\";\nimport {\n createClassBasedHierarchyDefinition, createNodesQueryClauseFactory, HierarchyNode, NodeSelectClauseColumnNames,\n} from \"@itwin/presentation-hierarchies\";\nimport { createBisInstanceLabelSelectClauseFactory, ECSql } from \"@itwin/presentation-shared\";\nimport { collect } from \"../common/Rxjs\";\nimport { createIdsSelector, parseIdsSelectorResult } from \"../common/Utils\";\n\nimport type { Id64String } from \"@itwin/core-bentley\";\nimport type { Observable } from \"rxjs\";\nimport type {\n DefineHierarchyLevelProps,\n DefineInstanceNodeChildHierarchyLevelProps,\n DefineRootHierarchyLevelProps,\n HierarchyDefinition,\n HierarchyLevelDefinition,\n HierarchyNodeIdentifiersPath,\n HierarchyNodesDefinition,\n LimitingECSqlQueryExecutor,\n NodesQueryClauseFactory,\n ProcessedHierarchyNode,\n} from \"@itwin/presentation-hierarchies\";\nimport type {\n ECClassHierarchyInspector,\n ECSchemaProvider,\n ECSqlBinding,\n ECSqlQueryDef,\n IInstanceLabelSelectClauseFactory,\n InstanceKey,\n} from \"@itwin/presentation-shared\";\nimport type { ModelsTreeIdsCache } from \"./internal/ModelsTreeIdsCache\";\n\nconst MAX_FILTERING_INSTANCE_KEY_COUNT = 100;\n\n/**\n * Defines hierarchy configuration supported by `ModelsTree`.\n * @beta\n */\nexport interface ModelsTreeHierarchyConfiguration {\n /** Should element nodes be grouped by class. Defaults to `enable`. */\n elementClassGrouping: \"enable\" | \"enableWithCounts\" | \"disable\";\n /** Full class name of a `GeometricElement3d` sub-class that should be used to load element nodes. Defaults to `BisCore.GeometricElement3d` */\n elementClassSpecification: string;\n /** Should models without elements be shown. Defaults to `false` */\n showEmptyModels: boolean;\n}\n\nexport const defaultHierarchyConfiguration: ModelsTreeHierarchyConfiguration = {\n elementClassGrouping: \"enable\",\n elementClassSpecification: \"BisCore.GeometricElement3d\",\n showEmptyModels: false,\n};\n\ninterface ModelsTreeDefinitionProps {\n imodelAccess: ECSchemaProvider & ECClassHierarchyInspector & LimitingECSqlQueryExecutor;\n idsCache: ModelsTreeIdsCache;\n hierarchyConfig: ModelsTreeHierarchyConfiguration;\n}\n\nexport interface ElementsGroupInfo {\n parent:\n | {\n ids: Id64String[];\n type: \"element\";\n }\n | {\n ids: Id64String[];\n modelIds: Id64String[];\n type: \"category\";\n };\n classes: string[];\n}\n\ninterface ModelsTreeInstanceKeyPathsFromInstanceKeysProps {\n imodelAccess: ECClassHierarchyInspector & LimitingECSqlQueryExecutor;\n idsCache: ModelsTreeIdsCache;\n keys: Array<InstanceKey | ElementsGroupInfo>;\n hierarchyConfig: ModelsTreeHierarchyConfiguration;\n}\n\ninterface ModelsTreeInstanceKeyPathsFromInstanceLabelProps {\n imodelAccess: ECClassHierarchyInspector & LimitingECSqlQueryExecutor;\n idsCache: ModelsTreeIdsCache;\n label: string;\n hierarchyConfig: ModelsTreeHierarchyConfiguration;\n}\n\nexport type ModelsTreeInstanceKeyPathsProps = ModelsTreeInstanceKeyPathsFromInstanceKeysProps | ModelsTreeInstanceKeyPathsFromInstanceLabelProps;\n\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace ModelsTreeInstanceKeyPathsProps {\n export function isLabelProps(props: ModelsTreeInstanceKeyPathsProps): props is ModelsTreeInstanceKeyPathsFromInstanceLabelProps {\n return !!(props as ModelsTreeInstanceKeyPathsFromInstanceLabelProps).label;\n }\n}\n\nexport class ModelsTreeDefinition implements HierarchyDefinition {\n private _impl: HierarchyDefinition;\n private _idsCache: ModelsTreeIdsCache;\n private _hierarchyConfig: ModelsTreeHierarchyConfiguration;\n private _selectQueryFactory: NodesQueryClauseFactory;\n private _nodeLabelSelectClauseFactory: IInstanceLabelSelectClauseFactory;\n private _queryExecutor: LimitingECSqlQueryExecutor;\n private _isSupported?: Promise<boolean>;\n\n public constructor(props: ModelsTreeDefinitionProps) {\n this._impl = createClassBasedHierarchyDefinition({\n classHierarchyInspector: props.imodelAccess,\n hierarchy: {\n rootNodes: async (requestProps) => this.createRootHierarchyLevelDefinition(requestProps),\n childNodes: [\n {\n parentNodeClassName: \"BisCore.Subject\",\n definitions: async (requestProps: DefineInstanceNodeChildHierarchyLevelProps) => this.createSubjectChildrenQuery(requestProps),\n },\n {\n parentNodeClassName: \"BisCore.ISubModeledElement\",\n definitions: async (requestProps: DefineInstanceNodeChildHierarchyLevelProps) => this.createISubModeledElementChildrenQuery(requestProps),\n },\n {\n parentNodeClassName: \"BisCore.GeometricModel3d\",\n definitions: async (requestProps: DefineInstanceNodeChildHierarchyLevelProps) => this.createGeometricModel3dChildrenQuery(requestProps),\n },\n {\n parentNodeClassName: \"BisCore.SpatialCategory\",\n definitions: async (requestProps: DefineInstanceNodeChildHierarchyLevelProps) => this.createSpatialCategoryChildrenQuery(requestProps),\n },\n {\n parentNodeClassName: \"BisCore.GeometricElement3d\",\n definitions: async (requestProps: DefineInstanceNodeChildHierarchyLevelProps) => this.createGeometricElement3dChildrenQuery(requestProps),\n },\n ],\n },\n });\n this._idsCache = props.idsCache;\n this._queryExecutor = props.imodelAccess;\n this._hierarchyConfig = props.hierarchyConfig;\n this._selectQueryFactory = createNodesQueryClauseFactory({ imodelAccess: props.imodelAccess });\n this._nodeLabelSelectClauseFactory = createBisInstanceLabelSelectClauseFactory({ classHierarchyInspector: props.imodelAccess });\n }\n\n public async postProcessNode(node: ProcessedHierarchyNode): Promise<ProcessedHierarchyNode> {\n if (HierarchyNode.isClassGroupingNode(node)) {\n return {\n ...node,\n label: this._hierarchyConfig.elementClassGrouping === \"enableWithCounts\" ? `${node.label} (${node.children.length})` : node.label,\n extendedData: {\n ...node.extendedData,\n // add `modelId` and `categoryId` from the first grouped element\n ...node.children[0].extendedData,\n // `imageId` is assigned to instance nodes at query time, but grouping ones need to\n // be handled during post-processing\n imageId: \"icon-ec-class\",\n },\n };\n }\n return node;\n }\n\n public async defineHierarchyLevel(props: DefineHierarchyLevelProps) {\n if (this._isSupported === undefined) {\n this._isSupported = this.isSupported();\n }\n\n if ((await this._isSupported) === false) {\n return [];\n }\n\n return this._impl.defineHierarchyLevel(props);\n }\n\n private async createRootHierarchyLevelDefinition(props: DefineRootHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n const instanceFilterClauses = await this._selectQueryFactory.createFilterClauses({\n filter: props.instanceFilter,\n contentClass: { fullName: \"BisCore.Subject\", alias: \"this\" },\n });\n return [\n {\n fullClassName: \"BisCore.Subject\",\n query: {\n ecsql: `\n SELECT\n ${await this._selectQueryFactory.createSelectClause({\n ecClassId: { selector: ECSql.createRawPropertyValueSelector(\"this\", \"ECClassId\") },\n ecInstanceId: { selector: \"this.ECInstanceId\" },\n nodeLabel: {\n selector: await this._nodeLabelSelectClauseFactory.createSelectClause({\n classAlias: \"this\",\n className: \"BisCore.Subject\",\n }),\n },\n extendedData: {\n imageId: \"icon-imodel-hollow-2\",\n isSubject: true,\n },\n autoExpand: true,\n supportsFiltering: true,\n })}\n FROM ${instanceFilterClauses.from} this\n ${instanceFilterClauses.joins}\n WHERE\n this.Parent IS NULL\n ${instanceFilterClauses.where ? `AND ${instanceFilterClauses.where}` : \"\"}\n `,\n },\n },\n ];\n }\n\n private async createSubjectChildrenQuery({\n parentNodeInstanceIds: subjectIds,\n instanceFilter,\n }: DefineInstanceNodeChildHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n const [subjectFilterClauses, modelFilterClauses] = await Promise.all([\n this._selectQueryFactory.createFilterClauses({\n filter: instanceFilter,\n contentClass: { fullName: \"BisCore.Subject\", alias: \"this\" },\n }),\n this._selectQueryFactory.createFilterClauses({\n filter: instanceFilter,\n contentClass: { fullName: \"BisCore.GeometricModel3d\", alias: \"this\" },\n }),\n ]);\n const [childSubjectIds, childModelIds] = await Promise.all([\n this._idsCache.getChildSubjectIds(subjectIds),\n this._idsCache.getChildSubjectModelIds(subjectIds),\n ]);\n const defs = new Array<HierarchyNodesDefinition>();\n childSubjectIds.length &&\n defs.push({\n fullClassName: \"BisCore.Subject\",\n query: {\n ecsql: `\n SELECT\n ${await this._selectQueryFactory.createSelectClause({\n ecClassId: { selector: \"this.ECClassId\" },\n ecInstanceId: { selector: \"this.ECInstanceId\" },\n nodeLabel: {\n selector: await this._nodeLabelSelectClauseFactory.createSelectClause({\n classAlias: \"this\",\n className: \"BisCore.Subject\",\n }),\n },\n hideIfNoChildren: true,\n hasChildren: { selector: `InVirtualSet(?, this.ECInstanceId)` },\n grouping: { byLabel: { action: \"merge\", groupId: \"subject\" } },\n extendedData: {\n imageId: \"icon-folder\",\n isSubject: true,\n },\n supportsFiltering: true,\n })}\n FROM ${subjectFilterClauses.from} this\n ${subjectFilterClauses.joins}\n WHERE\n this.ECInstanceId IN (${childSubjectIds.map(() => \"?\").join(\",\")})\n ${subjectFilterClauses.where ? `AND ${subjectFilterClauses.where}` : \"\"}\n `,\n bindings: [\n { type: \"idset\", value: await this._idsCache.getParentSubjectIds() },\n ...childSubjectIds.map((id): ECSqlBinding => ({ type: \"id\", value: id })),\n ],\n },\n });\n childModelIds.length &&\n defs.push({\n fullClassName: \"BisCore.GeometricModel3d\",\n query: {\n ecsql: `\n SELECT model.ECInstanceId AS ECInstanceId, model.*\n FROM (\n SELECT\n ${await this._selectQueryFactory.createSelectClause({\n ecClassId: { selector: \"m.ECClassId\" },\n ecInstanceId: { selector: \"m.ECInstanceId\" },\n nodeLabel: {\n selector: await this._nodeLabelSelectClauseFactory.createSelectClause({\n classAlias: \"partition\",\n className: \"BisCore.InformationPartitionElement\",\n }),\n },\n hideNodeInHierarchy: {\n selector: `\n CASE\n WHEN (\n json_extract([partition].JsonProperties, '$.PhysicalPartition.Model.Content') IS NOT NULL\n OR json_extract([partition].JsonProperties, '$.GraphicalPartition3d.Model.Content') IS NOT NULL\n ) THEN 1\n ELSE 0\n END\n `,\n },\n hasChildren: this._hierarchyConfig.showEmptyModels\n ? {\n selector: `\n IFNULL((\n SELECT 1\n FROM ${this._hierarchyConfig.elementClassSpecification} e\n WHERE e.Model.Id = m.ECInstanceId\n LIMIT 1\n ), 0)\n `,\n }\n : true,\n extendedData: {\n imageId: \"icon-model\",\n isModel: true,\n },\n supportsFiltering: true,\n })}\n FROM Bis.GeometricModel3d m\n JOIN bis.InformationPartitionElement [partition] ON [partition].ECInstanceId = m.ModeledElement.Id\n WHERE\n m.ECInstanceId IN (${childModelIds.map(() => \"?\").join(\",\")})\n ) model\n JOIN ${modelFilterClauses.from} this ON this.ECInstanceId = model.ECInstanceId\n ${modelFilterClauses.joins}\n ${modelFilterClauses.where ? `AND (model.${NodeSelectClauseColumnNames.HideNodeInHierarchy} OR ${modelFilterClauses.where})` : \"\"}\n `,\n bindings: childModelIds.map((id): ECSqlBinding => ({ type: \"id\", value: id })),\n },\n });\n return defs;\n }\n\n private async createISubModeledElementChildrenQuery({\n parentNodeInstanceIds: elementIds,\n }: DefineInstanceNodeChildHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n // note: we do not apply hierarchy level filtering on this hierarchy level, because it's always\n // hidden - the filter will get applied on the child hierarchy levels\n return [\n {\n fullClassName: \"BisCore.GeometricModel3d\",\n query: {\n ecsql: `\n SELECT\n ${await this._selectQueryFactory.createSelectClause({\n ecClassId: { selector: \"this.ECClassId\" },\n ecInstanceId: { selector: \"this.ECInstanceId\" },\n nodeLabel: \"\", // doesn't matter - the node is always hidden\n hideNodeInHierarchy: true,\n })}\n FROM BisCore.GeometricModel3d this\n WHERE\n this.ModeledElement.Id IN (${elementIds.map(() => \"?\").join(\",\")})\n AND NOT this.IsPrivate\n AND this.ECInstanceId IN (SELECT Model.Id FROM ${this._hierarchyConfig.elementClassSpecification})\n `,\n bindings: [...elementIds.map((id): ECSqlBinding => ({ type: \"id\", value: id }))],\n },\n },\n ];\n }\n\n private async createGeometricModel3dChildrenQuery({\n parentNodeInstanceIds: modelIds,\n instanceFilter,\n }: DefineInstanceNodeChildHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n const instanceFilterClauses = await this._selectQueryFactory.createFilterClauses({\n filter: instanceFilter,\n contentClass: { fullName: \"BisCore.SpatialCategory\", alias: \"this\" },\n });\n return [\n {\n fullClassName: \"BisCore.SpatialCategory\",\n query: {\n ecsql: `\n SELECT\n ${await this._selectQueryFactory.createSelectClause({\n ecClassId: { selector: \"this.ECClassId\" },\n ecInstanceId: { selector: \"this.ECInstanceId\" },\n nodeLabel: {\n selector: await this._nodeLabelSelectClauseFactory.createSelectClause({\n classAlias: \"this\",\n className: \"BisCore.SpatialCategory\",\n }),\n },\n grouping: { byLabel: { action: \"merge\", groupId: \"category\" } },\n hasChildren: true,\n extendedData: {\n imageId: \"icon-layers\",\n isCategory: true,\n modelIds: { selector: createIdsSelector(modelIds) },\n },\n supportsFiltering: true,\n })}\n FROM ${instanceFilterClauses.from} this\n ${instanceFilterClauses.joins}\n WHERE\n EXISTS (\n SELECT 1\n FROM ${this._hierarchyConfig.elementClassSpecification} element\n WHERE\n element.Model.Id IN (${modelIds.map(() => \"?\").join(\",\")})\n AND element.Category.Id = +this.ECInstanceId\n AND element.Parent IS NULL\n )\n ${instanceFilterClauses.where ? `AND ${instanceFilterClauses.where}` : \"\"}\n `,\n bindings: modelIds.map((id) => ({ type: \"id\", value: id })),\n },\n },\n ];\n }\n\n private async createSpatialCategoryChildrenQuery({\n parentNodeInstanceIds: categoryIds,\n parentNode,\n instanceFilter,\n }: DefineInstanceNodeChildHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n const modelIds = parseIdsSelectorResult(parentNode.extendedData?.modelIds);\n if (modelIds.length === 0) {\n throw new Error(`Invalid category node \"${parentNode.label}\" - missing model information.`);\n }\n const instanceFilterClauses = await this._selectQueryFactory.createFilterClauses({\n filter: instanceFilter,\n contentClass: { fullName: this._hierarchyConfig.elementClassSpecification, alias: \"this\" },\n });\n return [\n {\n fullClassName: this._hierarchyConfig.elementClassSpecification,\n query: {\n ecsql: `\n SELECT\n ${await this._selectQueryFactory.createSelectClause({\n ecClassId: { selector: \"this.ECClassId\" },\n ecInstanceId: { selector: \"this.ECInstanceId\" },\n nodeLabel: {\n selector: await this._nodeLabelSelectClauseFactory.createSelectClause({\n classAlias: \"this\",\n className: this._hierarchyConfig.elementClassSpecification,\n }),\n },\n grouping: {\n byClass: this._hierarchyConfig.elementClassGrouping !== \"disable\",\n },\n hasChildren: {\n selector: `\n IFNULL((\n SELECT 1\n FROM (\n SELECT Parent.Id ParentId FROM ${this._hierarchyConfig.elementClassSpecification}\n UNION ALL\n SELECT ModeledElement.Id ParentId FROM bis.GeometricModel3d\n )\n WHERE ParentId = this.ECInstanceId\n LIMIT 1\n ), 0)\n `,\n },\n extendedData: {\n modelId: { selector: \"IdToHex(this.Model.Id)\" },\n categoryId: { selector: \"IdToHex(this.Category.Id)\" },\n imageId: \"icon-item\",\n },\n supportsFiltering: true,\n })}\n FROM ${instanceFilterClauses.from} this\n ${instanceFilterClauses.joins}\n WHERE\n this.Category.Id IN (${categoryIds.map(() => \"?\").join(\",\")})\n AND this.Model.Id IN (${modelIds.map(() => \"?\").join(\",\")})\n AND this.Parent IS NULL\n ${instanceFilterClauses.where ? `AND ${instanceFilterClauses.where}` : \"\"}\n `,\n bindings: [...categoryIds.map((id) => ({ type: \"id\", value: id })), ...modelIds.map((id) => ({ type: \"id\", value: id }))] as ECSqlBinding[],\n },\n },\n ];\n }\n\n private async createGeometricElement3dChildrenQuery({\n parentNodeInstanceIds: elementIds,\n instanceFilter,\n }: DefineInstanceNodeChildHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n const instanceFilterClauses = await this._selectQueryFactory.createFilterClauses({\n filter: instanceFilter,\n contentClass: { fullName: this._hierarchyConfig.elementClassSpecification, alias: \"this\" },\n });\n return [\n {\n fullClassName: this._hierarchyConfig.elementClassSpecification,\n query: {\n ecsql: `\n SELECT\n ${await this._selectQueryFactory.createSelectClause({\n ecClassId: { selector: \"this.ECClassId\" },\n ecInstanceId: { selector: \"this.ECInstanceId\" },\n nodeLabel: {\n selector: await this._nodeLabelSelectClauseFactory.createSelectClause({\n classAlias: \"this\",\n className: this._hierarchyConfig.elementClassSpecification,\n }),\n },\n grouping: {\n byClass: this._hierarchyConfig.elementClassGrouping !== \"disable\",\n },\n hasChildren: {\n selector: `\n IFNULL((\n SELECT 1\n FROM (\n SELECT Parent.Id ParentId FROM ${this._hierarchyConfig.elementClassSpecification}\n UNION ALL\n SELECT ModeledElement.Id ParentId FROM bis.GeometricModel3d\n )\n WHERE ParentId = this.ECInstanceId\n LIMIT 1\n ), 0)\n `,\n },\n extendedData: {\n modelId: { selector: \"IdToHex(this.Model.Id)\" },\n categoryId: { selector: \"IdToHex(this.Category.Id)\" },\n imageId: \"icon-item\",\n },\n supportsFiltering: true,\n })}\n FROM ${instanceFilterClauses.from} this\n ${instanceFilterClauses.joins}\n WHERE\n this.Parent.Id IN (${elementIds.map(() => \"?\").join(\",\")})\n ${instanceFilterClauses.where ? `AND ${instanceFilterClauses.where}` : \"\"}\n `,\n bindings: elementIds.map((id) => ({ type: \"id\", value: id })),\n },\n },\n ];\n }\n\n public static async createInstanceKeyPaths(props: ModelsTreeInstanceKeyPathsProps) {\n if (ModelsTreeInstanceKeyPathsProps.isLabelProps(props)) {\n const labelsFactory = createBisInstanceLabelSelectClauseFactory({ classHierarchyInspector: props.imodelAccess });\n return createInstanceKeyPathsFromInstanceLabel({ ...props, labelsFactory });\n }\n return createInstanceKeyPathsFromInstanceKeys(props);\n }\n\n private async isSupported() {\n const [schemaName, className] = this._hierarchyConfig.elementClassSpecification.split(/[\\.:]/);\n if (!schemaName || !className) {\n throw new Error(\n `Provided class specification ${this._hierarchyConfig.elementClassSpecification} should be in format {SchemaName}:{ClassName} or {SchemaName}.{ClassName}`,\n );\n }\n\n const query: ECSqlQueryDef = {\n ecsql: `\n SELECT 1\n FROM ECDbMeta.ECSchemaDef s\n JOIN ECDbMeta.ECClassDef c ON c.Schema.Id = s.ECInstanceId\n WHERE s.Name = ? AND c.Name = ? AND c.ECInstanceId IS (BisCore.GeometricElement3d)\n `,\n bindings: [\n { type: \"string\", value: schemaName },\n { type: \"string\", value: className },\n ],\n };\n\n for await (const _row of this._queryExecutor.createQueryReader(query)) {\n return true;\n }\n return false;\n }\n}\n\nfunction createSubjectInstanceKeysPath(subjectId: Id64String, idsCache: ModelsTreeIdsCache): Observable<HierarchyNodeIdentifiersPath> {\n return from(idsCache.getSubjectAncestorsPath(subjectId)).pipe(map((idsPath) => idsPath.map((id) => ({ className: \"BisCore.Subject\", id }))));\n}\n\nfunction createModelInstanceKeyPaths(modelId: Id64String, idsCache: ModelsTreeIdsCache): Observable<HierarchyNodeIdentifiersPath> {\n return from(idsCache.getModelSubjects(modelId)).pipe(\n mergeAll(),\n mergeMap((modelSubjectId) =>\n createSubjectInstanceKeysPath(modelSubjectId, idsCache).pipe(\n map((subjectPath) => [...subjectPath, { className: \"BisCore.GeometricModel3d\", id: modelId }]),\n ),\n ),\n );\n}\n\nfunction createCategoryInstanceKeyPaths(categoryId: Id64String, idsCache: ModelsTreeIdsCache): Observable<HierarchyNodeIdentifiersPath> {\n return from(idsCache.getCategoryModels(categoryId)).pipe(\n mergeAll(),\n mergeMap((categoryModelId) =>\n createModelInstanceKeyPaths(categoryModelId, idsCache).pipe(map((modelPath) => [...modelPath, { className: \"BisCore.SpatialCategory\", id: categoryId }])),\n ),\n );\n}\n\nfunction createGeometricElementInstanceKeyPaths(\n imodelAccess: ECClassHierarchyInspector & LimitingECSqlQueryExecutor,\n idsCache: ModelsTreeIdsCache,\n hierarchyConfig: ModelsTreeHierarchyConfiguration,\n elementInfos: Array<Id64String | ElementsGroupInfo>,\n): Observable<HierarchyNodeIdentifiersPath> {\n return defer(() => {\n const elementIds = elementInfos.filter((info): info is Id64String => typeof info === \"string\");\n const groupInfos = elementInfos.filter((info): info is ElementsGroupInfo => typeof info !== \"string\");\n\n const elementsClause = elementIds.length > 0 ? `e.ECInstanceId IN (${elementIds.map(() => \"?\").join(\",\")})` : undefined;\n\n const createParentElementClause = (parent: { ids: Id64String[] }) => `e.Parent.Id IN (${parent.ids.map(() => \"?\").join(\",\")})`;\n const createParentCategoryClause = ({ ids, modelIds }: { ids: Id64String[]; modelIds: Id64String[] }) =>\n `e.Category.Id IN (${ids.map(() => \"?\").join(\",\")}) AND e.Model.Id IN (${modelIds.map(() => \"?\").join(\",\")})`;\n\n const classClause = groupInfos.map(\n ({ parent, classes }) =>\n `(${parent.type === \"element\" ? createParentElementClause(parent) : createParentCategoryClause(parent)} AND e.ECClassId IS (${classes.join(\",\")}))`,\n );\n\n const whereClause = [...(elementsClause ? [elementsClause] : []), ...(classClause ?? [])].join(\" OR \");\n\n const ctes = [\n `ModelsCategoriesElementsHierarchy(ECInstanceId, ParentId, ModelId, Path) AS (\n SELECT\n e.ECInstanceId,\n e.Parent.Id,\n e.Model.Id,\n json_array(\n ${createECInstanceKeySelectClause({ alias: \"e\" })},\n IIF(e.Parent.Id IS NULL, ${createECInstanceKeySelectClause({ alias: \"c\" })}, NULL),\n IIF(e.Parent.Id IS NULL, ${createECInstanceKeySelectClause({ alias: \"m\" })}, NULL)\n )\n FROM ${hierarchyConfig.elementClassSpecification} e\n JOIN bis.GeometricModel3d m ON m.ECInstanceId = e.Model.Id\n JOIN bis.SpatialCategory c ON c.ECInstanceId = e.Category.Id\n WHERE ${whereClause}\n\n UNION ALL\n\n SELECT\n pe.ECInstanceId,\n pe.Parent.Id,\n pe.Model.Id,\n json_insert(\n ce.Path,\n '$[#]', ${createECInstanceKeySelectClause({ alias: \"pe\" })},\n '$[#]', IIF(pe.Parent.Id IS NULL, ${createECInstanceKeySelectClause({ alias: \"c\" })}, NULL),\n '$[#]', IIF(pe.Parent.Id IS NULL, ${createECInstanceKeySelectClause({ alias: \"m\" })}, NULL)\n )\n FROM ModelsCategoriesElementsHierarchy ce\n JOIN ${hierarchyConfig.elementClassSpecification} pe ON (pe.ECInstanceId = ce.ParentId OR pe.ECInstanceId = ce.ModelId AND ce.ParentId IS NULL)\n JOIN bis.GeometricModel3d m ON m.ECInstanceId = pe.Model.Id\n JOIN bis.SpatialCategory c ON c.ECInstanceId = pe.Category.Id\n )`,\n ];\n const ecsql = `\n SELECT mce.ModelId, mce.Path\n FROM ModelsCategoriesElementsHierarchy mce\n WHERE mce.ParentId IS NULL\n `;\n const createIdBinding = (id: Id64String) => ({ type: \"id\" as const, value: id });\n const createCategoryElementsBindings = ({ ids, modelIds }: { ids: Id64String[]; modelIds: Id64String[] }) => [\n ...ids.map(createIdBinding),\n ...modelIds.map(createIdBinding),\n ];\n return imodelAccess.createQueryReader(\n {\n ctes,\n ecsql,\n bindings: [\n ...elementIds.map(createIdBinding),\n ...groupInfos.flatMap((info) =>\n info.parent.type === \"element\" ? info.parent.ids.map(createIdBinding) : createCategoryElementsBindings(info.parent),\n ),\n ],\n },\n { rowFormat: \"Indexes\" },\n );\n }).pipe(\n map((row) => ({\n modelId: row[0],\n elementHierarchyPath: flatten<InstanceKey | undefined>(JSON.parse(row[1])).reverse(),\n })),\n mergeMap(({ modelId, elementHierarchyPath }) =>\n createModelInstanceKeyPaths(modelId, idsCache).pipe(\n map((modelPath) => {\n modelPath.pop(); // model is already included in the element hierarchy path\n return [...modelPath, ...elementHierarchyPath.filter((x): x is InstanceKey => !!x)];\n }),\n ),\n ),\n );\n}\n\nasync function createInstanceKeyPathsFromInstanceKeys(props: ModelsTreeInstanceKeyPathsFromInstanceKeysProps): Promise<HierarchyNodeIdentifiersPath[]> {\n if (props.keys.length > MAX_FILTERING_INSTANCE_KEY_COUNT) {\n throw new Error(`Filter matches more than ${MAX_FILTERING_INSTANCE_KEY_COUNT} items`);\n }\n const ids = {\n models: new Array<Id64String>(),\n categories: new Array<Id64String>(),\n subjects: new Array<Id64String>(),\n elements: new Array<Id64String | ElementsGroupInfo>(),\n };\n await Promise.all(\n props.keys.map(async (key) => {\n if (\"parent\" in key) {\n ids.elements.push(key);\n } else if (await props.imodelAccess.classDerivesFrom(key.className, \"BisCore.Subject\")) {\n ids.subjects.push(key.id);\n } else if (await props.imodelAccess.classDerivesFrom(key.className, \"BisCore.Model\")) {\n ids.models.push(key.id);\n } else if (await props.imodelAccess.classDerivesFrom(key.className, \"BisCore.SpatialCategory\")) {\n ids.categories.push(key.id);\n } else {\n ids.elements.push(key.id);\n }\n }),\n );\n return collect(\n merge(\n from(ids.subjects).pipe(mergeMap((id) => createSubjectInstanceKeysPath(id, props.idsCache))),\n from(ids.models).pipe(mergeMap((id) => createModelInstanceKeyPaths(id, props.idsCache))),\n from(ids.categories).pipe(mergeMap((id) => createCategoryInstanceKeyPaths(id, props.idsCache))),\n ids.elements.length ? createGeometricElementInstanceKeyPaths(props.imodelAccess, props.idsCache, props.hierarchyConfig, ids.elements) : EMPTY,\n ),\n );\n}\n\nasync function createInstanceKeyPathsFromInstanceLabel(\n props: ModelsTreeInstanceKeyPathsFromInstanceLabelProps & { labelsFactory: IInstanceLabelSelectClauseFactory },\n) {\n const elementLabelSelectClause = await props.labelsFactory.createSelectClause({\n classAlias: \"e\",\n className: \"BisCore.Element\",\n // eslint-disable-next-line @typescript-eslint/unbound-method\n selectorsConcatenator: ECSql.createConcatenatedValueStringSelector,\n });\n const targetsReader = props.imodelAccess.createQueryReader(\n {\n ecsql: `\n SELECT *\n FROM (\n SELECT\n ec_classname(e.ECClassId, 's.c'),\n e.ECInstanceId,\n ${elementLabelSelectClause} Label\n FROM BisCore.Element e\n WHERE e.ECClassId IS (BisCore.Subject, BisCore.SpatialCategory, ${props.hierarchyConfig.elementClassSpecification})\n\n UNION ALL\n\n SELECT\n ec_classname(m.ECClassId, 's.c'),\n m.ECInstanceId,\n ${elementLabelSelectClause} Label\n FROM BisCore.GeometricModel3d m\n JOIN BisCore.Element e ON e.ECInstanceId = m.ModeledElement.Id\n WHERE NOT m.IsPrivate\n ${props.hierarchyConfig.showEmptyModels ? \"\" : `AND EXISTS (SELECT 1 FROM ${props.hierarchyConfig.elementClassSpecification} WHERE Model.Id = m.ECInstanceId)`}\n AND json_extract(e.JsonProperties, '$.PhysicalPartition.Model.Content') IS NULL\n AND json_extract(e.JsonProperties, '$.GraphicalPartition3d.Model.Content') IS NULL\n )\n WHERE Label LIKE '%' || ? || '%' ESCAPE '\\\\'\n LIMIT ${MAX_FILTERING_INSTANCE_KEY_COUNT + 1}\n `,\n bindings: [{ type: \"string\", value: props.label.replace(/[%_\\\\]/g, \"\\\\$&\") }],\n },\n { rowFormat: \"Indexes\", restartToken: \"tree-widget/models-tree/filter-by-label-query\" },\n );\n\n const targetKeys = new Array<InstanceKey>();\n for await (const row of targetsReader) {\n targetKeys.push({ className: row[0], id: row[1] });\n }\n\n return createInstanceKeyPathsFromInstanceKeys({ ...props, keys: targetKeys });\n}\n\nfunction createECInstanceKeySelectClause(props: { alias: string }) {\n const classIdSelector = `[${props.alias}].[ECClassId]`;\n const instanceHexIdSelector = `IdToHex([${props.alias}].[ECInstanceId])`;\n return `json_object('className', ec_classname(${classIdSelector}, 's.c'), 'id', ${instanceHexIdSelector})`;\n}\n\ntype ArrayOrValue<T> = T | Array<ArrayOrValue<T>>;\nfunction flatten<T>(source: Array<ArrayOrValue<T>>): T[] {\n return source.reduce<T[]>((flat, item): T[] => {\n return [...flat, ...(Array.isArray(item) ? flatten(item) : [item])];\n }, new Array<T>());\n}\n"]}
1
+ {"version":3,"file":"ModelsTreeDefinition.js","sourceRoot":"","sources":["../../../../../src/components/trees/models-tree/ModelsTreeDefinition.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,+BAA0E;AAC1E,8EAEyC;AACzC,oEAA8F;AAC9F,yCAAyC;AACzC,qDAAgE;AAChE,2CAA4E;AA+B5E,MAAM,gCAAgC,GAAG,GAAG,CAAC;AAehC,QAAA,6BAA6B,GAAqC;IAC7E,oBAAoB,EAAE,QAAQ;IAC9B,yBAAyB,EAAE,4BAA4B;IACvD,eAAe,EAAE,KAAK;CACvB,CAAC;AA0CF,2DAA2D;AAC3D,IAAiB,+BAA+B,CAI/C;AAJD,WAAiB,+BAA+B;IAC9C,SAAgB,YAAY,CAAC,KAAsC;QACjE,OAAO,CAAC,CAAE,KAA0D,CAAC,KAAK,CAAC;IAC7E,CAAC;IAFe,4CAAY,eAE3B,CAAA;AACH,CAAC,EAJgB,+BAA+B,GAA/B,uCAA+B,KAA/B,uCAA+B,QAI/C;AAED,MAAa,oBAAoB;IAS/B,YAAmB,KAAgC;QACjD,IAAI,CAAC,KAAK,GAAG,IAAA,8DAAmC,EAAC;YAC/C,uBAAuB,EAAE,KAAK,CAAC,YAAY;YAC3C,SAAS,EAAE;gBACT,SAAS,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,CAAC,IAAI,CAAC,kCAAkC,CAAC,YAAY,CAAC;gBACxF,UAAU,EAAE;oBACV;wBACE,mBAAmB,EAAE,iBAAiB;wBACtC,WAAW,EAAE,KAAK,EAAE,YAAwD,EAAE,EAAE,CAAC,IAAI,CAAC,0BAA0B,CAAC,YAAY,CAAC;qBAC/H;oBACD;wBACE,mBAAmB,EAAE,4BAA4B;wBACjD,WAAW,E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AO,CAAI,MAA8B;IAChD,OAAO,MAAM,CAAC,MAAM,CAAM,CAAC,IAAI,EAAE,IAAI,EAAO,EAAE;QAC5C,OAAO,CAAC,GAAG,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACtE,CAAC,EAAE,IAAI,KAAK,EAAK,CAAC,CAAC;AACrB,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 { defer, EMPTY, from, map, merge, mergeAll, mergeMap } from \"rxjs\";\nimport {\n createClassBasedHierarchyDefinition, createNodesQueryClauseFactory, HierarchyNode, NodeSelectClauseColumnNames,\n} from \"@itwin/presentation-hierarchies\";\nimport { createBisInstanceLabelSelectClauseFactory, ECSql } from \"@itwin/presentation-shared\";\nimport { collect } from \"../common/Rxjs\";\nimport { FilterLimitExceededError } from \"../common/TreeErrors\";\nimport { createIdsSelector, parseIdsSelectorResult } from \"../common/Utils\";\n\nimport type { Id64Array, Id64String } from \"@itwin/core-bentley\";\nimport type { Observable } from \"rxjs\";\nimport type {\n ClassGroupingNodeKey,\n createHierarchyProvider,\n DefineHierarchyLevelProps,\n DefineInstanceNodeChildHierarchyLevelProps,\n DefineRootHierarchyLevelProps,\n GroupingHierarchyNode,\n HierarchyDefinition,\n HierarchyLevelDefinition,\n HierarchyNodeIdentifiersPath,\n HierarchyNodesDefinition,\n LimitingECSqlQueryExecutor,\n NodesQueryClauseFactory,\n ProcessedHierarchyNode,\n} from \"@itwin/presentation-hierarchies\";\nimport type {\n ECClassHierarchyInspector,\n ECSchemaProvider,\n ECSqlBinding,\n ECSqlQueryDef,\n IInstanceLabelSelectClauseFactory,\n InstanceKey,\n} from \"@itwin/presentation-shared\";\nimport type { ModelsTreeIdsCache } from \"./internal/ModelsTreeIdsCache\";\n\nexport type ClassGroupingHierarchyNode = GroupingHierarchyNode & { key: ClassGroupingNodeKey };\n\nconst MAX_FILTERING_INSTANCE_KEY_COUNT = 100;\n\n/**\n * Defines hierarchy configuration supported by `ModelsTree`.\n * @beta\n */\nexport interface ModelsTreeHierarchyConfiguration {\n /** Should element nodes be grouped by class. Defaults to `enable`. */\n elementClassGrouping: \"enable\" | \"enableWithCounts\" | \"disable\";\n /** Full class name of a `GeometricElement3d` sub-class that should be used to load element nodes. Defaults to `BisCore.GeometricElement3d` */\n elementClassSpecification: string;\n /** Should models without elements be shown. Defaults to `false` */\n showEmptyModels: boolean;\n}\n\nexport const defaultHierarchyConfiguration: ModelsTreeHierarchyConfiguration = {\n elementClassGrouping: \"enable\",\n elementClassSpecification: \"BisCore.GeometricElement3d\",\n showEmptyModels: false,\n};\n\ninterface ModelsTreeDefinitionProps {\n imodelAccess: ECSchemaProvider & ECClassHierarchyInspector & LimitingECSqlQueryExecutor;\n idsCache: ModelsTreeIdsCache;\n hierarchyConfig: ModelsTreeHierarchyConfiguration;\n}\n\n/** @beta */\nexport interface ElementsGroupInfo {\n parent:\n | {\n ids: Id64String[];\n type: \"element\";\n }\n | {\n ids: Id64String[];\n modelIds: Id64String[];\n type: \"category\";\n };\n groupingNode: ClassGroupingHierarchyNode;\n}\n\ninterface ModelsTreeInstanceKeyPathsFromTargetItemsProps {\n imodelAccess: ECClassHierarchyInspector & LimitingECSqlQueryExecutor;\n idsCache: ModelsTreeIdsCache;\n targetItems: Array<InstanceKey | ElementsGroupInfo>;\n hierarchyConfig: ModelsTreeHierarchyConfiguration;\n}\n\ninterface ModelsTreeInstanceKeyPathsFromInstanceLabelProps {\n imodelAccess: ECClassHierarchyInspector & LimitingECSqlQueryExecutor;\n idsCache: ModelsTreeIdsCache;\n label: string;\n hierarchyConfig: ModelsTreeHierarchyConfiguration;\n}\n\nexport type ModelsTreeInstanceKeyPathsProps = ModelsTreeInstanceKeyPathsFromTargetItemsProps | ModelsTreeInstanceKeyPathsFromInstanceLabelProps;\ntype HierarchyProviderProps = Parameters<typeof createHierarchyProvider>[0];\ntype HierarchyFilteringPaths = NonNullable<NonNullable<HierarchyProviderProps[\"filtering\"]>[\"paths\"]>;\ntype HierarchyFilteringPath = HierarchyFilteringPaths[number];\n\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace ModelsTreeInstanceKeyPathsProps {\n export function isLabelProps(props: ModelsTreeInstanceKeyPathsProps): props is ModelsTreeInstanceKeyPathsFromInstanceLabelProps {\n return !!(props as ModelsTreeInstanceKeyPathsFromInstanceLabelProps).label;\n }\n}\n\nexport class ModelsTreeDefinition implements HierarchyDefinition {\n private _impl: HierarchyDefinition;\n private _idsCache: ModelsTreeIdsCache;\n private _hierarchyConfig: ModelsTreeHierarchyConfiguration;\n private _selectQueryFactory: NodesQueryClauseFactory;\n private _nodeLabelSelectClauseFactory: IInstanceLabelSelectClauseFactory;\n private _queryExecutor: LimitingECSqlQueryExecutor;\n private _isSupported?: Promise<boolean>;\n\n public constructor(props: ModelsTreeDefinitionProps) {\n this._impl = createClassBasedHierarchyDefinition({\n classHierarchyInspector: props.imodelAccess,\n hierarchy: {\n rootNodes: async (requestProps) => this.createRootHierarchyLevelDefinition(requestProps),\n childNodes: [\n {\n parentNodeClassName: \"BisCore.Subject\",\n definitions: async (requestProps: DefineInstanceNodeChildHierarchyLevelProps) => this.createSubjectChildrenQuery(requestProps),\n },\n {\n parentNodeClassName: \"BisCore.ISubModeledElement\",\n definitions: async (requestProps: DefineInstanceNodeChildHierarchyLevelProps) => this.createISubModeledElementChildrenQuery(requestProps),\n },\n {\n parentNodeClassName: \"BisCore.GeometricModel3d\",\n definitions: async (requestProps: DefineInstanceNodeChildHierarchyLevelProps) => this.createGeometricModel3dChildrenQuery(requestProps),\n },\n {\n parentNodeClassName: \"BisCore.SpatialCategory\",\n definitions: async (requestProps: DefineInstanceNodeChildHierarchyLevelProps) => this.createSpatialCategoryChildrenQuery(requestProps),\n },\n {\n parentNodeClassName: \"BisCore.GeometricElement3d\",\n definitions: async (requestProps: DefineInstanceNodeChildHierarchyLevelProps) => this.createGeometricElement3dChildrenQuery(requestProps),\n },\n ],\n },\n });\n this._idsCache = props.idsCache;\n this._queryExecutor = props.imodelAccess;\n this._hierarchyConfig = props.hierarchyConfig;\n this._selectQueryFactory = createNodesQueryClauseFactory({ imodelAccess: props.imodelAccess });\n this._nodeLabelSelectClauseFactory = createBisInstanceLabelSelectClauseFactory({ classHierarchyInspector: props.imodelAccess });\n }\n\n public async postProcessNode(node: ProcessedHierarchyNode): Promise<ProcessedHierarchyNode> {\n if (HierarchyNode.isClassGroupingNode(node)) {\n return {\n ...node,\n label: this._hierarchyConfig.elementClassGrouping === \"enableWithCounts\" ? `${node.label} (${node.children.length})` : node.label,\n extendedData: {\n ...node.extendedData,\n // add `modelId` and `categoryId` from the first grouped element\n ...node.children[0].extendedData,\n // `imageId` is assigned to instance nodes at query time, but grouping ones need to\n // be handled during post-processing\n imageId: \"icon-ec-class\",\n },\n };\n }\n return node;\n }\n\n public async defineHierarchyLevel(props: DefineHierarchyLevelProps) {\n if (this._isSupported === undefined) {\n this._isSupported = this.isSupported();\n }\n\n if ((await this._isSupported) === false) {\n return [];\n }\n\n return this._impl.defineHierarchyLevel(props);\n }\n\n private async createRootHierarchyLevelDefinition(props: DefineRootHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n const instanceFilterClauses = await this._selectQueryFactory.createFilterClauses({\n filter: props.instanceFilter,\n contentClass: { fullName: \"BisCore.Subject\", alias: \"this\" },\n });\n return [\n {\n fullClassName: \"BisCore.Subject\",\n query: {\n ecsql: `\n SELECT\n ${await this._selectQueryFactory.createSelectClause({\n ecClassId: { selector: ECSql.createRawPropertyValueSelector(\"this\", \"ECClassId\") },\n ecInstanceId: { selector: \"this.ECInstanceId\" },\n nodeLabel: {\n selector: await this._nodeLabelSelectClauseFactory.createSelectClause({\n classAlias: \"this\",\n className: \"BisCore.Subject\",\n }),\n },\n extendedData: {\n imageId: \"icon-imodel-hollow-2\",\n isSubject: true,\n },\n autoExpand: true,\n supportsFiltering: true,\n })}\n FROM ${instanceFilterClauses.from} this\n ${instanceFilterClauses.joins}\n WHERE\n this.Parent IS NULL\n ${instanceFilterClauses.where ? `AND ${instanceFilterClauses.where}` : \"\"}\n `,\n },\n },\n ];\n }\n\n private async createSubjectChildrenQuery({\n parentNodeInstanceIds: subjectIds,\n instanceFilter,\n }: DefineInstanceNodeChildHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n const [subjectFilterClauses, modelFilterClauses] = await Promise.all([\n this._selectQueryFactory.createFilterClauses({\n filter: instanceFilter,\n contentClass: { fullName: \"BisCore.Subject\", alias: \"this\" },\n }),\n this._selectQueryFactory.createFilterClauses({\n filter: instanceFilter,\n contentClass: { fullName: \"BisCore.GeometricModel3d\", alias: \"this\" },\n }),\n ]);\n const [childSubjectIds, childModelIds] = await Promise.all([\n this._idsCache.getChildSubjectIds(subjectIds),\n this._idsCache.getChildSubjectModelIds(subjectIds),\n ]);\n const defs = new Array<HierarchyNodesDefinition>();\n childSubjectIds.length &&\n defs.push({\n fullClassName: \"BisCore.Subject\",\n query: {\n ecsql: `\n SELECT\n ${await this._selectQueryFactory.createSelectClause({\n ecClassId: { selector: \"this.ECClassId\" },\n ecInstanceId: { selector: \"this.ECInstanceId\" },\n nodeLabel: {\n selector: await this._nodeLabelSelectClauseFactory.createSelectClause({\n classAlias: \"this\",\n className: \"BisCore.Subject\",\n }),\n },\n hideIfNoChildren: true,\n hasChildren: { selector: `InVirtualSet(?, this.ECInstanceId)` },\n grouping: { byLabel: { action: \"merge\", groupId: \"subject\" } },\n extendedData: {\n imageId: \"icon-folder\",\n isSubject: true,\n },\n supportsFiltering: true,\n })}\n FROM ${subjectFilterClauses.from} this\n ${subjectFilterClauses.joins}\n WHERE\n this.ECInstanceId IN (${childSubjectIds.map(() => \"?\").join(\",\")})\n ${subjectFilterClauses.where ? `AND ${subjectFilterClauses.where}` : \"\"}\n `,\n bindings: [\n { type: \"idset\", value: await this._idsCache.getParentSubjectIds() },\n ...childSubjectIds.map((id): ECSqlBinding => ({ type: \"id\", value: id })),\n ],\n },\n });\n childModelIds.length &&\n defs.push({\n fullClassName: \"BisCore.GeometricModel3d\",\n query: {\n ecsql: `\n SELECT model.ECInstanceId AS ECInstanceId, model.*\n FROM (\n SELECT\n ${await this._selectQueryFactory.createSelectClause({\n ecClassId: { selector: \"m.ECClassId\" },\n ecInstanceId: { selector: \"m.ECInstanceId\" },\n nodeLabel: {\n selector: await this._nodeLabelSelectClauseFactory.createSelectClause({\n classAlias: \"partition\",\n className: \"BisCore.InformationPartitionElement\",\n }),\n },\n hideNodeInHierarchy: {\n selector: `\n CASE\n WHEN (\n json_extract([partition].JsonProperties, '$.PhysicalPartition.Model.Content') IS NOT NULL\n OR json_extract([partition].JsonProperties, '$.GraphicalPartition3d.Model.Content') IS NOT NULL\n ) THEN 1\n ELSE 0\n END\n `,\n },\n hasChildren: this._hierarchyConfig.showEmptyModels\n ? {\n selector: `\n IFNULL((\n SELECT 1\n FROM ${this._hierarchyConfig.elementClassSpecification} e\n WHERE e.Model.Id = m.ECInstanceId\n LIMIT 1\n ), 0)\n `,\n }\n : true,\n extendedData: {\n imageId: \"icon-model\",\n isModel: true,\n },\n supportsFiltering: true,\n })}\n FROM Bis.GeometricModel3d m\n JOIN bis.InformationPartitionElement [partition] ON [partition].ECInstanceId = m.ModeledElement.Id\n WHERE\n m.ECInstanceId IN (${childModelIds.map(() => \"?\").join(\",\")})\n ) model\n JOIN ${modelFilterClauses.from} this ON this.ECInstanceId = model.ECInstanceId\n ${modelFilterClauses.joins}\n ${modelFilterClauses.where ? `AND (model.${NodeSelectClauseColumnNames.HideNodeInHierarchy} OR ${modelFilterClauses.where})` : \"\"}\n `,\n bindings: childModelIds.map((id): ECSqlBinding => ({ type: \"id\", value: id })),\n },\n });\n return defs;\n }\n\n private async createISubModeledElementChildrenQuery({\n parentNodeInstanceIds: elementIds,\n }: DefineInstanceNodeChildHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n // note: we do not apply hierarchy level filtering on this hierarchy level, because it's always\n // hidden - the filter will get applied on the child hierarchy levels\n return [\n {\n fullClassName: \"BisCore.GeometricModel3d\",\n query: {\n ecsql: `\n SELECT\n ${await this._selectQueryFactory.createSelectClause({\n ecClassId: { selector: \"this.ECClassId\" },\n ecInstanceId: { selector: \"this.ECInstanceId\" },\n nodeLabel: \"\", // doesn't matter - the node is always hidden\n hideNodeInHierarchy: true,\n })}\n FROM BisCore.GeometricModel3d this\n WHERE\n this.ModeledElement.Id IN (${elementIds.map(() => \"?\").join(\",\")})\n AND NOT this.IsPrivate\n AND this.ECInstanceId IN (SELECT Model.Id FROM ${this._hierarchyConfig.elementClassSpecification})\n `,\n bindings: [...elementIds.map((id): ECSqlBinding => ({ type: \"id\", value: id }))],\n },\n },\n ];\n }\n\n private async createGeometricModel3dChildrenQuery({\n parentNodeInstanceIds: modelIds,\n instanceFilter,\n }: DefineInstanceNodeChildHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n const instanceFilterClauses = await this._selectQueryFactory.createFilterClauses({\n filter: instanceFilter,\n contentClass: { fullName: \"BisCore.SpatialCategory\", alias: \"this\" },\n });\n return [\n {\n fullClassName: \"BisCore.SpatialCategory\",\n query: {\n ecsql: `\n SELECT\n ${await this._selectQueryFactory.createSelectClause({\n ecClassId: { selector: \"this.ECClassId\" },\n ecInstanceId: { selector: \"this.ECInstanceId\" },\n nodeLabel: {\n selector: await this._nodeLabelSelectClauseFactory.createSelectClause({\n classAlias: \"this\",\n className: \"BisCore.SpatialCategory\",\n }),\n },\n grouping: { byLabel: { action: \"merge\", groupId: \"category\" } },\n hasChildren: true,\n extendedData: {\n imageId: \"icon-layers\",\n isCategory: true,\n modelIds: { selector: createIdsSelector(modelIds) },\n },\n supportsFiltering: true,\n })}\n FROM ${instanceFilterClauses.from} this\n ${instanceFilterClauses.joins}\n WHERE\n EXISTS (\n SELECT 1\n FROM ${this._hierarchyConfig.elementClassSpecification} element\n WHERE\n element.Model.Id IN (${modelIds.map(() => \"?\").join(\",\")})\n AND element.Category.Id = +this.ECInstanceId\n AND element.Parent IS NULL\n )\n ${instanceFilterClauses.where ? `AND ${instanceFilterClauses.where}` : \"\"}\n `,\n bindings: modelIds.map((id) => ({ type: \"id\", value: id })),\n },\n },\n ];\n }\n\n private async createSpatialCategoryChildrenQuery({\n parentNodeInstanceIds: categoryIds,\n parentNode,\n instanceFilter,\n }: DefineInstanceNodeChildHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n const modelIds = parseIdsSelectorResult(parentNode.extendedData?.modelIds);\n if (modelIds.length === 0) {\n throw new Error(`Invalid category node \"${parentNode.label}\" - missing model information.`);\n }\n const instanceFilterClauses = await this._selectQueryFactory.createFilterClauses({\n filter: instanceFilter,\n contentClass: { fullName: this._hierarchyConfig.elementClassSpecification, alias: \"this\" },\n });\n return [\n {\n fullClassName: this._hierarchyConfig.elementClassSpecification,\n query: {\n ecsql: `\n SELECT\n ${await this._selectQueryFactory.createSelectClause({\n ecClassId: { selector: \"this.ECClassId\" },\n ecInstanceId: { selector: \"this.ECInstanceId\" },\n nodeLabel: {\n selector: await this._nodeLabelSelectClauseFactory.createSelectClause({\n classAlias: \"this\",\n className: this._hierarchyConfig.elementClassSpecification,\n }),\n },\n grouping: {\n byClass: this._hierarchyConfig.elementClassGrouping !== \"disable\",\n },\n hasChildren: {\n selector: `\n IFNULL((\n SELECT 1\n FROM (\n SELECT Parent.Id ParentId FROM ${this._hierarchyConfig.elementClassSpecification}\n UNION ALL\n SELECT ModeledElement.Id ParentId FROM bis.GeometricModel3d\n )\n WHERE ParentId = this.ECInstanceId\n LIMIT 1\n ), 0)\n `,\n },\n extendedData: {\n modelId: { selector: \"IdToHex(this.Model.Id)\" },\n categoryId: { selector: \"IdToHex(this.Category.Id)\" },\n imageId: \"icon-item\",\n },\n supportsFiltering: true,\n })}\n FROM ${instanceFilterClauses.from} this\n ${instanceFilterClauses.joins}\n WHERE\n this.Category.Id IN (${categoryIds.map(() => \"?\").join(\",\")})\n AND this.Model.Id IN (${modelIds.map(() => \"?\").join(\",\")})\n AND this.Parent IS NULL\n ${instanceFilterClauses.where ? `AND ${instanceFilterClauses.where}` : \"\"}\n `,\n bindings: [...categoryIds.map((id) => ({ type: \"id\", value: id })), ...modelIds.map((id) => ({ type: \"id\", value: id }))] as ECSqlBinding[],\n },\n },\n ];\n }\n\n private async createGeometricElement3dChildrenQuery({\n parentNodeInstanceIds: elementIds,\n instanceFilter,\n }: DefineInstanceNodeChildHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n const instanceFilterClauses = await this._selectQueryFactory.createFilterClauses({\n filter: instanceFilter,\n contentClass: { fullName: this._hierarchyConfig.elementClassSpecification, alias: \"this\" },\n });\n return [\n {\n fullClassName: this._hierarchyConfig.elementClassSpecification,\n query: {\n ecsql: `\n SELECT\n ${await this._selectQueryFactory.createSelectClause({\n ecClassId: { selector: \"this.ECClassId\" },\n ecInstanceId: { selector: \"this.ECInstanceId\" },\n nodeLabel: {\n selector: await this._nodeLabelSelectClauseFactory.createSelectClause({\n classAlias: \"this\",\n className: this._hierarchyConfig.elementClassSpecification,\n }),\n },\n grouping: {\n byClass: this._hierarchyConfig.elementClassGrouping !== \"disable\",\n },\n hasChildren: {\n selector: `\n IFNULL((\n SELECT 1\n FROM (\n SELECT Parent.Id ParentId FROM ${this._hierarchyConfig.elementClassSpecification}\n UNION ALL\n SELECT ModeledElement.Id ParentId FROM bis.GeometricModel3d\n )\n WHERE ParentId = this.ECInstanceId\n LIMIT 1\n ), 0)\n `,\n },\n extendedData: {\n modelId: { selector: \"IdToHex(this.Model.Id)\" },\n categoryId: { selector: \"IdToHex(this.Category.Id)\" },\n imageId: \"icon-item\",\n },\n supportsFiltering: true,\n })}\n FROM ${instanceFilterClauses.from} this\n ${instanceFilterClauses.joins}\n WHERE\n this.Parent.Id IN (${elementIds.map(() => \"?\").join(\",\")})\n ${instanceFilterClauses.where ? `AND ${instanceFilterClauses.where}` : \"\"}\n `,\n bindings: elementIds.map((id) => ({ type: \"id\", value: id })),\n },\n },\n ];\n }\n\n public static async createInstanceKeyPaths(props: ModelsTreeInstanceKeyPathsProps) {\n if (ModelsTreeInstanceKeyPathsProps.isLabelProps(props)) {\n const labelsFactory = createBisInstanceLabelSelectClauseFactory({ classHierarchyInspector: props.imodelAccess });\n return createInstanceKeyPathsFromInstanceLabel({ ...props, labelsFactory });\n }\n return createInstanceKeyPathsFromTargetItems(props);\n }\n\n private async isSupported() {\n const [schemaName, className] = this._hierarchyConfig.elementClassSpecification.split(/[\\.:]/);\n if (!schemaName || !className) {\n throw new Error(\n `Provided class specification ${this._hierarchyConfig.elementClassSpecification} should be in format {SchemaName}:{ClassName} or {SchemaName}.{ClassName}`,\n );\n }\n\n const query: ECSqlQueryDef = {\n ecsql: `\n SELECT 1\n FROM ECDbMeta.ECSchemaDef s\n JOIN ECDbMeta.ECClassDef c ON c.Schema.Id = s.ECInstanceId\n WHERE s.Name = ? AND c.Name = ? AND c.ECInstanceId IS (BisCore.GeometricElement3d)\n `,\n bindings: [\n { type: \"string\", value: schemaName },\n { type: \"string\", value: className },\n ],\n };\n\n for await (const _row of this._queryExecutor.createQueryReader(query)) {\n return true;\n }\n return false;\n }\n}\n\nfunction createSubjectInstanceKeysPath(subjectId: Id64String, idsCache: ModelsTreeIdsCache): Observable<HierarchyNodeIdentifiersPath> {\n return from(idsCache.getSubjectAncestorsPath(subjectId)).pipe(map((idsPath) => idsPath.map((id) => ({ className: \"BisCore.Subject\", id }))));\n}\n\nfunction createModelInstanceKeyPaths(modelId: Id64String, idsCache: ModelsTreeIdsCache): Observable<HierarchyNodeIdentifiersPath> {\n return from(idsCache.getModelSubjects(modelId)).pipe(\n mergeAll(),\n mergeMap((modelSubjectId) =>\n createSubjectInstanceKeysPath(modelSubjectId, idsCache).pipe(\n map((subjectPath) => [...subjectPath, { className: \"BisCore.GeometricModel3d\", id: modelId }]),\n ),\n ),\n );\n}\n\nfunction createCategoryInstanceKeyPaths(categoryId: Id64String, idsCache: ModelsTreeIdsCache): Observable<HierarchyNodeIdentifiersPath> {\n return from(idsCache.getCategoryModels(categoryId)).pipe(\n mergeAll(),\n mergeMap((categoryModelId) =>\n createModelInstanceKeyPaths(categoryModelId, idsCache).pipe(map((modelPath) => [...modelPath, { className: \"BisCore.SpatialCategory\", id: categoryId }])),\n ),\n );\n}\n\nfunction createGeometricElementInstanceKeyPaths(\n imodelAccess: ECClassHierarchyInspector & LimitingECSqlQueryExecutor,\n idsCache: ModelsTreeIdsCache,\n hierarchyConfig: ModelsTreeHierarchyConfiguration,\n targetItems: Array<Id64String | ElementsGroupInfo>,\n): Observable<HierarchyFilteringPath> {\n const elementIds = targetItems.filter((info): info is Id64String => typeof info === \"string\");\n const groupInfos = targetItems.filter((info): info is ElementsGroupInfo => typeof info !== \"string\");\n\n return defer(() => {\n const bindings = new Array<ECSqlBinding>();\n const bind = (selector: string, idSet: Id64Array) => {\n bindings.push(...idSet.map((id) => ({ type: \"id\" as const, value: id })));\n return `${selector} IN (${idSet.map(() => \"?\").join(\",\")})`;\n };\n\n const targetElementsInfoQuery =\n elementIds.length > 0\n ? `\n SELECT e.ECInstanceId, e.ECClassId, e.Parent.Id, e.Model.Id, e.Category.Id, -1\n FROM ${hierarchyConfig.elementClassSpecification} e\n WHERE ${bind(\"e.ECInstanceId\", elementIds)}\n `\n : undefined;\n\n const targetGroupingNodesElementInfoQueries = groupInfos.map(\n ({ parent, groupingNode }, index) => `\n SELECT e.ECInstanceId, e.ECClassId, e.Parent.Id, e.Model.Id, e.Category.Id, ${index}\n FROM ${hierarchyConfig.elementClassSpecification} e\n WHERE\n e.ECClassId IS (${groupingNode.key.className})\n AND ${parent.type === \"element\" ? bind(\"e.Parent.Id\", parent.ids) : `e.Parent IS NULL AND ${bind(\"e.Category.Id\", parent.ids)} AND ${bind(\"e.Model.Id\", parent.modelIds)}`}\n `,\n );\n\n const ctes = [\n `InstanceElementsWithClassGroupingNodes(ECInstanceId, ECClassId, ParentId, ModelId, CategoryId, GroupingNodeIndex) AS (\n ${[...(targetElementsInfoQuery ? [targetElementsInfoQuery] : []), ...targetGroupingNodesElementInfoQueries].join(\" UNION ALL \")}\n )`,\n `ModelsCategoriesElementsHierarchy(ECInstanceId, ParentId, ModelId, GroupingNodeIndex, Path) AS (\n SELECT\n e.ECInstanceId,\n e.ParentId,\n e.ModelId,\n e.GroupingNodeIndex,\n json_array(\n ${createECInstanceKeySelectClause({ alias: \"e\" })},\n IIF(e.ParentId IS NULL, ${createECInstanceKeySelectClause({ alias: \"c\" })}, NULL),\n IIF(e.ParentId IS NULL, ${createECInstanceKeySelectClause({ alias: \"m\" })}, NULL)\n )\n FROM InstanceElementsWithClassGroupingNodes e\n JOIN bis.GeometricModel3d m ON m.ECInstanceId = e.ModelId\n JOIN bis.SpatialCategory c ON c.ECInstanceId = e.CategoryId\n\n UNION ALL\n\n SELECT\n pe.ECInstanceId,\n pe.Parent.Id,\n pe.Model.Id,\n ce.GroupingNodeIndex,\n json_insert(\n ce.Path,\n '$[#]', ${createECInstanceKeySelectClause({ alias: \"pe\" })},\n '$[#]', IIF(pe.Parent.Id IS NULL, ${createECInstanceKeySelectClause({ alias: \"c\" })}, NULL),\n '$[#]', IIF(pe.Parent.Id IS NULL, ${createECInstanceKeySelectClause({ alias: \"m\" })}, NULL)\n )\n FROM ModelsCategoriesElementsHierarchy ce\n JOIN ${hierarchyConfig.elementClassSpecification} pe ON (pe.ECInstanceId = ce.ParentId OR pe.ECInstanceId = ce.ModelId AND ce.ParentId IS NULL)\n JOIN bis.GeometricModel3d m ON m.ECInstanceId = pe.Model.Id\n JOIN bis.SpatialCategory c ON c.ECInstanceId = pe.Category.Id\n )`,\n ];\n const ecsql = `\n SELECT mce.ModelId, mce.Path, mce.GroupingNodeIndex\n FROM ModelsCategoriesElementsHierarchy mce\n WHERE mce.ParentId IS NULL\n `;\n\n return imodelAccess.createQueryReader({ ctes, ecsql, bindings }, { rowFormat: \"Indexes\" });\n }).pipe(\n map((row) => ({\n modelId: row[0],\n elementHierarchyPath: flatten<InstanceKey | undefined>(JSON.parse(row[1])).reverse(),\n groupingNode: row[2] === -1 ? undefined : groupInfos[row[2]].groupingNode,\n })),\n mergeMap(({ modelId, elementHierarchyPath, groupingNode }) =>\n createModelInstanceKeyPaths(modelId, idsCache).pipe(\n map((modelPath) => {\n modelPath.pop(); // model is already included in the element hierarchy path\n const path = [...modelPath, ...elementHierarchyPath.filter((x): x is InstanceKey => !!x)];\n if (!groupingNode) {\n return path;\n }\n return {\n path,\n options: {\n autoExpand: {\n key: groupingNode.key,\n depth: groupingNode.parentKeys.length,\n },\n },\n };\n }),\n ),\n ),\n );\n}\n\nasync function createInstanceKeyPathsFromTargetItems({\n targetItems,\n imodelAccess,\n hierarchyConfig,\n idsCache,\n}: ModelsTreeInstanceKeyPathsFromTargetItemsProps): Promise<HierarchyFilteringPath[]> {\n if (targetItems.length > MAX_FILTERING_INSTANCE_KEY_COUNT) {\n throw new FilterLimitExceededError(MAX_FILTERING_INSTANCE_KEY_COUNT);\n }\n const ids = {\n models: new Array<Id64String>(),\n categories: new Array<Id64String>(),\n subjects: new Array<Id64String>(),\n elements: new Array<Id64String | ElementsGroupInfo>(),\n };\n await Promise.all(\n targetItems.map(async (key) => {\n if (\"parent\" in key) {\n ids.elements.push(key);\n } else if (await imodelAccess.classDerivesFrom(key.className, \"BisCore.Subject\")) {\n ids.subjects.push(key.id);\n } else if (await imodelAccess.classDerivesFrom(key.className, \"BisCore.Model\")) {\n ids.models.push(key.id);\n } else if (await imodelAccess.classDerivesFrom(key.className, \"BisCore.SpatialCategory\")) {\n ids.categories.push(key.id);\n } else {\n ids.elements.push(key.id);\n }\n }),\n );\n return collect(\n merge(\n from(ids.subjects).pipe(mergeMap((id) => createSubjectInstanceKeysPath(id, idsCache))),\n from(ids.models).pipe(mergeMap((id) => createModelInstanceKeyPaths(id, idsCache))),\n from(ids.categories).pipe(mergeMap((id) => createCategoryInstanceKeyPaths(id, idsCache))),\n ids.elements.length ? createGeometricElementInstanceKeyPaths(imodelAccess, idsCache, hierarchyConfig, ids.elements) : EMPTY,\n ),\n );\n}\n\nasync function createInstanceKeyPathsFromInstanceLabel(\n props: ModelsTreeInstanceKeyPathsFromInstanceLabelProps & { labelsFactory: IInstanceLabelSelectClauseFactory },\n) {\n const elementLabelSelectClause = await props.labelsFactory.createSelectClause({\n classAlias: \"e\",\n className: \"BisCore.Element\",\n // eslint-disable-next-line @typescript-eslint/unbound-method\n selectorsConcatenator: ECSql.createConcatenatedValueStringSelector,\n });\n const targetsReader = props.imodelAccess.createQueryReader(\n {\n ecsql: `\n SELECT *\n FROM (\n SELECT\n ec_classname(e.ECClassId, 's.c'),\n e.ECInstanceId,\n ${elementLabelSelectClause} Label\n FROM BisCore.Element e\n WHERE e.ECClassId IS (BisCore.Subject, BisCore.SpatialCategory, ${props.hierarchyConfig.elementClassSpecification})\n\n UNION ALL\n\n SELECT\n ec_classname(m.ECClassId, 's.c'),\n m.ECInstanceId,\n ${elementLabelSelectClause} Label\n FROM BisCore.GeometricModel3d m\n JOIN BisCore.Element e ON e.ECInstanceId = m.ModeledElement.Id\n WHERE NOT m.IsPrivate\n ${props.hierarchyConfig.showEmptyModels ? \"\" : `AND EXISTS (SELECT 1 FROM ${props.hierarchyConfig.elementClassSpecification} WHERE Model.Id = m.ECInstanceId)`}\n AND json_extract(e.JsonProperties, '$.PhysicalPartition.Model.Content') IS NULL\n AND json_extract(e.JsonProperties, '$.GraphicalPartition3d.Model.Content') IS NULL\n )\n WHERE Label LIKE '%' || ? || '%' ESCAPE '\\\\'\n LIMIT ${MAX_FILTERING_INSTANCE_KEY_COUNT + 1}\n `,\n bindings: [{ type: \"string\", value: props.label.replace(/[%_\\\\]/g, \"\\\\$&\") }],\n },\n { rowFormat: \"Indexes\", restartToken: \"tree-widget/models-tree/filter-by-label-query\" },\n );\n\n const targetKeys = new Array<InstanceKey>();\n for await (const row of targetsReader) {\n targetKeys.push({ className: row[0], id: row[1] });\n }\n\n return createInstanceKeyPathsFromTargetItems({ ...props, targetItems: targetKeys });\n}\n\nfunction createECInstanceKeySelectClause(props: { alias: string }) {\n const classIdSelector = `[${props.alias}].[ECClassId]`;\n const instanceHexIdSelector = `IdToHex([${props.alias}].[ECInstanceId])`;\n return `json_object('className', ec_classname(${classIdSelector}, 's.c'), 'id', ${instanceHexIdSelector})`;\n}\n\ntype ArrayOrValue<T> = T | Array<ArrayOrValue<T>>;\nfunction flatten<T>(source: Array<ArrayOrValue<T>>): T[] {\n return source.reduce<T[]>((flat, item): T[] => {\n return [...flat, ...(Array.isArray(item) ? flatten(item) : [item])];\n }, new Array<T>());\n}\n"]}
@@ -1,9 +1,11 @@
1
+ import type { InstanceKey } from "@itwin/presentation-shared";
1
2
  import type { ComponentPropsWithoutRef } from "react";
2
3
  import type { Viewport } from "@itwin/core-frontend";
3
- import type { ModelsTreeHierarchyConfiguration } from "./ModelsTreeDefinition";
4
+ import type { ElementsGroupInfo, ModelsTreeHierarchyConfiguration } from "./ModelsTreeDefinition";
4
5
  import type { ModelsTreeVisibilityHandlerOverrides } from "./internal/ModelsTreeVisibilityHandler";
5
6
  import type { VisibilityTree } from "../common/components/VisibilityTree";
6
7
  import type { VisibilityTreeRenderer } from "../common/components/VisibilityTreeRenderer";
8
+ type HierarchyFilteringPaths = Awaited<ReturnType<Required<VisibilityTreeProps>["getFilteredPaths"]>>;
7
9
  /** @beta */
8
10
  type VisibilityTreeRendererProps = ComponentPropsWithoutRef<typeof VisibilityTreeRenderer>;
9
11
  /** @beta */
@@ -14,6 +16,13 @@ interface UseModelsTreeProps {
14
16
  activeView: Viewport;
15
17
  hierarchyConfig?: Partial<ModelsTreeHierarchyConfiguration>;
16
18
  visibilityHandlerOverrides?: ModelsTreeVisibilityHandlerOverrides;
19
+ getFilteredPaths?: (props: {
20
+ createInstanceKeyPaths: (props: {
21
+ targetItems: Array<InstanceKey | ElementsGroupInfo>;
22
+ } | {
23
+ label: string;
24
+ }) => Promise<HierarchyFilteringPaths>;
25
+ }) => Promise<HierarchyFilteringPaths>;
17
26
  }
18
27
  /** @beta */
19
28
  interface UseModelsTreeResult {
@@ -24,6 +33,6 @@ interface UseModelsTreeResult {
24
33
  * Custom hook to create and manage state for the models tree.
25
34
  * @beta
26
35
  */
27
- export declare function useModelsTree({ activeView, filter, hierarchyConfig, visibilityHandlerOverrides }: UseModelsTreeProps): UseModelsTreeResult;
36
+ export declare function useModelsTree({ activeView, filter, hierarchyConfig, visibilityHandlerOverrides, getFilteredPaths }: UseModelsTreeProps): UseModelsTreeResult;
28
37
  export {};
29
38
  //# sourceMappingURL=UseModelsTree.d.ts.map
@@ -14,6 +14,7 @@ const presentation_core_interop_1 = require("@itwin/presentation-core-interop");
14
14
  const presentation_hierarchies_1 = require("@itwin/presentation-hierarchies");
15
15
  const TreeWidget_1 = require("../../../TreeWidget");
16
16
  const FocusedInstancesContext_1 = require("../common/FocusedInstancesContext");
17
+ const TreeErrors_1 = require("../common/TreeErrors");
17
18
  const UseIModelChangeListener_1 = require("../common/UseIModelChangeListener");
18
19
  const UseTelemetryContext_1 = require("../common/UseTelemetryContext");
19
20
  const ModelsTreeIdsCache_1 = require("./internal/ModelsTreeIdsCache");
@@ -23,7 +24,7 @@ const ModelsTreeDefinition_1 = require("./ModelsTreeDefinition");
23
24
  * Custom hook to create and manage state for the models tree.
24
25
  * @beta
25
26
  */
26
- function useModelsTree({ activeView, filter, hierarchyConfig, visibilityHandlerOverrides }) {
27
+ function useModelsTree({ activeView, filter, hierarchyConfig, visibilityHandlerOverrides, getFilteredPaths }) {
27
28
  const [filteringError, setFilteringError] = (0, react_1.useState)(undefined);
28
29
  const hierarchyConfiguration = (0, react_1.useMemo)(() => ({
29
30
  ...ModelsTreeDefinition_1.defaultHierarchyConfiguration,
@@ -33,7 +34,7 @@ function useModelsTree({ activeView, filter, hierarchyConfig, visibilityHandlerO
33
34
  Object.values(hierarchyConfig ?? {}));
34
35
  const { onFeatureUsed } = (0, UseTelemetryContext_1.useTelemetryContext)();
35
36
  const { getModelsTreeIdsCache, visibilityHandlerFactory } = useCachedVisibility(activeView, hierarchyConfiguration, visibilityHandlerOverrides);
36
- const { loadInstanceKeys: loadFocusedInstancesKeys } = (0, FocusedInstancesContext_1.useFocusedInstancesContext)();
37
+ const { loadFocusedItems } = (0, FocusedInstancesContext_1.useFocusedInstancesContext)();
37
38
  const getHierarchyDefinition = (0, react_1.useCallback)(({ imodelAccess }) => new ModelsTreeDefinition_1.ModelsTreeDefinition({ imodelAccess, idsCache: getModelsTreeIdsCache(), hierarchyConfig: hierarchyConfiguration }), [getModelsTreeIdsCache, hierarchyConfiguration]);
38
39
  const onNodeDoubleClick = (0, react_1.useCallback)(async ({ nodeData, extendedData }) => {
39
40
  if (!presentation_hierarchies_1.HierarchyNode.isInstancesNode(nodeData) || (extendedData && (extendedData.isSubject || extendedData.isModel || extendedData.isCategory))) {
@@ -43,21 +44,22 @@ function useModelsTree({ activeView, filter, hierarchyConfig, visibilityHandlerO
43
44
  await core_frontend_1.IModelApp.viewManager.selectedView?.zoomToElements(instanceIds);
44
45
  onFeatureUsed({ featureId: "zoom-to-node", reportInteraction: false });
45
46
  }, [onFeatureUsed]);
46
- const getFilteredPaths = (0, react_1.useMemo)(() => {
47
+ const getPaths = (0, react_1.useMemo)(() => {
47
48
  setFilteringError(undefined);
48
- if (loadFocusedInstancesKeys) {
49
+ if (loadFocusedItems) {
49
50
  return async ({ imodelAccess }) => {
50
51
  try {
51
- const targetKeys = await collectTargetKeys(loadFocusedInstancesKeys);
52
- return await ModelsTreeDefinition_1.ModelsTreeDefinition.createInstanceKeyPaths({
52
+ const focusedItems = await collectFocusedItems(loadFocusedItems);
53
+ const paths = await ModelsTreeDefinition_1.ModelsTreeDefinition.createInstanceKeyPaths({
53
54
  imodelAccess,
54
55
  idsCache: getModelsTreeIdsCache(),
55
- keys: targetKeys,
56
+ targetItems: focusedItems,
56
57
  hierarchyConfig: hierarchyConfiguration,
57
58
  });
59
+ return paths.map((path) => ("path" in path ? path : { path, options: { autoExpand: true } }));
58
60
  }
59
61
  catch (e) {
60
- const newError = e instanceof Error && e.message.match(/Filter matches more than \d+ items/) ? "tooManyInstancesFocused" : "unknownInstanceFocusError";
62
+ const newError = e instanceof TreeErrors_1.FilterLimitExceededError ? "tooManyInstancesFocused" : "unknownInstanceFocusError";
61
63
  if (newError !== "tooManyInstancesFocused") {
62
64
  const feature = e instanceof Error && e.message.includes("query too long to execute or server is too busy") ? "error-timeout" : "error-unknown";
63
65
  onFeatureUsed({ featureId: feature, reportInteraction: false });
@@ -67,19 +69,43 @@ function useModelsTree({ activeView, filter, hierarchyConfig, visibilityHandlerO
67
69
  }
68
70
  };
69
71
  }
72
+ if (getFilteredPaths) {
73
+ return async ({ imodelAccess }) => {
74
+ try {
75
+ return await getFilteredPaths({
76
+ createInstanceKeyPaths: async (props) => ModelsTreeDefinition_1.ModelsTreeDefinition.createInstanceKeyPaths({
77
+ ...props,
78
+ imodelAccess,
79
+ idsCache: getModelsTreeIdsCache(),
80
+ hierarchyConfig: hierarchyConfiguration,
81
+ }),
82
+ });
83
+ }
84
+ catch (e) {
85
+ const newError = e instanceof TreeErrors_1.FilterLimitExceededError ? "tooManyFilterMatches" : "unknownFilterError";
86
+ if (newError !== "tooManyFilterMatches") {
87
+ const feature = e instanceof Error && e.message.includes("query too long to execute or server is too busy") ? "error-timeout" : "error-unknown";
88
+ onFeatureUsed({ featureId: feature, reportInteraction: false });
89
+ }
90
+ setFilteringError(newError);
91
+ return [];
92
+ }
93
+ };
94
+ }
70
95
  if (filter) {
71
96
  return async ({ imodelAccess }) => {
72
97
  onFeatureUsed({ featureId: "filtering", reportInteraction: true });
73
98
  try {
74
- return await ModelsTreeDefinition_1.ModelsTreeDefinition.createInstanceKeyPaths({
99
+ const paths = await ModelsTreeDefinition_1.ModelsTreeDefinition.createInstanceKeyPaths({
75
100
  imodelAccess,
76
101
  label: filter,
77
102
  idsCache: getModelsTreeIdsCache(),
78
103
  hierarchyConfig: hierarchyConfiguration,
79
104
  });
105
+ return paths.map((path) => ("path" in path ? path : { path, options: { autoExpand: true } }));
80
106
  }
81
107
  catch (e) {
82
- const newError = e instanceof Error && e.message.match(/Filter matches more than \d+ items/) ? "tooManyFilterMatches" : "unknownFilterError";
108
+ const newError = e instanceof TreeErrors_1.FilterLimitExceededError ? "tooManyFilterMatches" : "unknownFilterError";
83
109
  if (newError !== "tooManyFilterMatches") {
84
110
  const feature = e instanceof Error && e.message.includes("query too long to execute or server is too busy") ? "error-timeout" : "error-unknown";
85
111
  onFeatureUsed({ featureId: feature, reportInteraction: false });
@@ -90,13 +116,13 @@ function useModelsTree({ activeView, filter, hierarchyConfig, visibilityHandlerO
90
116
  };
91
117
  }
92
118
  return undefined;
93
- }, [filter, loadFocusedInstancesKeys, getModelsTreeIdsCache, onFeatureUsed, hierarchyConfiguration]);
119
+ }, [filter, loadFocusedItems, getModelsTreeIdsCache, onFeatureUsed, getFilteredPaths, hierarchyConfiguration]);
94
120
  return {
95
121
  modelsTreeProps: {
96
122
  treeName: "models-tree-v2",
97
123
  visibilityHandlerFactory,
98
124
  getHierarchyDefinition,
99
- getFilteredPaths,
125
+ getFilteredPaths: getPaths,
100
126
  noDataMessage: getNoDataMessage(filter, filteringError),
101
127
  highlight: filter ? { text: filter } : undefined,
102
128
  },
@@ -183,39 +209,33 @@ function useCachedVisibility(activeView, hierarchyConfig, overrides) {
183
209
  function SvgClassGrouping() {
184
210
  return ((0, jsx_runtime_1.jsx)(itwinui_react_1.Icon, { children: (0, jsx_runtime_1.jsx)("svg", { id: "Calque_1", "data-name": "Calque 1", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 16 16", children: (0, jsx_runtime_1.jsx)("path", { d: "M8.00933,0,0,3.97672V11.986L8.00933,16,16,11.93V3.97651ZM1.66173,11.27642c-.26155.03734-.59754-.26154-.76553-.69085-.168-.41066-.09334-.784.168-.82152.26154-.03734.59754.26154.76553.67219C1.99772,10.86577,1.92306,11.23909,1.66173,11.27642Zm0-3.32319c-.26155.03733-.59754-.28-.76553-.69086-.168-.42932-.09334-.80285.168-.84.26133-.03733.59754.28.76532.69086C1.99772,7.54236,1.92306,7.89723,1.66173,7.95323Zm4.31276,5.52621a.18186.18186,0,0,1-.16821-.01866L3.41657,12.15394a.94275.94275,0,0,1-.29887-.80285c.03754-.33621.22421-.52265.41108-.41066L5.9185,12.24727a.88656.88656,0,0,1,.28.80285A.5057.5057,0,0,1,5.97449,13.47944Zm0-3.37919a.18184.18184,0,0,1-.16821-.01867L3.41657,8.77475a.943.943,0,0,1-.29887-.80286c.03754-.3362.22421-.52286.41108-.42953L5.9185,8.86786a.83112.83112,0,0,1,.28.78419A.51684.51684,0,0,1,5.97449,10.10025Z" }) }) }));
185
211
  }
186
- async function collectTargetKeys(loadFocusedInstancesKeys) {
187
- const targetKeys = [];
212
+ async function collectFocusedItems(loadFocusedItems) {
213
+ const focusedItems = [];
188
214
  const groupingNodeInfos = [];
189
- for await (const key of loadFocusedInstancesKeys()) {
215
+ for await (const key of loadFocusedItems()) {
190
216
  if ("id" in key) {
191
- targetKeys.push(key);
217
+ focusedItems.push(key);
192
218
  continue;
193
219
  }
194
220
  if (!presentation_hierarchies_1.HierarchyNodeKey.isClassGrouping(key.key)) {
195
- targetKeys.push(...key.groupedInstanceKeys);
196
221
  continue;
197
222
  }
198
- if (!key.nonGroupingAncestor || !presentation_hierarchies_1.HierarchyNodeKey.isInstances(key.nonGroupingAncestor.key)) {
223
+ const groupingNode = key;
224
+ if (!groupingNode.nonGroupingAncestor || !presentation_hierarchies_1.HierarchyNodeKey.isInstances(groupingNode.nonGroupingAncestor.key)) {
199
225
  continue;
200
226
  }
201
- const parentKey = key.nonGroupingAncestor.key;
202
- const type = key.nonGroupingAncestor.extendedData?.isCategory ? "category" : "element";
203
- const modelIds = (key.nonGroupingAncestor.extendedData?.modelIds ?? []).flatMap((ids) => ids);
204
- const groupInfo = groupingNodeInfos.find((group) => presentation_hierarchies_1.HierarchyNodeKey.equals(group.parentKey, parentKey));
205
- if (groupInfo) {
206
- groupInfo.classes.push(key.key.className);
207
- }
208
- else {
209
- groupingNodeInfos.push({ classes: [key.key.className], parentType: type, parentKey, modelIds });
210
- }
227
+ const parentKey = groupingNode.nonGroupingAncestor.key;
228
+ const type = groupingNode.nonGroupingAncestor.extendedData?.isCategory ? "category" : "element";
229
+ const modelIds = (groupingNode.nonGroupingAncestor.extendedData?.modelIds ?? []).flatMap((ids) => ids);
230
+ groupingNodeInfos.push({ groupingNode, parentType: type, parentKey, modelIds });
211
231
  }
212
- targetKeys.push(...groupingNodeInfos.map(({ parentKey, parentType, classes, modelIds }) => ({
232
+ focusedItems.push(...groupingNodeInfos.map(({ parentKey, parentType, groupingNode, modelIds }) => ({
213
233
  parent: parentType === "element"
214
234
  ? { type: "element", ids: parentKey.instanceKeys.map((key) => key.id) }
215
235
  : { type: "category", ids: parentKey.instanceKeys.map((key) => key.id), modelIds },
216
- classes,
236
+ groupingNode,
217
237
  })));
218
- return targetKeys;
238
+ return focusedItems;
219
239
  }
220
240
  function createLocalizedMessage(message, onClick) {
221
241
  const exp = new RegExp("<link>(.*)</link>");
@@ -1 +1 @@
1
- {"version":3,"file":"UseModelsTree.js","sourceRoot":"","sources":["../../../../../src/components/trees/models-tree/UseModelsTree.tsx"],"names":[],"mappings":";;;;AAAA;;;gGAGgG;AAEhG,iCAA0E;AAC1E,wDAAiD;AACjD,oEAAsG;AACtG,wDAA0D;AAC1D,gFAA4E;AAC5E,8EAAkF;AAClF,oDAAiD;AACjD,+EAA+E;AAC/E,+EAA4E;AAC5E,uEAAoE;AACpE,sEAAmE;AACnE,wFAA2F;AAC3F,iEAA6F;AAsC7F;;;GAGG;AACH,SAAgB,aAAa,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,eAAe,EAAE,0BAA0B,EAAsB;IACnH,MAAM,C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CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,IAC5B,CACJ,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, useEffect, useMemo, useRef, useState } from \"react\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { SvgFolder, SvgImodelHollow, SvgItem, SvgLayers, SvgModel } from \"@itwin/itwinui-icons-react\";\nimport { Anchor, Icon, Text } from \"@itwin/itwinui-react\";\nimport { createECSqlQueryExecutor } from \"@itwin/presentation-core-interop\";\nimport { HierarchyNode, HierarchyNodeKey } from \"@itwin/presentation-hierarchies\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { useFocusedInstancesContext } from \"../common/FocusedInstancesContext\";\nimport { useIModelChangeListener } from \"../common/UseIModelChangeListener\";\nimport { useTelemetryContext } from \"../common/UseTelemetryContext\";\nimport { ModelsTreeIdsCache } from \"./internal/ModelsTreeIdsCache\";\nimport { createModelsTreeVisibilityHandler } from \"./internal/ModelsTreeVisibilityHandler\";\nimport { defaultHierarchyConfiguration, ModelsTreeDefinition } from \"./ModelsTreeDefinition\";\n\nimport type { Id64String } from \"@itwin/core-bentley\";\nimport type { GroupingHierarchyNode, InstancesNodeKey } from \"@itwin/presentation-hierarchies\";\nimport type { InstanceKey } from \"@itwin/presentation-shared\";\nimport type { ComponentPropsWithoutRef, ReactElement } from \"react\";\nimport type { Viewport } from \"@itwin/core-frontend\";\nimport type { PresentationHierarchyNode } from \"@itwin/presentation-hierarchies-react\";\nimport type { ElementsGroupInfo, ModelsTreeHierarchyConfiguration } from \"./ModelsTreeDefinition\";\nimport type { ModelsTreeVisibilityHandlerOverrides } from \"./internal/ModelsTreeVisibilityHandler\";\nimport type { VisibilityTree } from \"../common/components/VisibilityTree\";\nimport type { VisibilityTreeRenderer } from \"../common/components/VisibilityTreeRenderer\";\n\ntype ModelsTreeFilteringError = \"tooManyFilterMatches\" | \"tooManyInstancesFocused\" | \"unknownFilterError\" | \"unknownInstanceFocusError\";\n\n/** @beta */\ntype VisibilityTreeRendererProps = ComponentPropsWithoutRef<typeof VisibilityTreeRenderer>;\n\n/** @beta */\ntype VisibilityTreeProps = ComponentPropsWithoutRef<typeof VisibilityTree>;\n\n/** @beta */\ninterface UseModelsTreeProps {\n filter?: string;\n activeView: Viewport;\n hierarchyConfig?: Partial<ModelsTreeHierarchyConfiguration>;\n visibilityHandlerOverrides?: ModelsTreeVisibilityHandlerOverrides;\n}\n\n/** @beta */\ninterface UseModelsTreeResult {\n modelsTreeProps: Pick<\n VisibilityTreeProps,\n \"treeName\" | \"getHierarchyDefinition\" | \"getFilteredPaths\" | \"visibilityHandlerFactory\" | \"highlight\" | \"noDataMessage\"\n >;\n rendererProps: Pick<Required<VisibilityTreeRendererProps>, \"getIcon\" | \"onNodeDoubleClick\">;\n}\n\n/**\n * Custom hook to create and manage state for the models tree.\n * @beta\n */\nexport function useModelsTree({ activeView, filter, hierarchyConfig, visibilityHandlerOverrides }: UseModelsTreeProps): UseModelsTreeResult {\n const [filteringError, setFilteringError] = useState<ModelsTreeFilteringError | undefined>(undefined);\n const hierarchyConfiguration = useMemo<ModelsTreeHierarchyConfiguration>(\n () => ({\n ...defaultHierarchyConfiguration,\n ...hierarchyConfig,\n }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n Object.values(hierarchyConfig ?? {}),\n );\n const { onFeatureUsed } = useTelemetryContext();\n\n const { getModelsTreeIdsCache, visibilityHandlerFactory } = useCachedVisibility(activeView, hierarchyConfiguration, visibilityHandlerOverrides);\n const { loadInstanceKeys: loadFocusedInstancesKeys } = useFocusedInstancesContext();\n\n const getHierarchyDefinition = useCallback<VisibilityTreeProps[\"getHierarchyDefinition\"]>(\n ({ imodelAccess }) => new ModelsTreeDefinition({ imodelAccess, idsCache: getModelsTreeIdsCache(), hierarchyConfig: hierarchyConfiguration }),\n [getModelsTreeIdsCache, hierarchyConfiguration],\n );\n\n const onNodeDoubleClick = useCallback(\n async ({ nodeData, extendedData }: PresentationHierarchyNode) => {\n if (!HierarchyNode.isInstancesNode(nodeData) || (extendedData && (extendedData.isSubject || extendedData.isModel || extendedData.isCategory))) {\n return;\n }\n const instanceIds = nodeData.key.instanceKeys.map((instanceKey) => instanceKey.id);\n await IModelApp.viewManager.selectedView?.zoomToElements(instanceIds);\n onFeatureUsed({ featureId: \"zoom-to-node\", reportInteraction: false });\n },\n [onFeatureUsed],\n );\n\n const getFilteredPaths = useMemo<VisibilityTreeProps[\"getFilteredPaths\"] | undefined>(() => {\n setFilteringError(undefined);\n if (loadFocusedInstancesKeys) {\n return async ({ imodelAccess }) => {\n try {\n const targetKeys = await collectTargetKeys(loadFocusedInstancesKeys);\n return await ModelsTreeDefinition.createInstanceKeyPaths({\n imodelAccess,\n idsCache: getModelsTreeIdsCache(),\n keys: targetKeys,\n hierarchyConfig: hierarchyConfiguration,\n });\n } catch (e) {\n const newError =\n e instanceof Error && e.message.match(/Filter matches more than \\d+ items/) ? \"tooManyInstancesFocused\" : \"unknownInstanceFocusError\";\n if (newError !== \"tooManyInstancesFocused\") {\n const feature = e instanceof Error && e.message.includes(\"query too long to execute or server is too busy\") ? \"error-timeout\" : \"error-unknown\";\n onFeatureUsed({ featureId: feature, reportInteraction: false });\n }\n setFilteringError(newError);\n return [];\n }\n };\n }\n\n if (filter) {\n return async ({ imodelAccess }) => {\n onFeatureUsed({ featureId: \"filtering\", reportInteraction: true });\n try {\n return await ModelsTreeDefinition.createInstanceKeyPaths({\n imodelAccess,\n label: filter,\n idsCache: getModelsTreeIdsCache(),\n hierarchyConfig: hierarchyConfiguration,\n });\n } catch (e) {\n const newError = e instanceof Error && e.message.match(/Filter matches more than \\d+ items/) ? \"tooManyFilterMatches\" : \"unknownFilterError\";\n if (newError !== \"tooManyFilterMatches\") {\n const feature = e instanceof Error && e.message.includes(\"query too long to execute or server is too busy\") ? \"error-timeout\" : \"error-unknown\";\n onFeatureUsed({ featureId: feature, reportInteraction: false });\n }\n setFilteringError(newError);\n return [];\n }\n };\n }\n return undefined;\n }, [filter, loadFocusedInstancesKeys, getModelsTreeIdsCache, onFeatureUsed, hierarchyConfiguration]);\n\n return {\n modelsTreeProps: {\n treeName: \"models-tree-v2\",\n visibilityHandlerFactory,\n getHierarchyDefinition,\n getFilteredPaths,\n noDataMessage: getNoDataMessage(filter, filteringError),\n highlight: filter ? { text: filter } : undefined,\n },\n rendererProps: {\n onNodeDoubleClick,\n getIcon,\n },\n };\n}\n\nfunction getNoDataMessage(filter?: string, error?: ModelsTreeFilteringError) {\n if (isInstanceFocusError(error)) {\n return <InstanceFocusError error={error!} />;\n }\n if (isFilterError(error)) {\n return <Text>{TreeWidget.translate(`modelsTree.filtering.${error}`)}</Text>;\n }\n if (filter) {\n return <Text>{TreeWidget.translate(\"modelsTree.filtering.noMatches\", { filter })}</Text>;\n }\n return undefined;\n}\n\nfunction isFilterError(error: ModelsTreeFilteringError | undefined) {\n return error === \"tooManyFilterMatches\" || error === \"unknownFilterError\";\n}\n\nfunction isInstanceFocusError(error: ModelsTreeFilteringError | undefined) {\n return error === \"tooManyInstancesFocused\" || error === \"unknownInstanceFocusError\";\n}\n\nfunction InstanceFocusError({ error }: { error: ModelsTreeFilteringError }) {\n const { toggle } = useFocusedInstancesContext();\n const localizedMessage = createLocalizedMessage(TreeWidget.translate(`modelsTree.filtering.${error}`), () => toggle());\n return <Text>{localizedMessage}</Text>;\n}\n\nfunction getIcon(node: PresentationHierarchyNode): ReactElement | undefined {\n if (node.extendedData?.imageId === undefined) {\n return undefined;\n }\n\n switch (node.extendedData.imageId) {\n case \"icon-layers\":\n return <SvgLayers />;\n case \"icon-item\":\n return <SvgItem />;\n case \"icon-ec-class\":\n return <SvgClassGrouping />;\n case \"icon-imodel-hollow-2\":\n return <SvgImodelHollow />;\n case \"icon-folder\":\n return <SvgFolder />;\n case \"icon-model\":\n return <SvgModel />;\n }\n\n return undefined;\n}\n\nfunction createVisibilityHandlerFactory(\n activeView: Viewport,\n idsCacheGetter: () => ModelsTreeIdsCache,\n overrides?: ModelsTreeVisibilityHandlerOverrides,\n): VisibilityTreeProps[\"visibilityHandlerFactory\"] {\n return ({ imodelAccess }) => createModelsTreeVisibilityHandler({ viewport: activeView, idsCache: idsCacheGetter(), imodelAccess, overrides });\n}\n\nfunction useCachedVisibility(activeView: Viewport, hierarchyConfig: ModelsTreeHierarchyConfiguration, overrides?: ModelsTreeVisibilityHandlerOverrides) {\n const cacheRef = useRef<ModelsTreeIdsCache>();\n const currentIModelRef = useRef(activeView.iModel);\n\n const getModelsTreeIdsCache = useCallback(() => {\n if (!cacheRef.current) {\n cacheRef.current = new ModelsTreeIdsCache(createECSqlQueryExecutor(currentIModelRef.current), hierarchyConfig);\n }\n return cacheRef.current;\n }, [hierarchyConfig]);\n\n const [visibilityHandlerFactory, setVisibilityHandlerFactory] = useState(() => createVisibilityHandlerFactory(activeView, getModelsTreeIdsCache, overrides));\n\n useIModelChangeListener({\n imodel: activeView.iModel,\n action: useCallback(() => {\n cacheRef.current = undefined;\n setVisibilityHandlerFactory(() => createVisibilityHandlerFactory(activeView, getModelsTreeIdsCache, overrides));\n }, [activeView, getModelsTreeIdsCache, overrides]),\n });\n\n useEffect(() => {\n currentIModelRef.current = activeView.iModel;\n cacheRef.current = undefined;\n setVisibilityHandlerFactory(() => createVisibilityHandlerFactory(activeView, getModelsTreeIdsCache, overrides));\n }, [activeView, getModelsTreeIdsCache, overrides]);\n\n return {\n getModelsTreeIdsCache,\n visibilityHandlerFactory,\n };\n}\n\nfunction SvgClassGrouping() {\n return (\n <Icon>\n <svg id=\"Calque_1\" data-name=\"Calque 1\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\">\n <path d=\"M8.00933,0,0,3.97672V11.986L8.00933,16,16,11.93V3.97651ZM1.66173,11.27642c-.26155.03734-.59754-.26154-.76553-.69085-.168-.41066-.09334-.784.168-.82152.26154-.03734.59754.26154.76553.67219C1.99772,10.86577,1.92306,11.23909,1.66173,11.27642Zm0-3.32319c-.26155.03733-.59754-.28-.76553-.69086-.168-.42932-.09334-.80285.168-.84.26133-.03733.59754.28.76532.69086C1.99772,7.54236,1.92306,7.89723,1.66173,7.95323Zm4.31276,5.52621a.18186.18186,0,0,1-.16821-.01866L3.41657,12.15394a.94275.94275,0,0,1-.29887-.80285c.03754-.33621.22421-.52265.41108-.41066L5.9185,12.24727a.88656.88656,0,0,1,.28.80285A.5057.5057,0,0,1,5.97449,13.47944Zm0-3.37919a.18184.18184,0,0,1-.16821-.01867L3.41657,8.77475a.943.943,0,0,1-.29887-.80286c.03754-.3362.22421-.52286.41108-.42953L5.9185,8.86786a.83112.83112,0,0,1,.28.78419A.51684.51684,0,0,1,5.97449,10.10025Z\" />\n </svg>\n </Icon>\n );\n}\n\nasync function collectTargetKeys(loadFocusedInstancesKeys: () => AsyncIterableIterator<InstanceKey | GroupingHierarchyNode>) {\n const targetKeys: Array<InstanceKey | ElementsGroupInfo> = [];\n const groupingNodeInfos: Array<{ parentKey: InstancesNodeKey; parentType: \"element\" | \"category\"; classes: string[]; modelIds: Id64String[] }> = [];\n for await (const key of loadFocusedInstancesKeys()) {\n if (\"id\" in key) {\n targetKeys.push(key);\n continue;\n }\n\n if (!HierarchyNodeKey.isClassGrouping(key.key)) {\n targetKeys.push(...key.groupedInstanceKeys);\n continue;\n }\n\n if (!key.nonGroupingAncestor || !HierarchyNodeKey.isInstances(key.nonGroupingAncestor.key)) {\n continue;\n }\n\n const parentKey = key.nonGroupingAncestor.key;\n const type = key.nonGroupingAncestor.extendedData?.isCategory ? \"category\" : \"element\";\n const modelIds = ((key.nonGroupingAncestor.extendedData?.modelIds as Id64String[][]) ?? []).flatMap((ids) => ids);\n const groupInfo = groupingNodeInfos.find((group) => HierarchyNodeKey.equals(group.parentKey, parentKey));\n if (groupInfo) {\n groupInfo.classes.push(key.key.className);\n } else {\n groupingNodeInfos.push({ classes: [key.key.className], parentType: type, parentKey, modelIds });\n }\n }\n targetKeys.push(\n ...groupingNodeInfos.map(({ parentKey, parentType, classes, modelIds }) => ({\n parent:\n parentType === \"element\"\n ? { type: \"element\" as const, ids: parentKey.instanceKeys.map((key) => key.id) }\n : { type: \"category\" as const, ids: parentKey.instanceKeys.map((key) => key.id), modelIds },\n classes,\n })),\n );\n return targetKeys;\n}\n\nfunction createLocalizedMessage(message: string, onClick?: () => void) {\n const exp = new RegExp(\"<link>(.*)</link>\");\n const match = message.match(exp);\n if (!match) {\n return message;\n }\n\n const [fullText, innerText] = match;\n const [textBefore, textAfter] = message.split(fullText);\n\n return (\n <>\n {textBefore ? textBefore : null}\n <Anchor\n underline\n onClick={(e) => {\n e.stopPropagation();\n onClick?.();\n }}\n >\n {innerText}\n </Anchor>\n {textAfter ? textAfter : null}\n </>\n );\n}\n"]}
1
+ {"version":3,"file":"UseModelsTree.js","sourceRoot":"","sources":["../../../../../src/components/trees/models-tree/UseModelsTree.tsx"],"names":[],"mappings":";;;;AAAA;;;gGAGgG;AAEhG,iCAA0E;AAC1E,wDAAiD;AACjD,oEAAsG;AACtG,wDAA0D;AAC1D,gFAA4E;AAC5E,8EAAkF;AAClF,oDAAiD;AACjD,+EAA+E;AAC/E,qDAAgE;AAChE,+EAA4E;AAC5E,uEAAoE;AACpE,sEAAmE;AACnE,wFAA2F;AAC3F,iEAA6F;AA0C7F;;;GAGG;AACH,SAAgB,aAAa,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,eAAe,EAAE,0BAA0B,EAAE,gBAAgB,EAAsB;IACrI,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,IAAA,gBAAQ,EAAuC,SAAS,CAAC,CAAC;IACtG,MAAM,sBAAsB,GAAG,IAAA,eAAO,EACpC,GAAG,EAAE,CAAC,CAAC;QACL,GAAG,oDAA6B;QAChC,GAAG,eAAe;KACnB,CAAC;IACF,uDAAuD;IACvD,MAAM,CAAC,MAAM,CAAC,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AAe,EAAE,OAAoB;IACnE,MAAM,GAAG,GAAG,IAAI,MAAM,CAAC,mBAAmB,CAAC,CAAC;IAC5C,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACjC,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,OAAO,CAAC;KAChB;IAED,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,GAAG,KAAK,CAAC;IACpC,MAAM,CAAC,UAAU,EAAE,SAAS,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAExD,OAAO,CACL,6DACG,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,EAC/B,uBAAC,sBAAM,IACL,SAAS,QACT,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;oBACb,CAAC,CAAC,eAAe,EAAE,CAAC;oBACpB,OAAO,EAAE,EAAE,CAAC;gBACd,CAAC,YAEA,SAAS,GACH,EACR,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,IAC5B,CACJ,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, useEffect, useMemo, useRef, useState } from \"react\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { SvgFolder, SvgImodelHollow, SvgItem, SvgLayers, SvgModel } from \"@itwin/itwinui-icons-react\";\nimport { Anchor, Icon, Text } from \"@itwin/itwinui-react\";\nimport { createECSqlQueryExecutor } from \"@itwin/presentation-core-interop\";\nimport { HierarchyNode, HierarchyNodeKey } from \"@itwin/presentation-hierarchies\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { useFocusedInstancesContext } from \"../common/FocusedInstancesContext\";\nimport { FilterLimitExceededError } from \"../common/TreeErrors\";\nimport { useIModelChangeListener } from \"../common/UseIModelChangeListener\";\nimport { useTelemetryContext } from \"../common/UseTelemetryContext\";\nimport { ModelsTreeIdsCache } from \"./internal/ModelsTreeIdsCache\";\nimport { createModelsTreeVisibilityHandler } from \"./internal/ModelsTreeVisibilityHandler\";\nimport { defaultHierarchyConfiguration, ModelsTreeDefinition } from \"./ModelsTreeDefinition\";\n\nimport type { Id64String } from \"@itwin/core-bentley\";\nimport type { GroupingHierarchyNode, InstancesNodeKey } from \"@itwin/presentation-hierarchies\";\nimport type { InstanceKey } from \"@itwin/presentation-shared\";\nimport type { ComponentPropsWithoutRef, ReactElement } from \"react\";\nimport type { Viewport } from \"@itwin/core-frontend\";\nimport type { PresentationHierarchyNode } from \"@itwin/presentation-hierarchies-react\";\nimport type { ClassGroupingHierarchyNode, ElementsGroupInfo, ModelsTreeHierarchyConfiguration } from \"./ModelsTreeDefinition\";\nimport type { ModelsTreeVisibilityHandlerOverrides } from \"./internal/ModelsTreeVisibilityHandler\";\nimport type { VisibilityTree } from \"../common/components/VisibilityTree\";\nimport type { VisibilityTreeRenderer } from \"../common/components/VisibilityTreeRenderer\";\n\ntype ModelsTreeFilteringError = \"tooManyFilterMatches\" | \"tooManyInstancesFocused\" | \"unknownFilterError\" | \"unknownInstanceFocusError\";\ntype HierarchyFilteringPaths = Awaited<ReturnType<Required<VisibilityTreeProps>[\"getFilteredPaths\"]>>;\n\n/** @beta */\ntype VisibilityTreeRendererProps = ComponentPropsWithoutRef<typeof VisibilityTreeRenderer>;\n\n/** @beta */\ntype VisibilityTreeProps = ComponentPropsWithoutRef<typeof VisibilityTree>;\n\n/** @beta */\ninterface UseModelsTreeProps {\n filter?: string;\n activeView: Viewport;\n hierarchyConfig?: Partial<ModelsTreeHierarchyConfiguration>;\n visibilityHandlerOverrides?: ModelsTreeVisibilityHandlerOverrides;\n getFilteredPaths?: (props: {\n createInstanceKeyPaths: (props: { targetItems: Array<InstanceKey | ElementsGroupInfo> } | { label: string }) => Promise<HierarchyFilteringPaths>;\n }) => Promise<HierarchyFilteringPaths>;\n}\n\n/** @beta */\ninterface UseModelsTreeResult {\n modelsTreeProps: Pick<\n VisibilityTreeProps,\n \"treeName\" | \"getHierarchyDefinition\" | \"getFilteredPaths\" | \"visibilityHandlerFactory\" | \"highlight\" | \"noDataMessage\"\n >;\n rendererProps: Pick<Required<VisibilityTreeRendererProps>, \"getIcon\" | \"onNodeDoubleClick\">;\n}\n\n/**\n * Custom hook to create and manage state for the models tree.\n * @beta\n */\nexport function useModelsTree({ activeView, filter, hierarchyConfig, visibilityHandlerOverrides, getFilteredPaths }: UseModelsTreeProps): UseModelsTreeResult {\n const [filteringError, setFilteringError] = useState<ModelsTreeFilteringError | undefined>(undefined);\n const hierarchyConfiguration = useMemo<ModelsTreeHierarchyConfiguration>(\n () => ({\n ...defaultHierarchyConfiguration,\n ...hierarchyConfig,\n }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n Object.values(hierarchyConfig ?? {}),\n );\n const { onFeatureUsed } = useTelemetryContext();\n\n const { getModelsTreeIdsCache, visibilityHandlerFactory } = useCachedVisibility(activeView, hierarchyConfiguration, visibilityHandlerOverrides);\n const { loadFocusedItems } = useFocusedInstancesContext();\n\n const getHierarchyDefinition = useCallback<VisibilityTreeProps[\"getHierarchyDefinition\"]>(\n ({ imodelAccess }) => new ModelsTreeDefinition({ imodelAccess, idsCache: getModelsTreeIdsCache(), hierarchyConfig: hierarchyConfiguration }),\n [getModelsTreeIdsCache, hierarchyConfiguration],\n );\n\n const onNodeDoubleClick = useCallback(\n async ({ nodeData, extendedData }: PresentationHierarchyNode) => {\n if (!HierarchyNode.isInstancesNode(nodeData) || (extendedData && (extendedData.isSubject || extendedData.isModel || extendedData.isCategory))) {\n return;\n }\n const instanceIds = nodeData.key.instanceKeys.map((instanceKey) => instanceKey.id);\n await IModelApp.viewManager.selectedView?.zoomToElements(instanceIds);\n onFeatureUsed({ featureId: \"zoom-to-node\", reportInteraction: false });\n },\n [onFeatureUsed],\n );\n\n const getPaths = useMemo<VisibilityTreeProps[\"getFilteredPaths\"] | undefined>(() => {\n setFilteringError(undefined);\n if (loadFocusedItems) {\n return async ({ imodelAccess }) => {\n try {\n const focusedItems = await collectFocusedItems(loadFocusedItems);\n const paths = await ModelsTreeDefinition.createInstanceKeyPaths({\n imodelAccess,\n idsCache: getModelsTreeIdsCache(),\n targetItems: focusedItems,\n hierarchyConfig: hierarchyConfiguration,\n });\n return paths.map((path) => (\"path\" in path ? path : { path, options: { autoExpand: true } }));\n } catch (e) {\n const newError = e instanceof FilterLimitExceededError ? \"tooManyInstancesFocused\" : \"unknownInstanceFocusError\";\n if (newError !== \"tooManyInstancesFocused\") {\n const feature = e instanceof Error && e.message.includes(\"query too long to execute or server is too busy\") ? \"error-timeout\" : \"error-unknown\";\n onFeatureUsed({ featureId: feature, reportInteraction: false });\n }\n setFilteringError(newError);\n return [];\n }\n };\n }\n\n if (getFilteredPaths) {\n return async ({ imodelAccess }) => {\n try {\n return await getFilteredPaths({\n createInstanceKeyPaths: async (props) =>\n ModelsTreeDefinition.createInstanceKeyPaths({\n ...props,\n imodelAccess,\n idsCache: getModelsTreeIdsCache(),\n hierarchyConfig: hierarchyConfiguration,\n }),\n });\n } catch (e) {\n const newError = e instanceof FilterLimitExceededError ? \"tooManyFilterMatches\" : \"unknownFilterError\";\n if (newError !== \"tooManyFilterMatches\") {\n const feature = e instanceof Error && e.message.includes(\"query too long to execute or server is too busy\") ? \"error-timeout\" : \"error-unknown\";\n onFeatureUsed({ featureId: feature, reportInteraction: false });\n }\n setFilteringError(newError);\n return [];\n }\n };\n }\n\n if (filter) {\n return async ({ imodelAccess }) => {\n onFeatureUsed({ featureId: \"filtering\", reportInteraction: true });\n try {\n const paths = await ModelsTreeDefinition.createInstanceKeyPaths({\n imodelAccess,\n label: filter,\n idsCache: getModelsTreeIdsCache(),\n hierarchyConfig: hierarchyConfiguration,\n });\n return paths.map((path) => (\"path\" in path ? path : { path, options: { autoExpand: true } }));\n } catch (e) {\n const newError = e instanceof FilterLimitExceededError ? \"tooManyFilterMatches\" : \"unknownFilterError\";\n if (newError !== \"tooManyFilterMatches\") {\n const feature = e instanceof Error && e.message.includes(\"query too long to execute or server is too busy\") ? \"error-timeout\" : \"error-unknown\";\n onFeatureUsed({ featureId: feature, reportInteraction: false });\n }\n setFilteringError(newError);\n return [];\n }\n };\n }\n return undefined;\n }, [filter, loadFocusedItems, getModelsTreeIdsCache, onFeatureUsed, getFilteredPaths, hierarchyConfiguration]);\n\n return {\n modelsTreeProps: {\n treeName: \"models-tree-v2\",\n visibilityHandlerFactory,\n getHierarchyDefinition,\n getFilteredPaths: getPaths,\n noDataMessage: getNoDataMessage(filter, filteringError),\n highlight: filter ? { text: filter } : undefined,\n },\n rendererProps: {\n onNodeDoubleClick,\n getIcon,\n },\n };\n}\n\nfunction getNoDataMessage(filter?: string, error?: ModelsTreeFilteringError) {\n if (isInstanceFocusError(error)) {\n return <InstanceFocusError error={error!} />;\n }\n if (isFilterError(error)) {\n return <Text>{TreeWidget.translate(`modelsTree.filtering.${error}`)}</Text>;\n }\n if (filter) {\n return <Text>{TreeWidget.translate(\"modelsTree.filtering.noMatches\", { filter })}</Text>;\n }\n return undefined;\n}\n\nfunction isFilterError(error: ModelsTreeFilteringError | undefined) {\n return error === \"tooManyFilterMatches\" || error === \"unknownFilterError\";\n}\n\nfunction isInstanceFocusError(error: ModelsTreeFilteringError | undefined) {\n return error === \"tooManyInstancesFocused\" || error === \"unknownInstanceFocusError\";\n}\n\nfunction InstanceFocusError({ error }: { error: ModelsTreeFilteringError }) {\n const { toggle } = useFocusedInstancesContext();\n const localizedMessage = createLocalizedMessage(TreeWidget.translate(`modelsTree.filtering.${error}`), () => toggle());\n return <Text>{localizedMessage}</Text>;\n}\n\nfunction getIcon(node: PresentationHierarchyNode): ReactElement | undefined {\n if (node.extendedData?.imageId === undefined) {\n return undefined;\n }\n\n switch (node.extendedData.imageId) {\n case \"icon-layers\":\n return <SvgLayers />;\n case \"icon-item\":\n return <SvgItem />;\n case \"icon-ec-class\":\n return <SvgClassGrouping />;\n case \"icon-imodel-hollow-2\":\n return <SvgImodelHollow />;\n case \"icon-folder\":\n return <SvgFolder />;\n case \"icon-model\":\n return <SvgModel />;\n }\n\n return undefined;\n}\n\nfunction createVisibilityHandlerFactory(\n activeView: Viewport,\n idsCacheGetter: () => ModelsTreeIdsCache,\n overrides?: ModelsTreeVisibilityHandlerOverrides,\n): VisibilityTreeProps[\"visibilityHandlerFactory\"] {\n return ({ imodelAccess }) => createModelsTreeVisibilityHandler({ viewport: activeView, idsCache: idsCacheGetter(), imodelAccess, overrides });\n}\n\nfunction useCachedVisibility(activeView: Viewport, hierarchyConfig: ModelsTreeHierarchyConfiguration, overrides?: ModelsTreeVisibilityHandlerOverrides) {\n const cacheRef = useRef<ModelsTreeIdsCache>();\n const currentIModelRef = useRef(activeView.iModel);\n\n const getModelsTreeIdsCache = useCallback(() => {\n if (!cacheRef.current) {\n cacheRef.current = new ModelsTreeIdsCache(createECSqlQueryExecutor(currentIModelRef.current), hierarchyConfig);\n }\n return cacheRef.current;\n }, [hierarchyConfig]);\n\n const [visibilityHandlerFactory, setVisibilityHandlerFactory] = useState(() => createVisibilityHandlerFactory(activeView, getModelsTreeIdsCache, overrides));\n\n useIModelChangeListener({\n imodel: activeView.iModel,\n action: useCallback(() => {\n cacheRef.current = undefined;\n setVisibilityHandlerFactory(() => createVisibilityHandlerFactory(activeView, getModelsTreeIdsCache, overrides));\n }, [activeView, getModelsTreeIdsCache, overrides]),\n });\n\n useEffect(() => {\n currentIModelRef.current = activeView.iModel;\n cacheRef.current = undefined;\n setVisibilityHandlerFactory(() => createVisibilityHandlerFactory(activeView, getModelsTreeIdsCache, overrides));\n }, [activeView, getModelsTreeIdsCache, overrides]);\n\n return {\n getModelsTreeIdsCache,\n visibilityHandlerFactory,\n };\n}\n\nfunction SvgClassGrouping() {\n return (\n <Icon>\n <svg id=\"Calque_1\" data-name=\"Calque 1\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\">\n <path d=\"M8.00933,0,0,3.97672V11.986L8.00933,16,16,11.93V3.97651ZM1.66173,11.27642c-.26155.03734-.59754-.26154-.76553-.69085-.168-.41066-.09334-.784.168-.82152.26154-.03734.59754.26154.76553.67219C1.99772,10.86577,1.92306,11.23909,1.66173,11.27642Zm0-3.32319c-.26155.03733-.59754-.28-.76553-.69086-.168-.42932-.09334-.80285.168-.84.26133-.03733.59754.28.76532.69086C1.99772,7.54236,1.92306,7.89723,1.66173,7.95323Zm4.31276,5.52621a.18186.18186,0,0,1-.16821-.01866L3.41657,12.15394a.94275.94275,0,0,1-.29887-.80285c.03754-.33621.22421-.52265.41108-.41066L5.9185,12.24727a.88656.88656,0,0,1,.28.80285A.5057.5057,0,0,1,5.97449,13.47944Zm0-3.37919a.18184.18184,0,0,1-.16821-.01867L3.41657,8.77475a.943.943,0,0,1-.29887-.80286c.03754-.3362.22421-.52286.41108-.42953L5.9185,8.86786a.83112.83112,0,0,1,.28.78419A.51684.51684,0,0,1,5.97449,10.10025Z\" />\n </svg>\n </Icon>\n );\n}\n\nasync function collectFocusedItems(loadFocusedItems: () => AsyncIterableIterator<InstanceKey | GroupingHierarchyNode>) {\n const focusedItems: Array<InstanceKey | ElementsGroupInfo> = [];\n const groupingNodeInfos: Array<{\n parentKey: InstancesNodeKey;\n parentType: \"element\" | \"category\";\n groupingNode: ClassGroupingHierarchyNode;\n modelIds: Id64String[];\n }> = [];\n for await (const key of loadFocusedItems()) {\n if (\"id\" in key) {\n focusedItems.push(key);\n continue;\n }\n\n if (!HierarchyNodeKey.isClassGrouping(key.key)) {\n continue;\n }\n\n const groupingNode = key as ClassGroupingHierarchyNode;\n if (!groupingNode.nonGroupingAncestor || !HierarchyNodeKey.isInstances(groupingNode.nonGroupingAncestor.key)) {\n continue;\n }\n\n const parentKey = groupingNode.nonGroupingAncestor.key;\n const type = groupingNode.nonGroupingAncestor.extendedData?.isCategory ? \"category\" : \"element\";\n const modelIds = ((groupingNode.nonGroupingAncestor.extendedData?.modelIds as Id64String[][]) ?? []).flatMap((ids) => ids);\n groupingNodeInfos.push({ groupingNode, parentType: type, parentKey, modelIds });\n }\n focusedItems.push(\n ...groupingNodeInfos.map(({ parentKey, parentType, groupingNode, modelIds }) => ({\n parent:\n parentType === \"element\"\n ? { type: \"element\" as const, ids: parentKey.instanceKeys.map((key) => key.id) }\n : { type: \"category\" as const, ids: parentKey.instanceKeys.map((key) => key.id), modelIds },\n groupingNode,\n })),\n );\n return focusedItems;\n}\n\nfunction createLocalizedMessage(message: string, onClick?: () => void) {\n const exp = new RegExp(\"<link>(.*)</link>\");\n const match = message.match(exp);\n if (!match) {\n return message;\n }\n\n const [fullText, innerText] = match;\n const [textBefore, textAfter] = message.split(fullText);\n\n return (\n <>\n {textBefore ? textBefore : null}\n <Anchor\n underline\n onClick={(e) => {\n e.stopPropagation();\n onClick?.();\n }}\n >\n {innerText}\n </Anchor>\n {textAfter ? textAfter : null}\n </>\n );\n}\n"]}
@@ -305,8 +305,8 @@ class ModelsTreeVisibilityHandlerImpl {
305
305
  }
306
306
  const imodelAccess = this._props.imodelAccess;
307
307
  // Remove all paths such that there are paths to any of the ancestors of the filter target.
308
- filterPaths = reduceFilterPaths(filterPaths);
309
- await Promise.all(filterPaths.map(async (path) => {
308
+ const paths = reduceFilterPaths(filterPaths);
309
+ await Promise.all(paths.map(async (path) => {
310
310
  const target = path[path.length - 1];
311
311
  if (!presentation_hierarchies_1.HierarchyNodeIdentifier.isInstanceNodeIdentifier(target)) {
312
312
  return;
@@ -662,7 +662,8 @@ function setIntersection(lhs, rhs) {
662
662
  lhs.forEach((x) => rhs.has(x) && result.add(x));
663
663
  return result;
664
664
  }
665
- function reduceFilterPaths(paths) {
665
+ function reduceFilterPaths(filteringPaths) {
666
+ let paths = filteringPaths.map((filteringPath) => ("path" in filteringPath ? filteringPath.path : filteringPath));
666
667
  const sorted = [...paths].sort((a, b) => a.length - b.length);
667
668
  paths = [];
668
669
  for (const path of sorted) {