@itwin/tree-widget-react 0.4.7 → 0.6.0
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/lib/cjs/TreeWidget.js +4 -2
- package/lib/cjs/TreeWidget.js.map +1 -1
- package/lib/cjs/components/TreeWidgetUiItemsProvider.js +20 -12
- package/lib/cjs/components/TreeWidgetUiItemsProvider.js.map +1 -1
- package/lib/cjs/components/rulesets/ClassificationSystems.json +122 -0
- package/lib/cjs/components/rulesets/IModelContent.json +407 -407
- package/lib/cjs/components/trees/Common.d.ts +21 -0
- package/lib/cjs/components/trees/Common.js +21 -0
- package/lib/cjs/components/trees/Common.js.map +1 -0
- package/lib/cjs/components/trees/VisibilityTreeBase.scss +53 -0
- package/lib/cjs/components/trees/VisibilityTreeEventHandler.d.ts +67 -0
- package/lib/cjs/components/trees/VisibilityTreeEventHandler.js +147 -0
- package/lib/cjs/components/trees/VisibilityTreeEventHandler.js.map +1 -0
- package/lib/cjs/components/trees/VisibilityTreeRenderer.d.ts +43 -0
- package/lib/cjs/components/trees/VisibilityTreeRenderer.js +81 -0
- package/lib/cjs/components/trees/VisibilityTreeRenderer.js.map +1 -0
- package/lib/cjs/components/trees/category-tree/Categories.json +102 -0
- package/lib/cjs/components/trees/category-tree/CategoriesTree.d.ts +65 -0
- package/lib/cjs/components/trees/category-tree/CategoriesTree.js +121 -0
- package/lib/cjs/components/trees/category-tree/CategoriesTree.js.map +1 -0
- package/lib/{esm/components/trees → cjs/components/trees/category-tree}/CategoriesTree.scss +5 -0
- package/lib/cjs/components/trees/{CategoriesTree.d.ts → category-tree/CategoriesTreeComponent.d.ts} +2 -2
- package/lib/cjs/components/trees/{CategoriesTree.js → category-tree/CategoriesTreeComponent.js} +14 -13
- package/lib/cjs/components/trees/category-tree/CategoriesTreeComponent.js.map +1 -0
- package/lib/cjs/components/trees/category-tree/CategoryVisibilityHandler.d.ts +54 -0
- package/lib/cjs/components/trees/category-tree/CategoryVisibilityHandler.js +213 -0
- package/lib/cjs/components/trees/category-tree/CategoryVisibilityHandler.js.map +1 -0
- package/lib/cjs/components/trees/index.d.ts +10 -3
- package/lib/cjs/components/trees/index.js +13 -6
- package/lib/cjs/components/trees/index.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/Hierarchy.GroupedByClass.json +392 -0
- package/lib/cjs/components/trees/models-tree/Hierarchy.json +387 -0
- package/lib/cjs/components/trees/models-tree/ModelsTree.d.ts +82 -0
- package/lib/cjs/components/trees/models-tree/ModelsTree.js +144 -0
- package/lib/cjs/components/trees/models-tree/ModelsTree.js.map +1 -0
- package/lib/cjs/components/trees/{ModelsTree.scss → models-tree/ModelsTree.scss} +5 -1
- package/lib/{esm/components/trees/ModelsTree.d.ts → cjs/components/trees/models-tree/ModelsTreeComponent.d.ts} +2 -2
- package/lib/cjs/components/trees/{ModelsTree.js → models-tree/ModelsTreeComponent.js} +6 -5
- package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.js.map +1 -0
- package/lib/cjs/components/trees/models-tree/ModelsTreeSearch.json +239 -0
- package/lib/cjs/components/trees/models-tree/ModelsVisibilityHandler.d.ts +100 -0
- package/lib/cjs/components/trees/models-tree/ModelsVisibilityHandler.js +477 -0
- package/lib/cjs/components/trees/models-tree/ModelsVisibilityHandler.js.map +1 -0
- package/lib/cjs/components/trees/models-tree/Utils.d.ts +10 -0
- package/lib/cjs/components/trees/models-tree/Utils.js +27 -0
- package/lib/cjs/components/trees/models-tree/Utils.js.map +1 -0
- package/lib/cjs/components/trees/{SpatialTree.d.ts → spatial-tree/SpatialTreeComponent.d.ts} +2 -2
- package/lib/cjs/components/trees/{SpatialTree.js → spatial-tree/SpatialTreeComponent.js} +2 -2
- package/lib/cjs/components/trees/spatial-tree/SpatialTreeComponent.js.map +1 -0
- package/lib/cjs/tree-widget-react.js +3 -3
- package/lib/cjs/tree-widget-react.js.map +1 -1
- package/lib/cjs/types.d.ts +7 -1
- package/lib/cjs/types.js +4 -0
- package/lib/cjs/types.js.map +1 -1
- package/lib/esm/TreeWidget.js +4 -2
- package/lib/esm/TreeWidget.js.map +1 -1
- package/lib/esm/components/TreeWidgetUiItemsProvider.js +17 -9
- package/lib/esm/components/TreeWidgetUiItemsProvider.js.map +1 -1
- package/lib/esm/components/rulesets/ClassificationSystems.json +122 -0
- package/lib/esm/components/rulesets/IModelContent.json +407 -407
- package/lib/esm/components/trees/Common.d.ts +21 -0
- package/lib/esm/components/trees/Common.js +18 -0
- package/lib/esm/components/trees/Common.js.map +1 -0
- package/lib/esm/components/trees/VisibilityTreeBase.scss +53 -0
- package/lib/esm/components/trees/VisibilityTreeEventHandler.d.ts +67 -0
- package/lib/esm/components/trees/VisibilityTreeEventHandler.js +143 -0
- package/lib/esm/components/trees/VisibilityTreeEventHandler.js.map +1 -0
- package/lib/esm/components/trees/VisibilityTreeRenderer.d.ts +43 -0
- package/lib/esm/components/trees/VisibilityTreeRenderer.js +54 -0
- package/lib/esm/components/trees/VisibilityTreeRenderer.js.map +1 -0
- package/lib/esm/components/trees/category-tree/Categories.json +102 -0
- package/lib/esm/components/trees/category-tree/CategoriesTree.d.ts +65 -0
- package/lib/esm/components/trees/category-tree/CategoriesTree.js +96 -0
- package/lib/esm/components/trees/category-tree/CategoriesTree.js.map +1 -0
- package/lib/{cjs/components/trees → esm/components/trees/category-tree}/CategoriesTree.scss +5 -0
- package/lib/esm/components/trees/{CategoriesTree.d.ts → category-tree/CategoriesTreeComponent.d.ts} +2 -2
- package/lib/esm/components/trees/{CategoriesTree.js → category-tree/CategoriesTreeComponent.js} +8 -7
- package/lib/esm/components/trees/category-tree/CategoriesTreeComponent.js.map +1 -0
- package/lib/esm/components/trees/category-tree/CategoryVisibilityHandler.d.ts +54 -0
- package/lib/esm/components/trees/category-tree/CategoryVisibilityHandler.js +188 -0
- package/lib/esm/components/trees/category-tree/CategoryVisibilityHandler.js.map +1 -0
- package/lib/esm/components/trees/index.d.ts +10 -3
- package/lib/esm/components/trees/index.js +13 -6
- package/lib/esm/components/trees/index.js.map +1 -1
- package/lib/esm/components/trees/models-tree/Hierarchy.GroupedByClass.json +392 -0
- package/lib/esm/components/trees/models-tree/Hierarchy.json +387 -0
- package/lib/esm/components/trees/models-tree/ModelsTree.d.ts +82 -0
- package/lib/esm/components/trees/models-tree/ModelsTree.js +121 -0
- package/lib/esm/components/trees/models-tree/ModelsTree.js.map +1 -0
- package/lib/esm/components/trees/{ModelsTree.scss → models-tree/ModelsTree.scss} +5 -1
- package/lib/{cjs/components/trees/ModelsTree.d.ts → esm/components/trees/models-tree/ModelsTreeComponent.d.ts} +2 -2
- package/lib/esm/components/trees/{ModelsTree.js → models-tree/ModelsTreeComponent.js} +6 -5
- package/lib/esm/components/trees/models-tree/ModelsTreeComponent.js.map +1 -0
- package/lib/esm/components/trees/models-tree/ModelsTreeSearch.json +239 -0
- package/lib/esm/components/trees/models-tree/ModelsVisibilityHandler.d.ts +100 -0
- package/lib/esm/components/trees/models-tree/ModelsVisibilityHandler.js +472 -0
- package/lib/esm/components/trees/models-tree/ModelsVisibilityHandler.js.map +1 -0
- package/lib/esm/components/trees/models-tree/Utils.d.ts +10 -0
- package/lib/esm/components/trees/models-tree/Utils.js +23 -0
- package/lib/esm/components/trees/models-tree/Utils.js.map +1 -0
- package/lib/esm/components/trees/{SpatialTree.d.ts → spatial-tree/SpatialTreeComponent.d.ts} +2 -2
- package/lib/esm/components/trees/{SpatialTree.js → spatial-tree/SpatialTreeComponent.js} +2 -2
- package/lib/esm/components/trees/spatial-tree/SpatialTreeComponent.js.map +1 -0
- package/lib/esm/tree-widget-react.js +3 -3
- package/lib/esm/tree-widget-react.js.map +1 -1
- package/lib/esm/types.d.ts +7 -1
- package/lib/esm/types.js +3 -1
- package/lib/esm/types.js.map +1 -1
- package/lib/public/locales/en/TreeWidget.json +39 -2
- package/package.json +54 -32
- package/lib/cjs/components/trees/CategoriesTree.js.map +0 -1
- package/lib/cjs/components/trees/ModelsTree.js.map +0 -1
- package/lib/cjs/components/trees/SpatialTree.js.map +0 -1
- package/lib/esm/components/trees/CategoriesTree.js.map +0 -1
- package/lib/esm/components/trees/ModelsTree.js.map +0 -1
- package/lib/esm/components/trees/SpatialTree.js.map +0 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An option of how class grouping should work in a component.
|
|
3
|
+
* @beta
|
|
4
|
+
*/
|
|
5
|
+
export declare enum ClassGroupingOption {
|
|
6
|
+
/** Class grouping is disabled */
|
|
7
|
+
No = 0,
|
|
8
|
+
/** Class grouping is enabled */
|
|
9
|
+
Yes = 1,
|
|
10
|
+
/** Class grouping is enabled and grouping node shows grouped items count */
|
|
11
|
+
YesWithCounts = 2
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Data structure that describes info used to filter visibility tree.
|
|
15
|
+
* @alpha
|
|
16
|
+
*/
|
|
17
|
+
export interface VisibilityTreeFilterInfo {
|
|
18
|
+
filter: string;
|
|
19
|
+
activeMatchIndex?: number;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=Common.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.ClassGroupingOption = void 0;
|
|
8
|
+
/**
|
|
9
|
+
* An option of how class grouping should work in a component.
|
|
10
|
+
* @beta
|
|
11
|
+
*/
|
|
12
|
+
var ClassGroupingOption;
|
|
13
|
+
(function (ClassGroupingOption) {
|
|
14
|
+
/** Class grouping is disabled */
|
|
15
|
+
ClassGroupingOption[ClassGroupingOption["No"] = 0] = "No";
|
|
16
|
+
/** Class grouping is enabled */
|
|
17
|
+
ClassGroupingOption[ClassGroupingOption["Yes"] = 1] = "Yes";
|
|
18
|
+
/** Class grouping is enabled and grouping node shows grouped items count */
|
|
19
|
+
ClassGroupingOption[ClassGroupingOption["YesWithCounts"] = 2] = "YesWithCounts";
|
|
20
|
+
})(ClassGroupingOption = exports.ClassGroupingOption || (exports.ClassGroupingOption = {}));
|
|
21
|
+
//# sourceMappingURL=Common.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Common.js","sourceRoot":"","sources":["../../../../src/components/trees/Common.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;;GAGG;AACH,IAAY,mBAOX;AAPD,WAAY,mBAAmB;IAC7B,iCAAiC;IACjC,yDAAE,CAAA;IACF,gCAAgC;IAChC,2DAAG,CAAA;IACH,4EAA4E;IAC5E,+EAAa,CAAA;AACf,CAAC,EAPW,mBAAmB,GAAnB,2BAAmB,KAAnB,2BAAmB,QAO9B","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 * An option of how class grouping should work in a component.\n * @beta\n */\nexport enum ClassGroupingOption {\n /** Class grouping is disabled */\n No,\n /** Class grouping is enabled */\n Yes,\n /** Class grouping is enabled and grouping node shows grouped items count */\n YesWithCounts,\n}\n\n/**\n * Data structure that describes info used to filter visibility tree.\n * @alpha\n */\nexport interface VisibilityTreeFilterInfo {\n filter: string;\n activeMatchIndex?: number;\n}\n"]}
|
|
@@ -0,0 +1,53 @@
|
|
|
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
|
+
@import "~@itwin/core-react/lib/cjs/core-react/style/themecolors";
|
|
6
|
+
|
|
7
|
+
@mixin tree-widget-visibility-tree-base {
|
|
8
|
+
height: 100%;
|
|
9
|
+
width: 100%;
|
|
10
|
+
display: flex;
|
|
11
|
+
flex-direction: column;
|
|
12
|
+
position: relative;
|
|
13
|
+
|
|
14
|
+
.core-tree-node.with-checkbox {
|
|
15
|
+
>.contents {
|
|
16
|
+
padding-left: 31px;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.contents > .core-image-checkbox {
|
|
21
|
+
position: absolute;
|
|
22
|
+
top: unset;
|
|
23
|
+
left: 5px;
|
|
24
|
+
margin: -2px 0px 0px 5px;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.filteredTreeOverlay {
|
|
28
|
+
position: absolute;
|
|
29
|
+
top: 0;
|
|
30
|
+
left: 0;
|
|
31
|
+
width: 100%;
|
|
32
|
+
height: 100%;
|
|
33
|
+
z-index: 9999;
|
|
34
|
+
background-color: rgba(255, 255, 255, .8);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.components-tree-errormessage {
|
|
38
|
+
position: absolute;
|
|
39
|
+
top: 40%;
|
|
40
|
+
left: 50%;
|
|
41
|
+
width: 75%;
|
|
42
|
+
text-align: center;
|
|
43
|
+
transform: translate(-50%, -50%);
|
|
44
|
+
font-style: italic;
|
|
45
|
+
color: $buic-foreground-muted;
|
|
46
|
+
|
|
47
|
+
.errormessage-header {
|
|
48
|
+
display: block;
|
|
49
|
+
font-weight: bold;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module IModelComponents
|
|
3
|
+
*/
|
|
4
|
+
import { UnifiedSelectionTreeEventHandler } from "@itwin/presentation-components";
|
|
5
|
+
import type { TreeCheckboxStateChangeEventArgs, TreeNodeItem, TreeSelectionModificationEventArgs, TreeSelectionReplacementEventArgs } from "@itwin/components-react";
|
|
6
|
+
import type { BeEvent, IDisposable } from "@itwin/core-bentley";
|
|
7
|
+
import type { NodeKey } from "@itwin/presentation-common";
|
|
8
|
+
import type { UnifiedSelectionTreeEventHandlerParams } from "@itwin/presentation-components";
|
|
9
|
+
/**
|
|
10
|
+
* Data structure that describes instance visibility status.
|
|
11
|
+
* @alpha
|
|
12
|
+
*/
|
|
13
|
+
export interface VisibilityStatus {
|
|
14
|
+
state: "visible" | "partial" | "hidden";
|
|
15
|
+
isDisabled?: boolean;
|
|
16
|
+
tooltip?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Type definition of visibility change event listener.
|
|
20
|
+
* @alpha
|
|
21
|
+
*/
|
|
22
|
+
export declare type VisibilityChangeListener = (nodeIds?: string[], visibilityStatus?: Map<string, VisibilityStatus>) => void;
|
|
23
|
+
/**
|
|
24
|
+
* Visibility handler used to change or get visibility of instances represented by the tree node.
|
|
25
|
+
* @alpha
|
|
26
|
+
*/
|
|
27
|
+
export interface IVisibilityHandler extends IDisposable {
|
|
28
|
+
getVisibilityStatus(node: TreeNodeItem, nodeKey: NodeKey): VisibilityStatus | Promise<VisibilityStatus>;
|
|
29
|
+
changeVisibility(node: TreeNodeItem, nodeKey: NodeKey, shouldDisplay: boolean): Promise<void>;
|
|
30
|
+
onVisibilityChange: BeEvent<VisibilityChangeListener>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Type definition of predicate used to decide if node can be selected.
|
|
34
|
+
* @alpha
|
|
35
|
+
*/
|
|
36
|
+
export declare type VisibilityTreeSelectionPredicate = (key: NodeKey, node: TreeNodeItem) => boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Parameters for [[VisibilityTreeEventHandler]]
|
|
39
|
+
* @alpha
|
|
40
|
+
*/
|
|
41
|
+
export interface VisibilityTreeEventHandlerParams extends UnifiedSelectionTreeEventHandlerParams {
|
|
42
|
+
visibilityHandler: IVisibilityHandler | undefined;
|
|
43
|
+
selectionPredicate?: VisibilityTreeSelectionPredicate;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Base event handler for visibility tree.
|
|
47
|
+
* @alpha
|
|
48
|
+
*/
|
|
49
|
+
export declare class VisibilityTreeEventHandler extends UnifiedSelectionTreeEventHandler {
|
|
50
|
+
private _visibilityHandler;
|
|
51
|
+
private _selectionPredicate?;
|
|
52
|
+
private _listeners;
|
|
53
|
+
constructor(params: VisibilityTreeEventHandlerParams);
|
|
54
|
+
dispose(): void;
|
|
55
|
+
private filterSelectionItems;
|
|
56
|
+
onSelectionModified({ modifications }: TreeSelectionModificationEventArgs): import("@itwin/components-react").Subscription | undefined;
|
|
57
|
+
onSelectionReplaced({ replacements }: TreeSelectionReplacementEventArgs): import("@itwin/components-react").Subscription | undefined;
|
|
58
|
+
onCheckboxStateChanged(event: TreeCheckboxStateChangeEventArgs): undefined;
|
|
59
|
+
private changeVisibility;
|
|
60
|
+
private updateCheckboxes;
|
|
61
|
+
private updateModel;
|
|
62
|
+
private collectAffectedNodesCheckboxInfos;
|
|
63
|
+
private collectAllNodesCheckboxInfos;
|
|
64
|
+
private getNodeCheckBoxInfo;
|
|
65
|
+
private createCheckboxInfo;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=VisibilityTreeEventHandler.d.ts.map
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
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
|
+
/** @packageDocumentation
|
|
7
|
+
* @module IModelComponents
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.VisibilityTreeEventHandler = void 0;
|
|
11
|
+
const empty_1 = require("rxjs/internal/observable/empty");
|
|
12
|
+
const from_1 = require("rxjs/internal/observable/from");
|
|
13
|
+
const map_1 = require("rxjs/internal/operators/map");
|
|
14
|
+
const mergeMap_1 = require("rxjs/internal/operators/mergeMap");
|
|
15
|
+
const components_react_1 = require("@itwin/components-react");
|
|
16
|
+
const core_react_1 = require("@itwin/core-react");
|
|
17
|
+
const presentation_components_1 = require("@itwin/presentation-components");
|
|
18
|
+
/**
|
|
19
|
+
* Base event handler for visibility tree.
|
|
20
|
+
* @alpha
|
|
21
|
+
*/
|
|
22
|
+
class VisibilityTreeEventHandler extends presentation_components_1.UnifiedSelectionTreeEventHandler {
|
|
23
|
+
constructor(params) {
|
|
24
|
+
super(params);
|
|
25
|
+
this._listeners = new Array();
|
|
26
|
+
this._visibilityHandler = params.visibilityHandler;
|
|
27
|
+
this._selectionPredicate = params.selectionPredicate;
|
|
28
|
+
if (this._visibilityHandler) {
|
|
29
|
+
this._listeners.push(this._visibilityHandler.onVisibilityChange.addListener(async (nodeIds, visibilityStatus) => this.updateCheckboxes(nodeIds, visibilityStatus)));
|
|
30
|
+
}
|
|
31
|
+
this._listeners.push(this.modelSource.onModelChanged.addListener(async ([_, changes]) => this.updateCheckboxes([...changes.addedNodeIds, ...changes.modifiedNodeIds])));
|
|
32
|
+
this.updateCheckboxes(); // eslint-disable-line @typescript-eslint/no-floating-promises
|
|
33
|
+
}
|
|
34
|
+
dispose() {
|
|
35
|
+
super.dispose();
|
|
36
|
+
this._listeners.forEach((disposeFunc) => disposeFunc());
|
|
37
|
+
}
|
|
38
|
+
filterSelectionItems(items) {
|
|
39
|
+
// istanbul ignore if
|
|
40
|
+
if (!this._selectionPredicate)
|
|
41
|
+
return items;
|
|
42
|
+
return items.filter((item) => this._selectionPredicate(this.getNodeKey(item), item));
|
|
43
|
+
}
|
|
44
|
+
onSelectionModified({ modifications }) {
|
|
45
|
+
const filteredModification = components_react_1.toRxjsObservable(modifications).pipe(map_1.map(({ selectedNodeItems, deselectedNodeItems }) => {
|
|
46
|
+
return {
|
|
47
|
+
selectedNodeItems: this.filterSelectionItems(selectedNodeItems),
|
|
48
|
+
deselectedNodeItems: this.filterSelectionItems(deselectedNodeItems),
|
|
49
|
+
};
|
|
50
|
+
}));
|
|
51
|
+
return super.onSelectionModified({ modifications: filteredModification });
|
|
52
|
+
}
|
|
53
|
+
onSelectionReplaced({ replacements }) {
|
|
54
|
+
const filteredReplacements = components_react_1.toRxjsObservable(replacements).pipe(map_1.map(({ selectedNodeItems }) => {
|
|
55
|
+
return {
|
|
56
|
+
selectedNodeItems: this.filterSelectionItems(selectedNodeItems),
|
|
57
|
+
};
|
|
58
|
+
}));
|
|
59
|
+
return super.onSelectionReplaced({ replacements: filteredReplacements });
|
|
60
|
+
}
|
|
61
|
+
onCheckboxStateChanged(event) {
|
|
62
|
+
// istanbul ignore if
|
|
63
|
+
if (!this._visibilityHandler)
|
|
64
|
+
return undefined;
|
|
65
|
+
from_1.from(event.stateChanges)
|
|
66
|
+
.pipe(mergeMap_1.mergeMap((changes) => this.changeVisibility(changes)))
|
|
67
|
+
.subscribe();
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
changeVisibility(changes) {
|
|
71
|
+
return from_1.from(changes)
|
|
72
|
+
.pipe(mergeMap_1.mergeMap(({ nodeItem, newState }) => {
|
|
73
|
+
// istanbul ignore if
|
|
74
|
+
if (!this._visibilityHandler)
|
|
75
|
+
return empty_1.EMPTY;
|
|
76
|
+
return from_1.from(this._visibilityHandler.changeVisibility(nodeItem, this.getNodeKey(nodeItem), newState === core_react_1.CheckBoxState.On));
|
|
77
|
+
}));
|
|
78
|
+
}
|
|
79
|
+
async updateCheckboxes(affectedNodes, visibilityStatus) {
|
|
80
|
+
const changes = await (affectedNodes ? this.collectAffectedNodesCheckboxInfos(affectedNodes, visibilityStatus) : this.collectAllNodesCheckboxInfos(visibilityStatus));
|
|
81
|
+
this.updateModel(changes);
|
|
82
|
+
}
|
|
83
|
+
updateModel(changes) {
|
|
84
|
+
this.modelSource.modifyModel((model) => {
|
|
85
|
+
for (const [nodeId, checkboxInfo] of changes) {
|
|
86
|
+
const node = model.getNode(nodeId);
|
|
87
|
+
// istanbul ignore if
|
|
88
|
+
if (!node)
|
|
89
|
+
continue;
|
|
90
|
+
node.checkbox.isDisabled = checkboxInfo.isDisabled;
|
|
91
|
+
node.checkbox.isVisible = checkboxInfo.isVisible;
|
|
92
|
+
node.checkbox.state = checkboxInfo.state;
|
|
93
|
+
node.checkbox.tooltip = checkboxInfo.tooltip;
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
async collectAffectedNodesCheckboxInfos(affectedNodes, visibilityStatus) {
|
|
98
|
+
const nodeStates = new Map();
|
|
99
|
+
if (affectedNodes.length === 0)
|
|
100
|
+
return nodeStates;
|
|
101
|
+
await Promise.all(affectedNodes.map(async (nodeId) => {
|
|
102
|
+
const node = this.modelSource.getModel().getNode(nodeId);
|
|
103
|
+
// istanbul ignore else
|
|
104
|
+
if (node)
|
|
105
|
+
nodeStates.set(nodeId, await this.getNodeCheckBoxInfo(node, visibilityStatus));
|
|
106
|
+
}));
|
|
107
|
+
return nodeStates;
|
|
108
|
+
}
|
|
109
|
+
async collectAllNodesCheckboxInfos(visibilityStatus) {
|
|
110
|
+
const nodeStates = new Map();
|
|
111
|
+
for (const node of this.modelSource.getModel().iterateTreeModelNodes()) {
|
|
112
|
+
nodeStates.set(node.id, await this.getNodeCheckBoxInfo(node, visibilityStatus));
|
|
113
|
+
}
|
|
114
|
+
return nodeStates;
|
|
115
|
+
}
|
|
116
|
+
async getNodeCheckBoxInfo(node, visibilityStatus) {
|
|
117
|
+
var _a;
|
|
118
|
+
if (!this._visibilityHandler)
|
|
119
|
+
return { ...node.checkbox, isVisible: false };
|
|
120
|
+
const result = (_a = visibilityStatus === null || visibilityStatus === void 0 ? void 0 : visibilityStatus.get(node.id)) !== null && _a !== void 0 ? _a : this._visibilityHandler.getVisibilityStatus(node.item, this.getNodeKey(node.item));
|
|
121
|
+
if (core_react_1.isPromiseLike(result))
|
|
122
|
+
return this.createCheckboxInfo(await result);
|
|
123
|
+
return this.createCheckboxInfo(result);
|
|
124
|
+
}
|
|
125
|
+
createCheckboxInfo(status) {
|
|
126
|
+
return {
|
|
127
|
+
state: visibilityStateToCheckboxState(status),
|
|
128
|
+
isDisabled: status.isDisabled || false,
|
|
129
|
+
isVisible: true,
|
|
130
|
+
tooltip: status.tooltip,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
exports.VisibilityTreeEventHandler = VisibilityTreeEventHandler;
|
|
135
|
+
const visibilityStateToCheckboxState = (status) => {
|
|
136
|
+
switch (status.state) {
|
|
137
|
+
case "visible":
|
|
138
|
+
return core_react_1.CheckBoxState.On;
|
|
139
|
+
// istanbul ignore next
|
|
140
|
+
case "partial":
|
|
141
|
+
return core_react_1.CheckBoxState.Partial;
|
|
142
|
+
case "hidden":
|
|
143
|
+
default:
|
|
144
|
+
return core_react_1.CheckBoxState.Off;
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
//# sourceMappingURL=VisibilityTreeEventHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VisibilityTreeEventHandler.js","sourceRoot":"","sources":["../../../../src/components/trees/VisibilityTreeEventHandler.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,0DAAuD;AACvD,wDAAqD;AACrD,qDAAkD;AAClD,+DAA4D;AAC5D,8DAA2D;AAC3D,kDAAiE;AACjE,4EAAkF;AAkDlF;;;GAGG;AACH,MAAa,0BAA2B,SAAQ,0DAAgC;IAK9E,YAAY,MAAwC;QAClD,KAAK,CAAC,MAAM,CAAC,CAAC;QAHR,eAAU,GAAG,IAAI,KAAK,EAAc,CAAC;QAI3C,IAAI,CAAC,kBAAkB,GAAG,MAAM,CAAC,iBAAiB,CAAC;QACnD,IAAI,CAAC,mBAAmB,GAAG,MAAM,CAAC,kBAAkB,CAAC;QAErD,IAAI,IAAI,CAAC,kBAAkB,EAAE;YAC3B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,C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EO,kBAAkB,CAAC,MAAwB;QACjD,OAAO;YACL,KAAK,EAAE,8BAA8B,CAAC,MAAM,CAAC;YAC7C,UAAU,EAAE,MAAM,CAAC,UAAU,IAAI,KAAK;YACtC,SAAS,EAAE,IAAI;YACf,OAAO,EAAE,MAAM,CAAC,OAAO;SACxB,CAAC;IACJ,CAAC;CACF;AA7ID,gEA6IC;AAED,MAAM,8BAA8B,GAAG,CAAC,MAAwB,EAAE,EAAE;IAClE,QAAQ,MAAM,CAAC,KAAK,EAAE;QACpB,KAAK,SAAS;YACZ,OAAO,0BAAa,CAAC,EAAE,CAAC;QAC1B,uBAAuB;QACvB,KAAK,SAAS;YACZ,OAAO,0BAAa,CAAC,OAAO,CAAC;QAC/B,KAAK,QAAQ,CAAC;QACd;YACE,OAAO,0BAAa,CAAC,GAAG,CAAC;KAC5B;AACH,CAAC,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/** @packageDocumentation\n * @module IModelComponents\n */\n\nimport { EMPTY } from \"rxjs/internal/observable/empty\";\nimport { from } from \"rxjs/internal/observable/from\";\nimport { map } from \"rxjs/internal/operators/map\";\nimport { mergeMap } from \"rxjs/internal/operators/mergeMap\";\nimport { toRxjsObservable } from \"@itwin/components-react\";\nimport { CheckBoxState, isPromiseLike } from \"@itwin/core-react\";\nimport { UnifiedSelectionTreeEventHandler } from \"@itwin/presentation-components\";\nimport type {\n CheckBoxInfo, CheckboxStateChange, TreeCheckboxStateChangeEventArgs, TreeModelNode, TreeNodeItem,\n TreeSelectionModificationEventArgs, TreeSelectionReplacementEventArgs,\n} from \"@itwin/components-react\";\nimport type { BeEvent, IDisposable } from \"@itwin/core-bentley\";\nimport type { NodeKey } from \"@itwin/presentation-common\";\nimport type { UnifiedSelectionTreeEventHandlerParams } from \"@itwin/presentation-components\";\n\n/**\n * Data structure that describes instance visibility status.\n * @alpha\n */\nexport interface VisibilityStatus {\n state: \"visible\" | \"partial\" | \"hidden\";\n isDisabled?: boolean;\n tooltip?: string;\n}\n\n/**\n * Type definition of visibility change event listener.\n * @alpha\n */\nexport type VisibilityChangeListener = (nodeIds?: string[], visibilityStatus?: Map<string, VisibilityStatus>) => void;\n\n/**\n * Visibility handler used to change or get visibility of instances represented by the tree node.\n * @alpha\n */\nexport interface IVisibilityHandler extends IDisposable {\n getVisibilityStatus(node: TreeNodeItem, nodeKey: NodeKey): VisibilityStatus | Promise<VisibilityStatus>;\n changeVisibility(node: TreeNodeItem, nodeKey: NodeKey, shouldDisplay: boolean): Promise<void>;\n onVisibilityChange: BeEvent<VisibilityChangeListener>;\n}\n\n/**\n * Type definition of predicate used to decide if node can be selected.\n * @alpha\n */\nexport type VisibilityTreeSelectionPredicate = (key: NodeKey, node: TreeNodeItem) => boolean;\n\n/**\n * Parameters for [[VisibilityTreeEventHandler]]\n * @alpha\n */\nexport interface VisibilityTreeEventHandlerParams extends UnifiedSelectionTreeEventHandlerParams {\n visibilityHandler: IVisibilityHandler | undefined;\n selectionPredicate?: VisibilityTreeSelectionPredicate;\n}\n\n/**\n * Base event handler for visibility tree.\n * @alpha\n */\nexport class VisibilityTreeEventHandler extends UnifiedSelectionTreeEventHandler {\n private _visibilityHandler: IVisibilityHandler | undefined;\n private _selectionPredicate?: VisibilityTreeSelectionPredicate;\n private _listeners = new Array<() => void>();\n\n constructor(params: VisibilityTreeEventHandlerParams) {\n super(params);\n this._visibilityHandler = params.visibilityHandler;\n this._selectionPredicate = params.selectionPredicate;\n\n if (this._visibilityHandler) {\n this._listeners.push(this._visibilityHandler.onVisibilityChange.addListener(async (nodeIds, visibilityStatus) => this.updateCheckboxes(nodeIds, visibilityStatus)));\n }\n\n this._listeners.push(this.modelSource.onModelChanged.addListener(async ([_, changes]) => this.updateCheckboxes([...changes.addedNodeIds, ...changes.modifiedNodeIds])));\n this.updateCheckboxes(); // eslint-disable-line @typescript-eslint/no-floating-promises\n }\n\n public override dispose() {\n super.dispose();\n this._listeners.forEach((disposeFunc) => disposeFunc());\n }\n\n private filterSelectionItems(items: TreeNodeItem[]) {\n // istanbul ignore if\n if (!this._selectionPredicate)\n return items;\n\n return items.filter((item) => this._selectionPredicate!(this.getNodeKey(item), item));\n }\n\n public override onSelectionModified({ modifications }: TreeSelectionModificationEventArgs) {\n const filteredModification = toRxjsObservable(modifications).pipe(\n map(({ selectedNodeItems, deselectedNodeItems }) => {\n return {\n selectedNodeItems: this.filterSelectionItems(selectedNodeItems),\n deselectedNodeItems: this.filterSelectionItems(deselectedNodeItems),\n };\n }),\n );\n return super.onSelectionModified({ modifications: filteredModification });\n }\n\n public override onSelectionReplaced({ replacements }: TreeSelectionReplacementEventArgs) {\n const filteredReplacements = toRxjsObservable(replacements).pipe(\n map(({ selectedNodeItems }) => {\n return {\n selectedNodeItems: this.filterSelectionItems(selectedNodeItems),\n };\n }),\n );\n return super.onSelectionReplaced({ replacements: filteredReplacements });\n }\n\n public override onCheckboxStateChanged(event: TreeCheckboxStateChangeEventArgs) {\n // istanbul ignore if\n if (!this._visibilityHandler)\n return undefined;\n\n from(event.stateChanges)\n .pipe(\n mergeMap((changes) => this.changeVisibility(changes)),\n )\n .subscribe();\n return undefined;\n }\n\n private changeVisibility(changes: CheckboxStateChange[]) {\n return from(changes)\n .pipe(\n mergeMap(({ nodeItem, newState }) => {\n // istanbul ignore if\n if (!this._visibilityHandler)\n return EMPTY;\n return from(this._visibilityHandler.changeVisibility(nodeItem, this.getNodeKey(nodeItem), newState === CheckBoxState.On));\n }),\n );\n }\n\n private async updateCheckboxes(affectedNodes?: string[], visibilityStatus?: Map<string, VisibilityStatus>) {\n const changes = await (affectedNodes ? this.collectAffectedNodesCheckboxInfos(affectedNodes, visibilityStatus) : this.collectAllNodesCheckboxInfos(visibilityStatus));\n this.updateModel(changes);\n }\n\n private updateModel(changes: Map<string, CheckBoxInfo>) {\n this.modelSource.modifyModel((model) => {\n for (const [nodeId, checkboxInfo] of changes) {\n const node = model.getNode(nodeId);\n // istanbul ignore if\n if (!node)\n continue;\n\n node.checkbox.isDisabled = checkboxInfo.isDisabled;\n node.checkbox.isVisible = checkboxInfo.isVisible;\n node.checkbox.state = checkboxInfo.state;\n node.checkbox.tooltip = checkboxInfo.tooltip;\n }\n });\n }\n\n private async collectAffectedNodesCheckboxInfos(affectedNodes: string[], visibilityStatus?: Map<string, VisibilityStatus>) {\n const nodeStates = new Map<string, CheckBoxInfo>();\n if (affectedNodes.length === 0)\n return nodeStates;\n\n await Promise.all(affectedNodes.map(async (nodeId) => {\n const node = this.modelSource.getModel().getNode(nodeId);\n // istanbul ignore else\n if (node)\n nodeStates.set(nodeId, await this.getNodeCheckBoxInfo(node, visibilityStatus));\n }));\n return nodeStates;\n }\n\n private async collectAllNodesCheckboxInfos(visibilityStatus?: Map<string, VisibilityStatus>) {\n const nodeStates = new Map<string, CheckBoxInfo>();\n for (const node of this.modelSource.getModel().iterateTreeModelNodes()) {\n nodeStates.set(node.id, await this.getNodeCheckBoxInfo(node, visibilityStatus));\n }\n return nodeStates;\n }\n\n private async getNodeCheckBoxInfo(node: TreeModelNode, visibilityStatus?: Map<string, VisibilityStatus>): Promise<CheckBoxInfo> {\n if (!this._visibilityHandler)\n return { ...node.checkbox, isVisible: false };\n\n const result = visibilityStatus?.get(node.id) ?? this._visibilityHandler.getVisibilityStatus(node.item, this.getNodeKey(node.item));\n\n if (isPromiseLike(result))\n return this.createCheckboxInfo(await result);\n return this.createCheckboxInfo(result);\n }\n\n private createCheckboxInfo(status: VisibilityStatus): CheckBoxInfo {\n return {\n state: visibilityStateToCheckboxState(status),\n isDisabled: status.isDisabled || false,\n isVisible: true,\n tooltip: status.tooltip,\n };\n }\n}\n\nconst visibilityStateToCheckboxState = (status: VisibilityStatus) => {\n switch (status.state) {\n case \"visible\":\n return CheckBoxState.On;\n // istanbul ignore next\n case \"partial\":\n return CheckBoxState.Partial;\n case \"hidden\":\n default:\n return CheckBoxState.Off;\n }\n};\n"]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { IPresentationTreeDataProvider } from "@itwin/presentation-components";
|
|
3
|
+
import type { AbstractTreeNodeLoaderWithProvider, TreeNodeRendererProps, TreeRendererProps } from "@itwin/components-react";
|
|
4
|
+
import type { NodeCheckboxRenderProps } from "@itwin/core-react";
|
|
5
|
+
import type { VisibilityTreeFilterInfo } from "./Common";
|
|
6
|
+
/**
|
|
7
|
+
* Creates Visibility tree renderer which renders nodes with eye checkbox.
|
|
8
|
+
* @alpha
|
|
9
|
+
*/
|
|
10
|
+
export declare const useVisibilityTreeRenderer: (iconsEnabled: boolean, descriptionsEnabled: boolean) => (props: TreeRendererProps) => JSX.Element;
|
|
11
|
+
/**
|
|
12
|
+
* Creates node renderer which renders node with eye checkbox.
|
|
13
|
+
* @alpha
|
|
14
|
+
*/
|
|
15
|
+
export declare const createVisibilityTreeNodeRenderer: (iconsEnabled: boolean, descriptionEnabled: boolean) => (props: TreeNodeRendererProps) => JSX.Element;
|
|
16
|
+
/**
|
|
17
|
+
* Checkbox renderer that renders an eye.
|
|
18
|
+
* @alpha
|
|
19
|
+
*/
|
|
20
|
+
export declare const visibilityTreeNodeCheckboxRenderer: (props: NodeCheckboxRenderProps) => JSX.Element;
|
|
21
|
+
/**
|
|
22
|
+
* Filters data provider used in supplied node loader and invokes onFilterApplied when filtering is completed.
|
|
23
|
+
* @alpha
|
|
24
|
+
*/
|
|
25
|
+
export declare const useVisibilityTreeFiltering: (nodeLoader: AbstractTreeNodeLoaderWithProvider<IPresentationTreeDataProvider>, filterInfo?: VisibilityTreeFilterInfo | undefined, onFilterApplied?: ((filteredDataProvider: IPresentationTreeDataProvider, matchesCount: number) => void) | undefined) => {
|
|
26
|
+
filteredNodeLoader: AbstractTreeNodeLoaderWithProvider<IPresentationTreeDataProvider>;
|
|
27
|
+
isFiltering: boolean;
|
|
28
|
+
nodeHighlightingProps: import("@itwin/components-react").HighlightableTreeProps | undefined;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Properties for [[VisibilityTreeNoFilteredData]] component.
|
|
32
|
+
* @alpha
|
|
33
|
+
*/
|
|
34
|
+
export interface VisibilityTreeNoFilteredDataProps {
|
|
35
|
+
title: string;
|
|
36
|
+
message: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Renders message that no nodes was found for filter.
|
|
40
|
+
* @alpha
|
|
41
|
+
*/
|
|
42
|
+
export declare function VisibilityTreeNoFilteredData(props: VisibilityTreeNoFilteredDataProps): JSX.Element;
|
|
43
|
+
//# sourceMappingURL=VisibilityTreeRenderer.d.ts.map
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
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
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.VisibilityTreeNoFilteredData = exports.useVisibilityTreeFiltering = exports.visibilityTreeNodeCheckboxRenderer = exports.createVisibilityTreeNodeRenderer = exports.useVisibilityTreeRenderer = void 0;
|
|
27
|
+
const React = __importStar(require("react"));
|
|
28
|
+
const components_react_1 = require("@itwin/components-react");
|
|
29
|
+
const core_react_1 = require("@itwin/core-react");
|
|
30
|
+
const presentation_components_1 = require("@itwin/presentation-components");
|
|
31
|
+
/**
|
|
32
|
+
* Creates Visibility tree renderer which renders nodes with eye checkbox.
|
|
33
|
+
* @alpha
|
|
34
|
+
*/
|
|
35
|
+
const useVisibilityTreeRenderer = (iconsEnabled, descriptionsEnabled) => {
|
|
36
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
37
|
+
const nodeRenderer = React.useCallback(exports.createVisibilityTreeNodeRenderer(iconsEnabled, descriptionsEnabled), [iconsEnabled, descriptionsEnabled]);
|
|
38
|
+
return React.useCallback((props) => (React.createElement(components_react_1.TreeRenderer, { ...props, nodeRenderer: nodeRenderer })), [nodeRenderer]);
|
|
39
|
+
};
|
|
40
|
+
exports.useVisibilityTreeRenderer = useVisibilityTreeRenderer;
|
|
41
|
+
const imageLoader = new components_react_1.TreeImageLoader();
|
|
42
|
+
/**
|
|
43
|
+
* Creates node renderer which renders node with eye checkbox.
|
|
44
|
+
* @alpha
|
|
45
|
+
*/
|
|
46
|
+
const createVisibilityTreeNodeRenderer = (iconsEnabled, descriptionEnabled) => {
|
|
47
|
+
return (props) => ( // eslint-disable-line react/display-name
|
|
48
|
+
React.createElement(components_react_1.TreeNodeRenderer, { ...props, checkboxRenderer: exports.visibilityTreeNodeCheckboxRenderer, descriptionEnabled: descriptionEnabled, imageLoader: iconsEnabled ? imageLoader : undefined, className: "with-checkbox" }));
|
|
49
|
+
};
|
|
50
|
+
exports.createVisibilityTreeNodeRenderer = createVisibilityTreeNodeRenderer;
|
|
51
|
+
/**
|
|
52
|
+
* Checkbox renderer that renders an eye.
|
|
53
|
+
* @alpha
|
|
54
|
+
*/
|
|
55
|
+
const visibilityTreeNodeCheckboxRenderer = (props) => (React.createElement(core_react_1.ImageCheckBox, { checked: props.checked, disabled: props.disabled, imageOn: "icon-visibility", imageOff: "icon-visibility-hide-2", onClick: props.onChange, tooltip: props.title }));
|
|
56
|
+
exports.visibilityTreeNodeCheckboxRenderer = visibilityTreeNodeCheckboxRenderer;
|
|
57
|
+
/**
|
|
58
|
+
* Filters data provider used in supplied node loader and invokes onFilterApplied when filtering is completed.
|
|
59
|
+
* @alpha
|
|
60
|
+
*/
|
|
61
|
+
const useVisibilityTreeFiltering = (nodeLoader, filterInfo, onFilterApplied) => {
|
|
62
|
+
const { filter, activeMatchIndex } = filterInfo !== null && filterInfo !== void 0 ? filterInfo : { filter: undefined, activeMatchIndex: undefined };
|
|
63
|
+
const { filteredNodeLoader, isFiltering, matchesCount, nodeHighlightingProps, } = presentation_components_1.useControlledPresentationTreeFiltering({ nodeLoader, filter, activeMatchIndex });
|
|
64
|
+
React.useEffect(() => {
|
|
65
|
+
if (filter && matchesCount !== undefined && filteredNodeLoader !== nodeLoader)
|
|
66
|
+
onFilterApplied && onFilterApplied(filteredNodeLoader.dataProvider, matchesCount);
|
|
67
|
+
}, [filter, matchesCount, nodeLoader, filteredNodeLoader, onFilterApplied]);
|
|
68
|
+
return { filteredNodeLoader, isFiltering, nodeHighlightingProps };
|
|
69
|
+
};
|
|
70
|
+
exports.useVisibilityTreeFiltering = useVisibilityTreeFiltering;
|
|
71
|
+
/**
|
|
72
|
+
* Renders message that no nodes was found for filter.
|
|
73
|
+
* @alpha
|
|
74
|
+
*/
|
|
75
|
+
function VisibilityTreeNoFilteredData(props) {
|
|
76
|
+
return (React.createElement("div", { className: "components-tree-errormessage" },
|
|
77
|
+
React.createElement("span", { className: "errormessage-header" }, props.title),
|
|
78
|
+
React.createElement("span", { className: "errormessage-body" }, props.message)));
|
|
79
|
+
}
|
|
80
|
+
exports.VisibilityTreeNoFilteredData = VisibilityTreeNoFilteredData;
|
|
81
|
+
//# sourceMappingURL=VisibilityTreeRenderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VisibilityTreeRenderer.js","sourceRoot":"","sources":["../../../../src/components/trees/VisibilityTreeRenderer.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;;;;;;;;;;;;;;;;;;;;;;AAE/F,6CAA+B;AAC/B,8DAA0F;AAC1F,kDAAkD;AAClD,4EAAwF;AAQxF;;;GAGG;AACI,MAAM,yBAAyB,GAAG,CAAC,YAAqB,EAAE,mBAA4B,EAAE,EAAE;IAC/F,uDAAuD;IACvD,MAAM,YAAY,GAAG,KAAK,CAAC,WAAW,CAAC,wCAAgC,CAAC,YAAY,EAAE,mBAAmB,CAAC,EAAE,CAAC,YAAY,EAAE,mBAAmB,CAAC,CAAC,CAAC;IACjJ,OAAO,KAAK,CAAC,WAAW,CAAC,CAAC,KAAwB,EAAE,EAAE,CAAC,CACrD,oBAAC,+BAAY,OACP,KAAK,EACT,YAAY,EAAE,YAAY,GAC1B,CACH,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;AACrB,CAAC,CAAC;AATW,QAAA,yBAAyB,6BASpC;AAEF,MAAM,WAAW,GAAG,IAAI,kCAAe,EAAE,CAAC;AAC1C;;;GAGG;AACI,MAAM,gCAAgC,GAAG,CAAC,YAAqB,EAAE,kBAA2B,EAAE,EAAE;IACrG,OAAO,CAAC,KAA4B,EAAE,EAAE,CAAC,EAAE,yCAAyC;IAClF,oBAAC,mCAAgB,OACX,KAAK,EACT,gBAAgB,EAAE,0CAAkC,EACpD,kBAAkB,EAAE,kBAAkB,EACtC,WAAW,EAAE,YAAY,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,EACnD,SAAS,EAAC,eAAe,GAC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ACnF,OAAO,CACL,6BAAK,SAAS,EAAC,8BAA8B;QAC3C,8BAAM,SAAS,EAAC,qBAAqB,IAAE,KAAK,CAAC,KAAK,CAAQ;QAC1D,8BAAM,SAAS,EAAC,mBAAmB,IAAE,KAAK,CAAC,OAAO,CAAQ,CACtD,CACP,CAAC;AACJ,CAAC;AAPD,oEAOC","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 * as React from \"react\";\nimport { TreeImageLoader, TreeNodeRenderer, TreeRenderer } from \"@itwin/components-react\";\nimport { ImageCheckBox } from \"@itwin/core-react\";\nimport { useControlledPresentationTreeFiltering } from \"@itwin/presentation-components\";\nimport type { IPresentationTreeDataProvider } from \"@itwin/presentation-components\";\nimport type {\n AbstractTreeNodeLoaderWithProvider, TreeNodeRendererProps, TreeRendererProps,\n} from \"@itwin/components-react\";\nimport type { NodeCheckboxRenderProps } from \"@itwin/core-react\";\nimport type { VisibilityTreeFilterInfo } from \"./Common\";\n\n/**\n * Creates Visibility tree renderer which renders nodes with eye checkbox.\n * @alpha\n */\nexport const useVisibilityTreeRenderer = (iconsEnabled: boolean, descriptionsEnabled: boolean) => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const nodeRenderer = React.useCallback(createVisibilityTreeNodeRenderer(iconsEnabled, descriptionsEnabled), [iconsEnabled, descriptionsEnabled]);\n return React.useCallback((props: TreeRendererProps) => (\n <TreeRenderer\n {...props}\n nodeRenderer={nodeRenderer}\n />\n ), [nodeRenderer]);\n};\n\nconst imageLoader = new TreeImageLoader();\n/**\n * Creates node renderer which renders node with eye checkbox.\n * @alpha\n */\nexport const createVisibilityTreeNodeRenderer = (iconsEnabled: boolean, descriptionEnabled: boolean) => {\n return (props: TreeNodeRendererProps) => ( // eslint-disable-line react/display-name\n <TreeNodeRenderer\n {...props}\n checkboxRenderer={visibilityTreeNodeCheckboxRenderer}\n descriptionEnabled={descriptionEnabled}\n imageLoader={iconsEnabled ? imageLoader : undefined}\n className=\"with-checkbox\"\n />\n );\n};\n\n/**\n * Checkbox renderer that renders an eye.\n * @alpha\n */\nexport const visibilityTreeNodeCheckboxRenderer = (props: NodeCheckboxRenderProps) => (\n <ImageCheckBox\n checked={props.checked}\n disabled={props.disabled}\n imageOn=\"icon-visibility\"\n imageOff=\"icon-visibility-hide-2\"\n onClick={props.onChange}\n tooltip={props.title}\n />\n);\n\n/**\n * Filters data provider used in supplied node loader and invokes onFilterApplied when filtering is completed.\n * @alpha\n */\nexport const useVisibilityTreeFiltering = (\n nodeLoader: AbstractTreeNodeLoaderWithProvider<IPresentationTreeDataProvider>,\n filterInfo?: VisibilityTreeFilterInfo,\n onFilterApplied?: (filteredDataProvider: IPresentationTreeDataProvider, matchesCount: number) => void,\n) => {\n const { filter, activeMatchIndex } = filterInfo ?? { filter: undefined, activeMatchIndex: undefined };\n const {\n filteredNodeLoader,\n isFiltering,\n matchesCount,\n nodeHighlightingProps,\n } = useControlledPresentationTreeFiltering({ nodeLoader, filter, activeMatchIndex });\n\n React.useEffect(\n () => {\n if (filter && matchesCount !== undefined && filteredNodeLoader !== nodeLoader)\n onFilterApplied && onFilterApplied(filteredNodeLoader.dataProvider, matchesCount);\n },\n [filter, matchesCount, nodeLoader, filteredNodeLoader, onFilterApplied],\n );\n\n return { filteredNodeLoader, isFiltering, nodeHighlightingProps };\n};\n\n/**\n * Properties for [[VisibilityTreeNoFilteredData]] component.\n * @alpha\n */\nexport interface VisibilityTreeNoFilteredDataProps {\n title: string;\n message: string;\n}\n\n/**\n * Renders message that no nodes was found for filter.\n * @alpha\n */\nexport function VisibilityTreeNoFilteredData(props: VisibilityTreeNoFilteredDataProps) {\n return (\n <div className=\"components-tree-errormessage\">\n <span className=\"errormessage-header\">{props.title}</span>\n <span className=\"errormessage-body\">{props.message}</span>\n </div>\n );\n}\n"]}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "../../../../node_modules/@itwin/presentation-common/Ruleset.schema.json",
|
|
3
|
+
"id": "tree-widget-react/CategoriesTree",
|
|
4
|
+
"rules": [
|
|
5
|
+
{
|
|
6
|
+
"ruleType": "RootNodes",
|
|
7
|
+
"subConditions": [
|
|
8
|
+
{
|
|
9
|
+
"condition": "GetVariableStringValue(\"ViewType\") = \"3d\"",
|
|
10
|
+
"specifications": [
|
|
11
|
+
{
|
|
12
|
+
"specType": "InstanceNodesOfSpecificClasses",
|
|
13
|
+
"classes": [
|
|
14
|
+
{
|
|
15
|
+
"schemaName": "BisCore",
|
|
16
|
+
"classNames": [
|
|
17
|
+
"SpatialCategory"
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"arePolymorphic": true,
|
|
22
|
+
"relatedInstances": [
|
|
23
|
+
{
|
|
24
|
+
"relationshipPath": {
|
|
25
|
+
"relationship": {
|
|
26
|
+
"schemaName": "BisCore",
|
|
27
|
+
"className": "ModelContainsElements"
|
|
28
|
+
},
|
|
29
|
+
"direction": "Backward"
|
|
30
|
+
},
|
|
31
|
+
"isRequired": true,
|
|
32
|
+
"alias": "model"
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
"instanceFilter": "NOT this.IsPrivate AND (NOT model.IsPrivate OR model.IsOfClass(\"DictionaryModel\", \"BisCore\")) AND this.HasRelatedInstance(\"BisCore:GeometricElement3dIsInCategory\", \"Backward\", \"BisCore:Element\")",
|
|
36
|
+
"groupByClass": false,
|
|
37
|
+
"groupByLabel": false
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"condition": "GetVariableStringValue(\"ViewType\") = \"2d\"",
|
|
43
|
+
"specifications": [
|
|
44
|
+
{
|
|
45
|
+
"specType": "InstanceNodesOfSpecificClasses",
|
|
46
|
+
"classes": [
|
|
47
|
+
{
|
|
48
|
+
"schemaName": "BisCore",
|
|
49
|
+
"classNames": [
|
|
50
|
+
"DrawingCategory"
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
],
|
|
54
|
+
"arePolymorphic": true,
|
|
55
|
+
"relatedInstances": [
|
|
56
|
+
{
|
|
57
|
+
"relationshipPath": {
|
|
58
|
+
"relationship": {
|
|
59
|
+
"schemaName": "BisCore",
|
|
60
|
+
"className": "ModelContainsElements"
|
|
61
|
+
},
|
|
62
|
+
"direction": "Backward"
|
|
63
|
+
},
|
|
64
|
+
"isRequired": true,
|
|
65
|
+
"alias": "model"
|
|
66
|
+
}
|
|
67
|
+
],
|
|
68
|
+
"instanceFilter": "NOT this.IsPrivate AND (NOT model.IsPrivate OR model.IsOfClass(\"DictionaryModel\", \"BisCore\")) AND this.HasRelatedInstance(\"BisCore:GeometricElement2dIsInCategory\", \"Backward\", \"BisCore:Element\")",
|
|
69
|
+
"groupByClass": false,
|
|
70
|
+
"groupByLabel": false
|
|
71
|
+
}
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"ruleType": "ChildNodes",
|
|
78
|
+
"condition": "ParentNode.IsOfClass(\"Category\", \"BisCore\") ANDALSO ParentNode.ECInstance.GetRelatedInstancesCount(\"BisCore:CategoryOwnsSubCategories\", \"Forward\", \"BisCore:SubCategory\") > 1",
|
|
79
|
+
"specifications": [
|
|
80
|
+
{
|
|
81
|
+
"specType": "RelatedInstanceNodes",
|
|
82
|
+
"relationshipPaths": [
|
|
83
|
+
{
|
|
84
|
+
"relationship": {
|
|
85
|
+
"schemaName": "BisCore",
|
|
86
|
+
"className": "CategoryOwnsSubCategories"
|
|
87
|
+
},
|
|
88
|
+
"direction": "Forward"
|
|
89
|
+
}
|
|
90
|
+
],
|
|
91
|
+
"groupByClass": false,
|
|
92
|
+
"groupByLabel": false
|
|
93
|
+
}
|
|
94
|
+
]
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"ruleType": "LabelOverride",
|
|
98
|
+
"condition": "this.IsOfClass(\"Category\", \"BisCore\")",
|
|
99
|
+
"description": "this.Description"
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import "./CategoriesTree.scss";
|
|
3
|
+
import { CategoryVisibilityHandler } from "./CategoryVisibilityHandler";
|
|
4
|
+
import type { IModelConnection, ViewManager, Viewport } from "@itwin/core-frontend";
|
|
5
|
+
import type { Ruleset } from "@itwin/presentation-common";
|
|
6
|
+
import type { IPresentationTreeDataProvider } from "@itwin/presentation-components";
|
|
7
|
+
import type { VisibilityTreeFilterInfo } from "../Common";
|
|
8
|
+
/**
|
|
9
|
+
* Presentation rules used by ControlledCategoriesTree
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export declare const RULESET_CATEGORIES: Ruleset;
|
|
13
|
+
/**
|
|
14
|
+
* Properties for the [[CategoryTree]] component
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
export interface CategoryTreeProps {
|
|
18
|
+
/** Flag for accommodating all viewports */
|
|
19
|
+
allViewports?: boolean;
|
|
20
|
+
/** Active viewport */
|
|
21
|
+
activeView?: Viewport;
|
|
22
|
+
/**
|
|
23
|
+
* An IModel to pull data from
|
|
24
|
+
*/
|
|
25
|
+
iModel: IModelConnection;
|
|
26
|
+
/** Width of the component */
|
|
27
|
+
width: number;
|
|
28
|
+
/** Height of the component */
|
|
29
|
+
height: number;
|
|
30
|
+
/**
|
|
31
|
+
* Information for tree filtering.
|
|
32
|
+
* @alpha
|
|
33
|
+
*/
|
|
34
|
+
filterInfo?: VisibilityTreeFilterInfo;
|
|
35
|
+
/**
|
|
36
|
+
* Callback invoked when tree is filtered.
|
|
37
|
+
*/
|
|
38
|
+
onFilterApplied?: (filteredDataProvider: IPresentationTreeDataProvider, matchesCount: number) => void;
|
|
39
|
+
/**
|
|
40
|
+
* Custom category visibility handler to use for testing
|
|
41
|
+
* @internal
|
|
42
|
+
*/
|
|
43
|
+
categoryVisibilityHandler?: CategoryVisibilityHandler;
|
|
44
|
+
/**
|
|
45
|
+
* Custom view manager to use for testing
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
viewManager?: ViewManager;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Tree which displays and manages categories contained in an iModel.
|
|
52
|
+
* @public
|
|
53
|
+
*/
|
|
54
|
+
export declare function CategoryTree(props: CategoryTreeProps): JSX.Element;
|
|
55
|
+
/**
|
|
56
|
+
* Toggles visibility of categories to show or hide.
|
|
57
|
+
* @alpha
|
|
58
|
+
*/
|
|
59
|
+
export declare function toggleAllCategories(viewManager: ViewManager, imodel: IModelConnection, display: boolean, viewport?: Viewport, forAllViewports?: boolean, filteredProvider?: IPresentationTreeDataProvider): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* Gets ids of all categories or categories from filtered data provider.
|
|
62
|
+
* @alpha
|
|
63
|
+
*/
|
|
64
|
+
export declare function getCategories(imodel: IModelConnection, viewport?: Viewport, filteredProvider?: IPresentationTreeDataProvider): Promise<string[]>;
|
|
65
|
+
//# sourceMappingURL=CategoriesTree.d.ts.map
|