@itwin/tree-widget-react 4.0.0-alpha.13 → 4.0.0-alpha.15

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 (121) hide show
  1. package/CHANGELOG.md +62 -1
  2. package/README.md +50 -2
  3. package/lib/esm/tree-widget-react/components/TreeWidgetUiItemsProvider.js.map +1 -1
  4. package/lib/esm/tree-widget-react/components/tree-header/WidgetHeader.css +1 -1
  5. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTree.d.ts +2 -2
  6. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTree.js +2 -2
  7. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTree.js.map +1 -1
  8. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeComponent.d.ts +1 -1
  9. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeComponent.js.map +1 -1
  10. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.d.ts +1 -0
  11. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js +25 -19
  12. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js.map +1 -1
  13. package/lib/esm/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js +3 -5
  14. package/lib/esm/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js.map +1 -1
  15. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.d.ts +7 -7
  16. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js +21 -17
  17. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js.map +1 -1
  18. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeVisibilityHandler.d.ts +0 -2
  19. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeVisibilityHandler.js +352 -311
  20. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeVisibilityHandler.js.map +1 -1
  21. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/UseFilteredPaths.js +4 -3
  22. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/UseFilteredPaths.js.map +1 -1
  23. package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTree.d.ts +2 -2
  24. package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTree.js +4 -3
  25. package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTree.js.map +1 -1
  26. package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeComponent.d.ts +1 -1
  27. package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeComponent.js +2 -2
  28. package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeComponent.js.map +1 -1
  29. package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeDefinition.d.ts +10 -1
  30. package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeDefinition.js +268 -0
  31. package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeDefinition.js.map +1 -1
  32. package/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTree.d.ts +3 -2
  33. package/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTree.js +46 -8
  34. package/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTree.js.map +1 -1
  35. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeIdsCache.d.ts +20 -7
  36. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeIdsCache.js +96 -20
  37. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeIdsCache.js.map +1 -1
  38. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeNode.d.ts +2 -2
  39. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeNode.js.map +1 -1
  40. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeVisibilityHandler.d.ts +3 -1
  41. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeVisibilityHandler.js +410 -253
  42. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeVisibilityHandler.js.map +1 -1
  43. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/FilteredTree.d.ts +37 -0
  44. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/FilteredTree.js +193 -0
  45. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/FilteredTree.js.map +1 -0
  46. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/UseFilteredPaths.d.ts +18 -0
  47. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/UseFilteredPaths.js +51 -0
  48. package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/UseFilteredPaths.js.map +1 -0
  49. package/lib/esm/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.d.ts +4 -0
  50. package/lib/esm/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.js +20 -17
  51. package/lib/esm/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.js.map +1 -1
  52. package/lib/esm/tree-widget-react/components/trees/common/UseHierarchyVisibility.d.ts +2 -2
  53. package/lib/esm/tree-widget-react/components/trees/common/UseHierarchyVisibility.js +1 -1
  54. package/lib/esm/tree-widget-react/components/trees/common/UseHierarchyVisibility.js.map +1 -1
  55. package/lib/esm/tree-widget-react/components/trees/common/Utils.d.ts +4 -0
  56. package/lib/esm/tree-widget-react/components/trees/common/Utils.js +49 -0
  57. package/lib/esm/tree-widget-react/components/trees/common/Utils.js.map +1 -1
  58. package/lib/esm/tree-widget-react/components/trees/common/components/BaseTreeRenderer.d.ts +1 -1
  59. package/lib/esm/tree-widget-react/components/trees/common/components/BaseTreeRenderer.js +2 -2
  60. package/lib/esm/tree-widget-react/components/trees/common/components/BaseTreeRenderer.js.map +1 -1
  61. package/lib/esm/tree-widget-react/components/trees/common/components/EmptyTree.d.ts +6 -0
  62. package/lib/esm/tree-widget-react/components/trees/common/components/EmptyTree.js +4 -0
  63. package/lib/esm/tree-widget-react/components/trees/common/components/EmptyTree.js.map +1 -1
  64. package/lib/esm/tree-widget-react/components/trees/common/components/TreeNodeVisibilityButton.d.ts +23 -3
  65. package/lib/esm/tree-widget-react/components/trees/common/components/TreeNodeVisibilityButton.js +26 -5
  66. package/lib/esm/tree-widget-react/components/trees/common/components/TreeNodeVisibilityButton.js.map +1 -1
  67. package/lib/esm/tree-widget-react/components/trees/common/components/TreeRenderer.d.ts +1 -1
  68. package/lib/esm/tree-widget-react/components/trees/common/components/TreeRenderer.js +7 -8
  69. package/lib/esm/tree-widget-react/components/trees/common/components/TreeRenderer.js.map +1 -1
  70. package/lib/esm/tree-widget-react/components/trees/common/components/UseVisibilityButtonHandler.d.ts +3 -3
  71. package/lib/esm/tree-widget-react/components/trees/common/components/UseVisibilityButtonHandler.js.map +1 -1
  72. package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTree.d.ts +2 -2
  73. package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTree.js.map +1 -1
  74. package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTreeRenderer.d.ts +3 -3
  75. package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTreeRenderer.js +10 -9
  76. package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTreeRenderer.js.map +1 -1
  77. package/lib/esm/tree-widget-react/components/trees/common/internal/ModelCategoryElementsCountCache.js +49 -34
  78. package/lib/esm/tree-widget-react/components/trees/common/internal/ModelCategoryElementsCountCache.js.map +1 -1
  79. package/lib/esm/tree-widget-react/components/trees/common/internal/UseIModelAccess.js.map +1 -1
  80. package/lib/esm/tree-widget-react/components/trees/common/internal/Utils.d.ts +7 -17
  81. package/lib/esm/tree-widget-react/components/trees/common/internal/Utils.js +26 -16
  82. package/lib/esm/tree-widget-react/components/trees/common/internal/Utils.js.map +1 -1
  83. package/lib/esm/tree-widget-react/components/trees/common/internal/VisibilityUtils.d.ts +5 -5
  84. package/lib/esm/tree-widget-react/components/trees/common/internal/VisibilityUtils.js +3 -2
  85. package/lib/esm/tree-widget-react/components/trees/common/internal/VisibilityUtils.js.map +1 -1
  86. package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.d.ts +2 -2
  87. package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.js +2 -2
  88. package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
  89. package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeComponent.d.ts +1 -1
  90. package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js.map +1 -1
  91. package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.d.ts +2 -2
  92. package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.js +2 -2
  93. package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
  94. package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeComponent.d.ts +1 -1
  95. package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeComponent.js +1 -1
  96. package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeComponent.js.map +1 -1
  97. package/lib/esm/tree-widget-react/components/trees/index.d.ts +2 -0
  98. package/lib/esm/tree-widget-react/components/trees/index.js +3 -0
  99. package/lib/esm/tree-widget-react/components/trees/index.js.map +1 -1
  100. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTree.d.ts +2 -2
  101. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTree.js +3 -2
  102. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTree.js.map +1 -1
  103. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.d.ts +1 -1
  104. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
  105. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.d.ts +12 -10
  106. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js +33 -29
  107. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js.map +1 -1
  108. package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.d.ts +19 -1
  109. package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.js +12 -5
  110. package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.js.map +1 -1
  111. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.d.ts +6 -4
  112. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js +24 -11
  113. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js.map +1 -1
  114. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.d.ts +35 -44
  115. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js +373 -186
  116. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js.map +1 -1
  117. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/UseFilteredPaths.d.ts +11 -2
  118. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/UseFilteredPaths.js +88 -34
  119. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/UseFilteredPaths.js.map +1 -1
  120. package/lib/public/locales/en/TreeWidget.json +11 -1
  121. package/package.json +12 -12
