@itwin/tree-widget-react 3.0.0-dev.3 → 3.0.0-dev.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +122 -6
- package/lib/cjs/components/SelectableTree.js +1 -2
- package/lib/cjs/components/SelectableTree.js.map +1 -1
- package/lib/cjs/components/SelectableTree.scss +5 -0
- package/lib/cjs/components/tree-header/TreeHeader.d.ts +12 -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 +3 -7
- package/lib/cjs/components/trees/categories-tree/CategoriesTree.js +7 -63
- package/lib/cjs/components/trees/categories-tree/CategoriesTree.js.map +1 -1
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeButtons.d.ts +9 -2
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeButtons.js +24 -4
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeButtons.js.map +1 -1
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeComponent.d.ts +0 -1
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeComponent.js +17 -19
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeComponent.js.map +1 -1
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeDefinition.d.ts +2 -2
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeDefinition.js +5 -4
- package/lib/cjs/components/trees/categories-tree/CategoriesTreeDefinition.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 +90 -0
- package/lib/cjs/components/trees/categories-tree/UseCategoriesTree.js.map +1 -0
- package/lib/cjs/components/trees/common/CategoriesVisibilityUtils.d.ts +6 -6
- package/lib/cjs/components/trees/common/CategoriesVisibilityUtils.js +32 -78
- package/lib/cjs/components/trees/common/CategoriesVisibilityUtils.js.map +1 -1
- package/lib/cjs/components/trees/common/FocusedInstancesContext.d.ts +1 -1
- package/lib/cjs/components/trees/common/FocusedInstancesContext.js.map +1 -1
- package/lib/cjs/components/trees/common/FocusedInstancesContextProvider.js +4 -4
- package/lib/cjs/components/trees/common/FocusedInstancesContextProvider.js.map +1 -1
- package/lib/cjs/components/trees/common/TreeErrors.d.ts +9 -0
- package/lib/cjs/components/trees/common/TreeErrors.js +19 -0
- package/lib/cjs/components/trees/common/TreeErrors.js.map +1 -0
- package/lib/cjs/components/trees/common/UseActiveViewport.d.ts +7 -0
- package/lib/cjs/components/trees/common/UseActiveViewport.js +25 -0
- package/lib/cjs/components/trees/common/UseActiveViewport.js.map +1 -0
- package/lib/cjs/components/trees/common/UseTelemetryContext.d.ts +1 -1
- package/lib/cjs/components/trees/common/UseTelemetryContext.js.map +1 -1
- package/lib/cjs/components/trees/common/components/Tree.d.ts +0 -2
- package/lib/cjs/components/trees/common/components/Tree.js +5 -4
- package/lib/cjs/components/trees/common/components/Tree.js.map +1 -1
- package/lib/cjs/components/trees/common/components/VisibilityTree.d.ts +2 -3
- package/lib/cjs/components/trees/common/components/VisibilityTree.js.map +1 -1
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.d.ts +1 -1
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js +1 -2
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js.map +1 -1
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.d.ts +1 -1
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTreeComponent.js +1 -2
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTreeComponent.js.map +1 -1
- package/lib/cjs/components/trees/index.d.ts +5 -0
- package/lib/cjs/components/trees/index.js +11 -1
- package/lib/cjs/components/trees/index.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsTree.d.ts +6 -11
- package/lib/cjs/components/trees/models-tree/ModelsTree.js +4 -203
- package/lib/cjs/components/trees/models-tree/ModelsTree.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsTreeButtons.d.ts +9 -3
- package/lib/cjs/components/trees/models-tree/ModelsTreeButtons.js +13 -3
- package/lib/cjs/components/trees/models-tree/ModelsTreeButtons.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.d.ts +1 -2
- package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.js +29 -21
- package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsTreeDefinition.d.ts +10 -6
- package/lib/cjs/components/trees/models-tree/ModelsTreeDefinition.js +63 -43
- package/lib/cjs/components/trees/models-tree/ModelsTreeDefinition.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/UseModelsTree.d.ts +38 -0
- package/lib/cjs/components/trees/models-tree/UseModelsTree.js +253 -0
- package/lib/cjs/components/trees/models-tree/UseModelsTree.js.map +1 -0
- package/lib/cjs/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js +5 -4
- package/lib/cjs/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js.map +1 -1
- package/lib/cjs/tree-widget-react.d.ts +1 -0
- package/lib/cjs/tree-widget-react.js +3 -1
- package/lib/cjs/tree-widget-react.js.map +1 -1
- package/lib/esm/components/SelectableTree.js +2 -3
- package/lib/esm/components/SelectableTree.js.map +1 -1
- package/lib/esm/components/SelectableTree.scss +5 -0
- package/lib/esm/components/tree-header/TreeHeader.d.ts +12 -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 +3 -7
- package/lib/esm/components/trees/categories-tree/CategoriesTree.js +7 -63
- package/lib/esm/components/trees/categories-tree/CategoriesTree.js.map +1 -1
- package/lib/esm/components/trees/categories-tree/CategoriesTreeButtons.d.ts +9 -2
- package/lib/esm/components/trees/categories-tree/CategoriesTreeButtons.js +22 -4
- package/lib/esm/components/trees/categories-tree/CategoriesTreeButtons.js.map +1 -1
- package/lib/esm/components/trees/categories-tree/CategoriesTreeComponent.d.ts +0 -1
- package/lib/esm/components/trees/categories-tree/CategoriesTreeComponent.js +18 -17
- package/lib/esm/components/trees/categories-tree/CategoriesTreeComponent.js.map +1 -1
- package/lib/esm/components/trees/categories-tree/CategoriesTreeDefinition.d.ts +2 -2
- package/lib/esm/components/trees/categories-tree/CategoriesTreeDefinition.js +5 -4
- package/lib/esm/components/trees/categories-tree/CategoriesTreeDefinition.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 +86 -0
- package/lib/esm/components/trees/categories-tree/UseCategoriesTree.js.map +1 -0
- package/lib/esm/components/trees/common/CategoriesVisibilityUtils.d.ts +6 -6
- package/lib/esm/components/trees/common/CategoriesVisibilityUtils.js +33 -79
- package/lib/esm/components/trees/common/CategoriesVisibilityUtils.js.map +1 -1
- package/lib/esm/components/trees/common/FocusedInstancesContext.d.ts +1 -1
- package/lib/esm/components/trees/common/FocusedInstancesContext.js.map +1 -1
- package/lib/esm/components/trees/common/FocusedInstancesContextProvider.js +4 -4
- package/lib/esm/components/trees/common/FocusedInstancesContextProvider.js.map +1 -1
- package/lib/esm/components/trees/common/TreeErrors.d.ts +9 -0
- package/lib/esm/components/trees/common/TreeErrors.js +15 -0
- package/lib/esm/components/trees/common/TreeErrors.js.map +1 -0
- package/lib/esm/components/trees/common/UseActiveViewport.d.ts +7 -0
- package/lib/esm/components/trees/common/UseActiveViewport.js +21 -0
- package/lib/esm/components/trees/common/UseActiveViewport.js.map +1 -0
- package/lib/esm/components/trees/common/UseTelemetryContext.d.ts +1 -1
- package/lib/esm/components/trees/common/UseTelemetryContext.js.map +1 -1
- package/lib/esm/components/trees/common/components/Tree.d.ts +0 -2
- package/lib/esm/components/trees/common/components/Tree.js +5 -4
- package/lib/esm/components/trees/common/components/Tree.js.map +1 -1
- package/lib/esm/components/trees/common/components/VisibilityTree.d.ts +2 -3
- package/lib/esm/components/trees/common/components/VisibilityTree.js.map +1 -1
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.d.ts +1 -1
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js +1 -2
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTreeComponent.js.map +1 -1
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.d.ts +1 -1
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTreeComponent.js +1 -2
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTreeComponent.js.map +1 -1
- package/lib/esm/components/trees/index.d.ts +5 -0
- package/lib/esm/components/trees/index.js +5 -0
- package/lib/esm/components/trees/index.js.map +1 -1
- package/lib/esm/components/trees/models-tree/ModelsTree.d.ts +6 -11
- package/lib/esm/components/trees/models-tree/ModelsTree.js +5 -204
- package/lib/esm/components/trees/models-tree/ModelsTree.js.map +1 -1
- package/lib/esm/components/trees/models-tree/ModelsTreeButtons.d.ts +9 -3
- package/lib/esm/components/trees/models-tree/ModelsTreeButtons.js +12 -2
- package/lib/esm/components/trees/models-tree/ModelsTreeButtons.js.map +1 -1
- package/lib/esm/components/trees/models-tree/ModelsTreeComponent.d.ts +1 -2
- package/lib/esm/components/trees/models-tree/ModelsTreeComponent.js +31 -20
- package/lib/esm/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
- package/lib/esm/components/trees/models-tree/ModelsTreeDefinition.d.ts +10 -6
- package/lib/esm/components/trees/models-tree/ModelsTreeDefinition.js +63 -43
- package/lib/esm/components/trees/models-tree/ModelsTreeDefinition.js.map +1 -1
- package/lib/esm/components/trees/models-tree/UseModelsTree.d.ts +38 -0
- package/lib/esm/components/trees/models-tree/UseModelsTree.js +249 -0
- package/lib/esm/components/trees/models-tree/UseModelsTree.js.map +1 -0
- package/lib/esm/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js +6 -5
- package/lib/esm/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js.map +1 -1
- package/lib/esm/tree-widget-react.d.ts +1 -0
- package/lib/esm/tree-widget-react.js +1 -0
- package/lib/esm/tree-widget-react.js.map +1 -1
- package/package.json +37 -41
- 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/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/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
|
@@ -1,22 +1,14 @@
|
|
|
1
1
|
import { BeEvent } from "@itwin/core-bentley";
|
|
2
2
|
import { HierarchyNode } from "@itwin/presentation-hierarchies";
|
|
3
|
-
import type {
|
|
4
|
-
import type { IModelConnection, ViewManager, Viewport } from "@itwin/core-frontend";
|
|
3
|
+
import type { Viewport } from "@itwin/core-frontend";
|
|
5
4
|
import type { HierarchyVisibilityHandler, VisibilityStatus } from "../common/UseHierarchyVisibility";
|
|
6
5
|
interface CategoriesVisibilityHandlerProps {
|
|
7
|
-
viewManager: ViewManager;
|
|
8
|
-
imodel: IModelConnection;
|
|
9
|
-
categories: CategoryInfo[];
|
|
10
6
|
viewport: Viewport;
|
|
11
|
-
allViewports?: boolean;
|
|
12
7
|
}
|
|
13
8
|
/** @internal */
|
|
14
9
|
export declare class CategoriesVisibilityHandler implements HierarchyVisibilityHandler {
|
|
15
|
-
private _viewManager;
|
|
16
|
-
private _imodel;
|
|
17
10
|
private _pendingVisibilityChange;
|
|
18
11
|
private _viewport;
|
|
19
|
-
private _useAllViewports;
|
|
20
12
|
constructor(props: CategoriesVisibilityHandlerProps);
|
|
21
13
|
dispose(): void;
|
|
22
14
|
onVisibilityChange: BeEvent<import("@itwin/core-bentley").Listener>;
|
|
@@ -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","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,E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AAC;IAC1C,CAAC;IAEM,qBAAqB,CAAC,IAAmB;QAC9C,MAAM,UAAU,GAAG,2BAA2B,CAAC,8BAA8B,CAAC,IAAI,CAAC,CAAC;QACpF,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC;IAC9E,CAAC;IAYO,0BAA0B;QAChC,IAAI,IAAI,CAAC,wBAAwB,EAAE;YACjC,OAAO;SACR;QAED,IAAI,CAAC,wBAAwB,GAAG,UAAU,CAAC,GAAG,EAAE;YAC9C,IAAI,CAAC,kBAAkB,CAAC,UAAU,EAAE,CAAC;YACrC,IAAI,CAAC,wBAAwB,GAAG,SAAS,CAAC;QAC5C,CAAC,EAAE,CAAC,CAAC,CAAC;IACR,CAAC;IAEM,MAAM,CAAC,8BAA8B,CAAC,IAAmB;QAC9D,OAAO,aAAa,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,0BAA0B,CAAC,EAAE,CAAC;IAC/I,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,GAAa,EAAE,OAAgB,EAAE,sBAAsB,GAAG,IAAI;QACxF,MAAM,qBAAqB,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,sBAAsB,CAAC,CAAC;IACpF,CAAC;IAEM,iBAAiB,CAAC,GAAW,EAAE,OAAgB;QACpD,wBAAwB,CAAC,IAAI,CAAC,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,86 @@
|
|
|
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 { FilterLimitExceededError } from "../common/TreeErrors";
|
|
11
|
+
import { useTelemetryContext } from "../common/UseTelemetryContext";
|
|
12
|
+
import { CategoriesTreeDefinition } from "./CategoriesTreeDefinition";
|
|
13
|
+
import { CategoriesVisibilityHandler } from "./CategoriesVisibilityHandler";
|
|
14
|
+
/**
|
|
15
|
+
* Custom hook to create and manage state for the categories tree.
|
|
16
|
+
* @beta
|
|
17
|
+
*/
|
|
18
|
+
export function useCategoriesTree({ filter, activeView }) {
|
|
19
|
+
const [filteringError, setFilteringError] = useState();
|
|
20
|
+
const visibilityHandlerFactory = useCallback(() => {
|
|
21
|
+
const visibilityHandler = new CategoriesVisibilityHandler({
|
|
22
|
+
viewport: activeView,
|
|
23
|
+
});
|
|
24
|
+
return {
|
|
25
|
+
getVisibilityStatus: async (node) => visibilityHandler.getVisibilityStatus(node),
|
|
26
|
+
changeVisibility: async (node, on) => visibilityHandler.changeVisibility(node, on),
|
|
27
|
+
onVisibilityChange: visibilityHandler.onVisibilityChange,
|
|
28
|
+
dispose: () => visibilityHandler.dispose(),
|
|
29
|
+
};
|
|
30
|
+
}, [activeView]);
|
|
31
|
+
const { onFeatureUsed } = useTelemetryContext();
|
|
32
|
+
const getHierarchyDefinition = useCallback((props) => {
|
|
33
|
+
return new CategoriesTreeDefinition({ ...props, viewType: activeView.view.is2d() ? "2d" : "3d" });
|
|
34
|
+
}, [activeView]);
|
|
35
|
+
const getFilteredPaths = useMemo(() => {
|
|
36
|
+
setFilteringError(undefined);
|
|
37
|
+
if (!filter) {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
return async ({ imodelAccess }) => {
|
|
41
|
+
onFeatureUsed({ featureId: "filtering", reportInteraction: true });
|
|
42
|
+
try {
|
|
43
|
+
return await CategoriesTreeDefinition.createInstanceKeyPaths({ imodelAccess, label: filter, viewType: activeView.view.is2d() ? "2d" : "3d" });
|
|
44
|
+
}
|
|
45
|
+
catch (e) {
|
|
46
|
+
const newError = e instanceof FilterLimitExceededError ? "tooManyFilterMatches" : "unknownFilterError";
|
|
47
|
+
if (newError !== "tooManyFilterMatches") {
|
|
48
|
+
const feature = e instanceof Error && e.message.includes("query too long to execute or server is too busy") ? "error-timeout" : "error-unknown";
|
|
49
|
+
onFeatureUsed({ featureId: feature, reportInteraction: false });
|
|
50
|
+
}
|
|
51
|
+
setFilteringError(newError);
|
|
52
|
+
return [];
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}, [filter, activeView, onFeatureUsed]);
|
|
56
|
+
return {
|
|
57
|
+
categoriesTreeProps: {
|
|
58
|
+
treeName: "categories-tree-v2",
|
|
59
|
+
getHierarchyDefinition,
|
|
60
|
+
getFilteredPaths,
|
|
61
|
+
visibilityHandlerFactory,
|
|
62
|
+
noDataMessage: getNoDataMessage(filter, filteringError),
|
|
63
|
+
highlight: filter ? { text: filter } : undefined,
|
|
64
|
+
},
|
|
65
|
+
rendererProps: {
|
|
66
|
+
getIcon,
|
|
67
|
+
getSublabel,
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function getNoDataMessage(filter, error) {
|
|
72
|
+
if (error) {
|
|
73
|
+
return _jsx(Text, { children: TreeWidget.translate(`categoriesTree.filtering.${error}`) });
|
|
74
|
+
}
|
|
75
|
+
if (filter) {
|
|
76
|
+
return _jsx(Text, { children: TreeWidget.translate("categoriesTree.filtering.noMatches", { filter }) });
|
|
77
|
+
}
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
function getIcon() {
|
|
81
|
+
return _jsx(SvgLayers, {});
|
|
82
|
+
}
|
|
83
|
+
function getSublabel(node) {
|
|
84
|
+
return node.extendedData?.description;
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=UseCategoriesTree.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UseCategoriesTree.js","sourceRoot":"","sources":["../../../../../src/components/trees/categories-tree/UseCategoriesTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,EAAE,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,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 { FilterLimitExceededError } from \"../common/TreeErrors\";\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 FilterLimitExceededError ? \"tooManyFilterMatches\" : \"unknownFilterError\";\n if (newError !== \"tooManyFilterMatches\") {\n const feature = e instanceof Error && e.message.includes(\"query too long to execute or server is too busy\") ? \"error-timeout\" : \"error-unknown\";\n onFeatureUsed({ featureId: feature, reportInteraction: false });\n }\n setFilteringError(newError);\n return [];\n }\n };\n }, [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,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Viewport } from "@itwin/core-frontend";
|
|
2
2
|
/**
|
|
3
3
|
* Data structure that describes category.
|
|
4
4
|
* @beta
|
|
@@ -10,20 +10,20 @@ export interface CategoryInfo {
|
|
|
10
10
|
/**
|
|
11
11
|
* Toggles visibility of categories to show or hide.
|
|
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
16
|
*/
|
|
17
|
-
export declare function getCategories(
|
|
17
|
+
export declare function getCategories(viewport: Viewport): Promise<string[]>;
|
|
18
18
|
/**
|
|
19
19
|
* Changes category display in the viewport.
|
|
20
20
|
*/
|
|
21
|
-
export declare function enableCategoryDisplay(
|
|
21
|
+
export declare function enableCategoryDisplay(viewport: Viewport, ids: string[], enabled: boolean, enableAllSubCategories?: boolean): Promise<void>;
|
|
22
22
|
/**
|
|
23
23
|
* Changes subcategory display in the viewport
|
|
24
24
|
*/
|
|
25
|
-
export declare function enableSubCategoryDisplay(
|
|
26
|
-
export declare function loadCategoriesFromViewport(
|
|
25
|
+
export declare function enableSubCategoryDisplay(viewport: Viewport, key: string, enabled: boolean): void;
|
|
26
|
+
export declare function loadCategoriesFromViewport(vp: Viewport): Promise<CategoryInfo[]>;
|
|
27
27
|
/**
|
|
28
28
|
* Enable display of all given categories.
|
|
29
29
|
* @public
|
|
@@ -3,123 +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
9
|
*/
|
|
10
|
-
export async function toggleAllCategories(
|
|
11
|
-
|
|
12
|
-
const activeView = viewport ?? viewManager.getFirstOpenView();
|
|
13
|
-
const ids = await getCategories(imodel, activeView);
|
|
14
|
-
// istanbul ignore if
|
|
10
|
+
export async function toggleAllCategories(viewport, display) {
|
|
11
|
+
const ids = await getCategories(viewport);
|
|
15
12
|
if (ids.length === 0) {
|
|
16
13
|
return;
|
|
17
14
|
}
|
|
18
|
-
await enableCategoryDisplay(
|
|
15
|
+
await enableCategoryDisplay(viewport, ids, display);
|
|
19
16
|
}
|
|
20
17
|
/**
|
|
21
18
|
* Gets ids of all categories from specified imodel and viewport.
|
|
22
19
|
*/
|
|
23
|
-
export async function getCategories(
|
|
24
|
-
const categories = await loadCategoriesFromViewport(
|
|
20
|
+
export async function getCategories(viewport) {
|
|
21
|
+
const categories = await loadCategoriesFromViewport(viewport);
|
|
25
22
|
return categories.map((category) => category.categoryId);
|
|
26
23
|
}
|
|
27
24
|
/**
|
|
28
25
|
* Changes category display in the viewport.
|
|
29
26
|
*/
|
|
30
|
-
export async function enableCategoryDisplay(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
//
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
vp.changeCategoryDisplay(ids, enabled, enableAllSubCategories);
|
|
39
|
-
// remove category overrides per model
|
|
40
|
-
const modelsContainingOverrides = [];
|
|
41
|
-
for (const ovr of vp.perModelCategoryVisibility) {
|
|
42
|
-
// istanbul ignore else
|
|
43
|
-
if (ids.findIndex((id) => id === ovr.categoryId) !== -1) {
|
|
44
|
-
modelsContainingOverrides.push(ovr.modelId);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
vp.perModelCategoryVisibility.setOverride(modelsContainingOverrides, ids, PerModelCategoryVisibility.Override.None);
|
|
48
|
-
// changeCategoryDisplay only enables subcategories, it does not disabled them. So we must do that ourselves.
|
|
49
|
-
if (false === enabled) {
|
|
50
|
-
(await imodel.categories.getCategoryInfo(ids)).forEach((categoryInfo) => {
|
|
51
|
-
categoryInfo.subCategories.forEach((value) => enableSubCategoryDisplay(viewManager, value.id, false, forAllViewports));
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
// This property let us act on all viewports or just on the selected one, configurable by the app
|
|
57
|
-
if (forAllViewports) {
|
|
58
|
-
for (const viewport of viewManager) {
|
|
59
|
-
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);
|
|
60
35
|
}
|
|
61
36
|
}
|
|
62
|
-
|
|
63
|
-
|
|
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
|
+
});
|
|
64
43
|
}
|
|
65
44
|
}
|
|
66
45
|
/**
|
|
67
46
|
* Changes subcategory display in the viewport
|
|
68
47
|
*/
|
|
69
|
-
export function enableSubCategoryDisplay(
|
|
70
|
-
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
const updateViewport = (vp) => {
|
|
74
|
-
// Only act on viewports that are both 3D or both 2D. Important if we have multiple viewports opened and we
|
|
75
|
-
// are using 'allViewports' property
|
|
76
|
-
if (viewManager.selectedView && viewManager.selectedView.view.is3d() === vp.view.is3d()) {
|
|
77
|
-
vp.changeSubCategoryDisplay(key, enabled);
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
// This property let us act on all viewports or just on the selected one, configurable by the app
|
|
81
|
-
if (forAllViewports) {
|
|
82
|
-
for (const viewport of viewManager) {
|
|
83
|
-
updateViewport(viewport);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
updateViewport(viewManager.selectedView);
|
|
88
|
-
}
|
|
48
|
+
export function enableSubCategoryDisplay(viewport, key, enabled) {
|
|
49
|
+
viewport.changeSubCategoryDisplay(key, enabled);
|
|
89
50
|
}
|
|
90
|
-
export async function loadCategoriesFromViewport(
|
|
91
|
-
if (!vp) {
|
|
92
|
-
return EMPTY_CATEGORIES_ARRAY;
|
|
93
|
-
}
|
|
51
|
+
export async function loadCategoriesFromViewport(vp) {
|
|
94
52
|
// Query categories and add them to state
|
|
95
53
|
const selectUsedSpatialCategoryIds = "SELECT DISTINCT Category.Id as id from BisCore.GeometricElement3d WHERE Category.Id IN (SELECT ECInstanceId from BisCore.SpatialCategory)";
|
|
96
54
|
const selectUsedDrawingCategoryIds = "SELECT DISTINCT Category.Id as id from BisCore.GeometricElement2d WHERE Model.Id=? AND Category.Id IN (SELECT ECInstanceId from BisCore.DrawingCategory)";
|
|
97
55
|
const ecsql = vp.view.is3d() ? selectUsedSpatialCategoryIds : selectUsedDrawingCategoryIds;
|
|
98
56
|
const ecsql2 = `SELECT ECInstanceId as id FROM ${vp.view.is3d() ? "BisCore.SpatialCategory" : "BisCore.DrawingCategory"} WHERE ECInstanceId IN (${ecsql})`;
|
|
99
57
|
const categories = [];
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
categories.push({ categoryId: val.id, subCategoryIds: val.subCategories.size ? [...val.subCategories.keys()] : undefined });
|
|
105
|
-
});
|
|
106
|
-
}
|
|
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
|
+
});
|
|
107
62
|
return categories;
|
|
108
63
|
}
|
|
109
|
-
const EMPTY_CATEGORIES_ARRAY = [];
|
|
110
64
|
/**
|
|
111
65
|
* Enable display of all given categories.
|
|
112
66
|
* @public
|
|
113
67
|
*/
|
|
114
68
|
export async function showAllCategories(categories, viewport) {
|
|
115
|
-
await enableCategoryDisplay(
|
|
69
|
+
await enableCategoryDisplay(viewport, categories, true, true);
|
|
116
70
|
}
|
|
117
71
|
/**
|
|
118
72
|
* Disable display of all given categories.
|
|
119
73
|
* @public
|
|
120
74
|
*/
|
|
121
75
|
export async function hideAllCategories(categories, viewport) {
|
|
122
|
-
await enableCategoryDisplay(
|
|
76
|
+
await enableCategoryDisplay(viewport, categories, false, true);
|
|
123
77
|
}
|
|
124
78
|
/**
|
|
125
79
|
* Invert display of all given categories.
|
|
@@ -146,10 +100,10 @@ export async function invertAllCategories(categories, viewport) {
|
|
|
146
100
|
}
|
|
147
101
|
}
|
|
148
102
|
// Disable enabled
|
|
149
|
-
enabledSubCategories.forEach((subCategory) => enableSubCategoryDisplay(
|
|
150
|
-
await enableCategoryDisplay(
|
|
103
|
+
enabledSubCategories.forEach((subCategory) => enableSubCategoryDisplay(viewport, subCategory, false));
|
|
104
|
+
await enableCategoryDisplay(viewport, enabled, false, true);
|
|
151
105
|
// Enable disabled
|
|
152
|
-
disabledSubCategories.forEach((subCategory) => enableSubCategoryDisplay(
|
|
153
|
-
await enableCategoryDisplay(
|
|
106
|
+
disabledSubCategories.forEach((subCategory) => enableSubCategoryDisplay(viewport, subCategory, true));
|
|
107
|
+
await enableCategoryDisplay(viewport, disabled, true, true);
|
|
154
108
|
}
|
|
155
109
|
//# sourceMappingURL=CategoriesVisibilityUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CategoriesVisibilityUtils.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/CategoriesVisibilityUtils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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 * @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(\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 */\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 */\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 */\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\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,KAAK,UAAU,aAAa,CAAC,QAAkB;IACpD,MAAM,UAAU,GAAG,MAAM,0BAA0B,CAAC,QAAQ,CAAC,CAAC;IAC9D,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;AAC3D,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,QAAkB,EAAE,GAAa,EAAE,OAAgB,EAAE,sBAAsB,GAAG,IAAI;IAC5H,QAAQ,CAAC,qBAAqB,CAAC,GAAG,EAAE,OAAO,EAAE,sBAAsB,CAAC,CAAC;IAErE,sCAAsC;IACtC,MAAM,yBAAyB,GAAa,EAAE,CAAC;IAC/C,KAAK,MAAM,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AC,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"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import type { InstanceKey } from "@itwin/presentation-shared";
|
|
3
3
|
import type { GroupingHierarchyNode } from "@itwin/presentation-hierarchies";
|
|
4
4
|
export interface FocusedInstancesContext {
|
|
5
|
-
|
|
5
|
+
loadFocusedItems?: () => AsyncIterableIterator<InstanceKey | GroupingHierarchyNode>;
|
|
6
6
|
enabled: boolean;
|
|
7
7
|
toggle: () => void;
|
|
8
8
|
}
|
|
@@ -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;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
|
|
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 loadFocusedItems?: () => 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"]}
|
|
@@ -17,13 +17,13 @@ export function FocusedInstancesContextProvider({ selectionStorage, imodelKey, c
|
|
|
17
17
|
const enabled = state.enabled;
|
|
18
18
|
useEffect(() => {
|
|
19
19
|
if (!enabled) {
|
|
20
|
-
setState((prev) => ({ ...prev,
|
|
20
|
+
setState((prev) => ({ ...prev, loadFocusedItems: undefined }));
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
23
23
|
const onSelectionChanged = () => {
|
|
24
24
|
const selection = selectionStorage.getSelection({ imodelKey, level: 0 });
|
|
25
25
|
if (Selectables.isEmpty(selection)) {
|
|
26
|
-
setState((prev) => ({ ...prev,
|
|
26
|
+
setState((prev) => ({ ...prev, loadFocusedItems: undefined }));
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
29
|
const selected = [];
|
|
@@ -38,7 +38,7 @@ export function FocusedInstancesContextProvider({ selectionStorage, imodelKey, c
|
|
|
38
38
|
}
|
|
39
39
|
selected.push(selectable.loadInstanceKeys);
|
|
40
40
|
});
|
|
41
|
-
const
|
|
41
|
+
const loadFocusedItems = async function* () {
|
|
42
42
|
for (const item of selected) {
|
|
43
43
|
if (typeof item === "function") {
|
|
44
44
|
yield* item();
|
|
@@ -48,7 +48,7 @@ export function FocusedInstancesContextProvider({ selectionStorage, imodelKey, c
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
|
-
setState((prev) => ({ ...prev,
|
|
51
|
+
setState((prev) => ({ ...prev, loadFocusedItems }));
|
|
52
52
|
};
|
|
53
53
|
onSelectionChanged();
|
|
54
54
|
return selectionStorage.selectionChangeEvent.addListener(({ imodelKey: changeImodelKey, level }) => {
|
|
@@ -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,MAAM,UAAU,+BAA+B,CAAC,EAC9C,gBAAgB,EAChB,SAAS,EACT,QAAQ,GACqE;IAC7E,MAAM,CAAC,KAAK,EAAE,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IAAI,CAAC,CAAC;oBAC/B,OAAO;iBACR;gBAED,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC;YAC7C,CAAC,CAAC,CAAC;YAEH,MAAM,gBAAgB,GAAqE,KAAK,SAAS,CAAC;gBACxG,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE;oBAC3B,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE;wBAC9B,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC;qBACf;yBAAM;wBACL,MAAM,IAAI,CAAC;qBACZ;iBACF;YACH,CAAC,CAAC;YAEF,QAAQ,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,gBAAgB,EAAE,CAAC,CAAC,CAAC;QACtD,CAAC,CAAC;QAEF,kBAAkB,EAAE,CAAC;QACrB,OAAO,gBAAgB,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,KAAK,EAAE,EAAE,EAAE;YACjG,IAAI,eAAe,KAAK,SAAS,IAAI,KAAK,KAAK,CAAC,EAAE;gBAChD,OAAO;aACR;YACD,kBAAkB,EAAE,CAAC;QACvB,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,OAAO,EAAE,SAAS,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,
|
|
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,MAAM,UAAU,+BAA+B,CAAC,EAC9C,gBAAgB,EAChB,SAAS,EACT,QAAQ,GACqE;IAC7E,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAA0B;QAC1D,OAAO,EAAE,KAAK;QACd,MAAM,EAAE,GAAG,EAAE;YACX,QAAQ,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,CAAC,IAAI,CAAC,OAAO,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I,QAAQ,EAAE;oBAC3B,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE;wBAC9B,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC;qBACf;yBAAM;wBACL,MAAM,IAAI,CAAC;qBACZ;iBACF;YACH,CAAC,CAAC;YAEF,QAAQ,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,gBAAgB,EAAE,CAAC,CAAC,CAAC;QACtD,CAAC,CAAC;QAEF,kBAAkB,EAAE,CAAC;QACrB,OAAO,gBAAgB,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,KAAK,EAAE,EAAE,EAAE;YACjG,IAAI,eAAe,KAAK,SAAS,IAAI,KAAK,KAAK,CAAC,EAAE;gBAChD,OAAO;aACR;YACD,kBAAkB,EAAE,CAAC;QACvB,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,OAAO,EAAE,SAAS,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, loadFocusedItems: 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, loadFocusedItems: 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 loadFocusedItems: () => 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, loadFocusedItems }));\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"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error that is thrown when too many matches are found while filtering the tree.
|
|
3
|
+
* @beta
|
|
4
|
+
*/
|
|
5
|
+
export declare class FilterLimitExceededError extends Error {
|
|
6
|
+
readonly limit: number;
|
|
7
|
+
constructor(limit: number);
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=TreeErrors.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
/**
|
|
6
|
+
* Error that is thrown when too many matches are found while filtering the tree.
|
|
7
|
+
* @beta
|
|
8
|
+
*/
|
|
9
|
+
export class FilterLimitExceededError extends Error {
|
|
10
|
+
constructor(limit) {
|
|
11
|
+
super("Too many filter matches");
|
|
12
|
+
this.limit = limit;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=TreeErrors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TreeErrors.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/TreeErrors.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG;;;GAGG;AACH,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IACjD,YAAmC,KAAa;QAC9C,KAAK,CAAC,yBAAyB,CAAC,CAAC;QADA,UAAK,GAAL,KAAK,CAAQ;IAEhD,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\n/**\n * Error that is thrown when too many matches are found while filtering the tree.\n * @beta\n */\nexport class FilterLimitExceededError extends Error {\n public constructor(public readonly limit: number) {\n super(\"Too many filter matches\");\n }\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ScreenViewport } from "@itwin/core-frontend";
|
|
2
|
+
/**
|
|
3
|
+
* A copy of `useActiveViewport` from `@itwin/appui-react` package until X is fixed.
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export declare function useActiveViewport(): ScreenViewport | undefined;
|
|
7
|
+
//# sourceMappingURL=UseActiveViewport.d.ts.map
|