@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":"UseClassificationsTree.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/classifications-tree/UseClassificationsTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,E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,aAAa,EAAE,8BAA8B;KAC9C,CAAC,CAAC;IAEH,MAAM,sBAAsB,GAAG,WAAW,CACxC,CAAC,KAAK,EAAE,EAAE;QACR,OAAO,IAAI,6BAA6B,CAAC,EAAE,GAAG,KAAK,EAAE,QAAQ,EAAE,8BAA8B,EAAE,EAAE,eAAe,EAAE,CAAC,CAAC;IACtH,CAAC,EACD,CAAC,8BAA8B,EAAE,eAAe,CAAC,CAClD,CAAC;IAEF,OAAO;QACL,mBAAmB,EAAE;YACnB,QAAQ,EAAE,4BAA4B,CAAC,EAAE;YACzC,sBAAsB;YACtB,wBAAwB;YACxB,gBAAgB,EAAE,gBAAgB,IAAI,KAAC,gBAAgB,IAAC,IAAI,EAAE,iBAAiB,GAAI;SACpF;QACD,aAAa,EAAE;YACb,cAAc,EAAE,WAAW,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAC,uBAAuB,IAAC,IAAI,EAAE,IAAI,GAAI,EAAE,EAAE,CAAC;SACnF;KACF,CAAC;AACJ,CAAC;AAED,SAAS,8BAA8B,CAAC,KAAiE;IACvG,MAAM,EAAE,UAAU,EAAE,cAAc,EAAE,GAAG,KAAK,CAAC;IAC7C,OAAO,CAAC,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC,0CAA0C,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,cAAc,EAAE,EAAE,YAAY,EAAE,CAAC,CAAC;AAC9I,CAAC;AAED,SAAS,WAAW,CAAC,KAAwF;IAC3G,OAAO,IAAI,2BAA2B,CAAC,wBAAwB,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;AACtH,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, useMemo } from \"react\";\nimport { createECSqlQueryExecutor } from \"@itwin/presentation-core-interop\";\nimport iconBisCategory3d from \"@stratakit/icons/bis-category-3d.svg\";\nimport { EmptyTreeContent } from \"../common/components/EmptyTree.js\";\nimport { useCachedVisibility } from \"../common/internal/useTreeHooks/UseCachedVisibility.js\";\nimport { useIdsCache } from \"../common/internal/useTreeHooks/UseIdsCache.js\";\nimport { ClassificationsTreeComponent } from \"./ClassificationsTreeComponent.js\";\nimport { ClassificationsTreeDefinition } from \"./ClassificationsTreeDefinition.js\";\nimport { ClassificationsTreeIcon } from \"./ClassificationsTreeIcon.js\";\nimport { ClassificationsTreeIdsCache } from \"./internal/ClassificationsTreeIdsCache.js\";\nimport { createClassificationsTreeVisibilityHandler } from \"./internal/ClassificationsTreeVisibilityHandler.js\";\n\nimport type { CreateCacheProps } from \"../common/internal/useTreeHooks/UseIdsCache.js\";\nimport type { CreateFactoryProps } from \"../common/internal/useTreeHooks/UseCachedVisibility.js\";\nimport type { ClassificationsTreeHierarchyConfiguration } from \"./ClassificationsTreeDefinition.js\";\nimport type { ReactNode } from \"react\";\nimport type { Viewport } from \"@itwin/core-frontend\";\nimport type { VisibilityTreeProps } from \"../common/components/VisibilityTree.js\";\nimport type { VisibilityTreeRendererProps } from \"../common/components/VisibilityTreeRenderer.js\";\n\n/** @alpha */\nexport interface UseClassificationsTreeProps {\n activeView: Viewport;\n hierarchyConfig: ClassificationsTreeHierarchyConfiguration;\n emptyTreeContent?: ReactNode;\n}\n\n/** @alpha */\ninterface UseClassificationsTreeResult {\n categoriesTreeProps: Pick<VisibilityTreeProps, \"treeName\" | \"getHierarchyDefinition\" | \"visibilityHandlerFactory\" | \"emptyTreeContent\">;\n rendererProps: Required<Pick<VisibilityTreeRendererProps, \"getDecorations\">>;\n}\n\n/**\n * Custom hook to create and manage state for the categories tree.\n * @alpha\n */\nexport function useClassificationsTree({ activeView, emptyTreeContent, ...rest }: UseClassificationsTreeProps): UseClassificationsTreeResult {\n const hierarchyConfig = useMemo(\n () => ({ ...rest.hierarchyConfig }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [...Object.values(rest.hierarchyConfig)],\n );\n\n const { getCache: getClassificationsTreeIdsCache } = useIdsCache<ClassificationsTreeIdsCache, { hierarchyConfig: ClassificationsTreeHierarchyConfiguration }>(\n {\n imodel: activeView.iModel,\n createCache,\n cacheSpecificProps: useMemo(() => ({ hierarchyConfig }), [hierarchyConfig]),\n },\n );\n\n const { visibilityHandlerFactory } = useCachedVisibility<ClassificationsTreeIdsCache, undefined>({\n activeView,\n getCache: getClassificationsTreeIdsCache,\n factoryProps: undefined,\n createFactory: createVisibilityHandlerFactory,\n });\n\n const getHierarchyDefinition = useCallback<VisibilityTreeProps[\"getHierarchyDefinition\"]>(\n (props) => {\n return new ClassificationsTreeDefinition({ ...props, idsCache: getClassificationsTreeIdsCache(), hierarchyConfig });\n },\n [getClassificationsTreeIdsCache, hierarchyConfig],\n );\n\n return {\n categoriesTreeProps: {\n treeName: ClassificationsTreeComponent.id,\n getHierarchyDefinition,\n visibilityHandlerFactory,\n emptyTreeContent: emptyTreeContent ?? <EmptyTreeContent icon={iconBisCategory3d} />,\n },\n rendererProps: {\n getDecorations: useCallback((node) => <ClassificationsTreeIcon node={node} />, []),\n },\n };\n}\n\nfunction createVisibilityHandlerFactory(props: CreateFactoryProps<ClassificationsTreeIdsCache, undefined>): VisibilityTreeProps[\"visibilityHandlerFactory\"] {\n const { activeView, idsCacheGetter } = props;\n return ({ imodelAccess }) => createClassificationsTreeVisibilityHandler({ viewport: activeView, idsCache: idsCacheGetter(), imodelAccess });\n}\n\nfunction createCache(props: CreateCacheProps<{ hierarchyConfig: ClassificationsTreeHierarchyConfiguration }>) {\n return new ClassificationsTreeIdsCache(createECSqlQueryExecutor(props.imodel), props.specificProps.hierarchyConfig);\n}\n"]}
1
+ {"version":3,"file":"UseClassificationsTree.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/classifications-tree/UseClassificationsTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGg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AAC,EAAE,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC,CAAC;IAE9B,OAAO;QACL,wBAAwB;QACxB,sBAAsB;KACvB,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 } from \"react\";\nimport { createECSqlQueryExecutor } from \"@itwin/presentation-core-interop\";\nimport iconBisCategory3d from \"@stratakit/icons/bis-category-3d.svg\";\nimport { EmptyTreeContent, FilterUnknownError, NoFilterMatches, TooManyFilterMatches } from \"../common/components/EmptyTree.js\";\nimport { useCachedVisibility } from \"../common/internal/useTreeHooks/UseCachedVisibility.js\";\nimport { useIdsCache } from \"../common/internal/useTreeHooks/UseIdsCache.js\";\nimport { ClassificationsTreeComponent } from \"./ClassificationsTreeComponent.js\";\nimport { ClassificationsTreeDefinition } from \"./ClassificationsTreeDefinition.js\";\nimport { ClassificationsTreeIcon } from \"./ClassificationsTreeIcon.js\";\nimport { ClassificationsTreeIdsCache } from \"./internal/ClassificationsTreeIdsCache.js\";\nimport { createClassificationsTreeVisibilityHandler } from \"./internal/ClassificationsTreeVisibilityHandler.js\";\nimport { useFilteredPaths } from \"./internal/UseFilteredPaths.js\";\n\nimport type { ClassificationsTreeFilteringError } from \"./internal/UseFilteredPaths.js\";\nimport type { CreateCacheProps } from \"../common/internal/useTreeHooks/UseIdsCache.js\";\nimport type { CreateFactoryProps } from \"../common/internal/useTreeHooks/UseCachedVisibility.js\";\nimport type { ClassificationsTreeHierarchyConfiguration } from \"./ClassificationsTreeDefinition.js\";\nimport type { ReactNode } from \"react\";\nimport type { Viewport } from \"@itwin/core-frontend\";\nimport type { VisibilityTreeProps } from \"../common/components/VisibilityTree.js\";\nimport type { VisibilityTreeRendererProps } from \"../common/components/VisibilityTreeRenderer.js\";\n\n/** @alpha */\nexport interface UseClassificationsTreeProps {\n activeView: Viewport;\n hierarchyConfig: ClassificationsTreeHierarchyConfiguration;\n emptyTreeContent?: ReactNode;\n filter?: string;\n}\n\n/** @alpha */\ninterface UseClassificationsTreeResult {\n classificationsTreeProps: Pick<\n VisibilityTreeProps,\n \"treeName\" | \"getHierarchyDefinition\" | \"visibilityHandlerFactory\" | \"getFilteredPaths\" | \"emptyTreeContent\" | \"highlight\"\n >;\n rendererProps: Required<Pick<VisibilityTreeRendererProps, \"getDecorations\">>;\n}\n\n/**\n * Custom hook to create and manage state for the categories tree.\n * @alpha\n */\nexport function useClassificationsTree({ activeView, emptyTreeContent, filter, ...rest }: UseClassificationsTreeProps): UseClassificationsTreeResult {\n const hierarchyConfig = useMemo(\n () => ({ ...rest.hierarchyConfig }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [...Object.values(rest.hierarchyConfig)],\n );\n const { getCache: getClassificationsTreeIdsCache } = useIdsCache<ClassificationsTreeIdsCache, { hierarchyConfig: ClassificationsTreeHierarchyConfiguration }>(\n {\n imodel: activeView.iModel,\n createCache,\n cacheSpecificProps: useMemo(() => ({ hierarchyConfig }), [hierarchyConfig]),\n },\n );\n\n const { visibilityHandlerFactory, onFilteredPathsChanged } = useClassificationsCachedVisibility({\n activeView,\n getCache: getClassificationsTreeIdsCache,\n });\n\n const getHierarchyDefinition = useCallback<VisibilityTreeProps[\"getHierarchyDefinition\"]>(\n (props) => {\n return new ClassificationsTreeDefinition({ ...props, idsCache: getClassificationsTreeIdsCache(), hierarchyConfig });\n },\n [getClassificationsTreeIdsCache, hierarchyConfig],\n );\n\n const { getPaths, filteringError } = useFilteredPaths({\n hierarchyConfiguration: hierarchyConfig,\n filter,\n getClassificationsTreeIdsCache,\n onFilteredPathsChanged,\n });\n\n return {\n classificationsTreeProps: {\n treeName: ClassificationsTreeComponent.id,\n getHierarchyDefinition,\n visibilityHandlerFactory,\n getFilteredPaths: getPaths,\n emptyTreeContent: useMemo(() => getEmptyTreeContentComponent(filter, filteringError, emptyTreeContent), [filter, filteringError, emptyTreeContent]),\n highlight: useMemo(() => (filter ? { text: filter } : undefined), [filter]),\n },\n rendererProps: {\n getDecorations: useCallback((node) => <ClassificationsTreeIcon node={node} />, []),\n },\n };\n}\n\nfunction createVisibilityHandlerFactory(props: CreateFactoryProps<ClassificationsTreeIdsCache, undefined>): VisibilityTreeProps[\"visibilityHandlerFactory\"] {\n const { activeView, idsCacheGetter } = props;\n return ({ imodelAccess }) => createClassificationsTreeVisibilityHandler({ viewport: activeView, idsCache: idsCacheGetter(), imodelAccess });\n}\n\nfunction createCache(props: CreateCacheProps<{ hierarchyConfig: ClassificationsTreeHierarchyConfiguration }>) {\n return new ClassificationsTreeIdsCache(createECSqlQueryExecutor(props.imodel), props.specificProps.hierarchyConfig);\n}\n\nfunction getEmptyTreeContentComponent(filter?: string, error?: ClassificationsTreeFilteringError, emptyTreeContent?: React.ReactNode) {\n if (error) {\n if (error === \"tooManyFilterMatches\") {\n return <TooManyFilterMatches base={\"classificationsTree\"} />;\n }\n return <FilterUnknownError base={\"classificationsTree\"} />;\n }\n if (filter) {\n return <NoFilterMatches base={\"classificationsTree\"} />;\n }\n if (emptyTreeContent) {\n return emptyTreeContent;\n }\n return <EmptyTreeContent icon={iconBisCategory3d} />;\n}\n\nfunction useClassificationsCachedVisibility(props: { activeView: Viewport; getCache: () => ClassificationsTreeIdsCache }) {\n const { activeView, getCache } = props;\n const { visibilityHandlerFactory, filteredPaths, onFilteredPathsChanged } = useCachedVisibility<ClassificationsTreeIdsCache, undefined>({\n activeView,\n getCache,\n factoryProps: undefined,\n createFactory: createVisibilityHandlerFactory,\n });\n\n useEffect(() => {\n getCache().clearFilteredElementsData();\n }, [filteredPaths, getCache]);\n\n return {\n visibilityHandlerFactory,\n onFilteredPathsChanged,\n };\n}\n"]}
@@ -1,6 +1,7 @@
1
- import type { Id64Array, Id64String } from "@itwin/core-bentley";
2
- import type { CategoryId, ModelId } from "../../common/internal/Types.js";
3
- import type { LimitingECSqlQueryExecutor } from "@itwin/presentation-hierarchies";
1
+ import type { Observable } from "rxjs";
2
+ import type { Id64Arg, Id64Array, Id64String } from "@itwin/core-bentley";
3
+ import type { CategoryId, ElementId, ModelId } from "../../common/internal/Types.js";
4
+ import type { HierarchyNodeIdentifiersPath, LimitingECSqlQueryExecutor } from "@itwin/presentation-hierarchies";
4
5
  import type { ClassificationsTreeHierarchyConfiguration } from "../ClassificationsTreeDefinition.js";