@@ -1 +1 @@
1
- {"version":3,"file":"ClassificationsTreeComponent.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeComponent.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,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,CAAC,CAAC;AAEF,SAAS,gCAAgC,CAAC,EACxC,MAAM,EACN,QAAQ,EACR,qBAAqB,EACrB,aAAa,EACb,GAAG,SAAS,EAC+E;IAC3F,OAAO,CACL,KAAC,wBAAwB,IAAC,mBAAmB,EAAE,4BAA4B,CAAC,EAAE,EAAE,aAAa,EAAE,aAAa,EAAE,qBAAqB,EAAE,qBAAqB,YACxJ,KAAC,cAAc,cACb,KAAC,mBAAmB,OAAK,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,GAAI,GAC7D,GACQ,CAC5B,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 { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport { SchemaKey, SchemaMatchType } from \"@itwin/ecschema-metadata\";\nimport { TreeWidget } from \"../../../TreeWidget.js\";\nimport { SelectableTree } from \"../../tree-header/SelectableTree.js\";\nimport { useActiveViewport } from \"../common/internal/UseActiveViewport.js\";\nimport { TelemetryContextProvider } from \"../common/UseTelemetryContext.js\";\nimport { ClassificationsTree } from \"./ClassificationsTree.js\";\n\nimport type { ClassificationsTreeProps } from \"./ClassificationsTree.js\";\nimport type { IModelConnection, ScreenViewport } from \"@itwin/core-frontend\";\n\n/** @alpha */\ninterface ClassificationsTreeComponentProps\n extends Pick<\n ClassificationsTreeProps,\n \"selectionStorage\" | \"hierarchyLevelConfig\" | \"selectionMode\" | \"emptyTreeContent\" | \"getActions\" | \"getDecorations\" | \"hierarchyConfig\"\n > {\n onPerformanceMeasured?: (featureId: string, duration: number) => void;\n onFeatureUsed?: (feature: string) => void;\n}\n\n/**\n * A component that renders `ClassificationsTree` with active iModel and viewport.\n * @alpha\n */\nexport const ClassificationsTreeComponent = (props: ClassificationsTreeComponentProps) => {\n const iModel = useActiveIModelConnection();\n const viewport = useActiveViewport();\n\n if (!iModel || !viewport) {\n return null;\n }\n\n return <ClassificationsTreeComponentImpl {...props} iModel={iModel} viewport={viewport} />;\n};\n\n/**\n * Id of the component. May be used when a creating a `TreeDefinition`.\n * @alpha\n */\nClassificationsTreeComponent.id = \"classifications-tree\";\n\n/**\n * Label of the component. May be used when a creating a `TreeDefinition`.\n * @alpha\n */\nClassificationsTreeComponent.getLabel = () => TreeWidget.translate(\"classificationsTree.label\");\n\n/** @alpha */\nClassificationsTreeComponent.isSupportedByIModel = async (imodel: IModelConnection) => {\n try {\n return !!(await imodel.schemaContext.getSchemaInfo(new SchemaKey(\"ClassificationSystems\"), SchemaMatchType.Latest));\n } catch {\n return false;\n }\n};\n\nfunction ClassificationsTreeComponentImpl({\n iModel,\n viewport,\n onPerformanceMeasured,\n onFeatureUsed,\n ...treeProps\n}: ClassificationsTreeComponentProps & { iModel: IModelConnection; viewport: ScreenViewport }) {\n return (\n <TelemetryContextProvider componentIdentifier={ClassificationsTreeComponent.id} onFeatureUsed={onFeatureUsed} onPerformanceMeasured={onPerformanceMeasured}>\n <SelectableTree>\n <ClassificationsTree {...treeProps} imodel={iModel} activeView={viewport} />\n </SelectableTree>\n </TelemetryContextProvider>\n );\n}\n"]}
1
+ {"version":3,"file":"ClassificationsTreeComponent.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeComponent.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAC5E,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;A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MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAI,GAC7E,GACQ,CAC5B,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 { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport { SchemaKey, SchemaMatchType } from \"@itwin/ecschema-metadata\";\nimport { TreeWidget } from \"../../../TreeWidget.js\";\nimport { SelectableTree } from \"../../tree-header/SelectableTree.js\";\nimport { useActiveViewport } from \"../common/internal/UseActiveViewport.js\";\nimport { TelemetryContextProvider } from \"../common/UseTelemetryContext.js\";\nimport { ClassificationsTree } from \"./ClassificationsTree.js\";\n\nimport type { ClassificationsTreeProps } from \"./ClassificationsTree.js\";\nimport type { IModelConnection, ScreenViewport } from \"@itwin/core-frontend\";\n\n/** @alpha */\ninterface ClassificationsTreeComponentProps\n extends Pick<\n ClassificationsTreeProps,\n | \"selectionStorage\"\n | \"hierarchyLevelConfig\"\n | \"selectionMode\"\n | \"filter\"\n | \"emptyTreeContent\"\n | \"getInlineActions\"\n | \"getMenuActions\"\n | \"getDecorations\"\n | \"hierarchyConfig\"\n | \"getEditingProps\"\n > {\n onPerformanceMeasured?: (featureId: string, duration: number) => void;\n onFeatureUsed?: (feature: string) => void;\n}\n\n/**\n * A component that renders `ClassificationsTree` with active iModel and viewport.\n * @alpha\n */\nexport const ClassificationsTreeComponent = (props: ClassificationsTreeComponentProps) => {\n const iModel = useActiveIModelConnection();\n const viewport = useActiveViewport();\n\n if (!iModel || !viewport) {\n return null;\n }\n\n return <ClassificationsTreeComponentImpl {...props} iModel={iModel} viewport={viewport} />;\n};\n\n/**\n * Id of the component. May be used when a creating a `TreeDefinition`.\n * @alpha\n */\nClassificationsTreeComponent.id = \"classifications-tree\";\n\n/**\n * Label of the component. May be used when a creating a `TreeDefinition`.\n * @alpha\n */\nClassificationsTreeComponent.getLabel = () => TreeWidget.translate(\"classificationsTree.label\");\n\n/** @alpha */\nClassificationsTreeComponent.isSupportedByIModel = async (imodel: IModelConnection) => {\n try {\n return !!(await imodel.schemaContext.getSchemaInfo(new SchemaKey(\"ClassificationSystems\"), SchemaMatchType.Latest));\n } catch {\n return false;\n }\n};\n\nfunction ClassificationsTreeComponentImpl({\n iModel,\n viewport,\n onPerformanceMeasured,\n onFeatureUsed,\n filter,\n ...treeProps\n}: ClassificationsTreeComponentProps & { iModel: IModelConnection; viewport: ScreenViewport }) {\n return (\n <TelemetryContextProvider componentIdentifier={ClassificationsTreeComponent.id} onFeatureUsed={onFeatureUsed} onPerformanceMeasured={onPerformanceMeasured}>\n <SelectableTree>\n <ClassificationsTree {...treeProps} imodel={iModel} activeView={viewport} filter={filter} />\n </SelectableTree>\n </TelemetryContextProvider>\n );\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { DefineHierarchyLevelProps, HierarchyDefinition, HierarchyLevelDefinition, LimitingECSqlQueryExecutor } from "@itwin/presentation-hierarchies";
1
+ import type { DefineHierarchyLevelProps, HierarchyDefinition, HierarchyFilteringPath, HierarchyLevelDefinition, LimitingECSqlQueryExecutor } from "@itwin/presentation-hierarchies";
2
2
  import type { ECClassHierarchyInspector, ECSchemaProvider } from "@itwin/presentation-shared";
3
3
  import type { ClassificationsTreeIdsCache } from "./internal/ClassificationsTreeIdsCache.js";
4
4
  interface ClassificationsTreeDefinitionProps {
@@ -14,6 +14,14 @@ export interface ClassificationsTreeHierarchyConfiguration {
14
14
  */
15
15
  rootClassificationSystemCode: string;
16
16
  }
17
+ /** @alpha */
18
+ export interface ClassificationsTreeInstanceKeyPathsFromInstanceLabelProps {
19
+ imodelAccess: ECClassHierarchyInspector & LimitingECSqlQueryExecutor;
20
+ label: string;
21
+ limit?: number | "unbounded";
22
+ idsCache: ClassificationsTreeIdsCache;
23
+ hierarchyConfig: ClassificationsTreeHierarchyConfiguration;
24
+ }
17
25
  /** @internal */
18
26
  export declare class ClassificationsTreeDefinition implements HierarchyDefinition {
19
27
  #private;
@@ -23,6 +31,7 @@ export declare class ClassificationsTreeDefinition implements HierarchyDefinitio
23
31
  private _nodeLabelSelectClauseFactory;
24
32
  constructor(_props: ClassificationsTreeDefinitionProps);
25
33
  defineHierarchyLevel(props: DefineHierarchyLevelProps): Promise<HierarchyLevelDefinition>;
34
+ static createInstanceKeyPaths(props: ClassificationsTreeInstanceKeyPathsFromInstanceLabelProps): Promise<HierarchyFilteringPath[]>;
26
35
  }
27
36
  export {};
28
37
  //# sourceMappingURL=ClassificationsTreeDefinition.d.ts.map
@@ -2,9 +2,13 @@
2
2
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
+ import { bufferCount, defer, EMPTY, from, identity, lastValueFrom, map, merge, mergeMap, of, reduce, toArray } from "rxjs";
5
6
  import { createNodesQueryClauseFactory, createPredicateBasedHierarchyDefinition } from "@itwin/presentation-hierarchies";
6
7
  import { createBisInstanceLabelSelectClauseFactory, ECSql, parseFullClassName } from "@itwin/presentation-shared";
7
8
  import { CLASS_NAME_Classification, CLASS_NAME_ClassificationSystem, CLASS_NAME_ClassificationTable, CLASS_NAME_Element, CLASS_NAME_ElementHasClassifications, CLASS_NAME_GeometricElement, CLASS_NAME_GeometricElement2d, CLASS_NAME_GeometricElement3d, } from "../common/internal/ClassNameDefinitions.js";
9
+ import { releaseMainThreadOnItemsCount } from "../common/internal/Utils.js";
10
+ import { FilterLimitExceededError } from "../common/TreeErrors.js";
11
+ const MAX_FILTERING_INSTANCE_KEY_COUNT = 100;
8
12
  /** @internal */
9
13
  export class ClassificationsTreeDefinition {
10
14
  _props;
@@ -254,6 +258,10 @@ export class ClassificationsTreeDefinition {
254
258
  supportsFiltering: true,
255
259
  });
256
260
  }
261
+ static async createInstanceKeyPaths(props) {
262
+ const labelsFactory = createBisInstanceLabelSelectClauseFactory({ classHierarchyInspector: props.imodelAccess });
263
+ return createInstanceKeyPathsFromInstanceLabel({ ...props, labelsFactory });
264
+ }
257
265
  }
258
266
  function createClassificationHasChildrenSelector(classificationAlias) {
259
267
  return `
@@ -272,4 +280,264 @@ function createClassificationHasChildrenSelector(classificationAlias) {
272
280
  )
273
281
  `;
274
282
  }
