@itwin/tree-widget-react 3.0.0-dev.2 → 3.0.0-dev.4
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/README.md +225 -1
- package/lib/cjs/components/SelectableTree.d.ts +12 -6
- package/lib/cjs/components/SelectableTree.js.map +1 -1
- package/lib/cjs/components/TreeSelector.d.ts +2 -2
- package/lib/cjs/components/TreeSelector.js.map +1 -1
- package/lib/cjs/components/TreeWidgetUiItemsProvider.d.ts +3 -2
- package/lib/cjs/components/TreeWidgetUiItemsProvider.js.map +1 -1
- package/lib/cjs/components/tree-header/TreeHeader.d.ts +11 -9
- package/lib/cjs/components/tree-header/TreeHeader.js +4 -6
- package/lib/cjs/components/tree-header/TreeHeader.js.map +1 -1
- package/lib/cjs/components/tree-header/TreeWithHeader.d.ts +13 -0
- package/lib/cjs/components/tree-header/TreeWithHeader.js +20 -0
- package/lib/cjs/components/tree-header/TreeWithHeader.js.map +1 -0
- package/lib/cjs/components/trees/categories-tree/CategoriesTree.d.ts +7 -10
- package/lib/cjs/components/trees/categories-tree/CategoriesTree.js +9 -66
- package/lib/cjs/components/trees/categories-tree/CategoriesTree.js.map +1 -1
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeButtons.d.ts +12 -5
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeButtons.js +27 -7
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeButtons.js.map +1 -1
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeComponent.d.ts +4 -5
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeComponent.js +17 -20
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeComponent.js.map +1 -1
- package/lib/cjs/components/trees/categories-tree/CategoriesVisibilityHandler.d.ts +1 -9
- package/lib/cjs/components/trees/categories-tree/CategoriesVisibilityHandler.js +2 -6
- package/lib/cjs/components/trees/categories-tree/CategoriesVisibilityHandler.js.map +1 -1
- package/lib/cjs/components/trees/categories-tree/UseCategoriesTree.d.ts +25 -0
- package/lib/cjs/components/trees/categories-tree/UseCategoriesTree.js +89 -0
- package/lib/cjs/components/trees/categories-tree/UseCategoriesTree.js.map +1 -0
- package/lib/cjs/components/trees/common/CategoriesVisibilityUtils.d.ts +7 -11
- package/lib/cjs/components/trees/common/CategoriesVisibilityUtils.js +32 -83
- package/lib/cjs/components/trees/common/CategoriesVisibilityUtils.js.map +1 -1
- package/lib/cjs/components/trees/common/FocusedInstancesContext.d.ts +0 -3
- package/lib/cjs/components/trees/common/FocusedInstancesContext.js +0 -2
- package/lib/cjs/components/trees/common/FocusedInstancesContext.js.map +1 -1
- package/lib/cjs/components/trees/common/FocusedInstancesContextProvider.d.ts +0 -1
- package/lib/cjs/components/trees/common/FocusedInstancesContextProvider.js +0 -1
- package/lib/cjs/components/trees/common/FocusedInstancesContextProvider.js.map +1 -1
- package/lib/cjs/components/trees/common/UseFiltering.d.ts +0 -1
- package/lib/cjs/components/trees/common/UseFiltering.js +0 -1
- package/lib/cjs/components/trees/common/UseFiltering.js.map +1 -1
- package/lib/cjs/components/trees/common/UseHierarchiesLocalization.d.ts +0 -1
- package/lib/cjs/components/trees/common/UseHierarchiesLocalization.js +0 -1
- package/lib/cjs/components/trees/common/UseHierarchiesLocalization.js.map +1 -1
- package/lib/cjs/components/trees/common/UseHierarchyFiltering.d.ts +1 -7
- package/lib/cjs/components/trees/common/UseHierarchyFiltering.js +4 -3
- package/lib/cjs/components/trees/common/UseHierarchyFiltering.js.map +1 -1
- package/lib/cjs/components/trees/common/UseHierarchyVisibility.d.ts +15 -10
- package/lib/cjs/components/trees/common/UseHierarchyVisibility.js +20 -17
- package/lib/cjs/components/trees/common/UseHierarchyVisibility.js.map +1 -1
- package/lib/cjs/components/trees/common/UseIModelChangeListener.d.ts +0 -1
- package/lib/cjs/components/trees/common/UseIModelChangeListener.js +0 -1
- package/lib/cjs/components/trees/common/UseIModelChangeListener.js.map +1 -1
- package/lib/cjs/components/trees/common/UseMultiCheckboxHandler.d.ts +0 -1
- package/lib/cjs/components/trees/common/UseMultiCheckboxHandler.js +0 -1
- package/lib/cjs/components/trees/common/UseMultiCheckboxHandler.js.map +1 -1
- package/lib/cjs/components/trees/common/UseNodeHighlighting.d.ts +9 -5
- package/lib/cjs/components/trees/common/UseNodeHighlighting.js +15 -24
- package/lib/cjs/components/trees/common/UseNodeHighlighting.js.map +1 -1
- package/lib/cjs/components/trees/common/UseTelemetryContext.d.ts +29 -0
- package/lib/cjs/components/trees/common/UseTelemetryContext.js +49 -0
- package/lib/cjs/components/trees/common/UseTelemetryContext.js.map +1 -0
- package/lib/cjs/components/trees/common/Utils.d.ts +3 -0
- package/lib/cjs/components/trees/common/Utils.js +11 -1
- package/lib/cjs/components/trees/common/Utils.js.map +1 -1
- package/lib/cjs/components/trees/common/components/Delayed.d.ts +0 -1
- package/lib/cjs/components/trees/common/components/Delayed.js +0 -1
- package/lib/cjs/components/trees/common/components/Delayed.js.map +1 -1
- package/lib/cjs/components/trees/common/components/ProgressOverlay.d.ts +0 -1
- package/lib/cjs/components/trees/common/components/ProgressOverlay.js +0 -1
- package/lib/cjs/components/trees/common/components/ProgressOverlay.js.map +1 -1
- package/lib/cjs/components/trees/common/components/Tree.d.ts +52 -0
- package/lib/cjs/components/trees/common/components/{BaseTree.js → Tree.js} +27 -23
- package/lib/cjs/components/trees/common/components/Tree.js.map +1 -0
- package/lib/cjs/components/trees/common/components/TreeNodeCheckbox.d.ts +14 -7
- package/lib/cjs/components/trees/common/components/TreeNodeCheckbox.js.map +1 -1
- package/lib/cjs/components/trees/common/components/TreeNodeRenderer.d.ts +7 -6
- package/lib/cjs/components/trees/common/components/TreeNodeRenderer.js +1 -1
- package/lib/cjs/components/trees/common/components/TreeNodeRenderer.js.map +1 -1
- package/lib/cjs/components/trees/common/components/TreeRenderer.d.ts +11 -1
- package/lib/cjs/components/trees/common/components/TreeRenderer.js +4 -1
- package/lib/cjs/components/trees/common/components/TreeRenderer.js.map +1 -1
- package/lib/cjs/components/trees/common/components/VisibilityTree.d.ts +27 -10
- package/lib/cjs/components/trees/common/components/VisibilityTree.js +8 -23
- package/lib/cjs/components/trees/common/components/VisibilityTree.js.map +1 -1
- package/lib/cjs/components/trees/common/components/VisibilityTreeRenderer.d.ts +12 -0
- package/lib/cjs/components/trees/common/components/VisibilityTreeRenderer.js +26 -0
- package/lib/cjs/components/trees/common/components/VisibilityTreeRenderer.js.map +1 -0
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.d.ts +8 -7
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.js +7 -10
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTreeComponent.d.ts +5 -5
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js +3 -4
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js.map +1 -1
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.d.ts +8 -7
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.js +9 -12
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTreeComponent.d.ts +5 -5
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTreeComponent.js +3 -4
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTreeComponent.js.map +1 -1
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTreeDefinition.js.map +1 -1
- package/lib/cjs/components/trees/index.d.ts +11 -0
- package/lib/cjs/components/trees/index.js +19 -1
- package/lib/cjs/components/trees/index.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsTree.d.ts +10 -9
- package/lib/cjs/components/trees/models-tree/ModelsTree.js +6 -206
- package/lib/cjs/components/trees/models-tree/ModelsTree.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsTreeButtons.d.ts +19 -8
- package/lib/cjs/components/trees/models-tree/ModelsTreeButtons.js +31 -8
- package/lib/cjs/components/trees/models-tree/ModelsTreeButtons.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.d.ts +11 -6
- package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.js +33 -34
- package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsTreeDefinition.d.ts +9 -5
- package/lib/cjs/components/trees/models-tree/ModelsTreeDefinition.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/UseModelsTree.d.ts +29 -0
- package/lib/cjs/components/trees/models-tree/UseModelsTree.js +233 -0
- package/lib/cjs/components/trees/models-tree/UseModelsTree.js.map +1 -0
- package/lib/cjs/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.d.ts +11 -3
- package/lib/cjs/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js +1 -1
- package/lib/cjs/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js.map +1 -1
- package/lib/cjs/tree-widget-react.d.ts +2 -1
- package/lib/cjs/tree-widget-react.js +3 -1
- package/lib/cjs/tree-widget-react.js.map +1 -1
- package/lib/esm/components/SelectableTree.d.ts +12 -6
- package/lib/esm/components/SelectableTree.js.map +1 -1
- package/lib/esm/components/TreeSelector.d.ts +2 -2
- package/lib/esm/components/TreeSelector.js.map +1 -1
- package/lib/esm/components/TreeWidgetUiItemsProvider.d.ts +3 -2
- package/lib/esm/components/TreeWidgetUiItemsProvider.js.map +1 -1
- package/lib/esm/components/tree-header/TreeHeader.d.ts +11 -9
- package/lib/esm/components/tree-header/TreeHeader.js +4 -6
- package/lib/esm/components/tree-header/TreeHeader.js.map +1 -1
- package/lib/esm/components/tree-header/TreeWithHeader.d.ts +13 -0
- package/lib/esm/components/tree-header/TreeWithHeader.js +13 -0
- package/lib/esm/components/tree-header/TreeWithHeader.js.map +1 -0
- package/lib/esm/components/trees/categories-tree/CategoriesTree.d.ts +7 -10
- package/lib/esm/components/trees/categories-tree/CategoriesTree.js +9 -66
- package/lib/esm/components/trees/categories-tree/CategoriesTree.js.map +1 -1
- package/lib/esm/components/trees/categories-tree/CategoriesTreeButtons.d.ts +12 -5
- package/lib/esm/components/trees/categories-tree/CategoriesTreeButtons.js +25 -7
- package/lib/esm/components/trees/categories-tree/CategoriesTreeButtons.js.map +1 -1
- package/lib/esm/components/trees/categories-tree/CategoriesTreeComponent.d.ts +4 -5
- package/lib/esm/components/trees/categories-tree/CategoriesTreeComponent.js +18 -18
- package/lib/esm/components/trees/categories-tree/CategoriesTreeComponent.js.map +1 -1
- package/lib/esm/components/trees/categories-tree/CategoriesVisibilityHandler.d.ts +1 -9
- package/lib/esm/components/trees/categories-tree/CategoriesVisibilityHandler.js +2 -6
- package/lib/esm/components/trees/categories-tree/CategoriesVisibilityHandler.js.map +1 -1
- package/lib/esm/components/trees/categories-tree/UseCategoriesTree.d.ts +25 -0
- package/lib/esm/components/trees/categories-tree/UseCategoriesTree.js +85 -0
- package/lib/esm/components/trees/categories-tree/UseCategoriesTree.js.map +1 -0
- package/lib/esm/components/trees/common/CategoriesVisibilityUtils.d.ts +7 -11
- package/lib/esm/components/trees/common/CategoriesVisibilityUtils.js +33 -84
- package/lib/esm/components/trees/common/CategoriesVisibilityUtils.js.map +1 -1
- package/lib/esm/components/trees/common/FocusedInstancesContext.d.ts +0 -3
- package/lib/esm/components/trees/common/FocusedInstancesContext.js +0 -2
- package/lib/esm/components/trees/common/FocusedInstancesContext.js.map +1 -1
- package/lib/esm/components/trees/common/FocusedInstancesContextProvider.d.ts +0 -1
- package/lib/esm/components/trees/common/FocusedInstancesContextProvider.js +0 -1
- package/lib/esm/components/trees/common/FocusedInstancesContextProvider.js.map +1 -1
- package/lib/esm/components/trees/common/UseFiltering.d.ts +0 -1
- package/lib/esm/components/trees/common/UseFiltering.js +0 -1
- package/lib/esm/components/trees/common/UseFiltering.js.map +1 -1
- package/lib/esm/components/trees/common/UseHierarchiesLocalization.d.ts +0 -1
- package/lib/esm/components/trees/common/UseHierarchiesLocalization.js +0 -1
- package/lib/esm/components/trees/common/UseHierarchiesLocalization.js.map +1 -1
- package/lib/esm/components/trees/common/UseHierarchyFiltering.d.ts +1 -7
- package/lib/esm/components/trees/common/UseHierarchyFiltering.js +4 -3
- package/lib/esm/components/trees/common/UseHierarchyFiltering.js.map +1 -1
- package/lib/esm/components/trees/common/UseHierarchyVisibility.d.ts +15 -10
- package/lib/esm/components/trees/common/UseHierarchyVisibility.js +20 -17
- package/lib/esm/components/trees/common/UseHierarchyVisibility.js.map +1 -1
- package/lib/esm/components/trees/common/UseIModelChangeListener.d.ts +0 -1
- package/lib/esm/components/trees/common/UseIModelChangeListener.js +0 -1
- package/lib/esm/components/trees/common/UseIModelChangeListener.js.map +1 -1
- package/lib/esm/components/trees/common/UseMultiCheckboxHandler.d.ts +0 -1
- package/lib/esm/components/trees/common/UseMultiCheckboxHandler.js +0 -1
- package/lib/esm/components/trees/common/UseMultiCheckboxHandler.js.map +1 -1
- package/lib/esm/components/trees/common/UseNodeHighlighting.d.ts +9 -5
- package/lib/esm/components/trees/common/UseNodeHighlighting.js +14 -23
- package/lib/esm/components/trees/common/UseNodeHighlighting.js.map +1 -1
- package/lib/esm/components/trees/common/UseTelemetryContext.d.ts +29 -0
- package/lib/esm/components/trees/common/UseTelemetryContext.js +43 -0
- package/lib/esm/components/trees/common/UseTelemetryContext.js.map +1 -0
- package/lib/esm/components/trees/common/Utils.d.ts +3 -0
- package/lib/esm/components/trees/common/Utils.js +9 -0
- package/lib/esm/components/trees/common/Utils.js.map +1 -1
- package/lib/esm/components/trees/common/components/Delayed.d.ts +0 -1
- package/lib/esm/components/trees/common/components/Delayed.js +0 -1
- package/lib/esm/components/trees/common/components/Delayed.js.map +1 -1
- package/lib/esm/components/trees/common/components/ProgressOverlay.d.ts +0 -1
- package/lib/esm/components/trees/common/components/ProgressOverlay.js +0 -1
- package/lib/esm/components/trees/common/components/ProgressOverlay.js.map +1 -1
- package/lib/esm/components/trees/common/components/Tree.d.ts +52 -0
- package/lib/esm/components/trees/common/components/{BaseTree.js → Tree.js} +26 -22
- package/lib/esm/components/trees/common/components/Tree.js.map +1 -0
- package/lib/esm/components/trees/common/components/TreeNodeCheckbox.d.ts +14 -7
- package/lib/esm/components/trees/common/components/TreeNodeCheckbox.js.map +1 -1
- package/lib/esm/components/trees/common/components/TreeNodeRenderer.d.ts +7 -6
- package/lib/esm/components/trees/common/components/TreeNodeRenderer.js +1 -1
- package/lib/esm/components/trees/common/components/TreeNodeRenderer.js.map +1 -1
- package/lib/esm/components/trees/common/components/TreeRenderer.d.ts +11 -1
- package/lib/esm/components/trees/common/components/TreeRenderer.js +4 -1
- package/lib/esm/components/trees/common/components/TreeRenderer.js.map +1 -1
- package/lib/esm/components/trees/common/components/VisibilityTree.d.ts +27 -10
- package/lib/esm/components/trees/common/components/VisibilityTree.js +8 -23
- package/lib/esm/components/trees/common/components/VisibilityTree.js.map +1 -1
- package/lib/esm/components/trees/common/components/VisibilityTreeRenderer.d.ts +12 -0
- package/lib/esm/components/trees/common/components/VisibilityTreeRenderer.js +22 -0
- package/lib/esm/components/trees/common/components/VisibilityTreeRenderer.js.map +1 -0
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.d.ts +8 -7
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.js +7 -10
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTreeComponent.d.ts +5 -5
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js +3 -4
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js.map +1 -1
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.d.ts +8 -7
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.js +9 -12
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTreeComponent.d.ts +5 -5
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTreeComponent.js +3 -4
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTreeComponent.js.map +1 -1
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTreeDefinition.js.map +1 -1
- package/lib/esm/components/trees/index.d.ts +11 -0
- package/lib/esm/components/trees/index.js +9 -0
- package/lib/esm/components/trees/index.js.map +1 -1
- package/lib/esm/components/trees/models-tree/ModelsTree.d.ts +10 -9
- package/lib/esm/components/trees/models-tree/ModelsTree.js +7 -207
- package/lib/esm/components/trees/models-tree/ModelsTree.js.map +1 -1
- package/lib/esm/components/trees/models-tree/ModelsTreeButtons.d.ts +19 -8
- package/lib/esm/components/trees/models-tree/ModelsTreeButtons.js +30 -8
- package/lib/esm/components/trees/models-tree/ModelsTreeButtons.js.map +1 -1
- package/lib/esm/components/trees/models-tree/ModelsTreeComponent.d.ts +11 -6
- package/lib/esm/components/trees/models-tree/ModelsTreeComponent.js +35 -33
- package/lib/esm/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
- package/lib/esm/components/trees/models-tree/ModelsTreeDefinition.d.ts +9 -5
- package/lib/esm/components/trees/models-tree/ModelsTreeDefinition.js.map +1 -1
- package/lib/esm/components/trees/models-tree/UseModelsTree.d.ts +29 -0
- package/lib/esm/components/trees/models-tree/UseModelsTree.js +229 -0
- package/lib/esm/components/trees/models-tree/UseModelsTree.js.map +1 -0
- package/lib/esm/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.d.ts +11 -3
- package/lib/esm/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js +2 -2
- package/lib/esm/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js.map +1 -1
- package/lib/esm/tree-widget-react.d.ts +2 -1
- package/lib/esm/tree-widget-react.js +1 -0
- package/lib/esm/tree-widget-react.js.map +1 -1
- package/package.json +12 -16
- package/lib/cjs/components/trees/categories-tree/UseCategories.d.ts +0 -8
- package/lib/cjs/components/trees/categories-tree/UseCategories.js +0 -22
- package/lib/cjs/components/trees/categories-tree/UseCategories.js.map +0 -1
- package/lib/cjs/components/trees/common/UseFeatureReporting.d.ts +0 -34
- package/lib/cjs/components/trees/common/UseFeatureReporting.js +0 -39
- package/lib/cjs/components/trees/common/UseFeatureReporting.js.map +0 -1
- package/lib/cjs/components/trees/common/UsePerformanceReporting.d.ts +0 -18
- package/lib/cjs/components/trees/common/UsePerformanceReporting.js +0 -25
- package/lib/cjs/components/trees/common/UsePerformanceReporting.js.map +0 -1
- package/lib/cjs/components/trees/common/components/BaseTree.d.ts +0 -34
- package/lib/cjs/components/trees/common/components/BaseTree.js.map +0 -1
- package/lib/cjs/components/utils/AutoSizer.d.ts +0 -13
- package/lib/cjs/components/utils/AutoSizer.js +0 -21
- package/lib/cjs/components/utils/AutoSizer.js.map +0 -1
- package/lib/esm/components/trees/categories-tree/UseCategories.d.ts +0 -8
- package/lib/esm/components/trees/categories-tree/UseCategories.js +0 -18
- package/lib/esm/components/trees/categories-tree/UseCategories.js.map +0 -1
- package/lib/esm/components/trees/common/UseFeatureReporting.d.ts +0 -34
- package/lib/esm/components/trees/common/UseFeatureReporting.js +0 -34
- package/lib/esm/components/trees/common/UseFeatureReporting.js.map +0 -1
- package/lib/esm/components/trees/common/UsePerformanceReporting.d.ts +0 -18
- package/lib/esm/components/trees/common/UsePerformanceReporting.js +0 -21
- package/lib/esm/components/trees/common/UsePerformanceReporting.js.map +0 -1
- package/lib/esm/components/trees/common/components/BaseTree.d.ts +0 -34
- package/lib/esm/components/trees/common/components/BaseTree.js.map +0 -1
- package/lib/esm/components/utils/AutoSizer.d.ts +0 -13
- package/lib/esm/components/utils/AutoSizer.js +0 -17
- package/lib/esm/components/utils/AutoSizer.js.map +0 -1
- /package/lib/cjs/components/{trees/Tree.scss → tree-header/TreeWithHeader.scss} +0 -0
- /package/lib/esm/components/{trees/Tree.scss → tree-header/TreeWithHeader.scss} +0 -0
|
@@ -17,11 +17,7 @@ export class CategoriesVisibilityHandler {
|
|
|
17
17
|
this.onViewedCategoriesChanged = () => {
|
|
18
18
|
this.onVisibilityChangeInternal();
|
|
19
19
|
};
|
|
20
|
-
this._viewManager = props.viewManager;
|
|
21
|
-
this._imodel = props.imodel;
|
|
22
20
|
this._viewport = props.viewport;
|
|
23
|
-
// istanbul ignore next
|
|
24
|
-
this._useAllViewports = props.allViewports ?? false;
|
|
25
21
|
this._viewport.onDisplayStyleChanged.addListener(this.onDisplayStyleChanged);
|
|
26
22
|
this._viewport.onViewedCategoriesChanged.addListener(this.onViewedCategoriesChanged);
|
|
27
23
|
}
|
|
@@ -81,10 +77,10 @@ export class CategoriesVisibilityHandler {
|
|
|
81
77
|
return HierarchyNode.isInstancesNode(node) && node.key.instanceKeys.length > 0 ? node.key.instanceKeys[0].id : /* istanbul ignore next */ "";
|
|
82
78
|
}
|
|
83
79
|
async enableCategory(ids, enabled, enableAllSubCategories = true) {
|
|
84
|
-
await enableCategoryDisplay(this.
|
|
80
|
+
await enableCategoryDisplay(this._viewport, ids, enabled, enableAllSubCategories);
|
|
85
81
|
}
|
|
86
82
|
enableSubCategory(key, enabled) {
|
|
87
|
-
enableSubCategoryDisplay(this.
|
|
83
|
+
enableSubCategoryDisplay(this._viewport, key, enabled);
|
|
88
84
|
}
|
|
89
85
|
}
|
|
90
86
|
//# sourceMappingURL=CategoriesVisibilityHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CategoriesVisibilityHandler.js","sourceRoot":"","sources":["../../../../../src/components/trees/categories-tree/CategoriesVisibilityHandler.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"CategoriesVisibilityHandler.js","source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SAAS,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IACzD,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 { BeEvent } from \"@itwin/core-bentley\";\nimport { HierarchyNode } from \"@itwin/presentation-hierarchies\";\nimport { enableCategoryDisplay, enableSubCategoryDisplay } from \"../common/CategoriesVisibilityUtils\";\n\nimport type { Viewport } from \"@itwin/core-frontend\";\nimport type { HierarchyVisibilityHandler, VisibilityStatus } from \"../common/UseHierarchyVisibility\";\n\ninterface CategoriesVisibilityHandlerProps {\n viewport: Viewport;\n}\n\n/** @internal */\nexport class CategoriesVisibilityHandler implements HierarchyVisibilityHandler {\n private _pendingVisibilityChange: any;\n private _viewport: Viewport;\n\n constructor(props: CategoriesVisibilityHandlerProps) {\n this._viewport = props.viewport;\n this._viewport.onDisplayStyleChanged.addListener(this.onDisplayStyleChanged);\n this._viewport.onViewedCategoriesChanged.addListener(this.onViewedCategoriesChanged);\n }\n\n public dispose() {\n this._viewport.onDisplayStyleChanged.removeListener(this.onDisplayStyleChanged);\n this._viewport.onViewedCategoriesChanged.removeListener(this.onViewedCategoriesChanged);\n clearTimeout(this._pendingVisibilityChange);\n }\n\n public onVisibilityChange = new BeEvent();\n\n /** Returns visibility status of the tree node. */\n public getVisibilityStatus(node: HierarchyNode): Promise<VisibilityStatus> | VisibilityStatus {\n if (!HierarchyNode.isInstancesNode(node)) {\n return { state: \"hidden\", isDisabled: true };\n }\n return { state: node.parentKeys.length ? this.getSubCategoryVisibility(node) : this.getCategoryVisibility(node) };\n }\n\n public async changeVisibility(node: HierarchyNode, on: boolean) {\n if (!HierarchyNode.isInstancesNode(node)) {\n return;\n }\n\n // handle subcategory visibility change\n if (node.parentKeys.length) {\n const childId = CategoriesVisibilityHandler.getInstanceIdFromHierarchyNode(node);\n const parentCategoryId = node.extendedData?.categoryId;\n\n // make sure parent category is enabled\n if (on && parentCategoryId) {\n await this.enableCategory([parentCategoryId], true, false);\n }\n\n this.enableSubCategory(childId, on);\n return;\n }\n\n const instanceId = CategoriesVisibilityHandler.getInstanceIdFromHierarchyNode(node);\n await this.enableCategory([instanceId], on, true);\n }\n\n public getSubCategoryVisibility(node: HierarchyNode) {\n const parentCategoryId = node.extendedData?.categoryId;\n if (!parentCategoryId) {\n return \"hidden\";\n }\n\n const subcategoryId = CategoriesVisibilityHandler.getInstanceIdFromHierarchyNode(node);\n const isVisible = this._viewport.view.viewsCategory(parentCategoryId) && this._viewport.isSubCategoryVisible(subcategoryId);\n return isVisible ? \"visible\" : \"hidden\";\n }\n\n public getCategoryVisibility(node: HierarchyNode) {\n const instanceId = CategoriesVisibilityHandler.getInstanceIdFromHierarchyNode(node);\n return this._viewport.view.viewsCategory(instanceId) ? \"visible\" : \"hidden\";\n }\n\n // eslint-disable-next-line @typescript-eslint/naming-convention\n private onDisplayStyleChanged = () => {\n this.onVisibilityChangeInternal();\n };\n\n // eslint-disable-next-line @typescript-eslint/naming-convention\n private onViewedCategoriesChanged = () => {\n this.onVisibilityChangeInternal();\n };\n\n private onVisibilityChangeInternal() {\n if (this._pendingVisibilityChange) {\n return;\n }\n\n this._pendingVisibilityChange = setTimeout(() => {\n this.onVisibilityChange.raiseEvent();\n this._pendingVisibilityChange = undefined;\n }, 0);\n }\n\n public static getInstanceIdFromHierarchyNode(node: HierarchyNode) {\n return HierarchyNode.isInstancesNode(node) && node.key.instanceKeys.length > 0 ? node.key.instanceKeys[0].id : /* istanbul ignore next */ \"\";\n }\n\n public async enableCategory(ids: string[], enabled: boolean, enableAllSubCategories = true) {\n await enableCategoryDisplay(this._viewport, ids, enabled, enableAllSubCategories);\n }\n\n public enableSubCategory(key: string, enabled: boolean) {\n enableSubCategoryDisplay(this._viewport, key, enabled);\n }\n}\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { VisibilityTree } from "../common/components/VisibilityTree";
|
|
2
|
+
import type { ComponentPropsWithoutRef } from "react";
|
|
3
|
+
import type { Viewport } from "@itwin/core-frontend";
|
|
4
|
+
import type { VisibilityTreeRenderer } from "../common/components/VisibilityTreeRenderer";
|
|
5
|
+
/** @beta */
|
|
6
|
+
type VisibilityTreeRendererProps = ComponentPropsWithoutRef<typeof VisibilityTreeRenderer>;
|
|
7
|
+
/** @beta */
|
|
8
|
+
type VisibilityTreeProps = ComponentPropsWithoutRef<typeof VisibilityTree>;
|
|
9
|
+
/** @beta */
|
|
10
|
+
interface UseCategoriesTreeProps {
|
|
11
|
+
filter: string;
|
|
12
|
+
activeView: Viewport;
|
|
13
|
+
}
|
|
14
|
+
/** @beta */
|
|
15
|
+
interface UseCategoriesTreeResult {
|
|
16
|
+
categoriesTreeProps: Pick<VisibilityTreeProps, "treeName" | "getHierarchyDefinition" | "getFilteredPaths" | "visibilityHandlerFactory" | "highlight" | "noDataMessage">;
|
|
17
|
+
rendererProps: Pick<Required<VisibilityTreeRendererProps>, "getIcon" | "getSublabel">;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Custom hook to create and manage state for the categories tree.
|
|
21
|
+
* @beta
|
|
22
|
+
*/
|
|
23
|
+
export declare function useCategoriesTree({ filter, activeView }: UseCategoriesTreeProps): UseCategoriesTreeResult;
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=UseCategoriesTree.d.ts.map
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
import { useCallback, useMemo, useState } from "react";
|
|
7
|
+
import { SvgLayers } from "@itwin/itwinui-icons-react";
|
|
8
|
+
import { Text } from "@itwin/itwinui-react";
|
|
9
|
+
import { TreeWidget } from "../../../TreeWidget";
|
|
10
|
+
import { useTelemetryContext } from "../common/UseTelemetryContext";
|
|
11
|
+
import { CategoriesTreeDefinition } from "./CategoriesTreeDefinition";
|
|
12
|
+
import { CategoriesVisibilityHandler } from "./CategoriesVisibilityHandler";
|
|
13
|
+
/**
|
|
14
|
+
* Custom hook to create and manage state for the categories tree.
|
|
15
|
+
* @beta
|
|
16
|
+
*/
|
|
17
|
+
export function useCategoriesTree({ filter, activeView }) {
|
|
18
|
+
const [filteringError, setFilteringError] = useState();
|
|
19
|
+
const visibilityHandlerFactory = useCallback(() => {
|
|
20
|
+
const visibilityHandler = new CategoriesVisibilityHandler({
|
|
21
|
+
viewport: activeView,
|
|
22
|
+
});
|
|
23
|
+
return {
|
|
24
|
+
getVisibilityStatus: async (node) => visibilityHandler.getVisibilityStatus(node),
|
|
25
|
+
changeVisibility: async (node, on) => visibilityHandler.changeVisibility(node, on),
|
|
26
|
+
onVisibilityChange: visibilityHandler.onVisibilityChange,
|
|
27
|
+
dispose: () => visibilityHandler.dispose(),
|
|
28
|
+
};
|
|
29
|
+
}, [activeView]);
|
|
30
|
+
const { onFeatureUsed } = useTelemetryContext();
|
|
31
|
+
const getHierarchyDefinition = useCallback((props) => {
|
|
32
|
+
return new CategoriesTreeDefinition({ ...props, viewType: activeView.view.is2d() ? "2d" : "3d" });
|
|
33
|
+
}, [activeView]);
|
|
34
|
+
const getFilteredPaths = useMemo(() => {
|
|
35
|
+
setFilteringError(undefined);
|
|
36
|
+
if (!filter) {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
return async ({ imodelAccess }) => {
|
|
40
|
+
onFeatureUsed({ featureId: "filtering", reportInteraction: true });
|
|
41
|
+
try {
|
|
42
|
+
return await CategoriesTreeDefinition.createInstanceKeyPaths({ imodelAccess, label: filter, viewType: activeView.view.is2d() ? "2d" : "3d" });
|
|
43
|
+
}
|
|
44
|
+
catch (e) {
|
|
45
|
+
const newError = e instanceof Error && e.message.match(/Filter matches more than \d+ items/) ? "tooManyFilterMatches" : "unknownFilterError";
|
|
46
|
+
if (newError !== "tooManyFilterMatches") {
|
|
47
|
+
const feature = e instanceof Error && e.message.includes("query too long to execute or server is too busy") ? "error-timeout" : "error-unknown";
|
|
48
|
+
onFeatureUsed({ featureId: feature, reportInteraction: false });
|
|
49
|
+
}
|
|
50
|
+
setFilteringError(newError);
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}, [filter, activeView, onFeatureUsed]);
|
|
55
|
+
return {
|
|
56
|
+
categoriesTreeProps: {
|
|
57
|
+
treeName: "categories-tree-v2",
|
|
58
|
+
getHierarchyDefinition,
|
|
59
|
+
getFilteredPaths,
|
|
60
|
+
visibilityHandlerFactory,
|
|
61
|
+
noDataMessage: getNoDataMessage(filter, filteringError),
|
|
62
|
+
highlight: filter ? { text: filter } : undefined,
|
|
63
|
+
},
|
|
64
|
+
rendererProps: {
|
|
65
|
+
getIcon,
|
|
66
|
+
getSublabel,
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function getNoDataMessage(filter, error) {
|
|
71
|
+
if (error) {
|
|
72
|
+
return _jsx(Text, { children: TreeWidget.translate(`categoriesTree.filtering.${error}`) });
|
|
73
|
+
}
|
|
74
|
+
if (filter) {
|
|
75
|
+
return _jsx(Text, { children: TreeWidget.translate("categoriesTree.filtering.noMatches", { filter }) });
|
|
76
|
+
}
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
function getIcon() {
|
|
80
|
+
return _jsx(SvgLayers, {});
|
|
81
|
+
}
|
|
82
|
+
function getSublabel(node) {
|
|
83
|
+
return node.extendedData?.description;
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=UseCategoriesTree.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UseCategoriesTree.js","sourceRoot":"","sources":["../../../../../src/components/trees/categories-tree/UseC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,CAAC,QAAQ,CAAC,CAAC;gBAC5B,OAAO,EAAE,CAAC;aACX;QACH,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC,CAAC;IAExC,OAAO;QACL,mBAAmB,EAAE;YACnB,QAAQ,EAAE,oBAAoB;YAC9B,sBAAsB;YACtB,gBAAgB;YAChB,wBAAwB;YACxB,aAAa,EAAE,gBAAgB,CAAC,MAAM,EAAE,cAAc,CAAC;YACvD,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS;SACjD;QACD,aAAa,EAAE;YACb,OAAO;YACP,WAAW;SACZ;KACF,CAAC;AACJ,CAAC;AAED,SAAS,gBAAgB,CAAC,MAAc,EAAE,KAAoC;IAC5E,IAAI,KAAK,EAAE;QACT,OAAO,KAAC,IAAI,cAAE,UAAU,CAAC,SAAS,CAAC,4BAA4B,KAAK,EAAE,CAAC,GAAQ,CAAC;KACjF;IACD,IAAI,MAAM,EAAE;QACV,OAAO,KAAC,IAAI,cAAE,UAAU,CAAC,SAAS,CAAC,oCAAoC,EAAE,EAAE,MAAM,EAAE,CAAC,GAAQ,CAAC;KAC9F;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,OAAO;IACd,OAAO,KAAC,SAAS,KAAG,CAAC;AACvB,CAAC;AAED,SAAS,WAAW,CAAC,IAA+B;IAClD,OAAO,IAAI,CAAC,YAAY,EAAE,WAAW,CAAC;AACxC,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, useState } from \"react\";\nimport { SvgLayers } from \"@itwin/itwinui-icons-react\";\nimport { Text } from \"@itwin/itwinui-react\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { useTelemetryContext } from \"../common/UseTelemetryContext\";\nimport { CategoriesTreeDefinition } from \"./CategoriesTreeDefinition\";\nimport { CategoriesVisibilityHandler } from \"./CategoriesVisibilityHandler\";\n\nimport type { VisibilityTree } from \"../common/components/VisibilityTree\";\nimport type { ComponentPropsWithoutRef } from \"react\";\nimport type { Viewport } from \"@itwin/core-frontend\";\nimport type { HierarchyNode } from \"@itwin/presentation-hierarchies\";\nimport type { PresentationHierarchyNode } from \"@itwin/presentation-hierarchies-react\";\nimport type { VisibilityTreeRenderer } from \"../common/components/VisibilityTreeRenderer\";\n\ntype CategoriesTreeFilteringError = \"tooManyFilterMatches\" | \"unknownFilterError\";\n\n/** @beta */\ntype VisibilityTreeRendererProps = ComponentPropsWithoutRef<typeof VisibilityTreeRenderer>;\n\n/** @beta */\ntype VisibilityTreeProps = ComponentPropsWithoutRef<typeof VisibilityTree>;\n\n/** @beta */\ninterface UseCategoriesTreeProps {\n filter: string;\n activeView: Viewport;\n}\n\n/** @beta */\ninterface UseCategoriesTreeResult {\n categoriesTreeProps: Pick<\n VisibilityTreeProps,\n \"treeName\" | \"getHierarchyDefinition\" | \"getFilteredPaths\" | \"visibilityHandlerFactory\" | \"highlight\" | \"noDataMessage\"\n >;\n rendererProps: Pick<Required<VisibilityTreeRendererProps>, \"getIcon\" | \"getSublabel\">;\n}\n\n/**\n * Custom hook to create and manage state for the categories tree.\n * @beta\n */\nexport function useCategoriesTree({ filter, activeView }: UseCategoriesTreeProps): UseCategoriesTreeResult {\n const [filteringError, setFilteringError] = useState<CategoriesTreeFilteringError | undefined>();\n const visibilityHandlerFactory = useCallback(() => {\n const visibilityHandler = new CategoriesVisibilityHandler({\n viewport: activeView,\n });\n return {\n getVisibilityStatus: async (node: HierarchyNode) => visibilityHandler.getVisibilityStatus(node),\n changeVisibility: async (node: HierarchyNode, on: boolean) => visibilityHandler.changeVisibility(node, on),\n onVisibilityChange: visibilityHandler.onVisibilityChange,\n dispose: () => visibilityHandler.dispose(),\n };\n }, [activeView]);\n const { onFeatureUsed } = useTelemetryContext();\n\n const getHierarchyDefinition = useCallback<VisibilityTreeProps[\"getHierarchyDefinition\"]>(\n (props) => {\n return new CategoriesTreeDefinition({ ...props, viewType: activeView.view.is2d() ? \"2d\" : \"3d\" });\n },\n [activeView],\n );\n\n const getFilteredPaths = useMemo<VisibilityTreeProps[\"getFilteredPaths\"] | undefined>(() => {\n setFilteringError(undefined);\n if (!filter) {\n return undefined;\n }\n return async ({ imodelAccess }) => {\n onFeatureUsed({ featureId: \"filtering\", reportInteraction: true });\n try {\n return await CategoriesTreeDefinition.createInstanceKeyPaths({ imodelAccess, label: filter, viewType: activeView.view.is2d() ? \"2d\" : \"3d\" });\n } catch (e) {\n const newError = e instanceof Error && e.message.match(/Filter matches more than \\d+ items/) ? \"tooManyFilterMatches\" : \"unknownFilterError\";\n if (newError !== \"tooManyFilterMatches\") {\n const feature = e instanceof Error && e.message.includes(\"query too long to execute or server is too busy\") ? \"error-timeout\" : \"error-unknown\";\n onFeatureUsed({ featureId: feature, reportInteraction: false });\n }\n setFilteringError(newError);\n return [];\n }\n };\n }, [filter, activeView, onFeatureUsed]);\n\n return {\n categoriesTreeProps: {\n treeName: \"categories-tree-v2\",\n getHierarchyDefinition,\n getFilteredPaths,\n visibilityHandlerFactory,\n noDataMessage: getNoDataMessage(filter, filteringError),\n highlight: filter ? { text: filter } : undefined,\n },\n rendererProps: {\n getIcon,\n getSublabel,\n },\n };\n}\n\nfunction getNoDataMessage(filter: string, error?: CategoriesTreeFilteringError) {\n if (error) {\n return <Text>{TreeWidget.translate(`categoriesTree.filtering.${error}`)}</Text>;\n }\n if (filter) {\n return <Text>{TreeWidget.translate(\"categoriesTree.filtering.noMatches\", { filter })}</Text>;\n }\n return undefined;\n}\n\nfunction getIcon() {\n return <SvgLayers />;\n}\n\nfunction getSublabel(node: PresentationHierarchyNode) {\n return node.extendedData?.description;\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Viewport } from "@itwin/core-frontend";
|
|
2
2
|
/**
|
|
3
3
|
* Data structure that describes category.
|
|
4
|
+
* @beta
|
|
4
5
|
*/
|
|
5
6
|
export interface CategoryInfo {
|
|
6
7
|
categoryId: string;
|
|
@@ -8,26 +9,21 @@ export interface CategoryInfo {
|
|
|
8
9
|
}
|
|
9
10
|
/**
|
|
10
11
|
* Toggles visibility of categories to show or hide.
|
|
11
|
-
* @internal
|
|
12
12
|
*/
|
|
13
|
-
export declare function toggleAllCategories(
|
|
13
|
+
export declare function toggleAllCategories(viewport: Viewport, display: boolean): Promise<void>;
|
|
14
14
|
/**
|
|
15
15
|
* Gets ids of all categories from specified imodel and viewport.
|
|
16
|
-
* @internal
|
|
17
16
|
*/
|
|
18
|
-
export declare function getCategories(
|
|
17
|
+
export declare function getCategories(viewport: Viewport): Promise<string[]>;
|
|
19
18
|
/**
|
|
20
19
|
* Changes category display in the viewport.
|
|
21
|
-
* @internal
|
|
22
20
|
*/
|
|
23
|
-
export declare function enableCategoryDisplay(
|
|
21
|
+
export declare function enableCategoryDisplay(viewport: Viewport, ids: string[], enabled: boolean, enableAllSubCategories?: boolean): Promise<void>;
|
|
24
22
|
/**
|
|
25
23
|
* Changes subcategory display in the viewport
|
|
26
|
-
* @internal
|
|
27
24
|
*/
|
|
28
|
-
export declare function enableSubCategoryDisplay(
|
|
29
|
-
|
|
30
|
-
export declare function loadCategoriesFromViewport(iModel?: IModelConnection, vp?: Viewport): Promise<CategoryInfo[]>;
|
|
25
|
+
export declare function enableSubCategoryDisplay(viewport: Viewport, key: string, enabled: boolean): void;
|
|
26
|
+
export declare function loadCategoriesFromViewport(vp: Viewport): Promise<CategoryInfo[]>;
|
|
31
27
|
/**
|
|
32
28
|
* Enable display of all given categories.
|
|
33
29
|
* @public
|
|
@@ -3,128 +3,77 @@
|
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import { QueryRowFormat } from "@itwin/core-common";
|
|
6
|
-
import {
|
|
6
|
+
import { PerModelCategoryVisibility } from "@itwin/core-frontend";
|
|
7
7
|
/**
|
|
8
8
|
* Toggles visibility of categories to show or hide.
|
|
9
|
-
* @internal
|
|
10
9
|
*/
|
|
11
|
-
export async function toggleAllCategories(
|
|
12
|
-
|
|
13
|
-
const activeView = viewport ?? viewManager.getFirstOpenView();
|
|
14
|
-
const ids = await getCategories(imodel, activeView);
|
|
15
|
-
// istanbul ignore if
|
|
10
|
+
export async function toggleAllCategories(viewport, display) {
|
|
11
|
+
const ids = await getCategories(viewport);
|
|
16
12
|
if (ids.length === 0) {
|
|
17
13
|
return;
|
|
18
14
|
}
|
|
19
|
-
await enableCategoryDisplay(
|
|
15
|
+
await enableCategoryDisplay(viewport, ids, display);
|
|
20
16
|
}
|
|
21
17
|
/**
|
|
22
18
|
* Gets ids of all categories from specified imodel and viewport.
|
|
23
|
-
* @internal
|
|
24
19
|
*/
|
|
25
|
-
export async function getCategories(
|
|
26
|
-
const categories = await loadCategoriesFromViewport(
|
|
20
|
+
export async function getCategories(viewport) {
|
|
21
|
+
const categories = await loadCategoriesFromViewport(viewport);
|
|
27
22
|
return categories.map((category) => category.categoryId);
|
|
28
23
|
}
|
|
29
24
|
/**
|
|
30
25
|
* Changes category display in the viewport.
|
|
31
|
-
* @internal
|
|
32
26
|
*/
|
|
33
|
-
export async function enableCategoryDisplay(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
//
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
vp.changeCategoryDisplay(ids, enabled, enableAllSubCategories);
|
|
42
|
-
// remove category overrides per model
|
|
43
|
-
const modelsContainingOverrides = [];
|
|
44
|
-
for (const ovr of vp.perModelCategoryVisibility) {
|
|
45
|
-
// istanbul ignore else
|
|
46
|
-
if (ids.findIndex((id) => id === ovr.categoryId) !== -1) {
|
|
47
|
-
modelsContainingOverrides.push(ovr.modelId);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
vp.perModelCategoryVisibility.setOverride(modelsContainingOverrides, ids, PerModelCategoryVisibility.Override.None);
|
|
51
|
-
// changeCategoryDisplay only enables subcategories, it does not disabled them. So we must do that ourselves.
|
|
52
|
-
if (false === enabled) {
|
|
53
|
-
(await imodel.categories.getCategoryInfo(ids)).forEach((categoryInfo) => {
|
|
54
|
-
categoryInfo.subCategories.forEach((value) => enableSubCategoryDisplay(viewManager, value.id, false, forAllViewports));
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
// This property let us act on all viewports or just on the selected one, configurable by the app
|
|
60
|
-
if (forAllViewports) {
|
|
61
|
-
for (const viewport of viewManager) {
|
|
62
|
-
await updateViewport(viewport);
|
|
27
|
+
export async function enableCategoryDisplay(viewport, ids, enabled, enableAllSubCategories = true) {
|
|
28
|
+
viewport.changeCategoryDisplay(ids, enabled, enableAllSubCategories);
|
|
29
|
+
// remove category overrides per model
|
|
30
|
+
const modelsContainingOverrides = [];
|
|
31
|
+
for (const ovr of viewport.perModelCategoryVisibility) {
|
|
32
|
+
// istanbul ignore else
|
|
33
|
+
if (ids.findIndex((id) => id === ovr.categoryId) !== -1) {
|
|
34
|
+
modelsContainingOverrides.push(ovr.modelId);
|
|
63
35
|
}
|
|
64
36
|
}
|
|
65
|
-
|
|
66
|
-
|
|
37
|
+
viewport.perModelCategoryVisibility.setOverride(modelsContainingOverrides, ids, PerModelCategoryVisibility.Override.None);
|
|
38
|
+
// changeCategoryDisplay only enables subcategories, it does not disabled them. So we must do that ourselves.
|
|
39
|
+
if (false === enabled) {
|
|
40
|
+
(await viewport.iModel.categories.getCategoryInfo(ids)).forEach((categoryInfo) => {
|
|
41
|
+
categoryInfo.subCategories.forEach((value) => enableSubCategoryDisplay(viewport, value.id, false));
|
|
42
|
+
});
|
|
67
43
|
}
|
|
68
44
|
}
|
|
69
45
|
/**
|
|
70
46
|
* Changes subcategory display in the viewport
|
|
71
|
-
* @internal
|
|
72
47
|
*/
|
|
73
|
-
export function enableSubCategoryDisplay(
|
|
74
|
-
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
const updateViewport = (vp) => {
|
|
78
|
-
// Only act on viewports that are both 3D or both 2D. Important if we have multiple viewports opened and we
|
|
79
|
-
// are using 'allViewports' property
|
|
80
|
-
if (viewManager.selectedView && viewManager.selectedView.view.is3d() === vp.view.is3d()) {
|
|
81
|
-
vp.changeSubCategoryDisplay(key, enabled);
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
// This property let us act on all viewports or just on the selected one, configurable by the app
|
|
85
|
-
if (forAllViewports) {
|
|
86
|
-
for (const viewport of viewManager) {
|
|
87
|
-
updateViewport(viewport);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
updateViewport(viewManager.selectedView);
|
|
92
|
-
}
|
|
48
|
+
export function enableSubCategoryDisplay(viewport, key, enabled) {
|
|
49
|
+
viewport.changeSubCategoryDisplay(key, enabled);
|
|
93
50
|
}
|
|
94
|
-
|
|
95
|
-
export async function loadCategoriesFromViewport(iModel, vp) {
|
|
96
|
-
if (!vp) {
|
|
97
|
-
return EMPTY_CATEGORIES_ARRAY;
|
|
98
|
-
}
|
|
51
|
+
export async function loadCategoriesFromViewport(vp) {
|
|
99
52
|
// Query categories and add them to state
|
|
100
53
|
const selectUsedSpatialCategoryIds = "SELECT DISTINCT Category.Id as id from BisCore.GeometricElement3d WHERE Category.Id IN (SELECT ECInstanceId from BisCore.SpatialCategory)";
|
|
101
54
|
const selectUsedDrawingCategoryIds = "SELECT DISTINCT Category.Id as id from BisCore.GeometricElement2d WHERE Model.Id=? AND Category.Id IN (SELECT ECInstanceId from BisCore.DrawingCategory)";
|
|
102
55
|
const ecsql = vp.view.is3d() ? selectUsedSpatialCategoryIds : selectUsedDrawingCategoryIds;
|
|
103
56
|
const ecsql2 = `SELECT ECInstanceId as id FROM ${vp.view.is3d() ? "BisCore.SpatialCategory" : "BisCore.DrawingCategory"} WHERE ECInstanceId IN (${ecsql})`;
|
|
104
57
|
const categories = [];
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
categories.push({ categoryId: val.id, subCategoryIds: val.subCategories.size ? [...val.subCategories.keys()] : undefined });
|
|
110
|
-
});
|
|
111
|
-
}
|
|
58
|
+
const rows = await vp.iModel.createQueryReader(ecsql2, undefined, { rowFormat: QueryRowFormat.UseJsPropertyNames }).toArray();
|
|
59
|
+
(await vp.iModel.categories.getCategoryInfo(rows.map((row) => row.id))).forEach((val) => {
|
|
60
|
+
categories.push({ categoryId: val.id, subCategoryIds: val.subCategories.size ? [...val.subCategories.keys()] : undefined });
|
|
61
|
+
});
|
|
112
62
|
return categories;
|
|
113
63
|
}
|
|
114
|
-
const EMPTY_CATEGORIES_ARRAY = [];
|
|
115
64
|
/**
|
|
116
65
|
* Enable display of all given categories.
|
|
117
66
|
* @public
|
|
118
67
|
*/
|
|
119
68
|
export async function showAllCategories(categories, viewport) {
|
|
120
|
-
await enableCategoryDisplay(
|
|
69
|
+
await enableCategoryDisplay(viewport, categories, true, true);
|
|
121
70
|
}
|
|
122
71
|
/**
|
|
123
72
|
* Disable display of all given categories.
|
|
124
73
|
* @public
|
|
125
74
|
*/
|
|
126
75
|
export async function hideAllCategories(categories, viewport) {
|
|
127
|
-
await enableCategoryDisplay(
|
|
76
|
+
await enableCategoryDisplay(viewport, categories, false, true);
|
|
128
77
|
}
|
|
129
78
|
/**
|
|
130
79
|
* Invert display of all given categories.
|
|
@@ -151,10 +100,10 @@ export async function invertAllCategories(categories, viewport) {
|
|
|
151
100
|
}
|
|
152
101
|
}
|
|
153
102
|
// Disable enabled
|
|
154
|
-
enabledSubCategories.forEach((subCategory) => enableSubCategoryDisplay(
|
|
155
|
-
await enableCategoryDisplay(
|
|
103
|
+
enabledSubCategories.forEach((subCategory) => enableSubCategoryDisplay(viewport, subCategory, false));
|
|
104
|
+
await enableCategoryDisplay(viewport, enabled, false, true);
|
|
156
105
|
// Enable disabled
|
|
157
|
-
disabledSubCategories.forEach((subCategory) => enableSubCategoryDisplay(
|
|
158
|
-
await enableCategoryDisplay(
|
|
106
|
+
disabledSubCategories.forEach((subCategory) => enableSubCategoryDisplay(viewport, subCategory, true));
|
|
107
|
+
await enableCategoryDisplay(viewport, disabled, true, true);
|
|
159
108
|
}
|
|
160
109
|
//# sourceMappingURL=CategoriesVisibilityUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CategoriesVisibilityUtils.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/CategoriesVisibilityUtils.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAY7E;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,WAAwB,EACxB,MAAwB,EACxB,OAAgB,EAChB,QAAmB,EACnB,eAAyB;IAEzB,uBAAuB;IACvB,MAAM,UAAU,GAAG,QAAQ,IAAI,WAAW,CAAC,gBAAgB,EAAE,CAAC;IAC9D,MAAM,GAAG,GAAG,MAAM,aAAa,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAEpD,qBAAqB;IACrB,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE;QACpB,OAAO;KACR;IAED,MAAM,qBAAqB,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,eAAe,IAAI,KAAK,CAAC,CAAC;AAC3F,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,MAAwB,EAAE,QAAmB;IAC/E,MAAM,UAAU,GAAG,MAAM,0BAA0B,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACtE,OAAO,UAAU,CAAC,GAAG,C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BAAwB,CAAC,SAAS,CAAC,WAAW,EAAE,WAAW,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;IAEzH,MAAM,qBAAqB,CAAC,SAAS,CAAC,WAAW,EAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;IAE1F,kBAAkB;IAClB,qBAAqB,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,wBAAwB,CAAC,SAAS,CAAC,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IAEzH,MAAM,qBAAqB,CAAC,SAAS,CAAC,WAAW,EAAE,QAAQ,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAC5F,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 { QueryRowFormat } from \"@itwin/core-common\";\nimport { IModelApp, PerModelCategoryVisibility } from \"@itwin/core-frontend\";\n\nimport type { IModelConnection, ViewManager, Viewport } from \"@itwin/core-frontend\";\n\n/**\n * Data structure that describes category.\n */\nexport interface CategoryInfo {\n categoryId: string;\n subCategoryIds?: string[];\n}\n\n/**\n * Toggles visibility of categories to show or hide.\n * @internal\n */\nexport async function toggleAllCategories(\n viewManager: ViewManager,\n imodel: IModelConnection,\n display: boolean,\n viewport?: Viewport,\n forAllViewports?: boolean,\n) {\n // istanbul ignore next\n const activeView = viewport ?? viewManager.getFirstOpenView();\n const ids = await getCategories(imodel, activeView);\n\n // istanbul ignore if\n if (ids.length === 0) {\n return;\n }\n\n await enableCategoryDisplay(viewManager, imodel, ids, display, forAllViewports ?? false);\n}\n\n/**\n * Gets ids of all categories from specified imodel and viewport.\n * @internal\n */\nexport async function getCategories(imodel: IModelConnection, viewport?: Viewport) {\n const categories = await loadCategoriesFromViewport(imodel, viewport);\n return categories.map((category) => category.categoryId);\n}\n\n/**\n * Changes category display in the viewport.\n * @internal\n */\nexport async function enableCategoryDisplay(\n viewManager: ViewManager,\n imodel: IModelConnection,\n ids: string[],\n enabled: boolean,\n forAllViewports: boolean,\n enableAllSubCategories = true,\n) {\n if (!viewManager.selectedView) {\n return;\n }\n\n const updateViewport = async (vp: Viewport) => {\n // Only act on viewports that are both 3D or both 2D. Important if we have multiple viewports opened and we\n // are using 'allViewports' property\n if (viewManager.selectedView && viewManager.selectedView.view.is3d() === vp.view.is3d()) {\n vp.changeCategoryDisplay(ids, enabled, enableAllSubCategories);\n\n // remove category overrides per model\n const modelsContainingOverrides: string[] = [];\n for (const ovr of vp.perModelCategoryVisibility) {\n // istanbul ignore else\n if (ids.findIndex((id) => id === ovr.categoryId) !== -1) {\n modelsContainingOverrides.push(ovr.modelId);\n }\n }\n vp.perModelCategoryVisibility.setOverride(modelsContainingOverrides, ids, PerModelCategoryVisibility.Override.None);\n\n // changeCategoryDisplay only enables subcategories, it does not disabled them. So we must do that ourselves.\n if (false === enabled) {\n (await imodel.categories.getCategoryInfo(ids)).forEach((categoryInfo) => {\n categoryInfo.subCategories.forEach((value) => enableSubCategoryDisplay(viewManager, value.id, false, forAllViewports));\n });\n }\n }\n };\n\n // This property let us act on all viewports or just on the selected one, configurable by the app\n if (forAllViewports) {\n for (const viewport of viewManager) {\n await updateViewport(viewport);\n }\n } else {\n await updateViewport(viewManager.selectedView);\n }\n}\n\n/**\n * Changes subcategory display in the viewport\n * @internal\n */\nexport function enableSubCategoryDisplay(viewManager: ViewManager, key: string, enabled: boolean, forAllViewports?: boolean) {\n if (!viewManager.selectedView) {\n return;\n }\n\n const updateViewport = (vp: Viewport) => {\n // Only act on viewports that are both 3D or both 2D. Important if we have multiple viewports opened and we\n // are using 'allViewports' property\n if (viewManager.selectedView && viewManager.selectedView.view.is3d() === vp.view.is3d()) {\n vp.changeSubCategoryDisplay(key, enabled);\n }\n };\n\n // This property let us act on all viewports or just on the selected one, configurable by the app\n if (forAllViewports) {\n for (const viewport of viewManager) {\n updateViewport(viewport);\n }\n } else {\n updateViewport(viewManager.selectedView);\n }\n}\n\n/** @internal */\nexport async function loadCategoriesFromViewport(iModel?: IModelConnection, vp?: Viewport) {\n if (!vp) {\n return EMPTY_CATEGORIES_ARRAY;\n }\n\n // Query categories and add them to state\n const selectUsedSpatialCategoryIds =\n \"SELECT DISTINCT Category.Id as id from BisCore.GeometricElement3d WHERE Category.Id IN (SELECT ECInstanceId from BisCore.SpatialCategory)\";\n const selectUsedDrawingCategoryIds =\n \"SELECT DISTINCT Category.Id as id from BisCore.GeometricElement2d WHERE Model.Id=? AND Category.Id IN (SELECT ECInstanceId from BisCore.DrawingCategory)\";\n const ecsql = vp.view.is3d() ? selectUsedSpatialCategoryIds : selectUsedDrawingCategoryIds;\n const ecsql2 = `SELECT ECInstanceId as id FROM ${vp.view.is3d() ? \"BisCore.SpatialCategory\" : \"BisCore.DrawingCategory\"} WHERE ECInstanceId IN (${ecsql})`;\n\n const categories: CategoryInfo[] = [];\n\n // istanbul ignore else\n if (iModel) {\n const rows = await iModel.createQueryReader(ecsql2, undefined, { rowFormat: QueryRowFormat.UseJsPropertyNames }).toArray();\n (await iModel.categories.getCategoryInfo(rows.map((row) => row.id))).forEach((val) => {\n categories.push({ categoryId: val.id, subCategoryIds: val.subCategories.size ? [...val.subCategories.keys()] : undefined });\n });\n }\n return categories;\n}\nconst EMPTY_CATEGORIES_ARRAY: CategoryInfo[] = [];\n\n/**\n * Enable display of all given categories.\n * @public\n */\nexport async function showAllCategories(categories: string[], viewport: Viewport) {\n await enableCategoryDisplay(IModelApp.viewManager, viewport.iModel, categories, true, true);\n}\n\n/**\n * Disable display of all given categories.\n * @public\n */\nexport async function hideAllCategories(categories: string[], viewport: Viewport) {\n await enableCategoryDisplay(IModelApp.viewManager, viewport.iModel, categories, false, true);\n}\n\n/**\n * Invert display of all given categories.\n * @public\n */\nexport async function invertAllCategories(categories: CategoryInfo[], viewport: Viewport) {\n const enabled: string[] = [];\n const disabled: string[] = [];\n const enabledSubCategories: string[] = [];\n const disabledSubCategories: string[] = [];\n\n for (const category of categories) {\n if (!viewport.view.viewsCategory(category.categoryId)) {\n disabled.push(category.categoryId);\n continue;\n }\n // First, we need to check if at least one subcategory is disabled. If it is true, then only subcategories should change display, not categories.\n if (category.subCategoryIds?.some((subCategory) => !viewport.isSubCategoryVisible(subCategory))) {\n for (const subCategory of category.subCategoryIds) {\n viewport.isSubCategoryVisible(subCategory) ? enabledSubCategories.push(subCategory) : disabledSubCategories.push(subCategory);\n }\n } else {\n enabled.push(category.categoryId);\n }\n }\n\n // Disable enabled\n enabledSubCategories.forEach((subCategory) => enableSubCategoryDisplay(IModelApp.viewManager, subCategory, false, true));\n\n await enableCategoryDisplay(IModelApp.viewManager, viewport.iModel, enabled, false, true);\n\n // Enable disabled\n disabledSubCategories.forEach((subCategory) => enableSubCategoryDisplay(IModelApp.viewManager, subCategory, true, true));\n\n await enableCategoryDisplay(IModelApp.viewManager, viewport.iModel, disabled, true, true);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CategoriesVisibilityUtils.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/CategoriesVisibilityUtils.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAalE;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,QAAkB,EAAE,OAAgB;IAC5E,MAAM,GAAG,GAAG,MAAM,aAAa,CAAC,QAAQ,CAAC,CAAC;IAC1C,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE;QACpB,OAAO;KACR;IAED,MAAM,qBAAqB,CAAC,QAAQ,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;AACtD,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KA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AC,UAAU,CAAC,CAAC;SACnC;KACF;IAED,kBAAkB;IAClB,oBAAoB,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,wBAAwB,CAAC,QAAQ,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC;IAEtG,MAAM,qBAAqB,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;IAE5D,kBAAkB;IAClB,qBAAqB,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,wBAAwB,CAAC,QAAQ,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC;IAEtG,MAAM,qBAAqB,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAC9D,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 { QueryRowFormat } from \"@itwin/core-common\";\nimport { PerModelCategoryVisibility } from \"@itwin/core-frontend\";\n\nimport type { Viewport } from \"@itwin/core-frontend\";\n\n/**\n * Data structure that describes category.\n * @beta\n */\nexport interface CategoryInfo {\n categoryId: string;\n subCategoryIds?: string[];\n}\n\n/**\n * Toggles visibility of categories to show or hide.\n */\nexport async function toggleAllCategories(viewport: Viewport, display: boolean) {\n const ids = await getCategories(viewport);\n if (ids.length === 0) {\n return;\n }\n\n await enableCategoryDisplay(viewport, ids, display);\n}\n\n/**\n * Gets ids of all categories from specified imodel and viewport.\n */\nexport async function getCategories(viewport: Viewport) {\n const categories = await loadCategoriesFromViewport(viewport);\n return categories.map((category) => category.categoryId);\n}\n\n/**\n * Changes category display in the viewport.\n */\nexport async function enableCategoryDisplay(viewport: Viewport, ids: string[], enabled: boolean, enableAllSubCategories = true) {\n viewport.changeCategoryDisplay(ids, enabled, enableAllSubCategories);\n\n // remove category overrides per model\n const modelsContainingOverrides: string[] = [];\n for (const ovr of viewport.perModelCategoryVisibility) {\n // istanbul ignore else\n if (ids.findIndex((id) => id === ovr.categoryId) !== -1) {\n modelsContainingOverrides.push(ovr.modelId);\n }\n }\n viewport.perModelCategoryVisibility.setOverride(modelsContainingOverrides, ids, PerModelCategoryVisibility.Override.None);\n\n // changeCategoryDisplay only enables subcategories, it does not disabled them. So we must do that ourselves.\n if (false === enabled) {\n (await viewport.iModel.categories.getCategoryInfo(ids)).forEach((categoryInfo) => {\n categoryInfo.subCategories.forEach((value) => enableSubCategoryDisplay(viewport, value.id, false));\n });\n }\n}\n\n/**\n * Changes subcategory display in the viewport\n */\nexport function enableSubCategoryDisplay(viewport: Viewport, key: string, enabled: boolean) {\n viewport.changeSubCategoryDisplay(key, enabled);\n}\n\nexport async function loadCategoriesFromViewport(vp: Viewport) {\n // Query categories and add them to state\n const selectUsedSpatialCategoryIds =\n \"SELECT DISTINCT Category.Id as id from BisCore.GeometricElement3d WHERE Category.Id IN (SELECT ECInstanceId from BisCore.SpatialCategory)\";\n const selectUsedDrawingCategoryIds =\n \"SELECT DISTINCT Category.Id as id from BisCore.GeometricElement2d WHERE Model.Id=? AND Category.Id IN (SELECT ECInstanceId from BisCore.DrawingCategory)\";\n const ecsql = vp.view.is3d() ? selectUsedSpatialCategoryIds : selectUsedDrawingCategoryIds;\n const ecsql2 = `SELECT ECInstanceId as id FROM ${vp.view.is3d() ? \"BisCore.SpatialCategory\" : \"BisCore.DrawingCategory\"} WHERE ECInstanceId IN (${ecsql})`;\n\n const categories: CategoryInfo[] = [];\n\n const rows = await vp.iModel.createQueryReader(ecsql2, undefined, { rowFormat: QueryRowFormat.UseJsPropertyNames }).toArray();\n (await vp.iModel.categories.getCategoryInfo(rows.map((row) => row.id))).forEach((val) => {\n categories.push({ categoryId: val.id, subCategoryIds: val.subCategories.size ? [...val.subCategories.keys()] : undefined });\n });\n return categories;\n}\n\n/**\n * Enable display of all given categories.\n * @public\n */\nexport async function showAllCategories(categories: string[], viewport: Viewport) {\n await enableCategoryDisplay(viewport, categories, true, true);\n}\n\n/**\n * Disable display of all given categories.\n * @public\n */\nexport async function hideAllCategories(categories: string[], viewport: Viewport) {\n await enableCategoryDisplay(viewport, categories, false, true);\n}\n\n/**\n * Invert display of all given categories.\n * @public\n */\nexport async function invertAllCategories(categories: CategoryInfo[], viewport: Viewport) {\n const enabled: string[] = [];\n const disabled: string[] = [];\n const enabledSubCategories: string[] = [];\n const disabledSubCategories: string[] = [];\n\n for (const category of categories) {\n if (!viewport.view.viewsCategory(category.categoryId)) {\n disabled.push(category.categoryId);\n continue;\n }\n // First, we need to check if at least one subcategory is disabled. If it is true, then only subcategories should change display, not categories.\n if (category.subCategoryIds?.some((subCategory) => !viewport.isSubCategoryVisible(subCategory))) {\n for (const subCategory of category.subCategoryIds) {\n viewport.isSubCategoryVisible(subCategory) ? enabledSubCategories.push(subCategory) : disabledSubCategories.push(subCategory);\n }\n } else {\n enabled.push(category.categoryId);\n }\n }\n\n // Disable enabled\n enabledSubCategories.forEach((subCategory) => enableSubCategoryDisplay(viewport, subCategory, false));\n\n await enableCategoryDisplay(viewport, enabled, false, true);\n\n // Enable disabled\n disabledSubCategories.forEach((subCategory) => enableSubCategoryDisplay(viewport, subCategory, true));\n\n await enableCategoryDisplay(viewport, disabled, true, true);\n}\n"]}
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { InstanceKey } from "@itwin/presentation-shared";
|
|
3
3
|
import type { GroupingHierarchyNode } from "@itwin/presentation-hierarchies";
|
|
4
|
-
/** @internal */
|
|
5
4
|
export interface FocusedInstancesContext {
|
|
6
5
|
loadInstanceKeys?: () => AsyncIterableIterator<InstanceKey | GroupingHierarchyNode>;
|
|
7
6
|
enabled: boolean;
|
|
8
7
|
toggle: () => void;
|
|
9
8
|
}
|
|
10
|
-
/** @internal */
|
|
11
9
|
export declare const focusedInstancesContext: import("react").Context<FocusedInstancesContext>;
|
|
12
|
-
/** @internal */
|
|
13
10
|
export declare function useFocusedInstancesContext(): FocusedInstancesContext;
|
|
14
11
|
//# sourceMappingURL=FocusedInstancesContext.d.ts.map
|
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import { createContext, useContext } from "react";
|
|
6
|
-
/** @internal */
|
|
7
6
|
export const focusedInstancesContext = createContext({ enabled: false, toggle: () => { } });
|
|
8
|
-
/** @internal */
|
|
9
7
|
export function useFocusedInstancesContext() {
|
|
10
8
|
return useContext(focusedInstancesContext);
|
|
11
9
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FocusedInstancesContext.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/FocusedInstancesContext.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"FocusedInstancesContext.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/FocusedInstancesContext.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAWlD,MAAM,CAAC,MAAM,uBAAuB,GAAG,aAAa,CAA0B,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,CAAC,CAAC;AAEpH,MAAM,UAAU,0BAA0B;IACxC,OAAO,UAAU,CAAC,uBAAuB,CAAC,CAAC;AAC7C,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 { createContext, useContext } from \"react\";\n\nimport type { InstanceKey } from \"@itwin/presentation-shared\";\nimport type { GroupingHierarchyNode } from \"@itwin/presentation-hierarchies\";\n\nexport interface FocusedInstancesContext {\n loadInstanceKeys?: () => AsyncIterableIterator<InstanceKey | GroupingHierarchyNode>;\n enabled: boolean;\n toggle: () => void;\n}\n\nexport const focusedInstancesContext = createContext<FocusedInstancesContext>({ enabled: false, toggle: () => {} });\n\nexport function useFocusedInstancesContext() {\n return useContext(focusedInstancesContext);\n}\n"]}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { SelectionStorage } from "@itwin/presentation-hierarchies-react";
|
|
2
2
|
import type { PropsWithChildren } from "react";
|
|
3
|
-
/** @internal */
|
|
4
3
|
export declare function FocusedInstancesContextProvider({ selectionStorage, imodelKey, children, }: PropsWithChildren<{
|
|
5
4
|
selectionStorage: SelectionStorage;
|
|
6
5
|
imodelKey: string;
|
|
@@ -7,7 +7,6 @@ import { useEffect, useState } from "react";
|
|
|
7
7
|
import { HierarchyNode } from "@itwin/presentation-hierarchies-react";
|
|
8
8
|
import { Selectable, Selectables } from "@itwin/unified-selection";
|
|
9
9
|
import { focusedInstancesContext } from "./FocusedInstancesContext";
|
|
10
|
-
/** @internal */
|
|
11
10
|
export function FocusedInstancesContextProvider({ selectionStorage, imodelKey, children, }) {
|
|
12
11
|
const [state, setState] = useState({
|
|
13
12
|
enabled: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FocusedInstancesContextProvider.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/FocusedInstancesContextProvider.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAQpE,
|
|
1
|
+
{"version":3,"file":"FocusedInstancesContextProvider.js","sourceR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,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAE3C,OAAO,KAAC,uBAAuB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAAoC,CAAC;AACvG,CAAC;AAED,SAAS,eAAe,CAAC,IAAa;IACpC,OAAO,CAAC,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,KAAK,IAAI,IAAI,CAAC;AAC7D,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 { useEffect, useState } from \"react\";\nimport { HierarchyNode } from \"@itwin/presentation-hierarchies-react\";\nimport { Selectable, Selectables } from \"@itwin/unified-selection\";\nimport { focusedInstancesContext } from \"./FocusedInstancesContext\";\n\nimport type { SelectionStorage } from \"@itwin/presentation-hierarchies-react\";\nimport type { PropsWithChildren } from \"react\";\nimport type { InstanceKey } from \"@itwin/presentation-common\";\nimport type { FocusedInstancesContext } from \"./FocusedInstancesContext\";\nimport type { GroupingHierarchyNode } from \"@itwin/presentation-hierarchies\";\n\nexport function FocusedInstancesContextProvider({\n selectionStorage,\n imodelKey,\n children,\n}: PropsWithChildren<{ selectionStorage: SelectionStorage; imodelKey: string }>) {\n const [state, setState] = useState<FocusedInstancesContext>({\n enabled: false,\n toggle: () => {\n setState((prev) => ({ ...prev, enabled: !prev.enabled }));\n },\n });\n const enabled = state.enabled;\n\n useEffect(() => {\n if (!enabled) {\n setState((prev) => ({ ...prev, loadInstanceKeys: undefined }));\n return;\n }\n\n const onSelectionChanged = () => {\n const selection = selectionStorage.getSelection({ imodelKey, level: 0 });\n if (Selectables.isEmpty(selection)) {\n setState((prev) => ({ ...prev, loadInstanceKeys: undefined }));\n return;\n }\n\n const selected: Array<InstanceKey | GroupingHierarchyNode | (() => AsyncIterableIterator<InstanceKey>)> = [];\n Selectables.forEach(selection, (selectable) => {\n if (Selectable.isInstanceKey(selectable)) {\n selected.push(selectable);\n return;\n }\n\n if (isHierarchyNode(selectable.data) && HierarchyNode.isGroupingNode(selectable.data)) {\n selected.push(selectable.data);\n return;\n }\n\n selected.push(selectable.loadInstanceKeys);\n });\n\n const loadInstanceKeys: () => AsyncIterableIterator<InstanceKey | GroupingHierarchyNode> = async function* () {\n for (const item of selected) {\n if (typeof item === \"function\") {\n yield* item();\n } else {\n yield item;\n }\n }\n };\n\n setState((prev) => ({ ...prev, loadInstanceKeys }));\n };\n\n onSelectionChanged();\n return selectionStorage.selectionChangeEvent.addListener(({ imodelKey: changeImodelKey, level }) => {\n if (changeImodelKey !== imodelKey || level !== 0) {\n return;\n }\n onSelectionChanged();\n });\n }, [enabled, imodelKey, selectionStorage]);\n\n return <focusedInstancesContext.Provider value={state}>{children}</focusedInstancesContext.Provider>;\n}\n\nfunction isHierarchyNode(data: unknown): data is HierarchyNode {\n return !!data && typeof data === \"object\" && \"key\" in data;\n}\n"]}
|
|
@@ -6,7 +6,6 @@ interface UseFilteringResult {
|
|
|
6
6
|
clearFilter: () => void;
|
|
7
7
|
onHighlightChanged: (index: number, matches?: number) => void;
|
|
8
8
|
}
|
|
9
|
-
/** @internal */
|
|
10
9
|
export declare function useFiltering(): UseFilteringResult;
|
|
11
10
|
export {};
|
|
12
11
|
//# sourceMappingURL=UseFiltering.d.ts.map
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import { useCallback, useState } from "react";
|
|
6
|
-
/** @internal */
|
|
7
6
|
export function useFiltering() {
|
|
8
7
|
const [filter, setFilter] = useState("");
|
|
9
8
|
const [activeMatchIndex, setActiveMatchIndex] = useState(0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UseFiltering.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/UseFiltering.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAW9C,
|
|
1
|
+
{"version":3,"file":"UseFiltering.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/UseFiltering.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAW9C,MAAM,UAAU,YAAY;IAC1B,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IACzC,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC5D,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAEpD,MAAM,WAAW,GAAG,WAAW,CAAC,CAAC,SAAiB,EAAE,EAAE;QACpD,mBAAmB,CAAC,CAAC,CAAC,CAAC;QACvB,SAAS,CAAC,SAAS,CAAC,CAAC;IACvB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,WAAW,GAAG,WAAW,CAAC,GAAG,EAAE;QACnC,mBAAmB,CAAC,CAAC,CAAC,CAAC;QACvB,SAAS,CAAC,EAAE,CAAC,CAAC;IAChB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,kBAAkB,GAAG,WAAW,CAAC,CAAC,KAAa,EAAE,OAAgB,EAAE,EAAE;QACzE,mBAAmB,CAAC,KAAK,CAAC,CAAC;QAC3B,OAAO,IAAI,eAAe,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,kBAAkB,EAAE,CAAC;AAClG,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useCallback, useState } from \"react\";\n\ninterface UseFilteringResult {\n filter: string;\n activeMatchIndex: number;\n totalMatches: number;\n applyFilter: (filter: string) => void;\n clearFilter: () => void;\n onHighlightChanged: (index: number, matches?: number) => void;\n}\n\nexport function useFiltering(): UseFilteringResult {\n const [filter, setFilter] = useState(\"\");\n const [activeMatchIndex, setActiveMatchIndex] = useState(0);\n const [totalMatches, setTotalMatches] = useState(0);\n\n const applyFilter = useCallback((newFilter: string) => {\n setActiveMatchIndex(0);\n setFilter(newFilter);\n }, []);\n\n const clearFilter = useCallback(() => {\n setActiveMatchIndex(0);\n setFilter(\"\");\n }, []);\n\n const onHighlightChanged = useCallback((index: number, matches?: number) => {\n setActiveMatchIndex(index);\n matches && setTotalMatches(matches);\n }, []);\n\n return { filter, activeMatchIndex, totalMatches, applyFilter, clearFilter, onHighlightChanged };\n}\n"]}
|
|
@@ -2,7 +2,6 @@ import type { TreeRenderer, useTree } from "@itwin/presentation-hierarchies-reac
|
|
|
2
2
|
type UseTreeLocalizedStrings = Parameters<typeof useTree>[0]["localizedStrings"];
|
|
3
3
|
type TreeRendererLocalizedStrings = Parameters<typeof TreeRenderer>[0]["localizedStrings"];
|
|
4
4
|
type UseHierarchiesLocalizationResult = UseTreeLocalizedStrings & TreeRendererLocalizedStrings;
|
|
5
|
-
/** @internal */
|
|
6
5
|
export declare function useHierarchiesLocalization(): UseHierarchiesLocalizationResult;
|
|
7
6
|
export {};
|
|
8
7
|
//# sourceMappingURL=UseHierarchiesLocalization.d.ts.map
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import { useMemo } from "react";
|
|
6
6
|
import { TreeWidget } from "../../../TreeWidget";
|
|
7
|
-
/** @internal */
|
|
8
7
|
export function useHierarchiesLocalization() {
|
|
9
8
|
const stringValues = Object.values(getLocalizedStrings());
|
|
10
9
|
const localizedStrings = useMemo(getLocalizedStrings, stringValues);
|