@itwin/tree-widget-react 4.0.0-alpha.1 → 4.0.0-alpha.11
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.
- package/CHANGELOG.md +84 -1
- package/README.md +5 -53
- package/lib/esm/tree-widget-react/TreeWidget.d.ts +7 -2
- package/lib/esm/tree-widget-react/TreeWidget.js +22 -2
- package/lib/esm/tree-widget-react/TreeWidget.js.map +1 -1
- package/lib/esm/tree-widget-react/components/{SelectableTree.scss → TreeWidgetComponentImpl.css} +0 -1
- package/lib/esm/tree-widget-react/components/{SelectableTree.d.ts → TreeWidgetComponentImpl.d.ts} +18 -14
- package/lib/esm/tree-widget-react/components/{SelectableTree.js → TreeWidgetComponentImpl.js} +28 -28
- package/lib/esm/tree-widget-react/components/TreeWidgetComponentImpl.js.map +1 -0
- package/lib/esm/tree-widget-react/components/TreeWidgetUiItemsProvider.d.ts +4 -6
- package/lib/esm/tree-widget-react/components/TreeWidgetUiItemsProvider.js +9 -10
- package/lib/esm/tree-widget-react/components/TreeWidgetUiItemsProvider.js.map +1 -1
- package/lib/esm/tree-widget-react/components/tree-header/ErrorState.d.ts +4 -0
- package/lib/esm/tree-widget-react/components/tree-header/ErrorState.js +14 -0
- package/lib/esm/tree-widget-react/components/tree-header/ErrorState.js.map +1 -0
- package/lib/esm/tree-widget-react/components/tree-header/SearchBox.d.ts +11 -0
- package/lib/esm/tree-widget-react/components/tree-header/SearchBox.js +33 -0
- package/lib/esm/tree-widget-react/components/tree-header/SearchBox.js.map +1 -0
- package/lib/esm/tree-widget-react/components/tree-header/{TreeWithHeader.scss → SelectableTree.css} +9 -8
- package/lib/esm/tree-widget-react/components/tree-header/SelectableTree.d.ts +16 -0
- package/lib/esm/tree-widget-react/components/tree-header/SelectableTree.js +14 -0
- package/lib/esm/tree-widget-react/components/tree-header/SelectableTree.js.map +1 -0
- package/lib/esm/tree-widget-react/components/{TreeSelector.scss → tree-header/WidgetHeader.css} +12 -5
- package/lib/esm/tree-widget-react/components/tree-header/WidgetHeader.d.ts +36 -0
- package/lib/esm/tree-widget-react/components/tree-header/WidgetHeader.js +31 -0
- package/lib/esm/tree-widget-react/components/tree-header/WidgetHeader.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTree.d.ts +3 -2
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTree.js +4 -2
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.d.ts +11 -5
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.js +60 -14
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeComponent.d.ts +1 -6
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeComponent.js +4 -10
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeComponent.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.d.ts +39 -4
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js +658 -114
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.d.ts +19 -6
- package/lib/esm/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js +83 -82
- package/lib/esm/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.d.ts +68 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js +442 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeNode.d.ts +41 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeNode.js +50 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeNode.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeVisibilityHandler.d.ts +23 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeVisibilityHandler.js +708 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeVisibilityHandler.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/FilteredTree.d.ts +39 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/FilteredTree.js +221 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/FilteredTree.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/UseFilteredPaths.d.ts +25 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/UseFilteredPaths.js +133 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/UseFilteredPaths.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/UseIdsCache.d.ts +8 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/UseIdsCache.js +48 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/UseIdsCache.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTree.d.ts +12 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTree.js +14 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTree.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeComponent.d.ts +23 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeComponent.js +47 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeComponent.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeDefinition.d.ts +38 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeDefinition.js +353 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeDefinition.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeIcon.d.ts +6 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeIcon.js +37 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/ClassificationsTreeIcon.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTree.d.ts +23 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTree.js +52 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/UseClassificationsTree.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeIdsCache.d.ts +38 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeIdsCache.js +269 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeIdsCache.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeNode.d.ts +20 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeNode.js +36 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeNode.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeVisibilityHandler.d.ts +19 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeVisibilityHandler.js +484 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/ClassificationsTreeVisibilityHandler.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/UseIdsCache.d.ts +8 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/UseIdsCache.js +45 -0
- package/lib/esm/tree-widget-react/components/trees/classifications-tree/internal/UseIdsCache.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.d.ts +5 -21
- package/lib/esm/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.js +5 -62
- package/lib/esm/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/FocusedInstancesContext.d.ts +28 -4
- package/lib/esm/tree-widget-react/components/trees/common/FocusedInstancesContext.js +73 -2
- package/lib/esm/tree-widget-react/components/trees/common/FocusedInstancesContext.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/TreeErrors.js +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/TreeErrors.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/UseHierarchyVisibility.d.ts +4 -4
- package/lib/esm/tree-widget-react/components/trees/common/UseHierarchyVisibility.js +12 -6
- package/lib/esm/tree-widget-react/components/trees/common/UseHierarchyVisibility.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/UseNodeHighlighting.d.ts +3 -3
- package/lib/esm/tree-widget-react/components/trees/common/UseNodeHighlighting.js +13 -15
- package/lib/esm/tree-widget-react/components/trees/common/UseNodeHighlighting.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/UseTelemetryContext.d.ts +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/UseTelemetryContext.js +2 -1
- package/lib/esm/tree-widget-react/components/trees/common/UseTelemetryContext.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/Utils.d.ts +38 -23
- package/lib/esm/tree-widget-react/components/trees/common/Utils.js +65 -47
- package/lib/esm/tree-widget-react/components/trees/common/Utils.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/BaseTreeRenderer.d.ts +6 -0
- package/lib/esm/tree-widget-react/components/trees/common/components/BaseTreeRenderer.js +13 -0
- package/lib/esm/tree-widget-react/components/trees/common/components/BaseTreeRenderer.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/components/Delayed.d.ts +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/components/Delayed.js +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/components/Delayed.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/EmptyTree.css +25 -0
- package/lib/esm/tree-widget-react/components/trees/common/components/EmptyTree.d.ts +21 -0
- package/lib/esm/tree-widget-react/components/trees/common/components/EmptyTree.js +43 -0
- package/lib/esm/tree-widget-react/components/trees/common/components/EmptyTree.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/components/ProgressOverlay.d.ts +2 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/ProgressOverlay.js +5 -4
- package/lib/esm/tree-widget-react/components/trees/common/components/ProgressOverlay.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/SkeletonTree.css +16 -0
- package/lib/esm/tree-widget-react/components/trees/common/components/SkeletonTree.d.ts +4 -0
- package/lib/esm/tree-widget-react/components/trees/common/components/SkeletonTree.js +16 -0
- package/lib/esm/tree-widget-react/components/trees/common/components/SkeletonTree.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/components/Tree.css +11 -0
- package/lib/esm/tree-widget-react/components/trees/common/components/Tree.d.ts +9 -13
- package/lib/esm/tree-widget-react/components/trees/common/components/Tree.js +53 -36
- package/lib/esm/tree-widget-react/components/trees/common/components/Tree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/TreeNodeVisibilityButton.css +2 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/TreeNodeVisibilityButton.d.ts +5 -10
- package/lib/esm/tree-widget-react/components/trees/common/components/TreeNodeVisibilityButton.js +14 -20
- package/lib/esm/tree-widget-react/components/trees/common/components/TreeNodeVisibilityButton.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/TreeRenderer.d.ts +2 -8
- package/lib/esm/tree-widget-react/components/trees/common/components/TreeRenderer.js +11 -7
- package/lib/esm/tree-widget-react/components/trees/common/components/TreeRenderer.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/UseVisibilityButtonHandler.d.ts +3 -2
- package/lib/esm/tree-widget-react/components/trees/common/components/UseVisibilityButtonHandler.js +7 -7
- package/lib/esm/tree-widget-react/components/trees/common/components/UseVisibilityButtonHandler.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTree.d.ts +2 -2
- package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTree.js +10 -6
- package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTreeRenderer.d.ts +3 -3
- package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTreeRenderer.js +13 -10
- package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTreeRenderer.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/internal/AlwaysAndNeverDrawnElementInfo.d.ts +43 -0
- package/lib/esm/tree-widget-react/components/trees/{models-tree → common}/internal/AlwaysAndNeverDrawnElementInfo.js +91 -34
- package/lib/esm/tree-widget-react/components/trees/common/internal/AlwaysAndNeverDrawnElementInfo.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/ClassNameDefinitions.d.ts +43 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/ClassNameDefinitions.js +47 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/ClassNameDefinitions.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/ModelCategoryElementsCountCache.d.ts +15 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/ModelCategoryElementsCountCache.js +79 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/ModelCategoryElementsCountCache.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/{Rxjs.d.ts → internal/Rxjs.d.ts} +9 -2
- package/lib/esm/tree-widget-react/components/trees/common/{Rxjs.js → internal/Rxjs.js} +10 -2
- package/lib/esm/tree-widget-react/components/trees/common/internal/Rxjs.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/{Tooltip.d.ts → internal/Tooltip.d.ts} +4 -8
- package/lib/esm/tree-widget-react/components/trees/common/internal/Tooltip.js +18 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/Tooltip.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/Types.d.ts +14 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/Types.js +6 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/Types.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/UseActiveViewport.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/{UseHierarchiesLocalization.d.ts → internal/UseHierarchiesLocalization.d.ts} +3 -2
- package/lib/esm/tree-widget-react/components/trees/common/{UseHierarchiesLocalization.js → internal/UseHierarchiesLocalization.js} +6 -2
- package/lib/esm/tree-widget-react/components/trees/common/internal/UseHierarchiesLocalization.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/{UseHierarchyFiltering.d.ts → internal/UseHierarchyFiltering.d.ts} +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/{UseHierarchyFiltering.js → internal/UseHierarchyFiltering.js} +5 -4
- package/lib/esm/tree-widget-react/components/trees/common/internal/UseHierarchyFiltering.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/UseIModelAccess.d.ts +17 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/UseIModelAccess.js +32 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/UseIModelAccess.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/{UseIModelChangeListener.d.ts → internal/UseIModelChangeListener.d.ts} +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/{UseIModelChangeListener.js → internal/UseIModelChangeListener.js} +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/UseIModelChangeListener.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/Utils.d.ts +46 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/Utils.js +101 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/Utils.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/VisibilityChangeEventListener.d.ts +19 -0
- package/lib/esm/tree-widget-react/components/trees/{models-tree → common}/internal/VisibilityChangeEventListener.js +17 -9
- package/lib/esm/tree-widget-react/components/trees/common/internal/VisibilityChangeEventListener.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/VisibilityUtils.d.ts +63 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/VisibilityUtils.js +205 -0
- package/lib/esm/tree-widget-react/components/trees/common/internal/VisibilityUtils.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.d.ts +8 -2
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.js +26 -16
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeComponent.d.ts +1 -5
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js +2 -1
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeDefinition.d.ts +1 -0
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeDefinition.js +6 -0
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTreeDefinition.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.d.ts +10 -2
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.js +46 -31
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeComponent.d.ts +1 -5
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeComponent.js +2 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeComponent.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeDefinition.d.ts +13 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeDefinition.js +47 -76
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTreeDefinition.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/internal/IModelContentTreeIdsCache.d.ts +5 -5
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/internal/IModelContentTreeIdsCache.js +29 -24
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/internal/IModelContentTreeIdsCache.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/index.d.ts +11 -4
- package/lib/esm/tree-widget-react/components/trees/index.js +10 -4
- package/lib/esm/tree-widget-react/components/trees/index.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTree.d.ts +3 -2
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTree.js +3 -2
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.d.ts +4 -4
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.js +38 -30
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.d.ts +7 -7
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.js +16 -19
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.d.ts +10 -3
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js +91 -114
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.d.ts +9 -3
- package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.js +70 -239
- package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/FilteredTree.d.ts +7 -9
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/FilteredTree.js +7 -9
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/FilteredTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.d.ts +10 -7
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js +106 -104
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeNode.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.d.ts +3 -29
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js +177 -333
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/UseFilteredPaths.d.ts +27 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/UseFilteredPaths.js +170 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/UseFilteredPaths.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/UseIdsCache.d.ts +8 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/UseIdsCache.js +47 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/UseIdsCache.js.map +1 -0
- package/lib/esm/tree-widget-react-internal.d.ts +11 -0
- package/lib/esm/tree-widget-react-internal.js +17 -0
- package/lib/esm/tree-widget-react-internal.js.map +1 -0
- package/lib/esm/tree-widget-react.d.ts +2 -2
- package/lib/esm/tree-widget-react.js +1 -2
- package/lib/esm/tree-widget-react.js.map +1 -1
- package/lib/public/locales/en/TreeWidget.json +36 -56
- package/package.json +75 -73
- package/lib/esm/tree-widget-react/components/SelectableTree.js.map +0 -1
- package/lib/esm/tree-widget-react/components/TreeSelector.d.ts +0 -30
- package/lib/esm/tree-widget-react/components/TreeSelector.js +0 -23
- package/lib/esm/tree-widget-react/components/TreeSelector.js.map +0 -1
- package/lib/esm/tree-widget-react/components/tree-header/TreeHeader.d.ts +0 -32
- package/lib/esm/tree-widget-react/components/tree-header/TreeHeader.js +0 -25
- package/lib/esm/tree-widget-react/components/tree-header/TreeHeader.js.map +0 -1
- package/lib/esm/tree-widget-react/components/tree-header/TreeHeader.scss +0 -56
- package/lib/esm/tree-widget-react/components/tree-header/TreeWithHeader.d.ts +0 -13
- package/lib/esm/tree-widget-react/components/tree-header/TreeWithHeader.js +0 -13
- package/lib/esm/tree-widget-react/components/tree-header/TreeWithHeader.js.map +0 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesVisibilityHandler.d.ts +0 -28
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesVisibilityHandler.js +0 -87
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesVisibilityHandler.js.map +0 -1
- package/lib/esm/tree-widget-react/components/trees/common/FocusedInstancesContextProvider.d.ts +0 -7
- package/lib/esm/tree-widget-react/components/trees/common/FocusedInstancesContextProvider.js +0 -66
- package/lib/esm/tree-widget-react/components/trees/common/FocusedInstancesContextProvider.js.map +0 -1
- package/lib/esm/tree-widget-react/components/trees/common/Rxjs.js.map +0 -1
- package/lib/esm/tree-widget-react/components/trees/common/Tooltip.js +0 -24
- package/lib/esm/tree-widget-react/components/trees/common/Tooltip.js.map +0 -1
- package/lib/esm/tree-widget-react/components/trees/common/UseActiveViewport.js.map +0 -1
- package/lib/esm/tree-widget-react/components/trees/common/UseFiltering.d.ts +0 -11
- package/lib/esm/tree-widget-react/components/trees/common/UseFiltering.js +0 -24
- package/lib/esm/tree-widget-react/components/trees/common/UseFiltering.js.map +0 -1
- package/lib/esm/tree-widget-react/components/trees/common/UseHierarchiesLocalization.js.map +0 -1
- package/lib/esm/tree-widget-react/components/trees/common/UseHierarchyFiltering.js.map +0 -1
- package/lib/esm/tree-widget-react/components/trees/common/UseIModelChangeListener.js.map +0 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/Utils.d.ts +0 -7
- package/lib/esm/tree-widget-react/components/trees/models-tree/Utils.js +0 -21
- package/lib/esm/tree-widget-react/components/trees/models-tree/Utils.js.map +0 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.d.ts +0 -29
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.js.map +0 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/VisibilityChangeEventListener.d.ts +0 -12
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/VisibilityChangeEventListener.js.map +0 -1
- /package/lib/esm/tree-widget-react/components/{TreeWidgetUiItemsProvider.scss → TreeWidgetUiItemsProvider.css} +0 -0
- /package/lib/esm/tree-widget-react/components/trees/common/components/{ProgressOverlay.scss → ProgressOverlay.css} +0 -0
- /package/lib/esm/tree-widget-react/components/trees/common/{UseActiveViewport.d.ts → internal/UseActiveViewport.d.ts} +0 -0
- /package/lib/esm/tree-widget-react/components/trees/common/{UseActiveViewport.js → internal/UseActiveViewport.js} +0 -0
package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ModelsTreeDefinition } from "../ModelsTreeDefinition.js";
|
|
2
|
-
import type { Id64Array, Id64String } from "@itwin/core-bentley";
|
|
2
|
+
import type { Id64Arg, Id64Array, Id64String } from "@itwin/core-bentley";
|
|
3
3
|
import type { HierarchyNodeIdentifiersPath, LimitingECSqlQueryExecutor } from "@itwin/presentation-hierarchies";
|
|
4
4
|
type ModelsTreeHierarchyConfiguration = ConstructorParameters<typeof ModelsTreeDefinition>[0]["hierarchyConfig"];
|
|
5
5
|
/** @internal */
|
|
@@ -10,6 +10,7 @@ export declare class ModelsTreeIdsCache {
|
|
|
10
10
|
private _subjectInfos;
|
|
11
11
|
private _parentSubjectIds;
|
|
12
12
|
private _modelInfos;
|
|
13
|
+
private _modelWithCategoryModeledElements;
|
|
13
14
|
private _modelKeyPaths;
|
|
14
15
|
private _subjectKeyPaths;
|
|
15
16
|
private _categoryKeyPaths;
|
|
@@ -19,24 +20,26 @@ export declare class ModelsTreeIdsCache {
|
|
|
19
20
|
private queryModels;
|
|
20
21
|
private getSubjectInfos;
|
|
21
22
|
/** Returns ECInstanceIDs of Subjects that either have direct Model or at least one child Subject with a Model. */
|
|
22
|
-
getParentSubjectIds(): Promise<
|
|
23
|
+
getParentSubjectIds(): Promise<Id64Array>;
|
|
23
24
|
/**
|
|
24
25
|
* Returns child subjects of the specified parent subjects as they're displayed in the hierarchy - taking into
|
|
25
26
|
* account `hideInHierarchy` flag.
|
|
26
27
|
*/
|
|
27
|
-
getChildSubjectIds(parentSubjectIds:
|
|
28
|
+
getChildSubjectIds(parentSubjectIds: Id64Array): Promise<Id64Array>;
|
|
28
29
|
/** Returns ECInstanceIDs of all Models under specific parent Subjects, including their child Subjects, etc. */
|
|
29
30
|
getSubjectModelIds(subjectIds: Id64Array): Promise<Id64Array>;
|
|
30
31
|
/** Returns ECInstanceIDs of Models under specific parent Subjects as they are displayed in the hierarchy. */
|
|
31
|
-
getChildSubjectModelIds(parentSubjectIds:
|
|
32
|
+
getChildSubjectModelIds(parentSubjectIds: Id64Array): Promise<Id64Array>;
|
|
32
33
|
createSubjectInstanceKeysPath(targetSubjectId: Id64String): Promise<HierarchyNodeIdentifiersPath>;
|
|
33
34
|
private queryModelElementCounts;
|
|
34
35
|
private queryModelCategories;
|
|
36
|
+
private queryModeledElements;
|
|
37
|
+
private getModelWithCategoryModeledElements;
|
|
35
38
|
private getModelInfos;
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
getModelCategoryIds(modelId: Id64String): Promise<Id64Array>;
|
|
40
|
+
hasSubModel(elementId: Id64String): Promise<boolean>;
|
|
41
|
+
getCategoriesModeledElements(modelId: Id64String, categoryIds: Id64Arg): Promise<Id64Array>;
|
|
38
42
|
createModelInstanceKeyPaths(modelId: Id64String): Promise<HierarchyNodeIdentifiersPath[]>;
|
|
39
|
-
private queryCategoryElementCounts;
|
|
40
43
|
getCategoryElementsCount(modelId: Id64String, categoryId: Id64String): Promise<number>;
|
|
41
44
|
createCategoryInstanceKeyPaths(categoryId: Id64String): Promise<HierarchyNodeIdentifiersPath[]>;
|
|
42
45
|
}
|
package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js
CHANGED
|
@@ -2,15 +2,27 @@
|
|
|
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 {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
5
|
+
import { assert, Id64 } from "@itwin/core-bentley";
|
|
6
|
+
import { IModel } from "@itwin/core-common";
|
|
7
|
+
import { CLASS_NAME_GeometricModel3d, CLASS_NAME_InformationPartitionElement, CLASS_NAME_Model, CLASS_NAME_SpatialCategory, CLASS_NAME_Subject, } from "../../common/internal/ClassNameDefinitions.js";
|
|
8
|
+
import { ModelCategoryElementsCountCache } from "../../common/internal/ModelCategoryElementsCountCache.js";
|
|
9
|
+
import { pushToMap } from "../../common/internal/Utils.js";
|
|
8
10
|
/** @internal */
|
|
9
11
|
export class ModelsTreeIdsCache {
|
|
12
|
+
_queryExecutor;
|
|
13
|
+
_hierarchyConfig;
|
|
14
|
+
_categoryElementCounts;
|
|
15
|
+
_subjectInfos;
|
|
16
|
+
_parentSubjectIds; // the list should contain a subject id if its node should be shown as having children
|
|
17
|
+
_modelInfos;
|
|
18
|
+
_modelWithCategoryModeledElements;
|
|
19
|
+
_modelKeyPaths;
|
|
20
|
+
_subjectKeyPaths;
|
|
21
|
+
_categoryKeyPaths;
|
|
10
22
|
constructor(_queryExecutor, _hierarchyConfig) {
|
|
11
23
|
this._queryExecutor = _queryExecutor;
|
|
12
24
|
this._hierarchyConfig = _hierarchyConfig;
|
|
13
|
-
this._categoryElementCounts = new ModelCategoryElementsCountCache(
|
|
25
|
+
this._categoryElementCounts = new ModelCategoryElementsCountCache(_queryExecutor, [this._hierarchyConfig.elementClassSpecification]);
|
|
14
26
|
this._modelKeyPaths = new Map();
|
|
15
27
|
this._subjectKeyPaths = new Map();
|
|
16
28
|
this._categoryKeyPaths = new Map();
|
|
@@ -25,7 +37,7 @@ export class ModelsTreeIdsCache {
|
|
|
25
37
|
s.Parent.Id parentId,
|
|
26
38
|
(
|
|
27
39
|
SELECT m.ECInstanceId
|
|
28
|
-
FROM
|
|
40
|
+
FROM ${CLASS_NAME_GeometricModel3d} m
|
|
29
41
|
WHERE m.ECInstanceId = HexToId(json_extract(s.JsonProperties, '$.Subject.Model.TargetPartition'))
|
|
30
42
|
AND NOT m.IsPrivate
|
|
31
43
|
AND EXISTS (SELECT 1 FROM ${this._hierarchyConfig.elementClassSpecification} WHERE Model.Id = m.ECInstanceId)
|
|
@@ -46,8 +58,8 @@ export class ModelsTreeIdsCache {
|
|
|
46
58
|
async *queryModels() {
|
|
47
59
|
const modelsQuery = `
|
|
48
60
|
SELECT p.ECInstanceId id, p.Parent.Id parentId
|
|
49
|
-
FROM
|
|
50
|
-
INNER JOIN
|
|
61
|
+
FROM ${CLASS_NAME_InformationPartitionElement} p
|
|
62
|
+
INNER JOIN ${CLASS_NAME_GeometricModel3d} m ON m.ModeledElement.Id = p.ECInstanceId
|
|
51
63
|
WHERE
|
|
52
64
|
NOT m.IsPrivate
|
|
53
65
|
${this._hierarchyConfig.showEmptyModels ? "" : `AND EXISTS (SELECT 1 FROM ${this._hierarchyConfig.elementClassSpecification} WHERE Model.Id = m.ECInstanceId)`}
|
|
@@ -63,13 +75,13 @@ export class ModelsTreeIdsCache {
|
|
|
63
75
|
const result = new Map();
|
|
64
76
|
for await (const subject of this.querySubjects()) {
|
|
65
77
|
const subjectInfo = {
|
|
66
|
-
|
|
78
|
+
parentSubjectId: subject.parentId,
|
|
67
79
|
hideInHierarchy: subject.hideInHierarchy,
|
|
68
|
-
|
|
69
|
-
|
|
80
|
+
childSubjectIds: new Set(),
|
|
81
|
+
childModelIds: new Set(),
|
|
70
82
|
};
|
|
71
83
|
if (subject.targetPartitionId) {
|
|
72
|
-
subjectInfo.
|
|
84
|
+
subjectInfo.childModelIds.add(subject.targetPartitionId);
|
|
73
85
|
}
|
|
74
86
|
result.set(subject.id, subjectInfo);
|
|
75
87
|
}
|
|
@@ -83,18 +95,18 @@ export class ModelsTreeIdsCache {
|
|
|
83
95
|
return result;
|
|
84
96
|
})(),
|
|
85
97
|
]);
|
|
86
|
-
for (const [subjectId, {
|
|
98
|
+
for (const [subjectId, { parentSubjectId }] of subjectInfos.entries()) {
|
|
87
99
|
if (parentSubjectId) {
|
|
88
100
|
const parentSubjectInfo = subjectInfos.get(parentSubjectId);
|
|
89
101
|
assert(!!parentSubjectInfo);
|
|
90
|
-
parentSubjectInfo.
|
|
102
|
+
parentSubjectInfo.childSubjectIds.add(subjectId);
|
|
91
103
|
}
|
|
92
104
|
}
|
|
93
105
|
for (const [partitionId, subjectIds] of targetPartitionSubjects) {
|
|
94
106
|
subjectIds.forEach((subjectId) => {
|
|
95
107
|
const subjectInfo = subjectInfos.get(subjectId);
|
|
96
108
|
assert(!!subjectInfo);
|
|
97
|
-
subjectInfo.
|
|
109
|
+
subjectInfo.childModelIds.add(partitionId);
|
|
98
110
|
});
|
|
99
111
|
}
|
|
100
112
|
return subjectInfos;
|
|
@@ -107,12 +119,12 @@ export class ModelsTreeIdsCache {
|
|
|
107
119
|
const subjectInfos = await this.getSubjectInfos();
|
|
108
120
|
const parentSubjectIds = new Set();
|
|
109
121
|
subjectInfos.forEach((subjectInfo, subjectId) => {
|
|
110
|
-
if (subjectInfo.
|
|
122
|
+
if (subjectInfo.childModelIds.size > 0) {
|
|
111
123
|
parentSubjectIds.add(subjectId);
|
|
112
|
-
let currParentId = subjectInfo.
|
|
124
|
+
let currParentId = subjectInfo.parentSubjectId;
|
|
113
125
|
while (currParentId) {
|
|
114
126
|
parentSubjectIds.add(currParentId);
|
|
115
|
-
currParentId = subjectInfos.get(currParentId)?.
|
|
127
|
+
currParentId = subjectInfos.get(currParentId)?.parentSubjectId;
|
|
116
128
|
}
|
|
117
129
|
}
|
|
118
130
|
});
|
|
@@ -152,8 +164,8 @@ export class ModelsTreeIdsCache {
|
|
|
152
164
|
if (!subjectInfo) {
|
|
153
165
|
continue;
|
|
154
166
|
}
|
|
155
|
-
result.push(...subjectInfo.
|
|
156
|
-
subjectStack.push(...subjectInfo.
|
|
167
|
+
result.push(...subjectInfo.childModelIds);
|
|
168
|
+
subjectStack.push(...subjectInfo.childSubjectIds);
|
|
157
169
|
}
|
|
158
170
|
return result;
|
|
159
171
|
}
|
|
@@ -173,7 +185,7 @@ export class ModelsTreeIdsCache {
|
|
|
173
185
|
const modelIds = new Array();
|
|
174
186
|
[...parentSubjectIds, ...hiddenSubjectIds].forEach((subjectId) => {
|
|
175
187
|
const subjectInfo = subjectInfos.get(subjectId);
|
|
176
|
-
subjectInfo && modelIds.push(...subjectInfo.
|
|
188
|
+
subjectInfo && modelIds.push(...subjectInfo.childModelIds);
|
|
177
189
|
});
|
|
178
190
|
return modelIds;
|
|
179
191
|
}
|
|
@@ -185,11 +197,14 @@ export class ModelsTreeIdsCache {
|
|
|
185
197
|
const result = new Array();
|
|
186
198
|
let currParentId = targetSubjectId;
|
|
187
199
|
while (currParentId) {
|
|
200
|
+
if (this._hierarchyConfig.hideRootSubject && currParentId === IModel.rootSubjectId) {
|
|
201
|
+
break;
|
|
202
|
+
}
|
|
188
203
|
const parentInfo = subjectInfos.get(currParentId);
|
|
189
204
|
if (!parentInfo?.hideInHierarchy) {
|
|
190
|
-
result.push({ className:
|
|
205
|
+
result.push({ className: CLASS_NAME_Subject, id: currParentId });
|
|
191
206
|
}
|
|
192
|
-
currParentId = parentInfo?.
|
|
207
|
+
currParentId = parentInfo?.parentSubjectId;
|
|
193
208
|
}
|
|
194
209
|
return result.reverse();
|
|
195
210
|
})();
|
|
@@ -198,7 +213,7 @@ export class ModelsTreeIdsCache {
|
|
|
198
213
|
return entry;
|
|
199
214
|
}
|
|
200
215
|
async *queryModelElementCounts() {
|
|
201
|
-
const query =
|
|
216
|
+
const query = `
|
|
202
217
|
SELECT Model.Id modelId, COUNT(*) elementCount
|
|
203
218
|
FROM ${this._hierarchyConfig.elementClassSpecification}
|
|
204
219
|
GROUP BY Model.Id
|
|
@@ -208,28 +223,63 @@ export class ModelsTreeIdsCache {
|
|
|
208
223
|
}
|
|
209
224
|
}
|
|
210
225
|
async *queryModelCategories() {
|
|
211
|
-
const query =
|
|
212
|
-
SELECT Model.Id modelId, Category.Id categoryId
|
|
213
|
-
FROM ${
|
|
214
|
-
|
|
215
|
-
|
|
226
|
+
const query = `
|
|
227
|
+
SELECT this.Model.Id modelId, this.Category.Id categoryId, m.IsPrivate isModelPrivate
|
|
228
|
+
FROM ${CLASS_NAME_Model} m
|
|
229
|
+
JOIN ${this._hierarchyConfig.elementClassSpecification} this ON m.ECInstanceId = this.Model.Id
|
|
230
|
+
WHERE this.Parent.Id IS NULL
|
|
231
|
+
GROUP BY modelId, categoryId, isModelPrivate
|
|
232
|
+
`;
|
|
233
|
+
for await (const row of this._queryExecutor.createQueryReader({ ecsql: query }, { rowFormat: "ECSqlPropertyNames", limit: "unbounded" })) {
|
|
234
|
+
yield { modelId: row.modelId, categoryId: row.categoryId, isModelPrivate: !!row.isModelPrivate };
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
async *queryModeledElements() {
|
|
238
|
+
const query = `
|
|
239
|
+
SELECT
|
|
240
|
+
pe.ECInstanceId modeledElementId,
|
|
241
|
+
pe.Category.Id categoryId,
|
|
242
|
+
pe.Model.Id modelId
|
|
243
|
+
FROM ${CLASS_NAME_Model} m
|
|
244
|
+
JOIN ${this._hierarchyConfig.elementClassSpecification} pe ON pe.ECInstanceId = m.ModeledElement.Id
|
|
245
|
+
WHERE
|
|
246
|
+
m.IsPrivate = false
|
|
247
|
+
AND m.ECInstanceId IN (SELECT Model.Id FROM ${this._hierarchyConfig.elementClassSpecification})
|
|
216
248
|
`;
|
|
217
249
|
for await (const row of this._queryExecutor.createQueryReader({ ecsql: query }, { rowFormat: "ECSqlPropertyNames", limit: "unbounded" })) {
|
|
218
|
-
yield { modelId: row.modelId, categoryId: row.categoryId };
|
|
250
|
+
yield { modelId: row.modelId, categoryId: row.categoryId, modeledElementId: row.modeledElementId };
|
|
219
251
|
}
|
|
220
252
|
}
|
|
253
|
+
async getModelWithCategoryModeledElements() {
|
|
254
|
+
this._modelWithCategoryModeledElements ??= (async () => {
|
|
255
|
+
const modelWithCategoryModeledElements = new Map();
|
|
256
|
+
for await (const { modelId, categoryId, modeledElementId } of this.queryModeledElements()) {
|
|
257
|
+
const key = `${modelId}-${categoryId}`;
|
|
258
|
+
const entry = modelWithCategoryModeledElements.get(key);
|
|
259
|
+
if (entry === undefined) {
|
|
260
|
+
modelWithCategoryModeledElements.set(key, new Set([modeledElementId]));
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
entry.add(modeledElementId);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
return modelWithCategoryModeledElements;
|
|
267
|
+
})();
|
|
268
|
+
return this._modelWithCategoryModeledElements;
|
|
269
|
+
}
|
|
221
270
|
async getModelInfos() {
|
|
222
271
|
this._modelInfos ??= (async () => {
|
|
223
272
|
const modelInfos = new Map();
|
|
224
273
|
await Promise.all([
|
|
225
274
|
(async () => {
|
|
226
|
-
for await (const { modelId, categoryId } of this.queryModelCategories()) {
|
|
275
|
+
for await (const { modelId, categoryId, isModelPrivate } of this.queryModelCategories()) {
|
|
227
276
|
const entry = modelInfos.get(modelId);
|
|
228
277
|
if (entry) {
|
|
229
|
-
entry.
|
|
278
|
+
entry.categoryIds.add(categoryId);
|
|
279
|
+
entry.isModelPrivate = isModelPrivate;
|
|
230
280
|
}
|
|
231
281
|
else {
|
|
232
|
-
modelInfos.set(modelId, {
|
|
282
|
+
modelInfos.set(modelId, { categoryIds: new Set([categoryId]), elementCount: 0, isModelPrivate });
|
|
233
283
|
}
|
|
234
284
|
}
|
|
235
285
|
})(),
|
|
@@ -240,7 +290,7 @@ export class ModelsTreeIdsCache {
|
|
|
240
290
|
entry.elementCount = elementCount;
|
|
241
291
|
}
|
|
242
292
|
else {
|
|
243
|
-
modelInfos.set(modelId, {
|
|
293
|
+
modelInfos.set(modelId, { categoryIds: new Set(), elementCount, isModelPrivate: false });
|
|
244
294
|
}
|
|
245
295
|
}
|
|
246
296
|
})(),
|
|
@@ -249,14 +299,29 @@ export class ModelsTreeIdsCache {
|
|
|
249
299
|
})();
|
|
250
300
|
return this._modelInfos;
|
|
251
301
|
}
|
|
252
|
-
async
|
|
302
|
+
async getModelCategoryIds(modelId) {
|
|
253
303
|
const modelInfos = await this.getModelInfos();
|
|
254
|
-
const categories = modelInfos.get(modelId)?.
|
|
304
|
+
const categories = modelInfos.get(modelId)?.categoryIds;
|
|
255
305
|
return categories ? [...categories] : [];
|
|
256
306
|
}
|
|
257
|
-
async
|
|
307
|
+
async hasSubModel(elementId) {
|
|
258
308
|
const modelInfos = await this.getModelInfos();
|
|
259
|
-
|
|
309
|
+
const modeledElementInfo = modelInfos.get(elementId);
|
|
310
|
+
if (!modeledElementInfo) {
|
|
311
|
+
return false;
|
|
312
|
+
}
|
|
313
|
+
return !modeledElementInfo.isModelPrivate;
|
|
314
|
+
}
|
|
315
|
+
async getCategoriesModeledElements(modelId, categoryIds) {
|
|
316
|
+
const modelWithCategoryModeledElements = await this.getModelWithCategoryModeledElements();
|
|
317
|
+
const result = new Array();
|
|
318
|
+
for (const categoryId of Id64.iterable(categoryIds)) {
|
|
319
|
+
const entry = modelWithCategoryModeledElements.get(`${modelId}-${categoryId}`);
|
|
320
|
+
if (entry !== undefined) {
|
|
321
|
+
result.push(...entry);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
return result;
|
|
260
325
|
}
|
|
261
326
|
async createModelInstanceKeyPaths(modelId) {
|
|
262
327
|
let entry = this._modelKeyPaths.get(modelId);
|
|
@@ -265,7 +330,7 @@ export class ModelsTreeIdsCache {
|
|
|
265
330
|
const result = new Array();
|
|
266
331
|
const subjectInfos = (await this.getSubjectInfos()).entries();
|
|
267
332
|
for (const [modelSubjectId, subjectInfo] of subjectInfos) {
|
|
268
|
-
if (subjectInfo.
|
|
333
|
+
if (subjectInfo.childModelIds.has(modelId)) {
|
|
269
334
|
const subjectPath = await this.createSubjectInstanceKeysPath(modelSubjectId);
|
|
270
335
|
result.push([...subjectPath, { className: "BisCore.GeometricModel3d", id: modelId }]);
|
|
271
336
|
}
|
|
@@ -276,39 +341,6 @@ export class ModelsTreeIdsCache {
|
|
|
276
341
|
}
|
|
277
342
|
return entry;
|
|
278
343
|
}
|
|
279
|
-
async queryCategoryElementCounts(input) {
|
|
280
|
-
const reader = this._queryExecutor.createQueryReader({
|
|
281
|
-
ctes: [
|
|
282
|
-
/* sql */ `
|
|
283
|
-
CategoryElements(id, modelId, categoryId) AS (
|
|
284
|
-
SELECT ECInstanceId, Model.Id, Category.Id
|
|
285
|
-
FROM ${this._hierarchyConfig.elementClassSpecification}
|
|
286
|
-
WHERE
|
|
287
|
-
Parent.Id IS NULL
|
|
288
|
-
AND (
|
|
289
|
-
${input.map(({ modelId, categoryId }) => `Model.Id = ${modelId} AND Category.Id = ${categoryId}`).join(" OR ")}
|
|
290
|
-
)
|
|
291
|
-
|
|
292
|
-
UNION ALL
|
|
293
|
-
|
|
294
|
-
SELECT c.ECInstanceId, p.modelId, p.categoryId
|
|
295
|
-
FROM ${this._hierarchyConfig.elementClassSpecification} c
|
|
296
|
-
JOIN CategoryElements p ON c.Parent.Id = p.id
|
|
297
|
-
)
|
|
298
|
-
`,
|
|
299
|
-
],
|
|
300
|
-
ecsql: `
|
|
301
|
-
SELECT modelId, categoryId, COUNT(id) elementsCount
|
|
302
|
-
FROM CategoryElements
|
|
303
|
-
GROUP BY modelId, categoryId
|
|
304
|
-
`,
|
|
305
|
-
}, { rowFormat: "ECSqlPropertyNames", limit: "unbounded" });
|
|
306
|
-
const result = new Array();
|
|
307
|
-
for await (const row of reader) {
|
|
308
|
-
result.push({ modelId: row.modelId, categoryId: row.categoryId, elementsCount: row.elementsCount });
|
|
309
|
-
}
|
|
310
|
-
return result;
|
|
311
|
-
}
|
|
312
344
|
async getCategoryElementsCount(modelId, categoryId) {
|
|
313
345
|
return this._categoryElementCounts.getCategoryElementsCount(modelId, categoryId);
|
|
314
346
|
}
|
|
@@ -319,7 +351,7 @@ export class ModelsTreeIdsCache {
|
|
|
319
351
|
const result = new Set();
|
|
320
352
|
const modelInfos = await this.getModelInfos();
|
|
321
353
|
modelInfos?.forEach((modelInfo, modelId) => {
|
|
322
|
-
if (modelInfo.
|
|
354
|
+
if (modelInfo.categoryIds.has(categoryId)) {
|
|
323
355
|
result.add(modelId);
|
|
324
356
|
}
|
|
325
357
|
});
|
|
@@ -327,7 +359,7 @@ export class ModelsTreeIdsCache {
|
|
|
327
359
|
for (const categoryModelId of [...result]) {
|
|
328
360
|
const modelPaths = await this.createModelInstanceKeyPaths(categoryModelId);
|
|
329
361
|
for (const modelPath of modelPaths) {
|
|
330
|
-
categoryPaths.push([...modelPath, { className:
|
|
362
|
+
categoryPaths.push([...modelPath, { className: CLASS_NAME_SpatialCategory, id: categoryId }]);
|
|
331
363
|
}
|
|
332
364
|
}
|
|
333
365
|
return categoryPaths;
|
|
@@ -340,7 +372,7 @@ export class ModelsTreeIdsCache {
|
|
|
340
372
|
function forEachChildSubject(subjectInfos, parentSubject, cb) {
|
|
341
373
|
const parentSubjectInfo = typeof parentSubject === "string" ? subjectInfos.get(parentSubject) : parentSubject;
|
|
342
374
|
parentSubjectInfo &&
|
|
343
|
-
parentSubjectInfo.
|
|
375
|
+
parentSubjectInfo.childSubjectIds.forEach((childSubjectId) => {
|
|
344
376
|
const childSubjectInfo = subjectInfos.get(childSubjectId);
|
|
345
377
|
if (cb(childSubjectId, childSubjectInfo) === "break") {
|
|
346
378
|
return;
|
|
@@ -348,34 +380,4 @@ function forEachChildSubject(subjectInfos, parentSubject, cb) {
|
|
|
348
380
|
forEachChildSubject(subjectInfos, childSubjectInfo, cb);
|
|
349
381
|
});
|
|
350
382
|
}
|
|
351
|
-
class ModelCategoryElementsCountCache {
|
|
352
|
-
constructor(_loader) {
|
|
353
|
-
this._loader = _loader;
|
|
354
|
-
this._cache = new Map();
|
|
355
|
-
this._requestsStream = new Subject();
|
|
356
|
-
this._subscription = this._requestsStream
|
|
357
|
-
.pipe(bufferTime(20), filter((requests) => requests.length > 0), mergeMap(async (requests) => this._loader(requests)), mergeAll())
|
|
358
|
-
.subscribe({
|
|
359
|
-
next: ({ modelId, categoryId, elementsCount }) => {
|
|
360
|
-
const subject = this._cache.get(`${modelId}${categoryId}`);
|
|
361
|
-
assert(!!subject);
|
|
362
|
-
subject.next(elementsCount);
|
|
363
|
-
},
|
|
364
|
-
});
|
|
365
|
-
}
|
|
366
|
-
[Symbol.dispose]() {
|
|
367
|
-
this._subscription.unsubscribe();
|
|
368
|
-
}
|
|
369
|
-
async getCategoryElementsCount(modelId, categoryId) {
|
|
370
|
-
const cacheKey = `${modelId}${categoryId}`;
|
|
371
|
-
let result = this._cache.get(cacheKey);
|
|
372
|
-
if (result !== undefined) {
|
|
373
|
-
return firstValueFrom(result);
|
|
374
|
-
}
|
|
375
|
-
result = new ReplaySubject(1);
|
|
376
|
-
this._cache.set(cacheKey, result);
|
|
377
|
-
this._requestsStream.next({ modelId, categoryId });
|
|
378
|
-
return firstValueFrom(result);
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
383
|
//# sourceMappingURL=ModelsTreeIdsCache.js.map
|
package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelsTreeIdsCache.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAGhG,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACtG,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAqBlD,gBAAgB;AAChB,MAAM,OAAO,kBAAkB;IAS7B,YACU,cAA0C,EAC1C,gBAAkD;QADlD,mBAAc,GAAd,cAAc,CAA4B;QAC1C,qBAAgB,GAAhB,gBAAgB,CAAkC;QAE1D,IAAI,CAAC,sBAAsB,GAAG,IAAI,+BAA+B,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,0BAA0B,CAAC,KAAK,CAAC,CAAC,CAAC;QAC3H,IAAI,CAAC,cAAc,GAAG,IAAI,GAAG,EAAE,CAAC;QAChC,IAAI,CAAC,gBAAgB,GAAG,IAAI,GAAG,EAAE,CAAC;QAClC,IAAI,CAAC,iBAAiB,GAAG,IAAI,GAAG,EAAE,CAAC;IACrC,CAAC;IAEM,CAAC,MAAM,CAAC,OAAO,CAAC;QACrB,IAAI,CAAC,sBAAsB,CAAC,M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AAM,KAAK,SAAS,EAAE;YACxB,OAAO,cAAc,CAAC,MAAM,CAAC,CAAC;SAC/B;QAED,MAAM,GAAG,IAAI,aAAa,CAAC,CAAC,CAAC,CAAC;QAC9B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAClC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC;QACnD,OAAO,cAAc,CAAC,MAAM,CAAC,CAAC;IAChC,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 type { Subscription } from \"rxjs\";\nimport { bufferTime, filter, firstValueFrom, mergeAll, mergeMap, ReplaySubject, Subject } from \"rxjs\";\nimport { assert } from \"@itwin/core-bentley\";\nimport { pushToMap } from \"../../common/Utils.js\";\n\nimport type { InstanceKey } from \"@itwin/presentation-shared\";\nimport type { ModelsTreeDefinition } from \"../ModelsTreeDefinition.js\";\nimport type { Id64Array, Id64Set, Id64String } from \"@itwin/core-bentley\";\nimport type { HierarchyNodeIdentifiersPath, LimitingECSqlQueryExecutor } from \"@itwin/presentation-hierarchies\";\n\ninterface SubjectInfo {\n parentSubject: Id64String | undefined;\n hideInHierarchy: boolean;\n childSubjects: Id64Set;\n childModels: Id64Set;\n}\n\ninterface ModelInfo {\n categories: Id64Set;\n elementCount: number;\n}\n\ntype ModelsTreeHierarchyConfiguration = ConstructorParameters<typeof ModelsTreeDefinition>[0][\"hierarchyConfig\"];\n\n/** @internal */\nexport class ModelsTreeIdsCache {\n private readonly _categoryElementCounts: ModelCategoryElementsCountCache;\n private _subjectInfos: Promise<Map<Id64String, SubjectInfo>> | undefined;\n private _parentSubjectIds: Promise<Id64Array> | undefined; // the list should contain a subject id if its node should be shown as having children\n private _modelInfos: Promise<Map<Id64String, ModelInfo>> | undefined;\n private _modelKeyPaths: Map<Id64String, Promise<HierarchyNodeIdentifiersPath[]>>;\n private _subjectKeyPaths: Map<Id64String, Promise<HierarchyNodeIdentifiersPath>>;\n private _categoryKeyPaths: Map<Id64String, Promise<HierarchyNodeIdentifiersPath[]>>;\n\n constructor(\n private _queryExecutor: LimitingECSqlQueryExecutor,\n private _hierarchyConfig: ModelsTreeHierarchyConfiguration,\n ) {\n this._categoryElementCounts = new ModelCategoryElementsCountCache(async (input) => this.queryCategoryElementCounts(input));\n this._modelKeyPaths = new Map();\n this._subjectKeyPaths = new Map();\n this._categoryKeyPaths = new Map();\n }\n\n public [Symbol.dispose]() {\n this._categoryElementCounts[Symbol.dispose]();\n }\n\n private async *querySubjects(): AsyncIterableIterator<{ id: Id64String; parentId?: Id64String; targetPartitionId?: Id64String; hideInHierarchy: boolean }> {\n const subjectsQuery = `\n SELECT\n s.ECInstanceId id,\n s.Parent.Id parentId,\n (\n SELECT m.ECInstanceId\n FROM bis.GeometricModel3d m\n WHERE m.ECInstanceId = HexToId(json_extract(s.JsonProperties, '$.Subject.Model.TargetPartition'))\n AND NOT m.IsPrivate\n AND EXISTS (SELECT 1 FROM ${this._hierarchyConfig.elementClassSpecification} WHERE Model.Id = m.ECInstanceId)\n ) targetPartitionId,\n CASE\n WHEN (\n json_extract(s.JsonProperties, '$.Subject.Job.Bridge') IS NOT NULL\n OR json_extract(s.JsonProperties, '$.Subject.Model.Type') = 'Hierarchy'\n ) THEN 1\n ELSE 0\n END hideInHierarchy\n FROM bis.Subject s\n `;\n for await (const row of this._queryExecutor.createQueryReader({ ecsql: subjectsQuery }, { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\" })) {\n yield { id: row.id, parentId: row.parentId, targetPartitionId: row.targetPartitionId, hideInHierarchy: !!row.hideInHierarchy };\n }\n }\n\n private async *queryModels(): AsyncIterableIterator<{ id: Id64String; parentId: Id64String }> {\n const modelsQuery = `\n SELECT p.ECInstanceId id, p.Parent.Id parentId\n FROM bis.InformationPartitionElement p\n INNER JOIN bis.GeometricModel3d m ON m.ModeledElement.Id = p.ECInstanceId\n WHERE\n NOT m.IsPrivate\n ${this._hierarchyConfig.showEmptyModels ? \"\" : `AND EXISTS (SELECT 1 FROM ${this._hierarchyConfig.elementClassSpecification} WHERE Model.Id = m.ECInstanceId)`}\n `;\n for await (const row of this._queryExecutor.createQueryReader({ ecsql: modelsQuery }, { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\" })) {\n yield { id: row.id, parentId: row.parentId };\n }\n }\n\n private async getSubjectInfos() {\n this._subjectInfos ??= (async () => {\n const [subjectInfos, targetPartitionSubjects] = await Promise.all([\n (async () => {\n const result = new Map<Id64String, SubjectInfo>();\n for await (const subject of this.querySubjects()) {\n const subjectInfo: SubjectInfo = {\n parentSubject: subject.parentId,\n hideInHierarchy: subject.hideInHierarchy,\n childSubjects: new Set(),\n childModels: new Set(),\n };\n if (subject.targetPartitionId) {\n subjectInfo.childModels.add(subject.targetPartitionId);\n }\n result.set(subject.id, subjectInfo);\n }\n return result;\n })(),\n (async () => {\n const result = new Map<Id64String, Set<Id64String>>();\n for await (const model of this.queryModels()) {\n pushToMap(result, model.id, model.parentId);\n }\n return result;\n })(),\n ]);\n\n for (const [subjectId, { parentSubject: parentSubjectId }] of subjectInfos.entries()) {\n if (parentSubjectId) {\n const parentSubjectInfo = subjectInfos.get(parentSubjectId);\n assert(!!parentSubjectInfo);\n parentSubjectInfo.childSubjects.add(subjectId);\n }\n }\n\n for (const [partitionId, subjectIds] of targetPartitionSubjects) {\n subjectIds.forEach((subjectId) => {\n const subjectInfo = subjectInfos.get(subjectId);\n assert(!!subjectInfo);\n subjectInfo.childModels.add(partitionId);\n });\n }\n\n return subjectInfos;\n })();\n return this._subjectInfos;\n }\n\n /** Returns ECInstanceIDs of Subjects that either have direct Model or at least one child Subject with a Model. */\n public async getParentSubjectIds(): Promise<Id64String[]> {\n this._parentSubjectIds ??= (async () => {\n const subjectInfos = await this.getSubjectInfos();\n const parentSubjectIds = new Set<Id64String>();\n subjectInfos.forEach((subjectInfo, subjectId) => {\n if (subjectInfo.childModels.size > 0) {\n parentSubjectIds.add(subjectId);\n let currParentId = subjectInfo.parentSubject;\n while (currParentId) {\n parentSubjectIds.add(currParentId);\n currParentId = subjectInfos.get(currParentId)?.parentSubject;\n }\n }\n });\n return [...parentSubjectIds];\n })();\n return this._parentSubjectIds;\n }\n\n /**\n * Returns child subjects of the specified parent subjects as they're displayed in the hierarchy - taking into\n * account `hideInHierarchy` flag.\n */\n public async getChildSubjectIds(parentSubjectIds: Id64String[]): Promise<Id64String[]> {\n const childSubjectIds = new Array<Id64String>();\n const subjectInfos = await this.getSubjectInfos();\n parentSubjectIds.forEach((subjectId) => {\n forEachChildSubject(subjectInfos, subjectId, (childSubjectId, childSubjectInfo) => {\n if (!childSubjectInfo.hideInHierarchy) {\n childSubjectIds.push(childSubjectId);\n return \"break\";\n }\n return \"continue\";\n });\n });\n return childSubjectIds;\n }\n\n /** Returns ECInstanceIDs of all Models under specific parent Subjects, including their child Subjects, etc. */\n public async getSubjectModelIds(subjectIds: Id64Array): Promise<Id64Array> {\n const subjectInfos = await this.getSubjectInfos();\n const subjectStack = [...subjectIds];\n const result = new Array<Id64String>();\n while (true) {\n const subjectId = subjectStack.pop();\n if (subjectId === undefined) {\n break;\n }\n const subjectInfo = subjectInfos.get(subjectId);\n if (!subjectInfo) {\n continue;\n }\n result.push(...subjectInfo.childModels);\n subjectStack.push(...subjectInfo.childSubjects);\n }\n return result;\n }\n\n /** Returns ECInstanceIDs of Models under specific parent Subjects as they are displayed in the hierarchy. */\n public async getChildSubjectModelIds(parentSubjectIds: Id64String[]): Promise<Id64String[]> {\n const subjectInfos = await this.getSubjectInfos();\n\n const hiddenSubjectIds = new Array<Id64String>();\n parentSubjectIds.forEach((subjectId) => {\n forEachChildSubject(subjectInfos, subjectId, (childSubjectId, childSubjectInfo) => {\n if (childSubjectInfo.hideInHierarchy) {\n hiddenSubjectIds.push(childSubjectId);\n return \"continue\";\n }\n return \"break\";\n });\n });\n\n const modelIds = new Array<Id64String>();\n [...parentSubjectIds, ...hiddenSubjectIds].forEach((subjectId) => {\n const subjectInfo = subjectInfos.get(subjectId);\n subjectInfo && modelIds.push(...subjectInfo.childModels);\n });\n return modelIds;\n }\n\n public async createSubjectInstanceKeysPath(targetSubjectId: Id64String): Promise<HierarchyNodeIdentifiersPath> {\n let entry = this._subjectKeyPaths.get(targetSubjectId);\n if (!entry) {\n entry = (async () => {\n const subjectInfos = await this.getSubjectInfos();\n const result = new Array<InstanceKey>();\n let currParentId: Id64String | undefined = targetSubjectId;\n while (currParentId) {\n const parentInfo = subjectInfos.get(currParentId);\n if (!parentInfo?.hideInHierarchy) {\n result.push({ className: \"BisCore.Subject\", id: currParentId });\n }\n currParentId = parentInfo?.parentSubject;\n }\n return result.reverse();\n })();\n this._subjectKeyPaths.set(targetSubjectId, entry);\n }\n return entry;\n }\n\n private async *queryModelElementCounts() {\n const query = /* sql */ `\n SELECT Model.Id modelId, COUNT(*) elementCount\n FROM ${this._hierarchyConfig.elementClassSpecification}\n GROUP BY Model.Id\n `;\n for await (const row of this._queryExecutor.createQueryReader({ ecsql: query }, { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\" })) {\n yield { modelId: row.modelId, elementCount: row.elementCount };\n }\n }\n\n private async *queryModelCategories() {\n const query = /* sql */ `\n SELECT Model.Id modelId, Category.Id categoryId\n FROM ${this._hierarchyConfig.elementClassSpecification}\n WHERE Parent.Id IS NULL\n GROUP BY modelId, categoryId\n `;\n for await (const row of this._queryExecutor.createQueryReader({ ecsql: query }, { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\" })) {\n yield { modelId: row.modelId, categoryId: row.categoryId };\n }\n }\n\n private async getModelInfos() {\n this._modelInfos ??= (async () => {\n const modelInfos = new Map<Id64String, { categories: Id64Set; elementCount: number }>();\n await Promise.all([\n (async () => {\n for await (const { modelId, categoryId } of this.queryModelCategories()) {\n const entry = modelInfos.get(modelId);\n if (entry) {\n entry.categories.add(categoryId);\n } else {\n modelInfos.set(modelId, { categories: new Set([categoryId]), elementCount: 0 });\n }\n }\n })(),\n (async () => {\n for await (const { modelId, elementCount } of this.queryModelElementCounts()) {\n const entry = modelInfos.get(modelId);\n if (entry) {\n entry.elementCount = elementCount;\n } else {\n modelInfos.set(modelId, { categories: new Set(), elementCount });\n }\n }\n })(),\n ]);\n return modelInfos;\n })();\n return this._modelInfos;\n }\n\n public async getModelCategories(modelId: Id64String): Promise<Id64Array> {\n const modelInfos = await this.getModelInfos();\n const categories = modelInfos.get(modelId)?.categories;\n return categories ? [...categories] : [];\n }\n\n public async getModelElementCount(modelId: Id64String): Promise<number> {\n const modelInfos = await this.getModelInfos();\n return modelInfos.get(modelId)?.elementCount ?? 0;\n }\n\n public async createModelInstanceKeyPaths(modelId: Id64String): Promise<HierarchyNodeIdentifiersPath[]> {\n let entry = this._modelKeyPaths.get(modelId);\n if (!entry) {\n entry = (async () => {\n const result = new Array<HierarchyNodeIdentifiersPath>();\n const subjectInfos = (await this.getSubjectInfos()).entries();\n for (const [modelSubjectId, subjectInfo] of subjectInfos) {\n if (subjectInfo.childModels.has(modelId)) {\n const subjectPath = await this.createSubjectInstanceKeysPath(modelSubjectId);\n result.push([...subjectPath, { className: \"BisCore.GeometricModel3d\", id: modelId }]);\n }\n }\n return result;\n })();\n\n this._modelKeyPaths.set(modelId, entry);\n }\n return entry;\n }\n\n private async queryCategoryElementCounts(\n input: Array<{ modelId: Id64String; categoryId: Id64String }>,\n ): Promise<Array<{ modelId: number; categoryId: number; elementsCount: number }>> {\n const reader = this._queryExecutor.createQueryReader(\n {\n ctes: [\n /* sql */ `\n CategoryElements(id, modelId, categoryId) AS (\n SELECT ECInstanceId, Model.Id, Category.Id\n FROM ${this._hierarchyConfig.elementClassSpecification}\n WHERE\n Parent.Id IS NULL\n AND (\n ${input.map(({ modelId, categoryId }) => `Model.Id = ${modelId} AND Category.Id = ${categoryId}`).join(\" OR \")}\n )\n\n UNION ALL\n\n SELECT c.ECInstanceId, p.modelId, p.categoryId\n FROM ${this._hierarchyConfig.elementClassSpecification} c\n JOIN CategoryElements p ON c.Parent.Id = p.id\n )\n `,\n ],\n ecsql: `\n SELECT modelId, categoryId, COUNT(id) elementsCount\n FROM CategoryElements\n GROUP BY modelId, categoryId\n `,\n },\n { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\" },\n );\n\n const result = new Array<{ modelId: number; categoryId: number; elementsCount: number }>();\n for await (const row of reader) {\n result.push({ modelId: row.modelId, categoryId: row.categoryId, elementsCount: row.elementsCount });\n }\n return result;\n }\n\n public async getCategoryElementsCount(modelId: Id64String, categoryId: Id64String): Promise<number> {\n return this._categoryElementCounts.getCategoryElementsCount(modelId, categoryId);\n }\n\n public async createCategoryInstanceKeyPaths(categoryId: Id64String): Promise<HierarchyNodeIdentifiersPath[]> {\n let entry = this._categoryKeyPaths.get(categoryId);\n if (!entry) {\n entry = (async () => {\n const result = new Set<Id64String>();\n const modelInfos = await this.getModelInfos();\n modelInfos?.forEach((modelInfo, modelId) => {\n if (modelInfo.categories.has(categoryId)) {\n result.add(modelId);\n }\n });\n\n const categoryPaths = new Array<HierarchyNodeIdentifiersPath>();\n for (const categoryModelId of [...result]) {\n const modelPaths = await this.createModelInstanceKeyPaths(categoryModelId);\n for (const modelPath of modelPaths) {\n categoryPaths.push([...modelPath, { className: \"BisCore.SpatialCategory\", id: categoryId }]);\n }\n }\n return categoryPaths;\n })();\n this._categoryKeyPaths.set(categoryId, entry);\n }\n return entry;\n }\n}\n\nfunction forEachChildSubject(\n subjectInfos: Map<Id64String, SubjectInfo>,\n parentSubject: Id64String | SubjectInfo,\n cb: (childSubjectId: Id64String, childSubjectInfo: SubjectInfo) => \"break\" | \"continue\",\n) {\n const parentSubjectInfo = typeof parentSubject === \"string\" ? subjectInfos.get(parentSubject) : parentSubject;\n parentSubjectInfo &&\n parentSubjectInfo.childSubjects.forEach((childSubjectId) => {\n const childSubjectInfo = subjectInfos.get(childSubjectId)!;\n if (cb(childSubjectId, childSubjectInfo) === \"break\") {\n return;\n }\n forEachChildSubject(subjectInfos, childSubjectInfo, cb);\n });\n}\n\nclass ModelCategoryElementsCountCache {\n private _cache = new Map<string, Subject<number>>();\n private _requestsStream = new Subject<{ modelId: Id64String; categoryId: Id64String }>();\n private _subscription: Subscription;\n\n public constructor(\n private _loader: (\n input: Array<{ modelId: Id64String; categoryId: Id64String }>,\n ) => Promise<Array<{ modelId: number; categoryId: number; elementsCount: number }>>,\n ) {\n this._subscription = this._requestsStream\n .pipe(\n bufferTime(20),\n filter((requests) => requests.length > 0),\n mergeMap(async (requests) => this._loader(requests)),\n mergeAll(),\n )\n .subscribe({\n next: ({ modelId, categoryId, elementsCount }) => {\n const subject = this._cache.get(`${modelId}${categoryId}`);\n assert(!!subject);\n subject.next(elementsCount);\n },\n });\n }\n\n public [Symbol.dispose]() {\n this._subscription.unsubscribe();\n }\n\n public async getCategoryElementsCount(modelId: Id64String, categoryId: Id64String): Promise<number> {\n const cacheKey = `${modelId}${categoryId}`;\n let result = this._cache.get(cacheKey);\n if (result !== undefined) {\n return firstValueFrom(result);\n }\n\n result = new ReplaySubject(1);\n this._cache.set(cacheKey, result);\n this._requestsStream.next({ modelId, categoryId });\n return firstValueFrom(result);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ModelsTreeIdsCache.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EACL,2BAA2B,EAC3B,sCAAsC,EACtC,gBAAgB,EAChB,0BAA0B,EAC1B,kBAAkB,GACnB,MAAM,+CAA+C,CAAC;AACvD,OAAO,EAAE,+BAA+B,EAAE,MAA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AC3D,IAAI,EAAE,CAAC,cAAc,EAAE,gBAAgB,CAAC,KAAK,OAAO,EAAE,CAAC;gBACrD,OAAO;YACT,CAAC;YACD,mBAAmB,CAAC,YAAY,EAAE,gBAAgB,EAAE,EAAE,CAAC,CAAC;QAC1D,CAAC,CAAC,CAAC;AACP,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 { assert, Id64 } from \"@itwin/core-bentley\";\nimport { IModel } from \"@itwin/core-common\";\nimport {\n CLASS_NAME_GeometricModel3d,\n CLASS_NAME_InformationPartitionElement,\n CLASS_NAME_Model,\n CLASS_NAME_SpatialCategory,\n CLASS_NAME_Subject,\n} from \"../../common/internal/ClassNameDefinitions.js\";\nimport { ModelCategoryElementsCountCache } from \"../../common/internal/ModelCategoryElementsCountCache.js\";\nimport { pushToMap } from \"../../common/internal/Utils.js\";\n\nimport type { InstanceKey } from \"@itwin/presentation-shared\";\nimport type { ModelsTreeDefinition } from \"../ModelsTreeDefinition.js\";\nimport type { Id64Arg, Id64Array, Id64Set, Id64String } from \"@itwin/core-bentley\";\nimport type { HierarchyNodeIdentifiersPath, LimitingECSqlQueryExecutor } from \"@itwin/presentation-hierarchies\";\nimport type { CategoryId, ElementId, ModelId, SubjectId } from \"../../common/internal/Types.js\";\n\ninterface SubjectInfo {\n parentSubjectId: Id64String | undefined;\n hideInHierarchy: boolean;\n childSubjectIds: Id64Set;\n childModelIds: Id64Set;\n}\n\ninterface ModelInfo {\n isModelPrivate: boolean;\n categoryIds: Id64Set;\n elementCount: number;\n}\n\ntype ModelsTreeHierarchyConfiguration = ConstructorParameters<typeof ModelsTreeDefinition>[0][\"hierarchyConfig\"];\n\ntype ModelCategoryKey = `${ModelId}-${CategoryId}`;\n\n/** @internal */\nexport class ModelsTreeIdsCache {\n private readonly _categoryElementCounts: ModelCategoryElementsCountCache;\n private _subjectInfos: Promise<Map<SubjectId, SubjectInfo>> | undefined;\n private _parentSubjectIds: Promise<Id64Array> | undefined; // the list should contain a subject id if its node should be shown as having children\n private _modelInfos: Promise<Map<ModelId, ModelInfo>> | undefined;\n private _modelWithCategoryModeledElements: Promise<Map<ModelCategoryKey, Set<ElementId>>> | undefined;\n private _modelKeyPaths: Map<ModelId, Promise<HierarchyNodeIdentifiersPath[]>>;\n private _subjectKeyPaths: Map<SubjectId, Promise<HierarchyNodeIdentifiersPath>>;\n private _categoryKeyPaths: Map<CategoryId, Promise<HierarchyNodeIdentifiersPath[]>>;\n\n constructor(\n private _queryExecutor: LimitingECSqlQueryExecutor,\n private _hierarchyConfig: ModelsTreeHierarchyConfiguration,\n ) {\n this._categoryElementCounts = new ModelCategoryElementsCountCache(_queryExecutor, [this._hierarchyConfig.elementClassSpecification]);\n this._modelKeyPaths = new Map();\n this._subjectKeyPaths = new Map();\n this._categoryKeyPaths = new Map();\n }\n\n public [Symbol.dispose]() {\n this._categoryElementCounts[Symbol.dispose]();\n }\n\n private async *querySubjects(): AsyncIterableIterator<{ id: SubjectId; parentId?: SubjectId; targetPartitionId?: ModelId; hideInHierarchy: boolean }> {\n const subjectsQuery = `\n SELECT\n s.ECInstanceId id,\n s.Parent.Id parentId,\n (\n SELECT m.ECInstanceId\n FROM ${CLASS_NAME_GeometricModel3d} m\n WHERE m.ECInstanceId = HexToId(json_extract(s.JsonProperties, '$.Subject.Model.TargetPartition'))\n AND NOT m.IsPrivate\n AND EXISTS (SELECT 1 FROM ${this._hierarchyConfig.elementClassSpecification} WHERE Model.Id = m.ECInstanceId)\n ) targetPartitionId,\n CASE\n WHEN (\n json_extract(s.JsonProperties, '$.Subject.Job.Bridge') IS NOT NULL\n OR json_extract(s.JsonProperties, '$.Subject.Model.Type') = 'Hierarchy'\n ) THEN 1\n ELSE 0\n END hideInHierarchy\n FROM bis.Subject s\n `;\n for await (const row of this._queryExecutor.createQueryReader({ ecsql: subjectsQuery }, { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\" })) {\n yield { id: row.id, parentId: row.parentId, targetPartitionId: row.targetPartitionId, hideInHierarchy: !!row.hideInHierarchy };\n }\n }\n\n private async *queryModels(): AsyncIterableIterator<{ id: ModelId; parentId: SubjectId }> {\n const modelsQuery = `\n SELECT p.ECInstanceId id, p.Parent.Id parentId\n FROM ${CLASS_NAME_InformationPartitionElement} p\n INNER JOIN ${CLASS_NAME_GeometricModel3d} m ON m.ModeledElement.Id = p.ECInstanceId\n WHERE\n NOT m.IsPrivate\n ${this._hierarchyConfig.showEmptyModels ? \"\" : `AND EXISTS (SELECT 1 FROM ${this._hierarchyConfig.elementClassSpecification} WHERE Model.Id = m.ECInstanceId)`}\n `;\n for await (const row of this._queryExecutor.createQueryReader({ ecsql: modelsQuery }, { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\" })) {\n yield { id: row.id, parentId: row.parentId };\n }\n }\n\n private async getSubjectInfos() {\n this._subjectInfos ??= (async () => {\n const [subjectInfos, targetPartitionSubjects] = await Promise.all([\n (async () => {\n const result = new Map<SubjectId, SubjectInfo>();\n for await (const subject of this.querySubjects()) {\n const subjectInfo: SubjectInfo = {\n parentSubjectId: subject.parentId,\n hideInHierarchy: subject.hideInHierarchy,\n childSubjectIds: new Set(),\n childModelIds: new Set(),\n };\n if (subject.targetPartitionId) {\n subjectInfo.childModelIds.add(subject.targetPartitionId);\n }\n result.set(subject.id, subjectInfo);\n }\n return result;\n })(),\n (async () => {\n const result = new Map<ModelId, Set<SubjectId>>();\n for await (const model of this.queryModels()) {\n pushToMap(result, model.id, model.parentId);\n }\n return result;\n })(),\n ]);\n\n for (const [subjectId, { parentSubjectId }] of subjectInfos.entries()) {\n if (parentSubjectId) {\n const parentSubjectInfo = subjectInfos.get(parentSubjectId);\n assert(!!parentSubjectInfo);\n parentSubjectInfo.childSubjectIds.add(subjectId);\n }\n }\n\n for (const [partitionId, subjectIds] of targetPartitionSubjects) {\n subjectIds.forEach((subjectId) => {\n const subjectInfo = subjectInfos.get(subjectId);\n assert(!!subjectInfo);\n subjectInfo.childModelIds.add(partitionId);\n });\n }\n\n return subjectInfos;\n })();\n return this._subjectInfos;\n }\n\n /** Returns ECInstanceIDs of Subjects that either have direct Model or at least one child Subject with a Model. */\n public async getParentSubjectIds(): Promise<Id64Array> {\n this._parentSubjectIds ??= (async () => {\n const subjectInfos = await this.getSubjectInfos();\n const parentSubjectIds = new Set<SubjectId>();\n subjectInfos.forEach((subjectInfo, subjectId) => {\n if (subjectInfo.childModelIds.size > 0) {\n parentSubjectIds.add(subjectId);\n let currParentId = subjectInfo.parentSubjectId;\n while (currParentId) {\n parentSubjectIds.add(currParentId);\n currParentId = subjectInfos.get(currParentId)?.parentSubjectId;\n }\n }\n });\n return [...parentSubjectIds];\n })();\n return this._parentSubjectIds;\n }\n\n /**\n * Returns child subjects of the specified parent subjects as they're displayed in the hierarchy - taking into\n * account `hideInHierarchy` flag.\n */\n public async getChildSubjectIds(parentSubjectIds: Id64Array): Promise<Id64Array> {\n const childSubjectIds = new Array<SubjectId>();\n const subjectInfos = await this.getSubjectInfos();\n parentSubjectIds.forEach((subjectId) => {\n forEachChildSubject(subjectInfos, subjectId, (childSubjectId, childSubjectInfo) => {\n if (!childSubjectInfo.hideInHierarchy) {\n childSubjectIds.push(childSubjectId);\n return \"break\";\n }\n return \"continue\";\n });\n });\n return childSubjectIds;\n }\n\n /** Returns ECInstanceIDs of all Models under specific parent Subjects, including their child Subjects, etc. */\n public async getSubjectModelIds(subjectIds: Id64Array): Promise<Id64Array> {\n const subjectInfos = await this.getSubjectInfos();\n const subjectStack = [...subjectIds];\n const result = new Array<ModelId>();\n while (true) {\n const subjectId = subjectStack.pop();\n if (subjectId === undefined) {\n break;\n }\n const subjectInfo = subjectInfos.get(subjectId);\n if (!subjectInfo) {\n continue;\n }\n result.push(...subjectInfo.childModelIds);\n subjectStack.push(...subjectInfo.childSubjectIds);\n }\n return result;\n }\n\n /** Returns ECInstanceIDs of Models under specific parent Subjects as they are displayed in the hierarchy. */\n public async getChildSubjectModelIds(parentSubjectIds: Id64Array): Promise<Id64Array> {\n const subjectInfos = await this.getSubjectInfos();\n\n const hiddenSubjectIds = new Array<SubjectId>();\n parentSubjectIds.forEach((subjectId) => {\n forEachChildSubject(subjectInfos, subjectId, (childSubjectId, childSubjectInfo) => {\n if (childSubjectInfo.hideInHierarchy) {\n hiddenSubjectIds.push(childSubjectId);\n return \"continue\";\n }\n return \"break\";\n });\n });\n\n const modelIds = new Array<ModelId>();\n [...parentSubjectIds, ...hiddenSubjectIds].forEach((subjectId) => {\n const subjectInfo = subjectInfos.get(subjectId);\n subjectInfo && modelIds.push(...subjectInfo.childModelIds);\n });\n return modelIds;\n }\n\n public async createSubjectInstanceKeysPath(targetSubjectId: Id64String): Promise<HierarchyNodeIdentifiersPath> {\n let entry = this._subjectKeyPaths.get(targetSubjectId);\n if (!entry) {\n entry = (async () => {\n const subjectInfos = await this.getSubjectInfos();\n const result = new Array<InstanceKey>();\n let currParentId: SubjectId | undefined = targetSubjectId;\n while (currParentId) {\n if (this._hierarchyConfig.hideRootSubject && currParentId === IModel.rootSubjectId) {\n break;\n }\n const parentInfo = subjectInfos.get(currParentId);\n if (!parentInfo?.hideInHierarchy) {\n result.push({ className: CLASS_NAME_Subject, id: currParentId });\n }\n currParentId = parentInfo?.parentSubjectId;\n }\n return result.reverse();\n })();\n this._subjectKeyPaths.set(targetSubjectId, entry);\n }\n return entry;\n }\n\n private async *queryModelElementCounts(): AsyncIterableIterator<{ modelId: Id64String; elementCount: number }> {\n const query = `\n SELECT Model.Id modelId, COUNT(*) elementCount\n FROM ${this._hierarchyConfig.elementClassSpecification}\n GROUP BY Model.Id\n `;\n for await (const row of this._queryExecutor.createQueryReader({ ecsql: query }, { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\" })) {\n yield { modelId: row.modelId, elementCount: row.elementCount };\n }\n }\n\n private async *queryModelCategories(): AsyncIterableIterator<{ modelId: Id64String; categoryId: Id64String; isModelPrivate: boolean }> {\n const query = `\n SELECT this.Model.Id modelId, this.Category.Id categoryId, m.IsPrivate isModelPrivate\n FROM ${CLASS_NAME_Model} m\n JOIN ${this._hierarchyConfig.elementClassSpecification} this ON m.ECInstanceId = this.Model.Id\n WHERE this.Parent.Id IS NULL\n GROUP BY modelId, categoryId, isModelPrivate\n `;\n for await (const row of this._queryExecutor.createQueryReader({ ecsql: query }, { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\" })) {\n yield { modelId: row.modelId, categoryId: row.categoryId, isModelPrivate: !!row.isModelPrivate };\n }\n }\n\n private async *queryModeledElements(): AsyncIterableIterator<{ modelId: Id64String; categoryId: Id64String; modeledElementId: Id64String }> {\n const query = `\n SELECT\n pe.ECInstanceId modeledElementId,\n pe.Category.Id categoryId,\n pe.Model.Id modelId\n FROM ${CLASS_NAME_Model} m\n JOIN ${this._hierarchyConfig.elementClassSpecification} pe ON pe.ECInstanceId = m.ModeledElement.Id\n WHERE\n m.IsPrivate = false\n AND m.ECInstanceId IN (SELECT Model.Id FROM ${this._hierarchyConfig.elementClassSpecification})\n `;\n for await (const row of this._queryExecutor.createQueryReader({ ecsql: query }, { rowFormat: \"ECSqlPropertyNames\", limit: \"unbounded\" })) {\n yield { modelId: row.modelId, categoryId: row.categoryId, modeledElementId: row.modeledElementId };\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 private async getModelInfos() {\n this._modelInfos ??= (async () => {\n const modelInfos = new Map<ModelId, { categoryIds: Id64Set; elementCount: number; isModelPrivate: boolean }>();\n await Promise.all([\n (async () => {\n for await (const { modelId, categoryId, isModelPrivate } of this.queryModelCategories()) {\n const entry = modelInfos.get(modelId);\n if (entry) {\n entry.categoryIds.add(categoryId);\n entry.isModelPrivate = isModelPrivate;\n } else {\n modelInfos.set(modelId, { categoryIds: new Set([categoryId]), elementCount: 0, isModelPrivate });\n }\n }\n })(),\n (async () => {\n for await (const { modelId, elementCount } of this.queryModelElementCounts()) {\n const entry = modelInfos.get(modelId);\n if (entry) {\n entry.elementCount = elementCount;\n } else {\n modelInfos.set(modelId, { categoryIds: new Set(), elementCount, isModelPrivate: false });\n }\n }\n })(),\n ]);\n return modelInfos;\n })();\n return this._modelInfos;\n }\n\n public async getModelCategoryIds(modelId: Id64String): Promise<Id64Array> {\n const modelInfos = await this.getModelInfos();\n const categories = modelInfos.get(modelId)?.categoryIds;\n return categories ? [...categories] : [];\n }\n\n public async hasSubModel(elementId: Id64String): Promise<boolean> {\n const modelInfos = await this.getModelInfos();\n const modeledElementInfo = modelInfos.get(elementId);\n if (!modeledElementInfo) {\n return false;\n }\n return !modeledElementInfo.isModelPrivate;\n }\n\n public async getCategoriesModeledElements(modelId: Id64String, categoryIds: Id64Arg): Promise<Id64Array> {\n const modelWithCategoryModeledElements = await this.getModelWithCategoryModeledElements();\n const result = new Array<Id64String>();\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 createModelInstanceKeyPaths(modelId: Id64String): Promise<HierarchyNodeIdentifiersPath[]> {\n let entry = this._modelKeyPaths.get(modelId);\n if (!entry) {\n entry = (async () => {\n const result = new Array<HierarchyNodeIdentifiersPath>();\n const subjectInfos = (await this.getSubjectInfos()).entries();\n for (const [modelSubjectId, subjectInfo] of subjectInfos) {\n if (subjectInfo.childModelIds.has(modelId)) {\n const subjectPath = await this.createSubjectInstanceKeysPath(modelSubjectId);\n result.push([...subjectPath, { className: \"BisCore.GeometricModel3d\", id: modelId }]);\n }\n }\n return result;\n })();\n\n this._modelKeyPaths.set(modelId, entry);\n }\n return entry;\n }\n\n public async getCategoryElementsCount(modelId: Id64String, categoryId: Id64String): Promise<number> {\n return this._categoryElementCounts.getCategoryElementsCount(modelId, categoryId);\n }\n\n public async createCategoryInstanceKeyPaths(categoryId: Id64String): Promise<HierarchyNodeIdentifiersPath[]> {\n let entry = this._categoryKeyPaths.get(categoryId);\n if (!entry) {\n entry = (async () => {\n const result = new Set<ModelId>();\n const modelInfos = await this.getModelInfos();\n modelInfos?.forEach((modelInfo, modelId) => {\n if (modelInfo.categoryIds.has(categoryId)) {\n result.add(modelId);\n }\n });\n\n const categoryPaths = new Array<HierarchyNodeIdentifiersPath>();\n for (const categoryModelId of [...result]) {\n const modelPaths = await this.createModelInstanceKeyPaths(categoryModelId);\n for (const modelPath of modelPaths) {\n categoryPaths.push([...modelPath, { className: CLASS_NAME_SpatialCategory, id: categoryId }]);\n }\n }\n return categoryPaths;\n })();\n this._categoryKeyPaths.set(categoryId, entry);\n }\n return entry;\n }\n}\n\nfunction forEachChildSubject(\n subjectInfos: Map<SubjectId, SubjectInfo>,\n parentSubject: SubjectId | SubjectInfo,\n cb: (childSubjectId: SubjectId, childSubjectInfo: SubjectInfo) => \"break\" | \"continue\",\n) {\n const parentSubjectInfo = typeof parentSubject === \"string\" ? subjectInfos.get(parentSubject) : parentSubject;\n parentSubjectInfo &&\n parentSubjectInfo.childSubjectIds.forEach((childSubjectId) => {\n const childSubjectInfo = subjectInfos.get(childSubjectId)!;\n if (cb(childSubjectId, childSubjectInfo) === \"break\") {\n return;\n }\n forEachChildSubject(subjectInfos, childSubjectInfo, cb);\n });\n}\n"]}
|
package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeNode.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelsTreeNode.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/models-tree/internal/ModelsTreeNode.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAGhG,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAOnE;;GAEG;AACH,MAAM,KAAW,cAAc,CAiD9B;AAjDD,WAAiB,cAAc;IAC7B;;OAEG;IACU,4BAAa,GAAG,CAAC,IAA0C,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC;IAE5G;;OAEG;IACU,0BAAW,GAAG,CAAC,IAA0C,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC;IAExG;;OAEG;IACU,6BAAc,GAAG,CAAC,IAA0C,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,EAAE,UAAU,CAAC;IAE9G,gCAAgC;IACnB,sBAAO,GAAG,CAAC,IAAoB,EAAyE,EAAE;QACrH,IAAI,gBAAgB,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"ModelsTreeNode.js","sourceRoot":"","sources":["../../../../../../../src/tree-widget-react/components/trees/models-tree/internal/ModelsTreeNode.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAGhG,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAOnE;;GAEG;AACH,MAAM,KAAW,cAAc,CAiD9B;AAjDD,WAAiB,cAAc;IAC7B;;OAEG;IACU,4BAAa,GAAG,CAAC,IAA0C,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC;IAE5G;;OAEG;IACU,0BAAW,GAAG,CAAC,IAA0C,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC;IAExG;;OAEG;IACU,6BAAc,GAAG,CAAC,IAA0C,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,EAAE,UAAU,CAAC;IAE9G,gCAAgC;IACnB,sBAAO,GAAG,CAAC,IAAoB,EAAyE,EAAE;QACrH,IAAI,gBAAgB,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YAC/C,OAAO,sBAAsB,CAAC;QAChC,CAAC;QACD,IAAI,eAAA,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC;YACxB,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,IAAI,eAAA,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;YACtB,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,IAAI,eAAA,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC;YACzB,OAAO,UAAU,CAAC;QACpB,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC;IAEF;;OAEG;IACU,yBAAU,GAAG,CAAC,IAA0C,EAA0B,EAAE;QAC/F,IAAI,IAAI,CAAC,YAAY,EAAE,OAAO,EAAE,CAAC;YAC/B,OAAO,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC;QACpC,CAAC;QAED,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC;QAClD,OAAO,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;IACxE,CAAC,CAAC;IAEF;;OAEG;IACU,4BAAa,GAAG,CAAC,IAA0C,EAA0B,EAAE,CAAC,IAAI,CAAC,YAAY,EAAE,UAAU,CAAC;AACrI,CAAC,EAjDgB,cAAc,KAAd,cAAc,QAiD9B","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 { HierarchyNodeKey } from \"@itwin/presentation-hierarchies\";\n\ninterface ModelsTreeNode {\n key: HierarchyNodeKey;\n extendedData?: { [id: string]: any };\n}\n\n/**\n * @internal\n */\nexport namespace ModelsTreeNode {\n /**\n * Determines if a node represents a subject.\n */\n export const isSubjectNode = (node: Pick<ModelsTreeNode, \"extendedData\">) => !!node.extendedData?.isSubject;\n\n /**\n * Determines if a node represents a model.\n */\n export const isModelNode = (node: Pick<ModelsTreeNode, \"extendedData\">) => !!node.extendedData?.isModel;\n\n /**\n * Determines if a node represents a category.\n */\n export const isCategoryNode = (node: Pick<ModelsTreeNode, \"extendedData\">) => !!node.extendedData?.isCategory;\n\n /** Returns type of the node. */\n export const getType = (node: ModelsTreeNode): \"subject\" | \"model\" | \"category\" | \"element\" | \"elements-class-group\" => {\n if (HierarchyNodeKey.isClassGrouping(node.key)) {\n return \"elements-class-group\";\n }\n if (isSubjectNode(node)) {\n return \"subject\";\n }\n if (isModelNode(node)) {\n return \"model\";\n }\n if (isCategoryNode(node)) {\n return \"category\";\n }\n return \"element\";\n };\n\n /**\n * Retrieves model ID from node's extended data.\n */\n export const getModelId = (node: Pick<ModelsTreeNode, \"extendedData\">): Id64String | undefined => {\n if (node.extendedData?.modelId) {\n return node.extendedData?.modelId;\n }\n\n const modelIds = node.extendedData?.modelIds?.[0];\n return modelIds && (Array.isArray(modelIds) ? modelIds[0] : modelIds);\n };\n\n /**\n * Retrieves category ID from node's extended data.\n */\n export const getCategoryId = (node: Pick<ModelsTreeNode, \"extendedData\">): Id64String | undefined => node.extendedData?.categoryId;\n}\n"]}
|