283
+ async function createInstanceKeyPathsFromInstanceLabel(props) {
284
+ const adjustedLabel = props.label.replace(/[%_\\]/g, "\\$&");
285
+ const CLASSIFICATION_TABLES_WITH_LABELS_CTE = "ClassificationTablesWithLabels";
286
+ const CLASSIFICATIONS_WITH_LABELS_CTE = "ClassificationsWithLabels";
287
+ const ELEMENTS_2D_WITH_LABELS_CTE = "Elements2dWithLabels";
288
+ const ELEMENTS_3D_WITH_LABELS_CTE = "Elements3dWithLabels";
289
+ return lastValueFrom(defer(async () => {
290
+ const [classificationTableLabelSelectClause, classificationLabelSelectClause, element2dLabelSelectClause, element3dLabelSelectClause] = await Promise.all([CLASS_NAME_ClassificationTable, CLASS_NAME_Classification, CLASS_NAME_GeometricElement2d, CLASS_NAME_GeometricElement3d].map(async (className) => props.labelsFactory.createSelectClause({ classAlias: "this", className })));
291
+ const classificationIds = await props.idsCache.getAllClassifications();
292
+ const ctes = [
293
+ `
294
+ ${CLASSIFICATION_TABLES_WITH_LABELS_CTE}(ClassName, ECInstanceId, DisplayLabel) AS (
295
+ SELECT
296
+ 'ct',
297
+ this.ECInstanceId,
298
+ ${classificationTableLabelSelectClause}
299
+ FROM
300
+ ${CLASS_NAME_ClassificationTable} this
301
+ JOIN ${CLASS_NAME_ClassificationSystem} system ON system.ECInstanceId = this.Parent.Id
302
+ WHERE
303
+ system.CodeValue = '${props.hierarchyConfig.rootClassificationSystemCode}'
304
+ AND NOT this.IsPrivate
305
+ )
306
+ `,
307
+ ...(classificationIds.length > 0
308
+ ? [
309
+ `${CLASSIFICATIONS_WITH_LABELS_CTE}(ClassName, ECInstanceId, DisplayLabel) AS (
310
+ SELECT
311
+ 'c',
312
+ this.ECInstanceId,
313
+ ${classificationLabelSelectClause}
314
+ FROM
315
+ ${CLASS_NAME_Classification} this
316
+ WHERE
317
+ this.ECInstanceId IN (${classificationIds.join(",")})
318
+ )`,
319
+ `${ELEMENTS_2D_WITH_LABELS_CTE}(ClassName, ECInstanceId, DisplayLabel) AS (
320
+ SELECT
321
+ 'e2d',
322
+ this.ECInstanceId,
323
+ ${element2dLabelSelectClause}
324
+ FROM
325
+ ${CLASS_NAME_GeometricElement2d} this
326
+ JOIN ${CLASS_NAME_ElementHasClassifications} ehc ON ehc.SourceECInstanceId = this.ECInstanceId
327
+ WHERE
328
+ ehc.TargetECInstanceId IN (${classificationIds.join(",")})
329
+ AND this.Parent.Id IS NULL
330
+
331
+ UNION ALL
332
+
333
+ SELECT
334
+ 'e2d',
335
+ this.ECInstanceId,
336
+ ${element2dLabelSelectClause}
337
+ FROM
338
+ ${CLASS_NAME_GeometricElement2d} this
339
+ JOIN ${ELEMENTS_2D_WITH_LABELS_CTE} pe ON pe.ECInstanceId = this.Parent.Id
340
+ )`,
341
+ `${ELEMENTS_3D_WITH_LABELS_CTE}(ClassName, ECInstanceId, DisplayLabel) AS (
342
+ SELECT
343
+ 'e3d',
344
+ this.ECInstanceId,
345
+ ${element3dLabelSelectClause}
346
+ FROM
347
+ ${CLASS_NAME_GeometricElement3d} this
348
+ JOIN ${CLASS_NAME_ElementHasClassifications} ehc ON ehc.SourceECInstanceId = this.ECInstanceId
349
+ WHERE
350
+ ehc.TargetECInstanceId IN (${classificationIds.join(",")})
351
+ AND this.Parent.Id IS NULL
352
+
353
+ UNION ALL
354
+
355
+ SELECT
356
+ 'e3d',
357
+ this.ECInstanceId,
358
+ ${element3dLabelSelectClause}
359
+ FROM
360
+ ${CLASS_NAME_GeometricElement3d} this
361
+ JOIN ${ELEMENTS_3D_WITH_LABELS_CTE} pe ON pe.ECInstanceId = this.Parent.Id
362
+ )`,
363
+ ]
364
+ : []),
365
+ ];
366
+ const ecsql = `
367
+ SELECT * FROM (
368
+ SELECT
369
+ ct.ClassName AS ClassName,
370
+ ct.ECInstanceId AS ECInstanceId
371
+ FROM
372
+ ${CLASSIFICATION_TABLES_WITH_LABELS_CTE} ct
373
+ WHERE
374
+ ct.DisplayLabel LIKE '%' || ? || '%' ESCAPE '\\'
375
+
376
+ ${classificationIds.length > 0
377
+ ? `
378
+ UNION ALL
379
+
380
+ SELECT
381
+ c.ClassName AS ClassName,
382
+ c.ECInstanceId AS ECInstanceId
383
+ FROM
384
+ ${CLASSIFICATIONS_WITH_LABELS_CTE} c
385
+ WHERE
386
+ c.DisplayLabel LIKE '%' || ? || '%' ESCAPE '\\'
387
+
388
+ UNION ALL
389
+
390
+ SELECT
391
+ e2d.ClassName AS ClassName,
392
+ e2d.ECInstanceId AS ECInstanceId
393
+ FROM
394
+ ${ELEMENTS_2D_WITH_LABELS_CTE} e2d
395
+ WHERE
396
+ e2d.DisplayLabel LIKE '%' || ? || '%' ESCAPE '\\'
397
+
398
+ UNION ALL
399
+
400
+ SELECT
401
+ e3d.ClassName AS ClassName,
402
+ e3d.ECInstanceId AS ECInstanceId
403
+ FROM
404
+ ${ELEMENTS_3D_WITH_LABELS_CTE} e3d
405
+ WHERE
406
+ e3d.DisplayLabel LIKE '%' || ? || '%' ESCAPE '\\'
407
+ `
408
+ : ""}
409
+ )
410
+ ${props.limit === undefined ? `LIMIT ${MAX_FILTERING_INSTANCE_KEY_COUNT + 1}` : props.limit !== "unbounded" ? `LIMIT ${props.limit}` : ""}
411
+ `;
412
+ const bindings = [
413
+ { type: "string", value: adjustedLabel },
414
+ ...(classificationIds.length > 0
415
+ ? [
416
+ { type: "string", value: adjustedLabel },
417
+ { type: "string", value: adjustedLabel },
418
+ { type: "string", value: adjustedLabel },
419
+ ]
420
+ : []),
421
+ ];
422
+ return { ctes, ecsql, bindings };
423
+ }).pipe(mergeMap((queryProps) => props.imodelAccess.createQueryReader(queryProps, { restartToken: "tree-widget/classifications-tree/filter-by-label-query", limit: props.limit })), map((row) => {
424
+ let className;
425
+ switch (row.ClassName) {
426
+ case "ct":
427
+ className = CLASS_NAME_ClassificationTable;
428
+ break;
429
+ case "c":
430
+ className = CLASS_NAME_Classification;
431
+ break;
432
+ case "e2d":
433
+ className = CLASS_NAME_GeometricElement2d;
434
+ break;
435
+ default:
436
+ className = CLASS_NAME_GeometricElement3d;
437
+ break;
438
+ }
439
+ return {
440
+ className,
441
+ id: row.ECInstanceId,
442
+ };
443
+ }), createInstanceKeyPathsFromTargetItems(props), toArray()));
444
+ }
445
+ function createInstanceKeyPathsFromTargetItems({ idsCache, imodelAccess, limit, }) {
446
+ const actualLimit = limit ?? MAX_FILTERING_INSTANCE_KEY_COUNT;
447
+ return (targetItems) => {
448
+ return targetItems.pipe(actualLimit !== "unbounded"
449
+ ? map((targetItem, index) => {
450
+ if (index >= actualLimit) {
451
+ throw new FilterLimitExceededError(actualLimit);
452
+ }
453
+ return targetItem;
454
+ })
455
+ : identity, releaseMainThreadOnItemsCount(2000), reduce((acc, { id, className }) => {
456
+ if (className === CLASS_NAME_ClassificationTable) {
457
+ acc.classificationTableIds.push(id);
458
+ return acc;
459
+ }
460
+ if (className === CLASS_NAME_Classification) {
461
+ acc.classificationIds.push(id);
462
+ return acc;
463
+ }
464
+ if (className === CLASS_NAME_GeometricElement2d) {
465
+ acc.element2dIds.push(id);
466
+ return acc;
467
+ }
468
+ acc.element3dIds.push(id);
469
+ return acc;
470
+ }, {
471
+ classificationTableIds: new Array(),
472
+ classificationIds: new Array(),
473
+ element2dIds: new Array(),
474
+ element3dIds: new Array(),
475
+ }), mergeMap((ids) => {
476
+ const elements2dLength = ids.element2dIds.length;
477
+ const elements3dLength = ids.element3dIds.length;
478
+ return merge(from(ids.classificationTableIds).pipe(map((id) => ({ path: [{ id, className: CLASS_NAME_ClassificationTable }], options: { autoExpand: true } }))), idsCache.getClassificationsPathObs(ids.classificationIds).pipe(map((path) => ({ path, options: { autoExpand: true } }))), from(ids.element2dIds).pipe(bufferCount(Math.ceil(elements2dLength / Math.ceil(elements2dLength / 5000))), releaseMainThreadOnItemsCount(1), mergeMap((block) => createGeometricElementInstanceKeyPaths({ idsCache, imodelAccess, targetItems: block, type: "2d" }), 10)), from(ids.element3dIds).pipe(bufferCount(Math.ceil(elements3dLength / Math.ceil(elements3dLength / 5000))), releaseMainThreadOnItemsCount(1), mergeMap((block) => createGeometricElementInstanceKeyPaths({ idsCache, imodelAccess, targetItems: block, type: "3d" }), 10)));
479
+ }));
480
+ };
481
+ }
482
+ function createGeometricElementInstanceKeyPaths(props) {
483
+ const { targetItems, imodelAccess, type, idsCache } = props;
484
+ if (targetItems.length === 0) {
485
+ return EMPTY;
486
+ }
487
+ const separator = ";";
488
+ return defer(() => {
489
+ const ctes = [
490
+ `ElementsHierarchy(ECInstanceId, ParentId, Path) AS (
491
+ SELECT
492
+ e.ECInstanceId,
493
+ e.Parent.Id,
494
+ 'e${type}${separator}' || CAST(IdToHex([e].[ECInstanceId]) AS TEXT)
495
+ FROM ${CLASS_NAME_Element} e
496
+ WHERE e.ECInstanceId IN (${targetItems.join(",")})
497
+
498
+ UNION ALL
499
+
500
+ SELECT
501
+ pe.ECInstanceId,
502
+ pe.Parent.Id,
503
+ 'e${type}${separator}' || CAST(IdToHex([pe].[ECInstanceId]) AS TEXT) || '${separator}' || ce.Path
504
+ FROM ElementsHierarchy ce
505
+ JOIN ${CLASS_NAME_Element} pe ON pe.ECInstanceId = ce.ParentId
506
+ )`,
507
+ ];
508
+ const ecsql = `
509
+ SELECT
510
+ e.Path path,
511
+ c.ECInstanceId classificationId
512
+ FROM
513
+ ${CLASS_NAME_Classification} c
514
+ JOIN ${CLASS_NAME_ElementHasClassifications} ehc ON ehc.TargetECInstanceId = c.ECInstanceId
515
+ JOIN ElementsHierarchy e ON ehc.SourceECInstanceId = e.ECInstanceId
516
+ WHERE e.ParentId IS NULL
517
+ `;
518
+ return imodelAccess.createQueryReader({ ctes, ecsql }, { rowFormat: "ECSqlPropertyNames", limit: "unbounded", restartToken: `tree-widget/classifications-tree/elements${type}-filter-paths-query` });
519
+ }).pipe(releaseMainThreadOnItemsCount(300), map((row) => parseQueryRow(row, separator)), mergeMap(({ path, parentClassificationId }) => {
520
+ if (parentClassificationId) {
521
+ return idsCache
522
+ .getClassificationsPathObs(parentClassificationId)
523
+ .pipe(map((parentClassificationPath) => ({ path: parentClassificationPath.concat(path), options: { autoExpand: true } })));
524
+ }
525
+ return of({ path, options: { autoExpand: true } });
526
+ }));
527
+ }
528
+ function parseQueryRow(row, separator) {
529
+ const rowElements = row.path.split(separator);
530
+ const path = [];
531
+ for (let i = 0; i < rowElements.length; i += 2) {
532
+ switch (rowElements[i]) {
533
+ case "e2d":
534
+ path.push({ className: CLASS_NAME_GeometricElement2d, id: rowElements[i + 1] });
535
+ break;
536
+ case "e3d":
537
+ path.push({ className: CLASS_NAME_GeometricElement3d, id: rowElements[i + 1] });
538
+ break;
539
+ }
540
+ }
541
+ return { path, parentClassificationId: row.classificationId };
542
+ }
275
543
  //# sourceMappingURL=ClassificationsTreeDefinition.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ClassificationsTreeDefinition.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeDefinition.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,6BAA6B,EAAE,uCAAuC,EAAE,MAAM,iCAAiC,CAAC;AACzH,OAAO,EAAE,yCAAyC,EAAE,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAClH,OAAO,EACL,yBAAyB,EACzB,+BAA+B,EAC/B,8BAA8B,EAC9B,kBAAkB,EAClB,oCAAoC,EACpC,2BAA2B,EAC3B,6BAA6B,EAC7B,6BAA6B,GAC9B,MAAM,4CAA4C,CAAC;AA8BpD,gBAAgB;AAChB,MAAM,OAAO,6BAA6B;IAKb;IAJnB,KAAK,CAAsB;IAC3B,mBAAmB,CAA0B;IAC7C,6B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2B;IAC1E,OAAO;;;eAGM,yBAAyB;2CACG,mBAAmB;;;;eAI/C,oCAAoC;yCACV,mBAAmB;;;;;GAKzD,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 { createNodesQueryClauseFactory, createPredicateBasedHierarchyDefinition } from \"@itwin/presentation-hierarchies\";\nimport { createBisInstanceLabelSelectClauseFactory, ECSql, parseFullClassName } from \"@itwin/presentation-shared\";\nimport {\n CLASS_NAME_Classification,\n CLASS_NAME_ClassificationSystem,\n CLASS_NAME_ClassificationTable,\n CLASS_NAME_Element,\n CLASS_NAME_ElementHasClassifications,\n CLASS_NAME_GeometricElement,\n CLASS_NAME_GeometricElement2d,\n CLASS_NAME_GeometricElement3d,\n} from \"../common/internal/ClassNameDefinitions.js\";\n\nimport type {\n DefineHierarchyLevelProps,\n DefineInstanceNodeChildHierarchyLevelProps,\n DefineRootHierarchyLevelProps,\n GenericInstanceFilter,\n HierarchyDefinition,\n HierarchyLevelDefinition,\n LimitingECSqlQueryExecutor,\n NodesQueryClauseFactory,\n} from \"@itwin/presentation-hierarchies\";\nimport type { ECClassHierarchyInspector, ECSchemaProvider, IInstanceLabelSelectClauseFactory } from \"@itwin/presentation-shared\";\nimport type { ClassificationId, ClassificationsTreeIdsCache, ClassificationTableId } from \"./internal/ClassificationsTreeIdsCache.js\";\n\ninterface ClassificationsTreeDefinitionProps {\n imodelAccess: ECSchemaProvider & ECClassHierarchyInspector & LimitingECSqlQueryExecutor;\n idsCache: ClassificationsTreeIdsCache;\n hierarchyConfig: ClassificationsTreeHierarchyConfiguration;\n}\n\n/** @alpha */\nexport interface ClassificationsTreeHierarchyConfiguration {\n /**\n * The classifications' hierarchy starts at the root `ClassificationSystem` element. This attribute identifiers that\n * root `ClassificationSystem`.\n */\n rootClassificationSystemCode: string;\n}\n\n/** @internal */\nexport class ClassificationsTreeDefinition implements HierarchyDefinition {\n private _impl: HierarchyDefinition;\n private _selectQueryFactory: NodesQueryClauseFactory;\n private _nodeLabelSelectClauseFactory: IInstanceLabelSelectClauseFactory;\n\n public constructor(private _props: ClassificationsTreeDefinitionProps) {\n this._nodeLabelSelectClauseFactory = createBisInstanceLabelSelectClauseFactory({ classHierarchyInspector: this._props.imodelAccess });\n this._selectQueryFactory = createNodesQueryClauseFactory({\n imodelAccess: this._props.imodelAccess,\n instanceLabelSelectClauseFactory: this._nodeLabelSelectClauseFactory,\n });\n this._impl = createPredicateBasedHierarchyDefinition({\n classHierarchyInspector: this._props.imodelAccess,\n hierarchy: {\n rootNodes: async (requestProps: DefineRootHierarchyLevelProps) => this.#createClassificationTablesQuery(requestProps),\n childNodes: [\n {\n parentInstancesNodePredicate: CLASS_NAME_ClassificationTable,\n definitions: async (requestProps: DefineInstanceNodeChildHierarchyLevelProps) => this.#createClassificationTableChildrenQuery(requestProps),\n },\n {\n parentInstancesNodePredicate: CLASS_NAME_Classification,\n definitions: async (requestProps: DefineInstanceNodeChildHierarchyLevelProps) => this.#createClassificationChildrenQuery(requestProps),\n },\n {\n parentInstancesNodePredicate: CLASS_NAME_GeometricElement,\n definitions: async (requestProps: DefineInstanceNodeChildHierarchyLevelProps) => this.#createGeometricElementChildrenQuery(requestProps),\n },\n ],\n },\n });\n }\n\n public async defineHierarchyLevel(props: DefineHierarchyLevelProps) {\n return this._impl.defineHierarchyLevel(props);\n }\n\n async #createClassificationTablesQuery(props: { instanceFilter?: GenericInstanceFilter }): Promise<HierarchyLevelDefinition> {\n const { instanceFilter } = props;\n const instanceFilterClauses = await this._selectQueryFactory.createFilterClauses({\n filter: instanceFilter,\n contentClass: { fullName: CLASS_NAME_ClassificationTable, alias: \"this\" },\n });\n return [\n {\n fullClassName: CLASS_NAME_ClassificationTable,\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: CLASS_NAME_ClassificationTable,\n }),\n },\n hasChildren: {\n selector: `\n IFNULL((\n SELECT 1\n FROM ${CLASS_NAME_Classification} classification\n WHERE classification.Model.Id = this.ECInstanceId\n LIMIT 1\n ), 0)\n `,\n },\n extendedData: {\n type: \"ClassificationTable\",\n },\n supportsFiltering: true,\n })}\n FROM\n ${instanceFilterClauses.from} this\n JOIN ${CLASS_NAME_ClassificationSystem} system ON system.ECInstanceId = this.Parent.Id\n ${instanceFilterClauses.joins}\n WHERE\n system.CodeValue = '${this._props.hierarchyConfig.rootClassificationSystemCode}'\n AND NOT this.IsPrivate\n ${instanceFilterClauses.where ? `AND ${instanceFilterClauses.where}` : \"\"}\n `,\n },\n },\n ];\n }\n\n async #createClassificationTableChildrenQuery(props: {\n parentNodeInstanceIds: ClassificationTableId[];\n instanceFilter?: GenericInstanceFilter;\n }): Promise<HierarchyLevelDefinition> {\n const { parentNodeInstanceIds: classificationTableIds, instanceFilter } = props;\n const instanceFilterClauses = await this._selectQueryFactory.createFilterClauses({\n filter: instanceFilter,\n contentClass: { fullName: CLASS_NAME_Classification, alias: \"this\" },\n });\n const classificationIds = await this._props.idsCache.getDirectChildClassifications(classificationTableIds);\n return classificationIds.length\n ? [\n {\n fullClassName: CLASS_NAME_Classification,\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: CLASS_NAME_Classification,\n }),\n },\n hasChildren: {\n selector: createClassificationHasChildrenSelector(\"this\"),\n },\n extendedData: {\n type: \"Classification\",\n },\n supportsFiltering: true,\n })}\n FROM\n ${instanceFilterClauses.from} this\n ${instanceFilterClauses.joins}\n WHERE\n this.ECInstanceId IN (${classificationIds.join(\",\")})\n ${instanceFilterClauses.where ? `AND ${instanceFilterClauses.where}` : \"\"}\n `,\n },\n },\n ]\n : [];\n }\n\n async #createClassificationChildrenQuery(props: {\n parentNodeInstanceIds: ClassificationId[];\n instanceFilter?: GenericInstanceFilter;\n }): Promise<HierarchyLevelDefinition> {\n const { parentNodeInstanceIds: parentClassificationIds, instanceFilter } = props;\n const classificationIds = await this._props.idsCache.getDirectChildClassifications(parentClassificationIds);\n return [\n // load child classifications\n ...(classificationIds.length\n ? [\n await (async () => {\n const instanceFilterClauses = await this._selectQueryFactory.createFilterClauses({\n filter: instanceFilter,\n contentClass: { fullName: CLASS_NAME_Classification, alias: \"this\" },\n });\n return {\n fullClassName: CLASS_NAME_Classification,\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: CLASS_NAME_Classification,\n }),\n },\n hasChildren: {\n selector: createClassificationHasChildrenSelector(\"this\"),\n },\n extendedData: {\n type: \"Classification\",\n },\n supportsFiltering: true,\n })}\n FROM\n ${instanceFilterClauses.from} this\n ${instanceFilterClauses.joins}\n WHERE\n this.ECInstanceId IN (${classificationIds.join(\",\")})\n ${instanceFilterClauses.where ? `AND ${instanceFilterClauses.where}` : \"\"}\n `,\n },\n };\n })(),\n ]\n : []),\n // load classification elements\n ...(await Promise.all(\n [CLASS_NAME_GeometricElement2d, CLASS_NAME_GeometricElement3d].map(async (elementClassName) => {\n const instanceFilterClauses = await this._selectQueryFactory.createFilterClauses({\n filter: instanceFilter,\n contentClass: { fullName: elementClassName, alias: \"this\" },\n });\n return {\n fullClassName: elementClassName,\n query: {\n ecsql: `\n SELECT ${await this.#createElementSelectClause(elementClassName)}\n FROM ${instanceFilterClauses.from} this\n JOIN ${CLASS_NAME_ElementHasClassifications} ehc ON ehc.SourceECInstanceId = this.ECInstanceId\n ${instanceFilterClauses.joins}\n WHERE\n ehc.TargetECInstanceId IN (${parentClassificationIds.join(\",\")})\n AND this.Parent.Id IS NULL\n ${instanceFilterClauses.where ? `AND ${instanceFilterClauses.where}` : \"\"}\n `,\n },\n };\n }),\n )),\n ];\n }\n\n async #createGeometricElementChildrenQuery({\n parentNodeInstanceIds: parentElementIds,\n instanceFilter,\n }: DefineInstanceNodeChildHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n return Promise.all(\n [CLASS_NAME_GeometricElement2d, CLASS_NAME_GeometricElement3d].map(async (elementClassName) => {\n const instanceFilterClauses = await this._selectQueryFactory.createFilterClauses({\n filter: instanceFilter,\n contentClass: { fullName: elementClassName, alias: \"this\" },\n });\n return {\n fullClassName: elementClassName,\n query: {\n ecsql: `\n SELECT ${await this.#createElementSelectClause(elementClassName)}\n FROM ${instanceFilterClauses.from} this\n ${instanceFilterClauses.joins}\n WHERE\n this.Parent.Id IN (${parentElementIds.join(\",\")})\n ${instanceFilterClauses.where ? `AND ${instanceFilterClauses.where}` : \"\"}\n `,\n },\n };\n }),\n );\n }\n\n async #createElementSelectClause(elementFullClassName: string): Promise<string> {\n const { className: elementClassName } = parseFullClassName(elementFullClassName);\n return 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: elementFullClassName,\n }),\n },\n hasChildren: {\n selector: `\n IFNULL((\n SELECT 1\n FROM ${CLASS_NAME_Element} ce\n WHERE ce.Parent.Id = this.ECInstanceId\n LIMIT 1\n ), 0)\n `,\n },\n extendedData: {\n type: elementClassName,\n modelId: { selector: \"IdToHex(this.Model.Id)\" },\n categoryId: { selector: \"IdToHex(this.Category.Id)\" },\n },\n supportsFiltering: true,\n });\n }\n}\n\nfunction createClassificationHasChildrenSelector(classificationAlias: string) {\n return `\n COALESCE((\n SELECT 1\n FROM ${CLASS_NAME_Classification} classification\n WHERE classification.Parent.Id = ${classificationAlias}.ECInstanceId\n LIMIT 1\n ), (\n SELECT 1\n FROM ${CLASS_NAME_ElementHasClassifications} ehc\n WHERE ehc.TargetECInstanceId = ${classificationAlias}.ECInstanceId\n LIMIT 1\n ),\n 0\n )\n `;\n}\n"]}