5
6
  /** @internal */
6
7
  export type ClassificationId = Id64String;
@@ -14,14 +15,15 @@ export declare class ClassificationsTreeIdsCache implements Disposable {
14
15
  private _elementModelsCategories;
15
16
  private _modelWithCategoryModeledElements;
16
17
  private _classificationInfos;
18
+ private _filteredElementsData;
17
19
  constructor(_queryExecutor: LimitingECSqlQueryExecutor, _hierarchyConfig: ClassificationsTreeHierarchyConfiguration);
18
20
  [Symbol.dispose](): void;
19
21
  private queryElementModelCategories;
20
22
  private getElementModelsCategories;
21
23
  private queryModeledElements;
22
24
  private getModelWithCategoryModeledElements;
23
- getCategoriesModeledElements(modelId: Id64String, categoryIds: Id64Array): Promise<Id64Array>;
24
- getCategoriesElementModels(categoryIds: Id64Array, includeSubModels?: boolean): Promise<Map<CategoryId, Array<ModelId>>>;
25
+ getCategoriesModeledElements(modelId: Id64String, categoryIds: Id64Arg): Promise<Id64Array>;
26
+ getCategoriesElementModels(categoryIds: Id64Arg, includeSubModels?: boolean): Promise<Map<CategoryId, Set<ModelId>>>;
25
27
  getModelCategoryIds(modelId: Id64String): Promise<{
26
28
  drawing: Id64Array;
27
29
  spatial: Id64Array;
@@ -30,10 +32,21 @@ export declare class ClassificationsTreeIdsCache implements Disposable {
30
32
  getCategoryElementsCount(modelId: Id64String, categoryId: Id64String): Promise<number>;
31
33
  private queryClassifications;
32
34
  private getClassificationsInfo;
33
- getAllContainedCategories(classificationOrTableIds: Id64Array): Promise<{
35
+ getAllContainedCategories(classificationOrTableIds: Id64Arg): Promise<{
34
36
  drawing: Id64Array;
35
37
  spatial: Id64Array;
36
38
  }>;
37
- getDirectChildClassifications(classificationOrTableIds: Id64Array): Promise<ClassificationId[]>;
39
+ getDirectChildClassifications(classificationOrTableIds: Id64Arg): Promise<ClassificationId[]>;
40
+ getClassificationsPathObs(classificationIds: Id64Arg): Observable<HierarchyNodeIdentifiersPath>;
41
+ getAllClassifications(): Promise<ClassificationId[]>;
42
+ private queryFilteredElementsData;
43
+ getFilteredElementsData({ element2dIds, element3dIds, }: {
44
+ element2dIds: Id64Arg;
45
+ element3dIds: Id64Arg;
46
+ }): Promise<Map<ElementId, {
47
+ categoryId: Id64String;
48
+ modelId: Id64String;
49
+ }>>;
50
+ clearFilteredElementsData(): void;
38
51
  }
39
52
  //# sourceMappingURL=ClassificationsTreeIdsCache.d.ts.map
@@ -2,10 +2,11 @@
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 { assert } from "@itwin/core-bentley";
5
+ import { from, map, mergeMap } from "rxjs";
6
+ import { Id64 } from "@itwin/core-bentley";
6
7
  import { CLASS_NAME_Classification, CLASS_NAME_ClassificationSystem, CLASS_NAME_ClassificationTable, CLASS_NAME_DrawingCategory, CLASS_NAME_ElementHasClassifications, CLASS_NAME_GeometricElement2d, CLASS_NAME_GeometricElement3d, CLASS_NAME_SpatialCategory, } from "../../common/internal/ClassNameDefinitions.js";
7
8
  import { ModelCategoryElementsCountCache } from "../../common/internal/ModelCategoryElementsCountCache.js";
8
- import { getDistinctMapValues } from "../../common/internal/Utils.js";
9
+ import { getDistinctMapValues, joinId64Arg } from "../../common/internal/Utils.js";
9
10
  /** @internal */
10
11
  export class ClassificationsTreeIdsCache {
11
12
  _queryExecutor;
@@ -14,6 +15,7 @@ export class ClassificationsTreeIdsCache {
14
15
  _elementModelsCategories;
15
16
  _modelWithCategoryModeledElements;
16
17
  _classificationInfos;
18
+ _filteredElementsData;
17
19
  constructor(_queryExecutor, _hierarchyConfig) {
18
20
  this._queryExecutor = _queryExecutor;
19
21
  this._hierarchyConfig = _hierarchyConfig;
@@ -124,7 +126,7 @@ export class ClassificationsTreeIdsCache {
124
126
  async getCategoriesModeledElements(modelId, categoryIds) {
125
127
  const modelWithCategoryModeledElements = await this.getModelWithCategoryModeledElements();
126
128
  const result = new Array();
127
- for (const categoryId of categoryIds) {
129
+ for (const categoryId of Id64.iterable(categoryIds)) {
128
130
  const entry = modelWithCategoryModeledElements.get(`${modelId}-${categoryId}`);
129
131
  if (entry !== undefined) {
130
132
  result.push(...entry);
@@ -135,15 +137,15 @@ export class ClassificationsTreeIdsCache {
135
137
  async getCategoriesElementModels(categoryIds, includeSubModels) {
136
138
  const elementModelsCategories = await this.getElementModelsCategories();
137
139
  const result = new Map();
138
- for (const categoryId of categoryIds) {
140
+ for (const categoryId of Id64.iterable(categoryIds)) {
139
141
  for (const [modelId, { category2dIds, category3dIds, isSubModel }] of elementModelsCategories) {
140
142
  if ((includeSubModels || !isSubModel) && (category2dIds.has(categoryId) || category3dIds.has(categoryId))) {
141
143
  let categoryModels = result.get(categoryId);
142
144
  if (!categoryModels) {
143
- categoryModels = new Array();
145
+ categoryModels = new Set();
144
146
  result.set(categoryId, categoryModels);
145
147
  }
146
- categoryModels.push(modelId);
148
+ categoryModels.add(modelId);
147
149
  }
148
150
  }
149
151
  }
@@ -233,14 +235,20 @@ export class ClassificationsTreeIdsCache {
233
235
  const classificationInfos = new Map();
234
236
  for await (const { id, tableId, parentId, relatedCategories2d, relatedCategories3d } of this.queryClassifications()) {
235
237
  const tableOrParentId = tableId ?? parentId;
236
- assert(!!tableOrParentId);
237
238
  let parentInfo = classificationInfos.get(tableOrParentId);
238
239
  if (!parentInfo) {
239
- parentInfo = { childClassificationIds: [], relatedCategories2d: [], relatedCategories3d: [] };
240
+ parentInfo = { childClassificationIds: [], relatedCategories2d: [], relatedCategories3d: [], parentClassificationOrTableId: undefined };
240
241
  classificationInfos.set(tableOrParentId, parentInfo);
241
242
  }
242
243
  parentInfo.childClassificationIds.push(id);
243
- classificationInfos.set(id, { childClassificationIds: [], relatedCategories2d, relatedCategories3d });
244
+ let classificationEntry = classificationInfos.get(id);
245
+ if (!classificationEntry) {
246
+ classificationEntry = { childClassificationIds: [], relatedCategories2d, relatedCategories3d, parentClassificationOrTableId: tableOrParentId };
247
+ classificationInfos.set(id, classificationEntry);
248
+ }
249
+ else {
250
+ classificationEntry.parentClassificationOrTableId = tableOrParentId;
251
+ }
244
252
  }
245
253
  return classificationInfos;
246
254
  })();
@@ -248,35 +256,103 @@ export class ClassificationsTreeIdsCache {
248
256
  }
249
257
  async getAllContainedCategories(classificationOrTableIds) {
250
258
  const result = { drawing: new Array(), spatial: new Array() };
251
- if (classificationOrTableIds.length === 0) {
259
+ if (Id64.sizeOf(classificationOrTableIds) === 0) {
252
260
  return result;
253
261
  }
254
262
  const classificationsInfo = await this.getClassificationsInfo();
255
- await Promise.all(classificationOrTableIds.map(async (classificationOrTableId) => {
263
+ const promises = new Array();
264
+ for (const classificationOrTableId of Id64.iterable(classificationOrTableIds)) {
256
265
  const classificationInfo = classificationsInfo.get(classificationOrTableId);
257
266
  if (classificationInfo === undefined) {
258
- return;
267
+ continue;
259
268
  }
260
- const childClassificationsResult = await this.getAllContainedCategories(classificationInfo.childClassificationIds);
261
- result.drawing.push(...classificationInfo.relatedCategories2d, ...childClassificationsResult.drawing);
262
- result.spatial.push(...classificationInfo.relatedCategories3d, ...childClassificationsResult.spatial);
263
- }));
269
+ result.drawing.push(...classificationInfo.relatedCategories2d);
270
+ result.spatial.push(...classificationInfo.relatedCategories3d);
271
+ promises.push(this.getAllContainedCategories(classificationInfo.childClassificationIds));
272
+ }
273
+ const promisesResult = await Promise.all(promises);
274
+ for (const { drawing, spatial } of promisesResult) {
275
+ result.drawing.push(...drawing);
276
+ result.spatial.push(...spatial);
277
+ }
264
278
  return result;
265
279
  }
266
280
  async getDirectChildClassifications(classificationOrTableIds) {
267
281
  const result = new Array();
268
- if (classificationOrTableIds.length === 0) {
282
+ if (Id64.sizeOf(classificationOrTableIds) === 0) {
269
283
  return result;
270
284
  }
271
285
  const classificationsInfo = await this.getClassificationsInfo();
272
- await Promise.all(classificationOrTableIds.map(async (classificationOrTableId) => {
286
+ for (const classificationOrTableId of Id64.iterable(classificationOrTableIds)) {
273
287
  const classificationInfo = classificationsInfo.get(classificationOrTableId);
274
288
  if (classificationInfo === undefined) {
275
- return;
289
+ continue;
276
290
  }
277
291
  result.push(...classificationInfo.childClassificationIds);
278
- }));
292
+ }
279
293
  return result;
280
294
  }
295
+ getClassificationsPathObs(classificationIds) {
296
+ return from(this.getClassificationsInfo()).pipe(mergeMap((classificationsInfo) => {
297
+ return from(Id64.iterable(classificationIds)).pipe(map((classificationId) => {
298
+ const path = [{ id: classificationId, className: CLASS_NAME_Classification }];
299
+ let parentId = classificationsInfo.get(classificationId)?.parentClassificationOrTableId;
300
+ while (parentId !== undefined) {
301
+ const parentIdOfParent = classificationsInfo.get(parentId)?.parentClassificationOrTableId;
302
+ if (parentIdOfParent) {
303
+ path.push({ className: CLASS_NAME_Classification, id: parentId });
304
+ }
305
+ else {
306
+ path.push({ className: CLASS_NAME_ClassificationTable, id: parentId });
307
+ }
308
+ parentId = parentIdOfParent;
309
+ }
310
+ return path.reverse();
311
+ }));
312
+ }));
313
+ }
314
+ async getAllClassifications() {
315
+ const classificationsInfo = await this.getClassificationsInfo();
316
+ return [...classificationsInfo.keys()];
317
+ }
318
+ async *queryFilteredElementsData({ element2dIds, element3dIds }) {
319
+ const queries = new Array();
320
+ if (Id64.sizeOf(element2dIds) > 0) {
321
+ queries.push(`
322
+ SELECT Model.Id modelId, Category.Id categoryId, ECInstanceId id
323
+ FROM ${CLASS_NAME_GeometricElement2d}
324
+ WHERE ECInstanceId IN (${joinId64Arg(element2dIds, ",")})
325
+ `);
326
+ }
327
+ if (Id64.sizeOf(element3dIds) > 0) {
328
+ queries.push(`
329
+ SELECT Model.Id modelId, Category.Id categoryId, ECInstanceId id
330
+ FROM ${CLASS_NAME_GeometricElement3d}
331
+ WHERE ECInstanceId IN (${joinId64Arg(element3dIds, ",")})
332
+ `);
333
+ }
334
+ for await (const row of this._queryExecutor.createQueryReader({ ecsql: queries.join(" UNION ALL ") }, { rowFormat: "ECSqlPropertyNames", limit: "unbounded" })) {
335
+ yield { modelId: row.modelId, id: row.id, categoryId: row.categoryId };
336
+ }
337
+ }
338
+ async getFilteredElementsData({ element2dIds, element3dIds, }) {
339
+ if (Id64.sizeOf(element2dIds) === 0 && Id64.sizeOf(element3dIds) === 0) {
340
+ return new Map();
341
+ }
342
+ this._filteredElementsData ??= (async () => {
343
+ const filteredElementsData = new Map();
344
+ for await (const { modelId, id, categoryId } of this.queryFilteredElementsData({
345
+ element2dIds,
346
+ element3dIds,
347
+ })) {
348
+ filteredElementsData.set(id, { modelId, categoryId });
349
+ }
350
+ return filteredElementsData;
351
+ })();
352
+ return this._filteredElementsData;
353
+ }
354
+ clearFilteredElementsData() {
355
+ this._filteredElementsData = undefined;
356
+ }
281
357
  }
282
358
  //# sourceMappingURL=ClassificationsTreeIdsCache.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ClassificationsTreeIdsCache.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeIdsCache.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EACL,yBAAyB,EACzB,+BAA+B,EAC/B,8BAA8B,EAC9B,0BAA0B,EAC1B,oCAAoC,EACpC,6BAA6B,EAC7B,6BAA6B,EAC7B,0BAA0B,GAC3B,MAAM,+CAA+C,CAAC;AACvD,OAAO,EAAE,+BAA+B,EAAE,MAAM,0DAA0D,CAAC;AAC3G,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAmBtE,gBAAgB;AAChB,MAAM,OAAO,2BAA2B;IAO5B;IACA;IAPO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AC,CACH,CAAC;QACF,OAAO,MAAM,CAAC;IAChB,CAAC;IAEM,KAAK,CAAC,6BAA6B,CAAC,wBAAmC;QAC5E,MAAM,MAAM,GAAG,IAAI,KAAK,EAAoB,CAAC;QAC7C,IAAI,wBAAwB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC1C,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,MAAM,mBAAmB,GAAG,MAAM,IAAI,CAAC,sBAAsB,EAAE,CAAC;QAChE,MAAM,OAAO,CAAC,GAAG,CACf,wBAAwB,CAAC,GAAG,CAAC,KAAK,EAAE,uBAAuB,EAAE,EAAE;YAC7D,MAAM,kBAAkB,GAAG,mBAAmB,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;YAC5E,IAAI,kBAAkB,KAAK,SAAS,EAAE,CAAC;gBACrC,OAAO;YACT,CAAC;YACD,MAAM,CAAC,IAAI,CAAC,GAAG,kBAAkB,CAAC,sBAAsB,CAAC,CAAC;QAC5D,CAAC,CAAC,CACH,CAAC;QACF,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { assert } from \"@itwin/core-bentley\";\nimport {\n CLASS_NAME_Classification,\n CLASS_NAME_ClassificationSystem,\n CLASS_NAME_ClassificationTable,\n CLASS_NAME_DrawingCategory,\n CLASS_NAME_ElementHasClassifications,\n CLASS_NAME_GeometricElement2d,\n CLASS_NAME_GeometricElement3d,\n CLASS_NAME_SpatialCategory,\n} from \"../../common/internal/ClassNameDefinitions.js\";\nimport { ModelCategoryElementsCountCache } from \"../../common/internal/ModelCategoryElementsCountCache.js\";\nimport { getDistinctMapValues } from \"../../common/internal/Utils.js\";\n\nimport type { Id64Array, Id64Set, Id64String } from \"@itwin/core-bentley\";\nimport type { CategoryId, ElementId, ModelId } from \"../../common/internal/Types.js\";\nimport type { LimitingECSqlQueryExecutor } from \"@itwin/presentation-hierarchies\";\nimport type { ClassificationsTreeHierarchyConfiguration } from \"../ClassificationsTreeDefinition.js\";\n/** @internal */\nexport type ClassificationId = Id64String;\n/** @internal */\nexport type ClassificationTableId = Id64String;\n\ninterface ClassificationInfo {\n childClassificationIds: ClassificationId[];\n relatedCategories2d: CategoryId[];\n relatedCategories3d: CategoryId[];\n}\n\ntype ModelCategoryKey = `${ModelId}-${CategoryId}`;\n\n/** @internal */\nexport class ClassificationsTreeIdsCache implements Disposable {\n private readonly _categoryElementCounts: ModelCategoryElementsCountCache;\n private _elementModelsCategories: Promise<Map<ModelId, { category2dIds: Id64Set; category3dIds: Id64Set; isSubModel: boolean }>> | undefined;\n private _modelWithCategoryModeledElements: Promise<Map<ModelCategoryKey, Set<ElementId>>> | undefined;\n private _classificationInfos: Promise<Map<ClassificationId | ClassificationTableId, ClassificationInfo>> | undefined;\n\n constructor(\n private _queryExecutor: LimitingECSqlQueryExecutor,\n private _hierarchyConfig: ClassificationsTreeHierarchyConfiguration,\n ) {\n this._categoryElementCounts = new ModelCategoryElementsCountCache(_queryExecutor, [\"BisCore.GeometricElement2d\", \"BisCore.GeometricElement3d\"]);\n }\n\n public [Symbol.dispose]() {\n this._categoryElementCounts[Symbol.dispose]();\n }\n\n private async *queryElementModelCategories(): AsyncIterableIterator<{\n modelId: Id64String;\n categoryId: Id64String;\n type: \"2d\" | \"3d\";\n }> {\n const query = `\n SELECT * FROM (\n SELECT '3d' type, this.Model.Id modelId, this.Category.Id categoryId\n FROM BisCore.GeometricModel m\n JOIN BisCore.GeometricElement3d this ON m.ECInstanceId = this.Model.Id\n WHERE this.Parent.Id IS NULL AND m.IsPrivate = false\n GROUP BY modelId, categoryId\n )\n UNION ALL\n SELECT * FROM (\n SELECT '2d' type, this.Model.Id modelId, this.Category.Id categoryId\n FROM BisCore.GeometricModel m\n JOIN BisCore.GeometricElement2d this ON m.ECInstanceId = this.Model.Id\n WHERE this.Parent.Id IS NULL AND m.IsPrivate = false\n GROUP BY modelId, categoryId\n )\n `;\n for await (const row of this._queryExecutor.createQueryReader(\n { ecsql: query },\n { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\", restartToken: \"tree-widget/classifications-tree/element-models-and-categories-query\" },\n )) {\n yield { modelId: row.modelId, categoryId: row.categoryId, type: row.type };\n }\n }\n\n private async getElementModelsCategories() {\n this._elementModelsCategories ??= (async () => {\n const [modelCategories, modelWithCategoryModeledElements] = await Promise.all([\n (async () => {\n const elementModelsCategories = new Map<ModelId, { category2dIds: Id64Set; category3dIds: Id64Set }>();\n for await (const queriedCategory of this.queryElementModelCategories()) {\n let modelEntry = elementModelsCategories.get(queriedCategory.modelId);\n if (modelEntry === undefined) {\n modelEntry = { category2dIds: new Set(), category3dIds: new Set() };\n elementModelsCategories.set(queriedCategory.modelId, modelEntry);\n }\n switch (queriedCategory.type) {\n case \"2d\":\n modelEntry.category2dIds.add(queriedCategory.categoryId);\n break;\n case \"3d\":\n modelEntry.category3dIds.add(queriedCategory.categoryId);\n break;\n }\n }\n return elementModelsCategories;\n })(),\n this.getModelWithCategoryModeledElements(),\n ]);\n const result = new Map<ModelId, { category2dIds: Id64Set; category3dIds: Id64Set; isSubModel: boolean }>();\n const subModels = getDistinctMapValues(modelWithCategoryModeledElements);\n for (const [modelId, modelEntry] of modelCategories) {\n const isSubModel = subModels.has(modelId);\n result.set(modelId, { category2dIds: modelEntry.category2dIds, category3dIds: modelEntry.category3dIds, isSubModel });\n }\n return result;\n })();\n return this._elementModelsCategories;\n }\n\n private async *queryModeledElements(): AsyncIterableIterator<{\n modelId: Id64String;\n modeledElementId: Id64String;\n categoryId: Id64String;\n rootCategoryId: Id64String;\n }> {\n const query = `\n SELECT\n pe.ECInstanceId modeledElementId,\n pe.Category.Id categoryId,\n pe.Model.Id modelId\n FROM BisCore.GeometricModel m\n JOIN BisCore.GeometricElement3d pe ON pe.ECInstanceId = m.ModeledElement.Id\n WHERE\n m.IsPrivate = false\n AND m.ECInstanceId IN (SELECT Model.Id FROM BisCore.Element)\n UNION ALL\n SELECT\n pe.ECInstanceId modeledElementId,\n pe.Category.Id categoryId,\n pe.Model.Id modelId\n FROM BisCore.GeometricModel m\n JOIN BisCore.GeometricElement2d pe ON pe.ECInstanceId = m.ModeledElement.Id\n WHERE\n m.IsPrivate = false\n AND m.ECInstanceId IN (SELECT Model.Id FROM BisCore.Element)\n `;\n for await (const row of this._queryExecutor.createQueryReader(\n { ecsql: query },\n { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\", restartToken: \"tree-widget/classifications-tree/modeled-elements-query\" },\n )) {\n yield { modelId: row.modelId, categoryId: row.categoryId, modeledElementId: row.modeledElementId, rootCategoryId: row.rootCategoryId };\n }\n }\n\n private async getModelWithCategoryModeledElements() {\n this._modelWithCategoryModeledElements ??= (async () => {\n const modelWithCategoryModeledElements = new Map<ModelCategoryKey, Set<ElementId>>();\n for await (const { modelId, categoryId, modeledElementId } of this.queryModeledElements()) {\n const key: ModelCategoryKey = `${modelId}-${categoryId}`;\n const entry = modelWithCategoryModeledElements.get(key);\n if (entry === undefined) {\n modelWithCategoryModeledElements.set(key, new Set([modeledElementId]));\n } else {\n entry.add(modeledElementId);\n }\n }\n return modelWithCategoryModeledElements;\n })();\n return this._modelWithCategoryModeledElements;\n }\n\n public async getCategoriesModeledElements(modelId: Id64String, categoryIds: Id64Array): Promise<Id64Array> {\n const modelWithCategoryModeledElements = await this.getModelWithCategoryModeledElements();\n const result = new Array<ElementId>();\n for (const categoryId of categoryIds) {\n const entry = modelWithCategoryModeledElements.get(`${modelId}-${categoryId}`);\n if (entry !== undefined) {\n result.push(...entry);\n }\n }\n return result;\n }\n\n public async getCategoriesElementModels(categoryIds: Id64Array, includeSubModels?: boolean): Promise<Map<CategoryId, Array<ModelId>>> {\n const elementModelsCategories = await this.getElementModelsCategories();\n const result = new Map<CategoryId, Array<ModelId>>();\n for (const categoryId of categoryIds) {\n for (const [modelId, { category2dIds, category3dIds, isSubModel }] of elementModelsCategories) {\n if ((includeSubModels || !isSubModel) && (category2dIds.has(categoryId) || category3dIds.has(categoryId))) {\n let categoryModels = result.get(categoryId);\n if (!categoryModels) {\n categoryModels = new Array<ModelId>();\n result.set(categoryId, categoryModels);\n }\n categoryModels.push(modelId);\n }\n }\n }\n return result;\n }\n\n public async getModelCategoryIds(modelId: Id64String): Promise<{ drawing: Id64Array; spatial: Id64Array }> {\n const elementModelsCategories = await this.getElementModelsCategories();\n return {\n drawing: Array.from(elementModelsCategories.get(modelId)?.category2dIds ?? []),\n spatial: Array.from(elementModelsCategories.get(modelId)?.category3dIds ?? []),\n };\n }\n\n public async hasSubModel(elementId: Id64String): Promise<boolean> {\n const elementModelsCategories = await this.getElementModelsCategories();\n return elementModelsCategories.has(elementId);\n }\n\n public async getCategoryElementsCount(modelId: Id64String, categoryId: Id64String): Promise<number> {\n return this._categoryElementCounts.getCategoryElementsCount(modelId, categoryId);\n }\n\n private async *queryClassifications(): AsyncIterableIterator<{\n id: Id64String;\n tableId?: ClassificationTableId;\n parentId?: ClassificationId;\n relatedCategories2d: CategoryId[];\n relatedCategories3d: CategoryId[];\n }> {\n const CLASSIFICATIONS_CTE = \"Classifications\";\n const ctes = [\n `\n ${CLASSIFICATIONS_CTE}(ClassificationId, ClassificationTableId, ParentClassificationId) AS (\n SELECT\n cl.ECInstanceId,\n ct.ECInstanceId,\n NULL\n FROM ${CLASS_NAME_Classification} cl\n JOIN ${CLASS_NAME_ClassificationTable} ct ON ct.ECInstanceId = cl.Model.Id\n JOIN ${CLASS_NAME_ClassificationSystem} cs ON cs.ECInstanceId = ct.Parent.Id\n WHERE\n cs.CodeValue = '${this._hierarchyConfig.rootClassificationSystemCode}'\n AND NOT ct.IsPrivate\n AND NOT cl.IsPrivate\n AND cl.Parent.Id IS NULL\n\n UNION ALL\n\n SELECT\n cl.ECInstanceId,\n NULL,\n cl.Parent.Id\n FROM\n ${CLASSIFICATIONS_CTE} cte\n JOIN ${CLASS_NAME_Classification} cl ON cl.Parent.Id = cte.ClassificationId\n WHERE\n NOT cl.IsPrivate\n )\n `,\n ];\n const ecsql = `\n SELECT\n cl.ClassificationId id,\n cl.ClassificationTableId tableId,\n cl.ParentClassificationId parentId,\n (\n SELECT group_concat(IdToHex(cat.ECInstanceId))\n FROM ${CLASS_NAME_GeometricElement2d} e\n JOIN ${CLASS_NAME_DrawingCategory} cat ON cat.ECInstanceId = e.Category.Id\n JOIN ${CLASS_NAME_ElementHasClassifications} ehc ON ehc.SourceECInstanceId = e.ECInstanceId\n WHERE e.Parent.Id IS NULL AND NOT cat.IsPrivate AND ehc.TargetECInstanceId = cl.ClassificationId\n GROUP BY ehc.TargetECInstanceId\n ) relatedCategories2d,\n (\n SELECT group_concat(IdToHex(cat.ECInstanceId))\n FROM ${CLASS_NAME_GeometricElement3d} e\n JOIN ${CLASS_NAME_SpatialCategory} cat ON cat.ECInstanceId = e.Category.Id\n JOIN ${CLASS_NAME_ElementHasClassifications} ehc ON ehc.SourceECInstanceId = e.ECInstanceId\n WHERE e.Parent.Id IS NULL AND NOT cat.IsPrivate AND ehc.TargetECInstanceId = cl.ClassificationId\n GROUP BY ehc.TargetECInstanceId\n ) relatedCategories3d\n FROM ${CLASSIFICATIONS_CTE} cl\n `;\n for await (const row of this._queryExecutor.createQueryReader(\n { ctes, ecsql },\n { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\", restartToken: \"tree-widget/classifications-tree/classifications-query\" },\n )) {\n yield {\n id: row.id,\n tableId: row.tableId,\n parentId: row.parentId,\n relatedCategories2d: row.relatedCategories2d ? (row.relatedCategories2d as string).split(\",\") : [],\n relatedCategories3d: row.relatedCategories3d ? (row.relatedCategories3d as string).split(\",\") : [],\n };\n }\n }\n\n private async getClassificationsInfo() {\n this._classificationInfos ??= (async () => {\n const classificationInfos = new Map<ClassificationId | ClassificationTableId, ClassificationInfo>();\n for await (const { id, tableId, parentId, relatedCategories2d, relatedCategories3d } of this.queryClassifications()) {\n const tableOrParentId = tableId ?? parentId;\n assert(!!tableOrParentId);\n let parentInfo = classificationInfos.get(tableOrParentId);\n if (!parentInfo) {\n parentInfo = { childClassificationIds: [], relatedCategories2d: [], relatedCategories3d: [] };\n classificationInfos.set(tableOrParentId, parentInfo);\n }\n parentInfo.childClassificationIds.push(id);\n\n classificationInfos.set(id, { childClassificationIds: [], relatedCategories2d, relatedCategories3d });\n }\n return classificationInfos;\n })();\n return this._classificationInfos;\n }\n\n public async getAllContainedCategories(classificationOrTableIds: Id64Array): Promise<{ drawing: Id64Array; spatial: Id64Array }> {\n const result = { drawing: new Array<CategoryId>(), spatial: new Array<CategoryId>() };\n if (classificationOrTableIds.length === 0) {\n return result;\n }\n const classificationsInfo = await this.getClassificationsInfo();\n await Promise.all(\n classificationOrTableIds.map(async (classificationOrTableId) => {\n const classificationInfo = classificationsInfo.get(classificationOrTableId);\n if (classificationInfo === undefined) {\n return;\n }\n const childClassificationsResult = await this.getAllContainedCategories(classificationInfo.childClassificationIds);\n result.drawing.push(...classificationInfo.relatedCategories2d, ...childClassificationsResult.drawing);\n result.spatial.push(...classificationInfo.relatedCategories3d, ...childClassificationsResult.spatial);\n }),\n );\n return result;\n }\n\n public async getDirectChildClassifications(classificationOrTableIds: Id64Array): Promise<ClassificationId[]> {\n const result = new Array<ClassificationId>();\n if (classificationOrTableIds.length === 0) {\n return result;\n }\n const classificationsInfo = await this.getClassificationsInfo();\n await Promise.all(\n classificationOrTableIds.map(async (classificationOrTableId) => {\n const classificationInfo = classificationsInfo.get(classificationOrTableId);\n if (classificationInfo === undefined) {\n return;\n }\n result.push(...classificationInfo.childClassificationIds);\n }),\n );\n return result;\n }\n}\n"]}
1
+ {"version":3,"file":"ClassificationsTreeIdsCache.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeIdsCache.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,IAAI,EAAE,GAAG,E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AAU,EAAE,GAAG,CAAC,UAAU,EAAE,CAAC;QACzE,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,uBAAuB,CAAC,EACnC,YAAY,EACZ,YAAY,GAIb;QACC,IAAI,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;YACvE,OAAO,IAAI,GAAG,EAAE,CAAC;QACnB,CAAC;QAED,IAAI,CAAC,qBAAqB,KAAK,CAAC,KAAK,IAAI,EAAE;YACzC,MAAM,oBAAoB,GAAG,IAAI,GAAG,EAAE,CAAC;YACvC,IAAI,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,IAAI,CAAC,yBAAyB,CAAC;gBAC7E,YAAY;gBACZ,YAAY;aACb,CAAC,EAAE,CAAC;gBACH,oBAAoB,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC;YACxD,CAAC;YACD,OAAO,oBAAoB,CAAC;QAC9B,CAAC,CAAC,EAAE,CAAC;QACL,OAAO,IAAI,CAAC,qBAAqB,CAAC;IACpC,CAAC;IAEM,yBAAyB;QAC9B,IAAI,CAAC,qBAAqB,GAAG,SAAS,CAAC;IACzC,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { from, map, mergeMap } from \"rxjs\";\nimport { Id64 } from \"@itwin/core-bentley\";\nimport {\n CLASS_NAME_Classification,\n CLASS_NAME_ClassificationSystem,\n CLASS_NAME_ClassificationTable,\n CLASS_NAME_DrawingCategory,\n CLASS_NAME_ElementHasClassifications,\n CLASS_NAME_GeometricElement2d,\n CLASS_NAME_GeometricElement3d,\n CLASS_NAME_SpatialCategory,\n} from \"../../common/internal/ClassNameDefinitions.js\";\nimport { ModelCategoryElementsCountCache } from \"../../common/internal/ModelCategoryElementsCountCache.js\";\nimport { getDistinctMapValues, joinId64Arg } from \"../../common/internal/Utils.js\";\n\nimport type { Observable } from \"rxjs\";\nimport type { Id64Arg, Id64Array, Id64Set, Id64String } from \"@itwin/core-bentley\";\nimport type { CategoryId, ElementId, ModelId } from \"../../common/internal/Types.js\";\nimport type { HierarchyNodeIdentifiersPath, LimitingECSqlQueryExecutor } from \"@itwin/presentation-hierarchies\";\nimport type { ClassificationsTreeHierarchyConfiguration } from \"../ClassificationsTreeDefinition.js\";\n\n/** @internal */\nexport type ClassificationId = Id64String;\n/** @internal */\nexport type ClassificationTableId = Id64String;\n\ninterface ClassificationInfo {\n parentClassificationOrTableId: ClassificationId | ClassificationTableId | undefined;\n childClassificationIds: ClassificationId[];\n relatedCategories2d: CategoryId[];\n relatedCategories3d: CategoryId[];\n}\n\ntype ModelCategoryKey = `${ModelId}-${CategoryId}`;\n\n/** @internal */\nexport class ClassificationsTreeIdsCache implements Disposable {\n private readonly _categoryElementCounts: ModelCategoryElementsCountCache;\n private _elementModelsCategories: Promise<Map<ModelId, { category2dIds: Id64Set; category3dIds: Id64Set; isSubModel: boolean }>> | undefined;\n private _modelWithCategoryModeledElements: Promise<Map<ModelCategoryKey, Set<ElementId>>> | undefined;\n private _classificationInfos: Promise<Map<ClassificationId | ClassificationTableId, ClassificationInfo>> | undefined;\n private _filteredElementsData: Promise<Map<ElementId, { modelId: Id64String; categoryId: Id64String }>> | undefined;\n\n constructor(\n private _queryExecutor: LimitingECSqlQueryExecutor,\n private _hierarchyConfig: ClassificationsTreeHierarchyConfiguration,\n ) {\n this._categoryElementCounts = new ModelCategoryElementsCountCache(_queryExecutor, [\"BisCore.GeometricElement2d\", \"BisCore.GeometricElement3d\"]);\n }\n\n public [Symbol.dispose]() {\n this._categoryElementCounts[Symbol.dispose]();\n }\n\n private async *queryElementModelCategories(): AsyncIterableIterator<{\n modelId: Id64String;\n categoryId: Id64String;\n type: \"2d\" | \"3d\";\n }> {\n const query = `\n SELECT * FROM (\n SELECT '3d' type, this.Model.Id modelId, this.Category.Id categoryId\n FROM BisCore.GeometricModel m\n JOIN BisCore.GeometricElement3d this ON m.ECInstanceId = this.Model.Id\n WHERE this.Parent.Id IS NULL AND m.IsPrivate = false\n GROUP BY modelId, categoryId\n )\n UNION ALL\n SELECT * FROM (\n SELECT '2d' type, this.Model.Id modelId, this.Category.Id categoryId\n FROM BisCore.GeometricModel m\n JOIN BisCore.GeometricElement2d this ON m.ECInstanceId = this.Model.Id\n WHERE this.Parent.Id IS NULL AND m.IsPrivate = false\n GROUP BY modelId, categoryId\n )\n `;\n for await (const row of this._queryExecutor.createQueryReader(\n { ecsql: query },\n { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\", restartToken: \"tree-widget/classifications-tree/element-models-and-categories-query\" },\n )) {\n yield { modelId: row.modelId, categoryId: row.categoryId, type: row.type };\n }\n }\n\n private async getElementModelsCategories() {\n this._elementModelsCategories ??= (async () => {\n const [modelCategories, modelWithCategoryModeledElements] = await Promise.all([\n (async () => {\n const elementModelsCategories = new Map<ModelId, { category2dIds: Id64Set; category3dIds: Id64Set }>();\n for await (const queriedCategory of this.queryElementModelCategories()) {\n let modelEntry = elementModelsCategories.get(queriedCategory.modelId);\n if (modelEntry === undefined) {\n modelEntry = { category2dIds: new Set(), category3dIds: new Set() };\n elementModelsCategories.set(queriedCategory.modelId, modelEntry);\n }\n switch (queriedCategory.type) {\n case \"2d\":\n modelEntry.category2dIds.add(queriedCategory.categoryId);\n break;\n case \"3d\":\n modelEntry.category3dIds.add(queriedCategory.categoryId);\n break;\n }\n }\n return elementModelsCategories;\n })(),\n this.getModelWithCategoryModeledElements(),\n ]);\n const result = new Map<ModelId, { category2dIds: Id64Set; category3dIds: Id64Set; isSubModel: boolean }>();\n const subModels = getDistinctMapValues(modelWithCategoryModeledElements);\n for (const [modelId, modelEntry] of modelCategories) {\n const isSubModel = subModels.has(modelId);\n result.set(modelId, { category2dIds: modelEntry.category2dIds, category3dIds: modelEntry.category3dIds, isSubModel });\n }\n return result;\n })();\n return this._elementModelsCategories;\n }\n\n private async *queryModeledElements(): AsyncIterableIterator<{\n modelId: Id64String;\n modeledElementId: Id64String;\n categoryId: Id64String;\n rootCategoryId: Id64String;\n }> {\n const query = `\n SELECT\n pe.ECInstanceId modeledElementId,\n pe.Category.Id categoryId,\n pe.Model.Id modelId\n FROM BisCore.GeometricModel m\n JOIN BisCore.GeometricElement3d pe ON pe.ECInstanceId = m.ModeledElement.Id\n WHERE\n m.IsPrivate = false\n AND m.ECInstanceId IN (SELECT Model.Id FROM BisCore.Element)\n UNION ALL\n SELECT\n pe.ECInstanceId modeledElementId,\n pe.Category.Id categoryId,\n pe.Model.Id modelId\n FROM BisCore.GeometricModel m\n JOIN BisCore.GeometricElement2d pe ON pe.ECInstanceId = m.ModeledElement.Id\n WHERE\n m.IsPrivate = false\n AND m.ECInstanceId IN (SELECT Model.Id FROM BisCore.Element)\n `;\n for await (const row of this._queryExecutor.createQueryReader(\n { ecsql: query },\n { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\", restartToken: \"tree-widget/classifications-tree/modeled-elements-query\" },\n )) {\n yield { modelId: row.modelId, categoryId: row.categoryId, modeledElementId: row.modeledElementId, rootCategoryId: row.rootCategoryId };\n }\n }\n\n private async getModelWithCategoryModeledElements() {\n this._modelWithCategoryModeledElements ??= (async () => {\n const modelWithCategoryModeledElements = new Map<ModelCategoryKey, Set<ElementId>>();\n for await (const { modelId, categoryId, modeledElementId } of this.queryModeledElements()) {\n const key: ModelCategoryKey = `${modelId}-${categoryId}`;\n const entry = modelWithCategoryModeledElements.get(key);\n if (entry === undefined) {\n modelWithCategoryModeledElements.set(key, new Set([modeledElementId]));\n } else {\n entry.add(modeledElementId);\n }\n }\n return modelWithCategoryModeledElements;\n })();\n return this._modelWithCategoryModeledElements;\n }\n\n public async getCategoriesModeledElements(modelId: Id64String, categoryIds: Id64Arg): Promise<Id64Array> {\n const modelWithCategoryModeledElements = await this.getModelWithCategoryModeledElements();\n const result = new Array<ElementId>();\n for (const categoryId of Id64.iterable(categoryIds)) {\n const entry = modelWithCategoryModeledElements.get(`${modelId}-${categoryId}`);\n if (entry !== undefined) {\n result.push(...entry);\n }\n }\n return result;\n }\n\n public async getCategoriesElementModels(categoryIds: Id64Arg, includeSubModels?: boolean): Promise<Map<CategoryId, Set<ModelId>>> {\n const elementModelsCategories = await this.getElementModelsCategories();\n const result = new Map<CategoryId, Set<ModelId>>();\n for (const categoryId of Id64.iterable(categoryIds)) {\n for (const [modelId, { category2dIds, category3dIds, isSubModel }] of elementModelsCategories) {\n if ((includeSubModels || !isSubModel) && (category2dIds.has(categoryId) || category3dIds.has(categoryId))) {\n let categoryModels = result.get(categoryId);\n if (!categoryModels) {\n categoryModels = new Set<ModelId>();\n result.set(categoryId, categoryModels);\n }\n categoryModels.add(modelId);\n }\n }\n }\n return result;\n }\n\n public async getModelCategoryIds(modelId: Id64String): Promise<{ drawing: Id64Array; spatial: Id64Array }> {\n const elementModelsCategories = await this.getElementModelsCategories();\n return {\n drawing: Array.from(elementModelsCategories.get(modelId)?.category2dIds ?? []),\n spatial: Array.from(elementModelsCategories.get(modelId)?.category3dIds ?? []),\n };\n }\n\n public async hasSubModel(elementId: Id64String): Promise<boolean> {\n const elementModelsCategories = await this.getElementModelsCategories();\n return elementModelsCategories.has(elementId);\n }\n\n public async getCategoryElementsCount(modelId: Id64String, categoryId: Id64String): Promise<number> {\n return this._categoryElementCounts.getCategoryElementsCount(modelId, categoryId);\n }\n\n private async *queryClassifications(): AsyncIterableIterator<\n {\n id: Id64String;\n relatedCategories2d: CategoryId[];\n relatedCategories3d: CategoryId[];\n } & ({ tableId: ClassificationTableId; parentId: undefined } | { tableId: undefined; parentId: ClassificationId })\n > {\n const CLASSIFICATIONS_CTE = \"Classifications\";\n const ctes = [\n `\n ${CLASSIFICATIONS_CTE}(ClassificationId, ClassificationTableId, ParentClassificationId) AS (\n SELECT\n cl.ECInstanceId,\n ct.ECInstanceId,\n NULL\n FROM ${CLASS_NAME_Classification} cl\n JOIN ${CLASS_NAME_ClassificationTable} ct ON ct.ECInstanceId = cl.Model.Id\n JOIN ${CLASS_NAME_ClassificationSystem} cs ON cs.ECInstanceId = ct.Parent.Id\n WHERE\n cs.CodeValue = '${this._hierarchyConfig.rootClassificationSystemCode}'\n AND NOT ct.IsPrivate\n AND NOT cl.IsPrivate\n AND cl.Parent.Id IS NULL\n\n UNION ALL\n\n SELECT\n cl.ECInstanceId,\n NULL,\n cl.Parent.Id\n FROM\n ${CLASSIFICATIONS_CTE} cte\n JOIN ${CLASS_NAME_Classification} cl ON cl.Parent.Id = cte.ClassificationId\n WHERE\n NOT cl.IsPrivate\n )\n `,\n ];\n const ecsql = `\n SELECT\n cl.ClassificationId id,\n cl.ClassificationTableId tableId,\n cl.ParentClassificationId parentId,\n (\n SELECT group_concat(IdToHex(cat.ECInstanceId))\n FROM ${CLASS_NAME_GeometricElement2d} e\n JOIN ${CLASS_NAME_DrawingCategory} cat ON cat.ECInstanceId = e.Category.Id\n JOIN ${CLASS_NAME_ElementHasClassifications} ehc ON ehc.SourceECInstanceId = e.ECInstanceId\n WHERE e.Parent.Id IS NULL AND NOT cat.IsPrivate AND ehc.TargetECInstanceId = cl.ClassificationId\n GROUP BY ehc.TargetECInstanceId\n ) relatedCategories2d,\n (\n SELECT group_concat(IdToHex(cat.ECInstanceId))\n FROM ${CLASS_NAME_GeometricElement3d} e\n JOIN ${CLASS_NAME_SpatialCategory} cat ON cat.ECInstanceId = e.Category.Id\n JOIN ${CLASS_NAME_ElementHasClassifications} ehc ON ehc.SourceECInstanceId = e.ECInstanceId\n WHERE e.Parent.Id IS NULL AND NOT cat.IsPrivate AND ehc.TargetECInstanceId = cl.ClassificationId\n GROUP BY ehc.TargetECInstanceId\n ) relatedCategories3d\n FROM ${CLASSIFICATIONS_CTE} cl\n `;\n for await (const row of this._queryExecutor.createQueryReader(\n { ctes, ecsql },\n { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\", restartToken: \"tree-widget/classifications-tree/classifications-query\" },\n )) {\n yield {\n id: row.id,\n tableId: row.tableId,\n parentId: row.parentId,\n relatedCategories2d: row.relatedCategories2d ? (row.relatedCategories2d as string).split(\",\") : [],\n relatedCategories3d: row.relatedCategories3d ? (row.relatedCategories3d as string).split(\",\") : [],\n };\n }\n }\n\n private async getClassificationsInfo() {\n this._classificationInfos ??= (async () => {\n const classificationInfos = new Map<ClassificationId | ClassificationTableId, ClassificationInfo>();\n for await (const { id, tableId, parentId, relatedCategories2d, relatedCategories3d } of this.queryClassifications()) {\n const tableOrParentId = tableId ?? parentId;\n let parentInfo = classificationInfos.get(tableOrParentId);\n if (!parentInfo) {\n parentInfo = { childClassificationIds: [], relatedCategories2d: [], relatedCategories3d: [], parentClassificationOrTableId: undefined };\n classificationInfos.set(tableOrParentId, parentInfo);\n }\n parentInfo.childClassificationIds.push(id);\n let classificationEntry = classificationInfos.get(id);\n if (!classificationEntry) {\n classificationEntry = { childClassificationIds: [], relatedCategories2d, relatedCategories3d, parentClassificationOrTableId: tableOrParentId };\n classificationInfos.set(id, classificationEntry);\n } else {\n classificationEntry.parentClassificationOrTableId = tableOrParentId;\n }\n }\n return classificationInfos;\n })();\n return this._classificationInfos;\n }\n\n public async getAllContainedCategories(classificationOrTableIds: Id64Arg): Promise<{ drawing: Id64Array; spatial: Id64Array }> {\n const result = { drawing: new Array<CategoryId>(), spatial: new Array<CategoryId>() };\n if (Id64.sizeOf(classificationOrTableIds) === 0) {\n return result;\n }\n const classificationsInfo = await this.getClassificationsInfo();\n const promises = new Array<Promise<{ drawing: Id64Array; spatial: Id64Array }>>();\n for (const classificationOrTableId of Id64.iterable(classificationOrTableIds)) {\n const classificationInfo = classificationsInfo.get(classificationOrTableId);\n if (classificationInfo === undefined) {\n continue;\n }\n result.drawing.push(...classificationInfo.relatedCategories2d);\n result.spatial.push(...classificationInfo.relatedCategories3d);\n promises.push(this.getAllContainedCategories(classificationInfo.childClassificationIds));\n }\n const promisesResult = await Promise.all(promises);\n for (const { drawing, spatial } of promisesResult) {\n result.drawing.push(...drawing);\n result.spatial.push(...spatial);\n }\n return result;\n }\n\n public async getDirectChildClassifications(classificationOrTableIds: Id64Arg): Promise<ClassificationId[]> {\n const result = new Array<ClassificationId>();\n if (Id64.sizeOf(classificationOrTableIds) === 0) {\n return result;\n }\n const classificationsInfo = await this.getClassificationsInfo();\n for (const classificationOrTableId of Id64.iterable(classificationOrTableIds)) {\n const classificationInfo = classificationsInfo.get(classificationOrTableId);\n if (classificationInfo === undefined) {\n continue;\n }\n result.push(...classificationInfo.childClassificationIds);\n }\n return result;\n }\n\n public getClassificationsPathObs(classificationIds: Id64Arg): Observable<HierarchyNodeIdentifiersPath> {\n return from(this.getClassificationsInfo()).pipe(\n mergeMap((classificationsInfo) => {\n return from(Id64.iterable(classificationIds)).pipe(\n map((classificationId) => {\n const path: HierarchyNodeIdentifiersPath = [{ id: classificationId, className: CLASS_NAME_Classification }];\n let parentId = classificationsInfo.get(classificationId)?.parentClassificationOrTableId;\n while (parentId !== undefined) {\n const parentIdOfParent = classificationsInfo.get(parentId)?.parentClassificationOrTableId;\n if (parentIdOfParent) {\n path.push({ className: CLASS_NAME_Classification, id: parentId });\n } else {\n path.push({ className: CLASS_NAME_ClassificationTable, id: parentId });\n }\n parentId = parentIdOfParent;\n }\n return path.reverse();\n }),\n );\n }),\n );\n }\n\n public async getAllClassifications(): Promise<ClassificationId[]> {\n const classificationsInfo = await this.getClassificationsInfo();\n return [...classificationsInfo.keys()];\n }\n\n private async *queryFilteredElementsData({ element2dIds, element3dIds }: { element2dIds: Id64Arg; element3dIds: Id64Arg }): AsyncIterableIterator<{\n modelId: Id64String;\n id: ElementId;\n categoryId: Id64String;\n }> {\n const queries = new Array<string>();\n if (Id64.sizeOf(element2dIds) > 0) {\n queries.push(`\n SELECT Model.Id modelId, Category.Id categoryId, ECInstanceId id\n FROM ${CLASS_NAME_GeometricElement2d}\n WHERE ECInstanceId IN (${joinId64Arg(element2dIds, \",\")})\n `);\n }\n if (Id64.sizeOf(element3dIds) > 0) {\n queries.push(`\n SELECT Model.Id modelId, Category.Id categoryId, ECInstanceId id\n FROM ${CLASS_NAME_GeometricElement3d}\n WHERE ECInstanceId IN (${joinId64Arg(element3dIds, \",\")})\n `);\n }\n for await (const row of this._queryExecutor.createQueryReader(\n { ecsql: queries.join(\" UNION ALL \") },\n { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\" },\n )) {\n yield { modelId: row.modelId, id: row.id, categoryId: row.categoryId };\n }\n }\n\n public async getFilteredElementsData({\n element2dIds,\n element3dIds,\n }: {\n element2dIds: Id64Arg;\n element3dIds: Id64Arg;\n }): Promise<Map<ElementId, { categoryId: Id64String; modelId: Id64String }>> {\n if (Id64.sizeOf(element2dIds) === 0 && Id64.sizeOf(element3dIds) === 0) {\n return new Map();\n }\n\n this._filteredElementsData ??= (async () => {\n const filteredElementsData = new Map();\n for await (const { modelId, id, categoryId } of this.queryFilteredElementsData({\n element2dIds,\n element3dIds,\n })) {\n filteredElementsData.set(id, { modelId, categoryId });\n }\n return filteredElementsData;\n })();\n return this._filteredElementsData;\n }\n\n public clearFilteredElementsData() {\n this._filteredElementsData = undefined;\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { Id64String } from "@itwin/core-bentley";
1
+ import type { Id64Array, Id64String } from "@itwin/core-bentley";
2
2
  import type { HierarchyNodeKey } from "@itwin/presentation-hierarchies";
3
3
  interface ClassificationsTreeNode {
4
4
  key: HierarchyNodeKey;
@@ -11,7 +11,7 @@ export declare namespace ClassificationsTreeNode {
11
11
  const isClassificationTableNode: (node: Pick<ClassificationsTreeNode, "extendedData">) => boolean;
12
12
  const isClassificationNode: (node: Pick<ClassificationsTreeNode, "extendedData">) => boolean;
13
13
  const isGeometricElementNode: (node: Pick<ClassificationsTreeNode, "extendedData">) => boolean;
14
- const getClassificationIds: (node: Pick<ClassificationsTreeNode, "extendedData">) => Id64String[];
14
+ const getClassificationIds: (node: Pick<ClassificationsTreeNode, "extendedData">) => Id64Array;
15
15
  const getModelId: (node: Pick<ClassificationsTreeNode, "extendedData">) => Id64String;
16
16
  const getCategoryId: (node: Pick<ClassificationsTreeNode, "extendedData">) => Id64String;
17
17
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ClassificationsTreeNode.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeNode.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAGhG,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AASxE,gBAAgB;AAChB,MAAM,KAAW,uBAAuB,CA0BvC;AA1BD,WAAiB,uBAAuB;IACzB,iDAAyB,GAAG,CAAC,IAAmD,EAAE,EAAE,CAC/F,WAAW,CAAC,IAAI,CAAC,KAAK,qBAAqB,CAAC;IAEjC,4CAAoB,GAAG,CAAC,IAAmD,EAAE,EAAE,CAC1F,WAAW,CAAC,IAAI,CAAC,KAAK,gBAAgB,CAAC;IAE5B,8CAAsB,GAAG,CAAC,IAAmD,EAAE,EAAE;QAC5F,MAAM,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;QAC/B,OAAO,IAAI,KAAK,oBAAoB,IAAI,IAAI,KAAK,oBAAoB,CAAC;IACxE,CAAC,CAAA;IAEY,4CAAoB,GAAG,CAAC,IAAmD,EAAgB,EAAE;QACxG,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,IAAI,mBAAmB,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC;QACxE,OAAO,sBAAsB,CAAC,IAAI,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAAC;IACrE,CAAC,CAAA;IAEY,kCAAU,GAAG,CAAC,IAAmD,EAAc,EAAE;QAC5F,MAAM,CAAC,OAAO,IAAI,CAAC,YAAY,EAAE,OAAO,KAAK,QAAQ,CAAC,CAAC;QACvD,OAAO,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC;IACnC,CAAC,CAAA;IAEY,qCAAa,GAAG,CAAC,IAAmD,EAAc,EAAE;QAC/F,MAAM,CAAC,OAAO,IAAI,CAAC,YAAY,EAAE,UAAU,KAAK,QAAQ,CAAC,CAAC;QAC1D,OAAO,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC;IACtC,CAAC,CAAA;AACH,CAAC,EA1BgB,uBAAuB,KAAvB,uBAAuB,QA0BvC;AAED,SAAS,WAAW,CAAC,IAAmD;IACtE,OAAO,IAAI,CAAC,YAAY,IAAI,MAAM,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;AAC/F,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport type { Id64String } from \"@itwin/core-bentley\";\nimport { assert } from \"@itwin/core-bentley\";\nimport { parseIdsSelectorResult } from \"../../common/internal/Utils.js\";\n\nimport type { HierarchyNodeKey } from \"@itwin/presentation-hierarchies\";\n\ninterface ClassificationsTreeNode {\n key: HierarchyNodeKey;\n extendedData?: { [id: string]: any };\n}\n\n/** @internal */\nexport namespace ClassificationsTreeNode {\n export const isClassificationTableNode = (node: Pick<ClassificationsTreeNode, \"extendedData\">) =>\n getNodeType(node) === \"ClassificationTable\";\n\n export const isClassificationNode = (node: Pick<ClassificationsTreeNode, \"extendedData\">) =>\n getNodeType(node) === \"Classification\";\n\n export const isGeometricElementNode = (node: Pick<ClassificationsTreeNode, \"extendedData\">) => {\n const type = getNodeType(node);\n return type === \"GeometricElement3d\" || type === \"GeometricElement2d\";\n }\n\n export const getClassificationIds = (node: Pick<ClassificationsTreeNode, \"extendedData\">): Id64String[] => {\n assert(!!node.extendedData && \"classificationIds\" in node.extendedData);\n return parseIdsSelectorResult(node.extendedData.classificationIds);\n }\n\n export const getModelId = (node: Pick<ClassificationsTreeNode, \"extendedData\">): Id64String => {\n assert(typeof node.extendedData?.modelId === \"string\");\n return node.extendedData.modelId;\n }\n\n export const getCategoryId = (node: Pick<ClassificationsTreeNode, \"extendedData\">): Id64String => {\n assert(typeof node.extendedData?.categoryId === \"string\");\n return node.extendedData.categoryId;\n }\n}\n\nfunction getNodeType(node: Pick<ClassificationsTreeNode, \"extendedData\">) {\n return node.extendedData && \"type\" in node.extendedData ? node.extendedData.type : undefined;\n}\n"]}
1
+ {"version":3,"file":"ClassificationsTreeNode.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeNode.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAGhG,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AASxE,gBAAgB;AAChB,MAAM,KAAW,uBAAuB,CAwBvC;AAxBD,WAAiB,uBAAuB;IACzB,iDAAyB,GAAG,CAAC,IAAmD,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,qBAAqB,CAAC;IAEjI,4CAAoB,GAAG,CAAC,IAAmD,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,gBAAgB,CAAC;IAEvH,8CAAsB,GAAG,CAAC,IAAmD,EAAE,EAAE;QAC5F,MAAM,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;QAC/B,OAAO,IAAI,KAAK,oBAAoB,IAAI,IAAI,KAAK,oBAAoB,CAAC;IACxE,CAAC,CAAC;IAEW,4CAAoB,GAAG,CAAC,IAAmD,EAAa,EAAE;QACrG,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,IAAI,mBAAmB,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC;QACxE,OAAO,sBAAsB,CAAC,IAAI,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAAC;IACrE,CAAC,CAAC;IAEW,kCAAU,GAAG,CAAC,IAAmD,EAAc,EAAE;QAC5F,MAAM,CAAC,OAAO,IAAI,CAAC,YAAY,EAAE,OAAO,KAAK,QAAQ,CAAC,CAAC;QACvD,OAAO,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC;IACnC,CAAC,CAAC;IAEW,qCAAa,GAAG,CAAC,IAAmD,EAAc,EAAE;QAC/F,MAAM,CAAC,OAAO,IAAI,CAAC,YAAY,EAAE,UAAU,KAAK,QAAQ,CAAC,CAAC;QAC1D,OAAO,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC;IACtC,CAAC,CAAC;AACJ,CAAC,EAxBgB,uBAAuB,KAAvB,uBAAuB,QAwBvC;AAED,SAAS,WAAW,CAAC,IAAmD;IACtE,OAAO,IAAI,CAAC,YAAY,IAAI,MAAM,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;AAC/F,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport type { Id64Array, Id64String } from \"@itwin/core-bentley\";\nimport { assert } from \"@itwin/core-bentley\";\nimport { parseIdsSelectorResult } from \"../../common/internal/Utils.js\";\n\nimport type { HierarchyNodeKey } from \"@itwin/presentation-hierarchies\";\n\ninterface ClassificationsTreeNode {\n key: HierarchyNodeKey;\n extendedData?: { [id: string]: any };\n}\n\n/** @internal */\nexport namespace ClassificationsTreeNode {\n export const isClassificationTableNode = (node: Pick<ClassificationsTreeNode, \"extendedData\">) => getNodeType(node) === \"ClassificationTable\";\n\n export const isClassificationNode = (node: Pick<ClassificationsTreeNode, \"extendedData\">) => getNodeType(node) === \"Classification\";\n\n export const isGeometricElementNode = (node: Pick<ClassificationsTreeNode, \"extendedData\">) => {\n const type = getNodeType(node);\n return type === \"GeometricElement3d\" || type === \"GeometricElement2d\";\n };\n\n export const getClassificationIds = (node: Pick<ClassificationsTreeNode, \"extendedData\">): Id64Array => {\n assert(!!node.extendedData && \"classificationIds\" in node.extendedData);\n return parseIdsSelectorResult(node.extendedData.classificationIds);\n };\n\n export const getModelId = (node: Pick<ClassificationsTreeNode, \"extendedData\">): Id64String => {\n assert(typeof node.extendedData?.modelId === \"string\");\n return node.extendedData.modelId;\n };\n\n export const getCategoryId = (node: Pick<ClassificationsTreeNode, \"extendedData\">): Id64String => {\n assert(typeof node.extendedData?.categoryId === \"string\");\n return node.extendedData.categoryId;\n };\n}\n\nfunction getNodeType(node: Pick<ClassificationsTreeNode, \"extendedData\">) {\n return node.extendedData && \"type\" in node.extendedData ? node.extendedData.type : undefined;\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import type { Viewport } from "@itwin/core-frontend";
2
- import type { HierarchyVisibilityHandler } from "../../common/UseHierarchyVisibility.js";
2
+ import type { HierarchyFilteringPath } from "@itwin/presentation-hierarchies";
3
3
  import type { ECClassHierarchyInspector } from "@itwin/presentation-shared";
4
+ import type { HierarchyVisibilityHandler } from "../../common/UseHierarchyVisibility.js";
4
5
  import type { ClassificationsTreeIdsCache } from "./ClassificationsTreeIdsCache.js";
5
6
  /**
6
7
  * Props for `createClassificationsTreeVisibilityHandler`.
@@ -10,6 +11,7 @@ export interface ClassificationsTreeVisibilityHandlerProps {
10
11
  viewport: Viewport;
11
12
  idsCache: ClassificationsTreeIdsCache;
12
13
  imodelAccess: ECClassHierarchyInspector;
14
+ filteredPaths?: HierarchyFilteringPath[];
13
15
  }
14
16
  /**
15
17
  * Creates an instance if `ClassificationsTreeVisibilityHandler`.