1
+ {"version":3,"file":"ClassificationsTreeDefinition.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeDefinition.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC3H,OAAO,EAAE,6BAA6B,EAAE,uCAAuC,EAAE,MAAM,iCAAiC,CAAC;AACzH,OAAO,EAAE,yCAAyC,EAAE,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAClH,OAAO,EACL,yBAAyB,EACzB,+BAA+B,EAC/B,8BAA8B,EAC9B,kBAAkB,EAClB,oCAAoC,EACpC,2BAA2B,EAC3B,6BAA6B,EAC7B,6BAA6B,GAC9B,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,6BAA6B,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAoBnE,MAAM,gCAAgC,GAAG,GAAG,CAAC;AA0B7C,gBAAgB;AAChB,MAAM,OAAO,6BAA6B;IAKb;IAJnB,KAAK,CAAsB;IAC3B,mBAAmB,CAA0B;IAC7C,6BAA6B,CAAoC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E,OAAO,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;QAC/H,CAAC;QACD,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;IACrD,CAAC,CAAC,CACH,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CAAC,GAAkB,EAAE,SAAiB;IAC1D,MAAM,WAAW,GAAa,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IACxD,MAAM,IAAI,GAAiC,EAAE,CAAC;IAC9C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QAC/C,QAAQ,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC;YACvB,KAAK,KAAK;gBACR,IAAI,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,6BAA6B,EAAE,EAAE,EAAE,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;gBAChF,MAAM;YACR,KAAK,KAAK;gBACR,IAAI,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,6BAA6B,EAAE,EAAE,EAAE,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;gBAChF,MAAM;QACV,CAAC;IACH,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,sBAAsB,EAAE,GAAG,CAAC,gBAAgB,EAAE,CAAC;AAChE,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { bufferCount, defer, EMPTY, from, identity, lastValueFrom, map, merge, mergeMap, of, reduce, toArray } from \"rxjs\";\nimport { createNodesQueryClauseFactory, createPredicateBasedHierarchyDefinition } from \"@itwin/presentation-hierarchies\";\nimport { createBisInstanceLabelSelectClauseFactory, ECSql, parseFullClassName } from \"@itwin/presentation-shared\";\nimport {\n CLASS_NAME_Classification,\n CLASS_NAME_ClassificationSystem,\n CLASS_NAME_ClassificationTable,\n CLASS_NAME_Element,\n CLASS_NAME_ElementHasClassifications,\n CLASS_NAME_GeometricElement,\n CLASS_NAME_GeometricElement2d,\n CLASS_NAME_GeometricElement3d,\n} from \"../common/internal/ClassNameDefinitions.js\";\nimport { releaseMainThreadOnItemsCount } from \"../common/internal/Utils.js\";\nimport { FilterLimitExceededError } from \"../common/TreeErrors.js\";\n\nimport type { Observable, OperatorFunction } from \"rxjs\";\nimport type { Id64Array, Id64String } from \"@itwin/core-bentley\";\nimport type {\n DefineHierarchyLevelProps,\n DefineInstanceNodeChildHierarchyLevelProps,\n DefineRootHierarchyLevelProps,\n GenericInstanceFilter,\n HierarchyDefinition,\n HierarchyFilteringPath,\n HierarchyLevelDefinition,\n HierarchyNodeIdentifiersPath,\n LimitingECSqlQueryExecutor,\n NodesQueryClauseFactory,\n} from \"@itwin/presentation-hierarchies\";\nimport type { ECClassHierarchyInspector, ECSchemaProvider, ECSqlQueryRow, IInstanceLabelSelectClauseFactory, InstanceKey } from \"@itwin/presentation-shared\";\nimport type { ElementId } from \"../common/internal/Types.js\";\nimport type { ClassificationId, ClassificationsTreeIdsCache, ClassificationTableId } from \"./internal/ClassificationsTreeIdsCache.js\";\n\nconst MAX_FILTERING_INSTANCE_KEY_COUNT = 100;\n\ninterface ClassificationsTreeDefinitionProps {\n imodelAccess: ECSchemaProvider & ECClassHierarchyInspector & LimitingECSqlQueryExecutor;\n idsCache: ClassificationsTreeIdsCache;\n hierarchyConfig: ClassificationsTreeHierarchyConfiguration;\n}\n\n/** @alpha */\nexport interface ClassificationsTreeHierarchyConfiguration {\n /**\n * The classifications' hierarchy starts at the root `ClassificationSystem` element. This attribute identifiers that\n * root `ClassificationSystem`.\n */\n rootClassificationSystemCode: string;\n}\n\n/** @alpha */\nexport interface ClassificationsTreeInstanceKeyPathsFromInstanceLabelProps {\n imodelAccess: ECClassHierarchyInspector & LimitingECSqlQueryExecutor;\n label: string;\n limit?: number | \"unbounded\";\n idsCache: ClassificationsTreeIdsCache;\n hierarchyConfig: ClassificationsTreeHierarchyConfiguration;\n}\n\n/** @internal */\nexport class ClassificationsTreeDefinition implements HierarchyDefinition {\n private _impl: HierarchyDefinition;\n private _selectQueryFactory: NodesQueryClauseFactory;\n private _nodeLabelSelectClauseFactory: IInstanceLabelSelectClauseFactory;\n\n public constructor(private _props: ClassificationsTreeDefinitionProps) {\n this._nodeLabelSelectClauseFactory = createBisInstanceLabelSelectClauseFactory({ classHierarchyInspector: this._props.imodelAccess });\n this._selectQueryFactory = createNodesQueryClauseFactory({\n imodelAccess: this._props.imodelAccess,\n instanceLabelSelectClauseFactory: this._nodeLabelSelectClauseFactory,\n });\n this._impl = createPredicateBasedHierarchyDefinition({\n classHierarchyInspector: this._props.imodelAccess,\n hierarchy: {\n rootNodes: async (requestProps: DefineRootHierarchyLevelProps) => this.#createClassificationTablesQuery(requestProps),\n childNodes: [\n {\n parentInstancesNodePredicate: CLASS_NAME_ClassificationTable,\n definitions: async (requestProps: DefineInstanceNodeChildHierarchyLevelProps) => this.#createClassificationTableChildrenQuery(requestProps),\n },\n {\n parentInstancesNodePredicate: CLASS_NAME_Classification,\n definitions: async (requestProps: DefineInstanceNodeChildHierarchyLevelProps) => this.#createClassificationChildrenQuery(requestProps),\n },\n {\n parentInstancesNodePredicate: CLASS_NAME_GeometricElement,\n definitions: async (requestProps: DefineInstanceNodeChildHierarchyLevelProps) => this.#createGeometricElementChildrenQuery(requestProps),\n },\n ],\n },\n });\n }\n\n public async defineHierarchyLevel(props: DefineHierarchyLevelProps) {\n return this._impl.defineHierarchyLevel(props);\n }\n\n async #createClassificationTablesQuery(props: { instanceFilter?: GenericInstanceFilter }): Promise<HierarchyLevelDefinition> {\n const { instanceFilter } = props;\n const instanceFilterClauses = await this._selectQueryFactory.createFilterClauses({\n filter: instanceFilter,\n contentClass: { fullName: CLASS_NAME_ClassificationTable, alias: \"this\" },\n });\n return [\n {\n fullClassName: CLASS_NAME_ClassificationTable,\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: CLASS_NAME_ClassificationTable,\n }),\n },\n hasChildren: {\n selector: `\n IFNULL((\n SELECT 1\n FROM ${CLASS_NAME_Classification} classification\n WHERE classification.Model.Id = this.ECInstanceId\n LIMIT 1\n ), 0)\n `,\n },\n extendedData: {\n type: \"ClassificationTable\",\n },\n supportsFiltering: true,\n })}\n FROM\n ${instanceFilterClauses.from} this\n JOIN ${CLASS_NAME_ClassificationSystem} system ON system.ECInstanceId = this.Parent.Id\n ${instanceFilterClauses.joins}\n WHERE\n system.CodeValue = '${this._props.hierarchyConfig.rootClassificationSystemCode}'\n AND NOT this.IsPrivate\n ${instanceFilterClauses.where ? `AND ${instanceFilterClauses.where}` : \"\"}\n `,\n },\n },\n ];\n }\n\n async #createClassificationTableChildrenQuery(props: {\n parentNodeInstanceIds: ClassificationTableId[];\n instanceFilter?: GenericInstanceFilter;\n }): Promise<HierarchyLevelDefinition> {\n const { parentNodeInstanceIds: classificationTableIds, instanceFilter } = props;\n const instanceFilterClauses = await this._selectQueryFactory.createFilterClauses({\n filter: instanceFilter,\n contentClass: { fullName: CLASS_NAME_Classification, alias: \"this\" },\n });\n const classificationIds = await this._props.idsCache.getDirectChildClassifications(classificationTableIds);\n return classificationIds.length\n ? [\n {\n fullClassName: CLASS_NAME_Classification,\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: CLASS_NAME_Classification,\n }),\n },\n hasChildren: {\n selector: createClassificationHasChildrenSelector(\"this\"),\n },\n extendedData: {\n type: \"Classification\",\n },\n supportsFiltering: true,\n })}\n FROM\n ${instanceFilterClauses.from} this\n ${instanceFilterClauses.joins}\n WHERE\n this.ECInstanceId IN (${classificationIds.join(\",\")})\n ${instanceFilterClauses.where ? `AND ${instanceFilterClauses.where}` : \"\"}\n `,\n },\n },\n ]\n : [];\n }\n\n async #createClassificationChildrenQuery(props: {\n parentNodeInstanceIds: ClassificationId[];\n instanceFilter?: GenericInstanceFilter;\n }): Promise<HierarchyLevelDefinition> {\n const { parentNodeInstanceIds: parentClassificationIds, instanceFilter } = props;\n const classificationIds = await this._props.idsCache.getDirectChildClassifications(parentClassificationIds);\n return [\n // load child classifications\n ...(classificationIds.length\n ? [\n await (async () => {\n const instanceFilterClauses = await this._selectQueryFactory.createFilterClauses({\n filter: instanceFilter,\n contentClass: { fullName: CLASS_NAME_Classification, alias: \"this\" },\n });\n return {\n fullClassName: CLASS_NAME_Classification,\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: CLASS_NAME_Classification,\n }),\n },\n hasChildren: {\n selector: createClassificationHasChildrenSelector(\"this\"),\n },\n extendedData: {\n type: \"Classification\",\n },\n supportsFiltering: true,\n })}\n FROM\n ${instanceFilterClauses.from} this\n ${instanceFilterClauses.joins}\n WHERE\n this.ECInstanceId IN (${classificationIds.join(\",\")})\n ${instanceFilterClauses.where ? `AND ${instanceFilterClauses.where}` : \"\"}\n `,\n },\n };\n })(),\n ]\n : []),\n // load classification elements\n ...(await Promise.all(\n [CLASS_NAME_GeometricElement2d, CLASS_NAME_GeometricElement3d].map(async (elementClassName) => {\n const instanceFilterClauses = await this._selectQueryFactory.createFilterClauses({\n filter: instanceFilter,\n contentClass: { fullName: elementClassName, alias: \"this\" },\n });\n return {\n fullClassName: elementClassName,\n query: {\n ecsql: `\n SELECT ${await this.#createElementSelectClause(elementClassName)}\n FROM ${instanceFilterClauses.from} this\n JOIN ${CLASS_NAME_ElementHasClassifications} ehc ON ehc.SourceECInstanceId = this.ECInstanceId\n ${instanceFilterClauses.joins}\n WHERE\n ehc.TargetECInstanceId IN (${parentClassificationIds.join(\",\")})\n AND this.Parent.Id IS NULL\n ${instanceFilterClauses.where ? `AND ${instanceFilterClauses.where}` : \"\"}\n `,\n },\n };\n }),\n )),\n ];\n }\n\n async #createGeometricElementChildrenQuery({\n parentNodeInstanceIds: parentElementIds,\n instanceFilter,\n }: DefineInstanceNodeChildHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n return Promise.all(\n [CLASS_NAME_GeometricElement2d, CLASS_NAME_GeometricElement3d].map(async (elementClassName) => {\n const instanceFilterClauses = await this._selectQueryFactory.createFilterClauses({\n filter: instanceFilter,\n contentClass: { fullName: elementClassName, alias: \"this\" },\n });\n return {\n fullClassName: elementClassName,\n query: {\n ecsql: `\n SELECT ${await this.#createElementSelectClause(elementClassName)}\n FROM ${instanceFilterClauses.from} this\n ${instanceFilterClauses.joins}\n WHERE\n this.Parent.Id IN (${parentElementIds.join(\",\")})\n ${instanceFilterClauses.where ? `AND ${instanceFilterClauses.where}` : \"\"}\n `,\n },\n };\n }),\n );\n }\n\n async #createElementSelectClause(elementFullClassName: string): Promise<string> {\n const { className: elementClassName } = parseFullClassName(elementFullClassName);\n return 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: elementFullClassName,\n }),\n },\n hasChildren: {\n selector: `\n IFNULL((\n SELECT 1\n FROM ${CLASS_NAME_Element} ce\n WHERE ce.Parent.Id = this.ECInstanceId\n LIMIT 1\n ), 0)\n `,\n },\n extendedData: {\n type: elementClassName,\n modelId: { selector: \"IdToHex(this.Model.Id)\" },\n categoryId: { selector: \"IdToHex(this.Category.Id)\" },\n },\n supportsFiltering: true,\n });\n }\n\n public static async createInstanceKeyPaths(props: ClassificationsTreeInstanceKeyPathsFromInstanceLabelProps): Promise<HierarchyFilteringPath[]> {\n const labelsFactory = createBisInstanceLabelSelectClauseFactory({ classHierarchyInspector: props.imodelAccess });\n return createInstanceKeyPathsFromInstanceLabel({ ...props, labelsFactory });\n }\n}\n\nfunction createClassificationHasChildrenSelector(classificationAlias: string) {\n return `\n COALESCE((\n SELECT 1\n FROM ${CLASS_NAME_Classification} classification\n WHERE classification.Parent.Id = ${classificationAlias}.ECInstanceId\n LIMIT 1\n ), (\n SELECT 1\n FROM ${CLASS_NAME_ElementHasClassifications} ehc\n WHERE ehc.TargetECInstanceId = ${classificationAlias}.ECInstanceId\n LIMIT 1\n ),\n 0\n )\n `;\n}\n\nasync function createInstanceKeyPathsFromInstanceLabel(\n props: ClassificationsTreeInstanceKeyPathsFromInstanceLabelProps & { labelsFactory: IInstanceLabelSelectClauseFactory },\n): Promise<HierarchyFilteringPath[]> {\n const adjustedLabel = props.label.replace(/[%_\\\\]/g, \"\\\\$&\");\n\n const CLASSIFICATION_TABLES_WITH_LABELS_CTE = \"ClassificationTablesWithLabels\";\n const CLASSIFICATIONS_WITH_LABELS_CTE = \"ClassificationsWithLabels\";\n const ELEMENTS_2D_WITH_LABELS_CTE = \"Elements2dWithLabels\";\n const ELEMENTS_3D_WITH_LABELS_CTE = \"Elements3dWithLabels\";\n return lastValueFrom(\n defer(async () => {\n const [classificationTableLabelSelectClause, classificationLabelSelectClause, element2dLabelSelectClause, element3dLabelSelectClause] = await Promise.all(\n [CLASS_NAME_ClassificationTable, CLASS_NAME_Classification, CLASS_NAME_GeometricElement2d, CLASS_NAME_GeometricElement3d].map(async (className) =>\n props.labelsFactory.createSelectClause({ classAlias: \"this\", className }),\n ),\n );\n const classificationIds = await props.idsCache.getAllClassifications();\n const ctes = [\n `\n ${CLASSIFICATION_TABLES_WITH_LABELS_CTE}(ClassName, ECInstanceId, DisplayLabel) AS (\n SELECT\n 'ct',\n this.ECInstanceId,\n ${classificationTableLabelSelectClause}\n FROM\n ${CLASS_NAME_ClassificationTable} this\n JOIN ${CLASS_NAME_ClassificationSystem} system ON system.ECInstanceId = this.Parent.Id\n WHERE\n system.CodeValue = '${props.hierarchyConfig.rootClassificationSystemCode}'\n AND NOT this.IsPrivate\n )\n `,\n ...(classificationIds.length > 0\n ? [\n `${CLASSIFICATIONS_WITH_LABELS_CTE}(ClassName, ECInstanceId, DisplayLabel) AS (\n SELECT\n 'c',\n this.ECInstanceId,\n ${classificationLabelSelectClause}\n FROM\n ${CLASS_NAME_Classification} this\n WHERE\n this.ECInstanceId IN (${classificationIds.join(\",\")})\n )`,\n `${ELEMENTS_2D_WITH_LABELS_CTE}(ClassName, ECInstanceId, DisplayLabel) AS (\n SELECT\n 'e2d',\n this.ECInstanceId,\n ${element2dLabelSelectClause}\n FROM\n ${CLASS_NAME_GeometricElement2d} this\n JOIN ${CLASS_NAME_ElementHasClassifications} ehc ON ehc.SourceECInstanceId = this.ECInstanceId\n WHERE\n ehc.TargetECInstanceId IN (${classificationIds.join(\",\")})\n AND this.Parent.Id IS NULL\n\n UNION ALL\n\n SELECT\n 'e2d',\n this.ECInstanceId,\n ${element2dLabelSelectClause}\n FROM\n ${CLASS_NAME_GeometricElement2d} this\n JOIN ${ELEMENTS_2D_WITH_LABELS_CTE} pe ON pe.ECInstanceId = this.Parent.Id\n )`,\n `${ELEMENTS_3D_WITH_LABELS_CTE}(ClassName, ECInstanceId, DisplayLabel) AS (\n SELECT\n 'e3d',\n this.ECInstanceId,\n ${element3dLabelSelectClause}\n FROM\n ${CLASS_NAME_GeometricElement3d} this\n JOIN ${CLASS_NAME_ElementHasClassifications} ehc ON ehc.SourceECInstanceId = this.ECInstanceId\n WHERE\n ehc.TargetECInstanceId IN (${classificationIds.join(\",\")})\n AND this.Parent.Id IS NULL\n\n UNION ALL\n\n SELECT\n 'e3d',\n this.ECInstanceId,\n ${element3dLabelSelectClause}\n FROM\n ${CLASS_NAME_GeometricElement3d} this\n JOIN ${ELEMENTS_3D_WITH_LABELS_CTE} pe ON pe.ECInstanceId = this.Parent.Id\n )`,\n ]\n : []),\n ];\n const ecsql = `\n SELECT * FROM (\n SELECT\n ct.ClassName AS ClassName,\n ct.ECInstanceId AS ECInstanceId\n FROM\n ${CLASSIFICATION_TABLES_WITH_LABELS_CTE} ct\n WHERE\n ct.DisplayLabel LIKE '%' || ? || '%' ESCAPE '\\\\'\n\n ${\n classificationIds.length > 0\n ? `\n UNION ALL\n\n SELECT\n c.ClassName AS ClassName,\n c.ECInstanceId AS ECInstanceId\n FROM\n ${CLASSIFICATIONS_WITH_LABELS_CTE} c\n WHERE\n c.DisplayLabel LIKE '%' || ? || '%' ESCAPE '\\\\'\n\n UNION ALL\n\n SELECT\n e2d.ClassName AS ClassName,\n e2d.ECInstanceId AS ECInstanceId\n FROM\n ${ELEMENTS_2D_WITH_LABELS_CTE} e2d\n WHERE\n e2d.DisplayLabel LIKE '%' || ? || '%' ESCAPE '\\\\'\n\n UNION ALL\n\n SELECT\n e3d.ClassName AS ClassName,\n e3d.ECInstanceId AS ECInstanceId\n FROM\n ${ELEMENTS_3D_WITH_LABELS_CTE} e3d\n WHERE\n e3d.DisplayLabel LIKE '%' || ? || '%' ESCAPE '\\\\'\n `\n : \"\"\n }\n )\n ${props.limit === undefined ? `LIMIT ${MAX_FILTERING_INSTANCE_KEY_COUNT + 1}` : props.limit !== \"unbounded\" ? `LIMIT ${props.limit}` : \"\"}\n `;\n const bindings = [\n { type: \"string\" as const, value: adjustedLabel },\n ...(classificationIds.length > 0\n ? [\n { type: \"string\" as const, value: adjustedLabel },\n { type: \"string\" as const, value: adjustedLabel },\n { type: \"string\" as const, value: adjustedLabel },\n ]\n : []),\n ];\n return { ctes, ecsql, bindings };\n }).pipe(\n mergeMap((queryProps) =>\n props.imodelAccess.createQueryReader(queryProps, { restartToken: \"tree-widget/classifications-tree/filter-by-label-query\", limit: props.limit }),\n ),\n map((row): InstanceKey => {\n let className: string;\n switch (row.ClassName) {\n case \"ct\":\n className = CLASS_NAME_ClassificationTable;\n break;\n case \"c\":\n className = CLASS_NAME_Classification;\n break;\n case \"e2d\":\n className = CLASS_NAME_GeometricElement2d;\n break;\n default:\n className = CLASS_NAME_GeometricElement3d;\n break;\n }\n return {\n className,\n id: row.ECInstanceId,\n };\n }),\n createInstanceKeyPathsFromTargetItems(props),\n toArray(),\n ),\n );\n}\n\nfunction createInstanceKeyPathsFromTargetItems({\n idsCache,\n imodelAccess,\n limit,\n}: Pick<ClassificationsTreeInstanceKeyPathsFromInstanceLabelProps, \"limit\" | \"imodelAccess\" | \"idsCache\">): OperatorFunction<\n InstanceKey,\n HierarchyFilteringPath\n> {\n const actualLimit = limit ?? MAX_FILTERING_INSTANCE_KEY_COUNT;\n return (targetItems: Observable<InstanceKey>) => {\n return targetItems.pipe(\n actualLimit !== \"unbounded\"\n ? map((targetItem, index) => {\n if (index >= actualLimit) {\n throw new FilterLimitExceededError(actualLimit);\n }\n return targetItem;\n })\n : identity,\n releaseMainThreadOnItemsCount(2000),\n reduce(\n (acc, { id, className }) => {\n if (className === CLASS_NAME_ClassificationTable) {\n acc.classificationTableIds.push(id);\n return acc;\n }\n if (className === CLASS_NAME_Classification) {\n acc.classificationIds.push(id);\n return acc;\n }\n if (className === CLASS_NAME_GeometricElement2d) {\n acc.element2dIds.push(id);\n return acc;\n }\n\n acc.element3dIds.push(id);\n return acc;\n },\n {\n classificationTableIds: new Array<ClassificationTableId>(),\n classificationIds: new Array<ClassificationId>(),\n element2dIds: new Array<ElementId>(),\n element3dIds: new Array<ElementId>(),\n },\n ),\n mergeMap((ids) => {\n const elements2dLength = ids.element2dIds.length;\n const elements3dLength = ids.element3dIds.length;\n return merge(\n from(ids.classificationTableIds).pipe(\n map((id): HierarchyFilteringPath => ({ path: [{ id, className: CLASS_NAME_ClassificationTable }], options: { autoExpand: true } })),\n ),\n idsCache.getClassificationsPathObs(ids.classificationIds).pipe(map((path) => ({ path, options: { autoExpand: true } }))),\n from(ids.element2dIds).pipe(\n bufferCount(Math.ceil(elements2dLength / Math.ceil(elements2dLength / 5000))),\n releaseMainThreadOnItemsCount(1),\n mergeMap((block) => createGeometricElementInstanceKeyPaths({ idsCache, imodelAccess, targetItems: block, type: \"2d\" }), 10),\n ),\n from(ids.element3dIds).pipe(\n bufferCount(Math.ceil(elements3dLength / Math.ceil(elements3dLength / 5000))),\n releaseMainThreadOnItemsCount(1),\n mergeMap((block) => createGeometricElementInstanceKeyPaths({ idsCache, imodelAccess, targetItems: block, type: \"3d\" }), 10),\n ),\n );\n }),\n );\n };\n}\n\nfunction createGeometricElementInstanceKeyPaths(props: {\n idsCache: ClassificationsTreeIdsCache;\n imodelAccess: ECClassHierarchyInspector & LimitingECSqlQueryExecutor;\n targetItems: Id64Array;\n type: \"2d\" | \"3d\";\n}): Observable<HierarchyFilteringPath> {\n const { targetItems, imodelAccess, type, idsCache } = props;\n if (targetItems.length === 0) {\n return EMPTY;\n }\n\n const separator = \";\";\n\n return defer(() => {\n const ctes = [\n `ElementsHierarchy(ECInstanceId, ParentId, Path) AS (\n SELECT\n e.ECInstanceId,\n e.Parent.Id,\n 'e${type}${separator}' || CAST(IdToHex([e].[ECInstanceId]) AS TEXT)\n FROM ${CLASS_NAME_Element} e\n WHERE e.ECInstanceId IN (${targetItems.join(\",\")})\n\n UNION ALL\n\n SELECT\n pe.ECInstanceId,\n pe.Parent.Id,\n 'e${type}${separator}' || CAST(IdToHex([pe].[ECInstanceId]) AS TEXT) || '${separator}' || ce.Path\n FROM ElementsHierarchy ce\n JOIN ${CLASS_NAME_Element} pe ON pe.ECInstanceId = ce.ParentId\n )`,\n ];\n const ecsql = `\n SELECT\n e.Path path,\n c.ECInstanceId classificationId\n FROM\n ${CLASS_NAME_Classification} c\n JOIN ${CLASS_NAME_ElementHasClassifications} ehc ON ehc.TargetECInstanceId = c.ECInstanceId\n JOIN ElementsHierarchy e ON ehc.SourceECInstanceId = e.ECInstanceId\n WHERE e.ParentId IS NULL\n `;\n\n return imodelAccess.createQueryReader(\n { ctes, ecsql },\n { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\", restartToken: `tree-widget/classifications-tree/elements${type}-filter-paths-query` },\n );\n }).pipe(\n releaseMainThreadOnItemsCount(300),\n map((row) => parseQueryRow(row, separator)),\n mergeMap(({ path, parentClassificationId }) => {\n if (parentClassificationId) {\n return idsCache\n .getClassificationsPathObs(parentClassificationId)\n .pipe(map((parentClassificationPath) => ({ path: parentClassificationPath.concat(path), options: { autoExpand: true } })));\n }\n return of({ path, options: { autoExpand: true } });\n }),\n );\n}\n\nfunction parseQueryRow(row: ECSqlQueryRow, separator: string): { path: HierarchyNodeIdentifiersPath; parentClassificationId: Id64String | undefined } {\n const rowElements: string[] = row.path.split(separator);\n const path: HierarchyNodeIdentifiersPath = [];\n for (let i = 0; i < rowElements.length; i += 2) {\n switch (rowElements[i]) {\n case \"e2d\":\n path.push({ className: CLASS_NAME_GeometricElement2d, id: rowElements[i + 1] });\n break;\n case \"e3d\":\n path.push({ className: CLASS_NAME_GeometricElement3d, id: rowElements[i + 1] });\n break;\n }\n }\n\n return { path, parentClassificationId: row.classificationId };\n}\n"]}
@@ -8,16 +8,17 @@ export interface UseClassificationsTreeProps {
8
8
  activeView: Viewport;
9
9
  hierarchyConfig: ClassificationsTreeHierarchyConfiguration;
10
10
  emptyTreeContent?: ReactNode;
11
+ filter?: string;
11
12
  }
12
13
  /** @alpha */
13
14
  interface UseClassificationsTreeResult {
14
- categoriesTreeProps: Pick<VisibilityTreeProps, "treeName" | "getHierarchyDefinition" | "visibilityHandlerFactory" | "emptyTreeContent">;
15
+ classificationsTreeProps: Pick<VisibilityTreeProps, "treeName" | "getHierarchyDefinition" | "visibilityHandlerFactory" | "getFilteredPaths" | "emptyTreeContent" | "highlight">;
15
16
  rendererProps: Required<Pick<VisibilityTreeRendererProps, "getDecorations">>;
16
17
  }
17
18
  /**
18
19
  * Custom hook to create and manage state for the categories tree.
19
20
  * @alpha
20
21
  */
21
- export declare function useClassificationsTree({ activeView, emptyTreeContent, ...rest }: UseClassificationsTreeProps): UseClassificationsTreeResult;
22
+ export declare function useClassificationsTree({ activeView, emptyTreeContent, filter, ...rest }: UseClassificationsTreeProps): UseClassificationsTreeResult;
22
23
  export {};
23
24
  //# sourceMappingURL=UseClassificationsTree.d.ts.map
@@ -3,10 +3,10 @@ import { jsx as _jsx } from "react/jsx-runtime";
3
3
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
4
  * See LICENSE.md in the project root for license terms and full copyright notice.
5
5
  *--------------------------------------------------------------------------------------------*/
6
- import { useCallback, useMemo } from "react";
6
+ import { useCallback, useEffect, useMemo } from "react";
7
7
  import { createECSqlQueryExecutor } from "@itwin/presentation-core-interop";
8
8
  import iconBisCategory3d from "@stratakit/icons/bis-category-3d.svg";
9
- import { EmptyTreeContent } from "../common/components/EmptyTree.js";
9
+ import { EmptyTreeContent, FilterUnknownError, NoFilterMatches, TooManyFilterMatches } from "../common/components/EmptyTree.js";
10
10
  import { useCachedVisibility } from "../common/internal/useTreeHooks/UseCachedVisibility.js";
11
11
  import { useIdsCache } from "../common/internal/useTreeHooks/UseIdsCache.js";
12
12
  import { ClassificationsTreeComponent } from "./ClassificationsTreeComponent.js";
@@ -14,11 +14,12 @@ import { ClassificationsTreeDefinition } from "./ClassificationsTreeDefinition.j
14
14
  import { ClassificationsTreeIcon } from "./ClassificationsTreeIcon.js";
15
15
  import { ClassificationsTreeIdsCache } from "./internal/ClassificationsTreeIdsCache.js";
16
16
  import { createClassificationsTreeVisibilityHandler } from "./internal/ClassificationsTreeVisibilityHandler.js";
17
+ import { useFilteredPaths } from "./internal/UseFilteredPaths.js";
17
18
  /**
18
19
  * Custom hook to create and manage state for the categories tree.
19
20
  * @alpha
20
21
  */
21
- export function useClassificationsTree({ activeView, emptyTreeContent, ...rest }) {
22
+ export function useClassificationsTree({ activeView, emptyTreeContent, filter, ...rest }) {
22
23
  const hierarchyConfig = useMemo(() => ({ ...rest.hierarchyConfig }),
23
24
  // eslint-disable-next-line react-hooks/exhaustive-deps
24
25
  [...Object.values(rest.hierarchyConfig)]);
@@ -27,21 +28,27 @@ export function useClassificationsTree({ activeView, emptyTreeContent, ...rest }
27
28
  createCache,
28
29
  cacheSpecificProps: useMemo(() => ({ hierarchyConfig }), [hierarchyConfig]),
29
30
  });
30
- const { visibilityHandlerFactory } = useCachedVisibility({
31
+ const { visibilityHandlerFactory, onFilteredPathsChanged } = useClassificationsCachedVisibility({
31
32
  activeView,
32
33
  getCache: getClassificationsTreeIdsCache,
33
- factoryProps: undefined,
34
- createFactory: createVisibilityHandlerFactory,
35
34
  });
36
35
  const getHierarchyDefinition = useCallback((props) => {
37
36
  return new ClassificationsTreeDefinition({ ...props, idsCache: getClassificationsTreeIdsCache(), hierarchyConfig });
38
37
  }, [getClassificationsTreeIdsCache, hierarchyConfig]);
38
+ const { getPaths, filteringError } = useFilteredPaths({
39
+ hierarchyConfiguration: hierarchyConfig,
40
+ filter,
41
+ getClassificationsTreeIdsCache,
42
+ onFilteredPathsChanged,
43
+ });
39
44
  return {
40
- categoriesTreeProps: {
45
+ classificationsTreeProps: {
41
46
  treeName: ClassificationsTreeComponent.id,
42
47
  getHierarchyDefinition,
43
48
  visibilityHandlerFactory,
44
- emptyTreeContent: emptyTreeContent ?? _jsx(EmptyTreeContent, { icon: iconBisCategory3d }),
49
+ getFilteredPaths: getPaths,
50
+ emptyTreeContent: useMemo(() => getEmptyTreeContentComponent(filter, filteringError, emptyTreeContent), [filter, filteringError, emptyTreeContent]),
51
+ highlight: useMemo(() => (filter ? { text: filter } : undefined), [filter]),
45
52
  },
46
53
  rendererProps: {
47
54
  getDecorations: useCallback((node) => _jsx(ClassificationsTreeIcon, { node: node }), []),
@@ -55,4 +62,35 @@ function createVisibilityHandlerFactory(props) {
55
62
  function createCache(props) {
56
63
  return new ClassificationsTreeIdsCache(createECSqlQueryExecutor(props.imodel), props.specificProps.hierarchyConfig);
57
64
  }
65
+ function getEmptyTreeContentComponent(filter, error, emptyTreeContent) {
66
+ if (error) {
67
+ if (error === "tooManyFilterMatches") {
68
+ return _jsx(TooManyFilterMatches, { base: "classificationsTree" });
69
+ }
70
+ return _jsx(FilterUnknownError, { base: "classificationsTree" });
71
+ }
72
+ if (filter) {
73
+ return _jsx(NoFilterMatches, { base: "classificationsTree" });
74
+ }
75
+ if (emptyTreeContent) {
76
+ return emptyTreeContent;
77
+ }
78
+ return _jsx(EmptyTreeContent, { icon: iconBisCategory3d });
79
+ }
80
+ function useClassificationsCachedVisibility(props) {
81
+ const { activeView, getCache } = props;
82
+ const { visibilityHandlerFactory, filteredPaths, onFilteredPathsChanged } = useCachedVisibility({
83
+ activeView,
84
+ getCache,
85
+ factoryProps: undefined,
86
+ createFactory: createVisibilityHandlerFactory,
87
+ });
88
+ useEffect(() => {
89
+ getCache().clearFilteredElementsData();
90
+ }, [filteredPaths, getCache]);
91
+ return {
92
+ visibilityHandlerFactory,
93
+ onFilteredPathsChanged,
94
+ };
95
+ }
58
96
  //# sourceMappingURL=UseClassificationsTree.js.map