@itwin/tree-widget-react 2.0.2 → 2.2.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/CHANGELOG.md +22 -2
- package/README.md +105 -0
- package/lib/cjs/components/SelectableTree.d.ts +4 -0
- package/lib/cjs/components/SelectableTree.js +1 -1
- package/lib/cjs/components/SelectableTree.js.map +1 -1
- package/lib/cjs/components/TreeSelector.d.ts +2 -0
- package/lib/cjs/components/TreeSelector.js +4 -1
- package/lib/cjs/components/TreeSelector.js.map +1 -1
- package/lib/cjs/components/TreeWidgetUiItemsProvider.d.ts +4 -0
- package/lib/cjs/components/TreeWidgetUiItemsProvider.js +7 -7
- package/lib/cjs/components/TreeWidgetUiItemsProvider.js.map +1 -1
- package/lib/cjs/components/tree-header/TreeHeader.d.ts +1 -0
- package/lib/cjs/components/tree-header/TreeHeader.js.map +1 -1
- package/lib/cjs/components/trees/VisibilityTreeEventHandler.js +6 -4
- package/lib/cjs/components/trees/VisibilityTreeEventHandler.js.map +1 -1
- package/lib/cjs/components/trees/VisibilityTreeRenderer.d.ts +11 -3
- package/lib/cjs/components/trees/VisibilityTreeRenderer.js +8 -5
- package/lib/cjs/components/trees/VisibilityTreeRenderer.js.map +1 -1
- package/lib/cjs/components/trees/category-tree/CategoriesTree.d.ts +13 -0
- package/lib/cjs/components/trees/category-tree/CategoriesTree.js +14 -2
- package/lib/cjs/components/trees/category-tree/CategoriesTree.js.map +1 -1
- package/lib/cjs/components/trees/category-tree/CategoriesTreeComponent.js +17 -8
- package/lib/cjs/components/trees/category-tree/CategoriesTreeComponent.js.map +1 -1
- package/lib/cjs/components/trees/common/ReportingTreeEventHandler.d.ts +27 -0
- package/lib/cjs/components/trees/common/ReportingTreeEventHandler.js +51 -0
- package/lib/cjs/components/trees/common/ReportingTreeEventHandler.js.map +1 -0
- package/lib/cjs/components/trees/common/TreeRenderer.d.ts +17 -2
- package/lib/cjs/components/trees/common/TreeRenderer.js +19 -3
- package/lib/cjs/components/trees/common/TreeRenderer.js.map +1 -1
- package/lib/cjs/components/trees/common/TreeRenderer.scss +1 -1
- package/lib/cjs/components/trees/common/UseFeatureReporting.d.ts +23 -0
- package/lib/cjs/components/trees/common/UseFeatureReporting.js +30 -0
- package/lib/cjs/components/trees/common/UseFeatureReporting.js.map +1 -0
- package/lib/cjs/components/trees/common/UsePerformanceReporting.d.ts +18 -0
- package/lib/cjs/components/trees/common/UsePerformanceReporting.js +25 -0
- package/lib/cjs/components/trees/common/UsePerformanceReporting.js.map +1 -0
- package/lib/cjs/components/trees/common/UseVisibilityTreeState.d.ts +8 -1
- package/lib/cjs/components/trees/common/UseVisibilityTreeState.js +5 -3
- package/lib/cjs/components/trees/common/UseVisibilityTreeState.js.map +1 -1
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.d.ts +13 -0
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.js +21 -5
- package/lib/cjs/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.d.ts +13 -0
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.js +22 -1
- package/lib/cjs/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsTree.d.ts +13 -0
- package/lib/cjs/components/trees/models-tree/ModelsTree.js +24 -10
- package/lib/cjs/components/trees/models-tree/ModelsTree.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.js +27 -12
- package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsTreeEventHandler.d.ts +10 -0
- package/lib/cjs/components/trees/models-tree/ModelsTreeEventHandler.js +5 -0
- package/lib/cjs/components/trees/models-tree/ModelsTreeEventHandler.js.map +1 -1
- package/lib/cjs/components/trees/models-tree/ModelsVisibilityHandler.d.ts +4 -1
- package/lib/cjs/components/trees/models-tree/ModelsVisibilityHandler.js +43 -28
- package/lib/cjs/components/trees/models-tree/ModelsVisibilityHandler.js.map +1 -1
- package/lib/esm/components/SelectableTree.d.ts +4 -0
- package/lib/esm/components/SelectableTree.js +1 -1
- package/lib/esm/components/SelectableTree.js.map +1 -1
- package/lib/esm/components/TreeSelector.d.ts +2 -0
- package/lib/esm/components/TreeSelector.js +4 -1
- package/lib/esm/components/TreeSelector.js.map +1 -1
- package/lib/esm/components/TreeWidgetUiItemsProvider.d.ts +4 -0
- package/lib/esm/components/TreeWidgetUiItemsProvider.js +7 -7
- package/lib/esm/components/TreeWidgetUiItemsProvider.js.map +1 -1
- package/lib/esm/components/tree-header/TreeHeader.d.ts +1 -0
- package/lib/esm/components/tree-header/TreeHeader.js.map +1 -1
- package/lib/esm/components/trees/VisibilityTreeEventHandler.js +7 -5
- package/lib/esm/components/trees/VisibilityTreeEventHandler.js.map +1 -1
- package/lib/esm/components/trees/VisibilityTreeRenderer.d.ts +11 -3
- package/lib/esm/components/trees/VisibilityTreeRenderer.js +8 -5
- package/lib/esm/components/trees/VisibilityTreeRenderer.js.map +1 -1
- package/lib/esm/components/trees/category-tree/CategoriesTree.d.ts +13 -0
- package/lib/esm/components/trees/category-tree/CategoriesTree.js +14 -2
- package/lib/esm/components/trees/category-tree/CategoriesTree.js.map +1 -1
- package/lib/esm/components/trees/category-tree/CategoriesTreeComponent.js +17 -8
- package/lib/esm/components/trees/category-tree/CategoriesTreeComponent.js.map +1 -1
- package/lib/esm/components/trees/common/ReportingTreeEventHandler.d.ts +27 -0
- package/lib/esm/components/trees/common/ReportingTreeEventHandler.js +47 -0
- package/lib/esm/components/trees/common/ReportingTreeEventHandler.js.map +1 -0
- package/lib/esm/components/trees/common/TreeRenderer.d.ts +17 -2
- package/lib/esm/components/trees/common/TreeRenderer.js +19 -3
- package/lib/esm/components/trees/common/TreeRenderer.js.map +1 -1
- package/lib/esm/components/trees/common/TreeRenderer.scss +1 -1
- package/lib/esm/components/trees/common/UseFeatureReporting.d.ts +23 -0
- package/lib/esm/components/trees/common/UseFeatureReporting.js +26 -0
- package/lib/esm/components/trees/common/UseFeatureReporting.js.map +1 -0
- package/lib/esm/components/trees/common/UsePerformanceReporting.d.ts +18 -0
- package/lib/esm/components/trees/common/UsePerformanceReporting.js +21 -0
- package/lib/esm/components/trees/common/UsePerformanceReporting.js.map +1 -0
- package/lib/esm/components/trees/common/UseVisibilityTreeState.d.ts +8 -1
- package/lib/esm/components/trees/common/UseVisibilityTreeState.js +5 -3
- package/lib/esm/components/trees/common/UseVisibilityTreeState.js.map +1 -1
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.d.ts +13 -0
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.js +22 -6
- package/lib/esm/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.d.ts +13 -0
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.js +23 -2
- package/lib/esm/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
- package/lib/esm/components/trees/models-tree/ModelsTree.d.ts +13 -0
- package/lib/esm/components/trees/models-tree/ModelsTree.js +24 -10
- package/lib/esm/components/trees/models-tree/ModelsTree.js.map +1 -1
- package/lib/esm/components/trees/models-tree/ModelsTreeComponent.js +27 -12
- package/lib/esm/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
- package/lib/esm/components/trees/models-tree/ModelsTreeEventHandler.d.ts +10 -0
- package/lib/esm/components/trees/models-tree/ModelsTreeEventHandler.js +5 -0
- package/lib/esm/components/trees/models-tree/ModelsTreeEventHandler.js.map +1 -1
- package/lib/esm/components/trees/models-tree/ModelsVisibilityHandler.d.ts +4 -1
- package/lib/esm/components/trees/models-tree/ModelsVisibilityHandler.js +43 -28
- package/lib/esm/components/trees/models-tree/ModelsVisibilityHandler.js.map +1 -1
- package/package.json +20 -20
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VisibilityTreeEventHand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B,KAAK,SAAS;YACZ,OAAO,aAAa,CAAC,OAAO,CAAC;QAC/B,KAAK,QAAQ,CAAC;QACd;YACE,OAAO,aAAa,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 { from, map, mergeMap, Observable } from \"rxjs\";\nimport { CheckBoxState } from \"@itwin/core-react\";\nimport { UnifiedSelectionTreeEventHandler } from \"@itwin/presentation-components\";\nimport { isPromiseLike } from \"../utils/IsPromiseLike\";\n\nimport type { BeEvent, IDisposable } from \"@itwin/core-bentley\";\nimport type {\n CheckBoxInfo,\n CheckboxStateChange,\n TreeCheckboxStateChangeEventArgs,\n TreeModelNode,\n TreeNodeItem,\n TreeSelectionChange,\n TreeSelectionModificationEventArgs,\n TreeSelectionReplacementEventArgs,\n} from \"@itwin/components-react\";\nimport type { UnifiedSelectionTreeEventHandlerParams } from \"@itwin/presentation-components\";\n/**\n * Data structure that describes instance visibility status.\n * @public\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 * @public\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 * @public\n */\nexport interface IVisibilityHandler extends IDisposable {\n getVisibilityStatus(node: TreeNodeItem): VisibilityStatus | Promise<VisibilityStatus>;\n changeVisibility(node: TreeNodeItem, 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 * @public\n */\nexport type VisibilityTreeSelectionPredicate = (node: TreeNodeItem) => boolean;\n\n/**\n * Parameters for [[VisibilityTreeEventHandler]]\n * @public\n */\nexport interface VisibilityTreeEventHandlerParams extends UnifiedSelectionTreeEventHandlerParams {\n visibilityHandler: IVisibilityHandler;\n selectionPredicate?: VisibilityTreeSelectionPredicate;\n}\n\n/**\n * Base event handler for visibility tree.\n * @public\n */\nexport class VisibilityTreeEventHandler extends UnifiedSelectionTreeEventHandler {\n private _visibilityHandler: IVisibilityHandler;\n private _selectionPredicate?: VisibilityTreeSelectionPredicate;\n private _listeners = new Array<() => void>();\n private _isChangingVisibility: boolean;\n\n constructor(params: VisibilityTreeEventHandlerParams) {\n super(params);\n this._visibilityHandler = params.visibilityHandler;\n this._selectionPredicate = params.selectionPredicate;\n this._isChangingVisibility = false;\n this._listeners.push(\n this._visibilityHandler.onVisibilityChange.addListener(async (nodeIds, visibilityStatus) => {\n if (this._isChangingVisibility) {\n return;\n }\n void this.updateCheckboxes(nodeIds, visibilityStatus);\n }),\n );\n this._listeners.push(\n this.modelSource.onModelChanged.addListener(async ([_, changes]) => {\n void this.updateCheckboxes([...changes.addedNodeIds, ...changes.modifiedNodeIds]);\n }),\n );\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\n return items.filter((item) => this._selectionPredicate!(item));\n }\n\n public override onSelectionModified({ modifications }: TreeSelectionModificationEventArgs) {\n const filteredModification = new Observable<TreeSelectionChange>((subscriber) => modifications.subscribe(subscriber)).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 = new Observable<{ selectedNodeItems: TreeNodeItem[] }>((subscriber) => replacements.subscribe(subscriber)).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 const handleStateChanged = () => {\n this._isChangingVisibility = false;\n void this.updateCheckboxes();\n };\n\n new Observable<CheckboxStateChange[]>((subscriber) => event.stateChanges.subscribe(subscriber))\n .pipe(\n mergeMap((changes) => this.changeVisibility(changes)),\n )\n .subscribe({\n complete: handleStateChanged,\n error: handleStateChanged,\n });\n return undefined;\n }\n\n private changeVisibility(changes: CheckboxStateChange[]) {\n return from(changes)\n .pipe(\n mergeMap(({ nodeItem, newState }) => {\n this._isChangingVisibility = true;\n return from(this._visibilityHandler.changeVisibility(nodeItem, newState === CheckBoxState.On));\n }, 1),\n );\n }\n\n private async updateCheckboxes(affectedNodes?: string[], visibilityStatus?: Map<string, VisibilityStatus>) {\n const changes = await (affectedNodes\n ? this.collectAffectedNodesCheckboxInfos(affectedNodes, visibilityStatus)\n : 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\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\n await Promise.all(\n 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 }),\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 const result = visibilityStatus?.get(node.id) ?? this._visibilityHandler.getVisibilityStatus(node.item);\n\n if (isPromiseLike(result)) {\n return this.createCheckboxInfo(await result);\n }\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"]}
|
|
1
|
+
{"version":3,"file":"VisibilityTreeEventHandler.js","sourceRoot":"","sources":["../../../../src/components/trees/VisibilityTreeEventHandler.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,GAAG,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,gCAAgC,EAAE,MAAM,gCAAgC,CAAC;AAClF,OAAO,EAAE,aAAa,EAAE,MAAM,wBAA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C,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 { endWith, from, ignoreElements, map, mergeMap, Observable } from \"rxjs\";\nimport { CheckBoxState } from \"@itwin/core-react\";\nimport { UnifiedSelectionTreeEventHandler } from \"@itwin/presentation-components\";\nimport { isPromiseLike } from \"../utils/IsPromiseLike\";\n\nimport type { BeEvent, IDisposable } from \"@itwin/core-bentley\";\nimport type {\n CheckBoxInfo,\n CheckboxStateChange,\n TreeCheckboxStateChangeEventArgs,\n TreeModelNode,\n TreeNodeItem,\n TreeSelectionChange,\n TreeSelectionModificationEventArgs,\n TreeSelectionReplacementEventArgs,\n} from \"@itwin/components-react\";\nimport type { UnifiedSelectionTreeEventHandlerParams } from \"@itwin/presentation-components\";\n/**\n * Data structure that describes instance visibility status.\n * @public\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 * @public\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 * @public\n */\nexport interface IVisibilityHandler extends IDisposable {\n getVisibilityStatus(node: TreeNodeItem): VisibilityStatus | Promise<VisibilityStatus>;\n changeVisibility(node: TreeNodeItem, 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 * @public\n */\nexport type VisibilityTreeSelectionPredicate = (node: TreeNodeItem) => boolean;\n\n/**\n * Parameters for [[VisibilityTreeEventHandler]]\n * @public\n */\nexport interface VisibilityTreeEventHandlerParams extends UnifiedSelectionTreeEventHandlerParams {\n visibilityHandler: IVisibilityHandler;\n selectionPredicate?: VisibilityTreeSelectionPredicate;\n}\n\n/**\n * Base event handler for visibility tree.\n * @public\n */\nexport class VisibilityTreeEventHandler extends UnifiedSelectionTreeEventHandler {\n private _visibilityHandler: IVisibilityHandler;\n private _selectionPredicate?: VisibilityTreeSelectionPredicate;\n private _listeners = new Array<() => void>();\n private _isChangingVisibility: boolean;\n\n constructor(params: VisibilityTreeEventHandlerParams) {\n super(params);\n this._visibilityHandler = params.visibilityHandler;\n this._selectionPredicate = params.selectionPredicate;\n this._isChangingVisibility = false;\n this._listeners.push(\n this._visibilityHandler.onVisibilityChange.addListener(async (nodeIds, visibilityStatus) => {\n if (this._isChangingVisibility) {\n return;\n }\n void this.updateCheckboxes(nodeIds, visibilityStatus);\n }),\n );\n this._listeners.push(\n this.modelSource.onModelChanged.addListener(async ([_, changes]) => {\n void this.updateCheckboxes([...changes.addedNodeIds, ...changes.modifiedNodeIds]);\n }),\n );\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\n return items.filter((item) => this._selectionPredicate!(item));\n }\n\n public override onSelectionModified({ modifications }: TreeSelectionModificationEventArgs) {\n const filteredModification = new Observable<TreeSelectionChange>((subscriber) => modifications.subscribe(subscriber)).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 = new Observable<{ selectedNodeItems: TreeNodeItem[] }>((subscriber) => replacements.subscribe(subscriber)).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 const handleStateChanged = () => {\n this._isChangingVisibility = false;\n void this.updateCheckboxes();\n };\n\n new Observable<CheckboxStateChange[]>((subscriber) => event.stateChanges.subscribe(subscriber))\n .pipe(mergeMap((changes) => this.changeVisibility(changes)))\n .subscribe({\n next: (nodeId) => {\n void this.updateCheckboxes([nodeId]);\n },\n complete: handleStateChanged,\n error: handleStateChanged,\n });\n return undefined;\n }\n\n private changeVisibility(changes: CheckboxStateChange[]) {\n return from(changes).pipe(\n mergeMap(({ nodeItem, newState }) => {\n this._isChangingVisibility = true;\n return from(this._visibilityHandler.changeVisibility(nodeItem, newState === CheckBoxState.On)).pipe(ignoreElements(), endWith(nodeItem.id));\n }),\n );\n }\n\n private async updateCheckboxes(affectedNodes?: string[], visibilityStatus?: Map<string, VisibilityStatus>) {\n const changes = await (affectedNodes\n ? this.collectAffectedNodesCheckboxInfos(affectedNodes, visibilityStatus)\n : 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\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\n await Promise.all(\n 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 }),\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 const result = visibilityStatus?.get(node.id) ?? this._visibilityHandler.getVisibilityStatus(node.item);\n\n if (isPromiseLike(result)) {\n return this.createCheckboxInfo(await result);\n }\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"]}
|
|
@@ -40,6 +40,10 @@ export interface VisibilityTreeNodeRendererProps {
|
|
|
40
40
|
* Is `false` by default
|
|
41
41
|
*/
|
|
42
42
|
isEnlarged?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Callback called when visibility is toggled using a checkbox.
|
|
45
|
+
*/
|
|
46
|
+
onVisibilityToggled?: (enabled: boolean) => void;
|
|
43
47
|
}
|
|
44
48
|
/**
|
|
45
49
|
* Creates Visibility tree renderer which renders nodes with eye checkbox.
|
|
@@ -50,12 +54,15 @@ export declare function createVisibilityTreeRenderer({ nodeRendererProps, ...res
|
|
|
50
54
|
* Creates node renderer which renders node with eye checkbox.
|
|
51
55
|
* @public
|
|
52
56
|
*/
|
|
53
|
-
export declare function createVisibilityTreeNodeRenderer({ levelOffset, disableRootNodeCollapse, descriptionEnabled, iconsEnabled, }: VisibilityTreeNodeRendererProps): (treeNodeProps: TreeNodeRendererProps) => JSX.Element;
|
|
57
|
+
export declare function createVisibilityTreeNodeRenderer({ levelOffset, disableRootNodeCollapse, descriptionEnabled, iconsEnabled, onVisibilityToggled, }: VisibilityTreeNodeRendererProps): (treeNodeProps: TreeNodeRendererProps) => JSX.Element;
|
|
58
|
+
interface VisibilityTreeNodeCheckboxProps extends NodeCheckboxRenderProps {
|
|
59
|
+
onVisibilityToggled?: (enabled: boolean) => void;
|
|
60
|
+
}
|
|
54
61
|
/**
|
|
55
62
|
* Checkbox renderer that renders an eye.
|
|
56
63
|
* @public
|
|
57
64
|
*/
|
|
58
|
-
export declare function VisibilityTreeNodeCheckbox(props:
|
|
65
|
+
export declare function VisibilityTreeNodeCheckbox(props: VisibilityTreeNodeCheckboxProps): JSX.Element;
|
|
59
66
|
/**
|
|
60
67
|
* Props for [[FilterableVisibilityTreeNodeRenderer]].
|
|
61
68
|
* @beta
|
|
@@ -65,7 +72,7 @@ export type FilterableVisibilityTreeNodeRendererProps = Omit<PresentationTreeNod
|
|
|
65
72
|
* Creates node renderer which renders node with eye checkbox and hierarchy level filtering actions.
|
|
66
73
|
* @beta
|
|
67
74
|
*/
|
|
68
|
-
export declare function FilterableVisibilityTreeNodeRenderer({ levelOffset, disableRootNodeCollapse, descriptionEnabled, isEnlarged, ...restProps }: FilterableVisibilityTreeNodeRendererProps): JSX.Element;
|
|
75
|
+
export declare function FilterableVisibilityTreeNodeRenderer({ levelOffset, disableRootNodeCollapse, descriptionEnabled, isEnlarged, onVisibilityToggled, ...restProps }: FilterableVisibilityTreeNodeRendererProps): JSX.Element;
|
|
69
76
|
/**
|
|
70
77
|
* Filters data provider used in supplied node loader and invokes onFilterApplied when filtering is completed.
|
|
71
78
|
* @public
|
|
@@ -89,4 +96,5 @@ export interface VisibilityTreeNoFilteredDataProps {
|
|
|
89
96
|
* @public
|
|
90
97
|
*/
|
|
91
98
|
export declare function VisibilityTreeNoFilteredData(props: VisibilityTreeNoFilteredDataProps): JSX.Element;
|
|
99
|
+
export {};
|
|
92
100
|
//# sourceMappingURL=VisibilityTreeRenderer.d.ts.map
|
|
@@ -31,10 +31,10 @@ export function createVisibilityTreeRenderer({ nodeRendererProps, ...restProps }
|
|
|
31
31
|
* Creates node renderer which renders node with eye checkbox.
|
|
32
32
|
* @public
|
|
33
33
|
*/
|
|
34
|
-
export function createVisibilityTreeNodeRenderer({ levelOffset = 20, disableRootNodeCollapse = false, descriptionEnabled, iconsEnabled, }) {
|
|
34
|
+
export function createVisibilityTreeNodeRenderer({ levelOffset = 20, disableRootNodeCollapse = false, descriptionEnabled, iconsEnabled, onVisibilityToggled, }) {
|
|
35
35
|
return function VisibilityTreeNodeRenderer(treeNodeProps) {
|
|
36
36
|
const nodeOffset = treeNodeProps.node.depth * levelOffset + (treeNodeProps.node.numChildren === 0 ? EXPANSION_TOGGLE_WIDTH : 0);
|
|
37
|
-
return (_jsx(TreeNodeRenderer, { ...treeNodeProps, node: { ...treeNodeProps.node, depth: 0, numChildren: 1 }, checkboxRenderer: (checkboxProps) => (_jsx("div", { className: "visibility-tree-checkbox-container", style: { marginRight: `${nodeOffset}px` }, children: _jsx(VisibilityTreeNodeCheckbox, { ...checkboxProps }) })), descriptionEnabled: descriptionEnabled, imageLoader: iconsEnabled ? imageLoader : undefined, className: classNames("with-checkbox", (treeNodeProps.node.numChildren === 0 || (disableRootNodeCollapse && treeNodeProps.node.parentId === undefined)) && "disable-expander", treeNodeProps.className) }));
|
|
37
|
+
return (_jsx(TreeNodeRenderer, { ...treeNodeProps, node: { ...treeNodeProps.node, depth: 0, numChildren: 1 }, checkboxRenderer: (checkboxProps) => (_jsx("div", { className: "visibility-tree-checkbox-container", style: { marginRight: `${nodeOffset}px` }, children: _jsx(VisibilityTreeNodeCheckbox, { ...checkboxProps, onVisibilityToggled: onVisibilityToggled }) })), descriptionEnabled: descriptionEnabled, imageLoader: iconsEnabled ? imageLoader : undefined, className: classNames("with-checkbox", (treeNodeProps.node.numChildren === 0 || (disableRootNodeCollapse && treeNodeProps.node.parentId === undefined)) && "disable-expander", treeNodeProps.className) }));
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
@@ -42,16 +42,19 @@ export function createVisibilityTreeNodeRenderer({ levelOffset = 20, disableRoot
|
|
|
42
42
|
* @public
|
|
43
43
|
*/
|
|
44
44
|
export function VisibilityTreeNodeCheckbox(props) {
|
|
45
|
-
return (_jsx(Checkbox, { className: "visibility-tree-checkbox", variant: "eyeball", checked: props.checked, onChange: (e) =>
|
|
45
|
+
return (_jsx(Checkbox, { className: "visibility-tree-checkbox", variant: "eyeball", checked: props.checked, onChange: (e) => {
|
|
46
|
+
props.onVisibilityToggled?.(e.currentTarget.checked);
|
|
47
|
+
props.onChange(e.currentTarget.checked);
|
|
48
|
+
}, onMouseDown: (e) => e.stopPropagation(), onClick: props.onClick, disabled: props.disabled, title: props.title }));
|
|
46
49
|
}
|
|
47
50
|
/**
|
|
48
51
|
* Creates node renderer which renders node with eye checkbox and hierarchy level filtering actions.
|
|
49
52
|
* @beta
|
|
50
53
|
*/
|
|
51
|
-
export function FilterableVisibilityTreeNodeRenderer({ levelOffset = 20, disableRootNodeCollapse, descriptionEnabled, isEnlarged, ...restProps }) {
|
|
54
|
+
export function FilterableVisibilityTreeNodeRenderer({ levelOffset = 20, disableRootNodeCollapse, descriptionEnabled, isEnlarged, onVisibilityToggled, ...restProps }) {
|
|
52
55
|
const expansionToggleWidth = isEnlarged ? EXPANDED_EXPANSION_TOGGLE_WIDTH : EXPANSION_TOGGLE_WIDTH;
|
|
53
56
|
const nodeOffset = restProps.node.depth * levelOffset + (restProps.node.numChildren === 0 ? expansionToggleWidth : 0);
|
|
54
|
-
return (_jsx(PresentationTreeNodeRenderer, { ...restProps, checkboxRenderer: (checkboxProps) => (_jsx("div", { className: "visibility-tree-checkbox-container", style: { marginRight: `${nodeOffset}px` }, children: _jsx(VisibilityTreeNodeCheckbox, { ...checkboxProps }) })), descriptionEnabled: descriptionEnabled, imageLoader: imageLoader, className: classNames("with-checkbox", (restProps.node.numChildren === 0 || (disableRootNodeCollapse && restProps.node.parentId === undefined)) && "disable-expander") }));
|
|
57
|
+
return (_jsx(PresentationTreeNodeRenderer, { ...restProps, checkboxRenderer: (checkboxProps) => (_jsx("div", { className: "visibility-tree-checkbox-container", style: { marginRight: `${nodeOffset}px` }, children: _jsx(VisibilityTreeNodeCheckbox, { ...checkboxProps, onVisibilityToggled: onVisibilityToggled }) })), descriptionEnabled: descriptionEnabled, imageLoader: imageLoader, className: classNames("with-checkbox", (restProps.node.numChildren === 0 || (disableRootNodeCollapse && restProps.node.parentId === undefined)) && "disable-expander") }));
|
|
55
58
|
}
|
|
56
59
|
/**
|
|
57
60
|
* Filters data provider used in supplied node loader and invokes onFilterApplied when filtering is completed.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VisibilityTreeRenderer.js","sourceRoot":"","sources":["../../../../src/components/trees/VisibilityTreeRenderer.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,4BAA4B,EAAE,sCAAsC,EAAE,MAAM,gCAAgC,CAAC;AACtH,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAOrD;;;;;GAKG;AACH,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAClC,MAAM,+BAA+B,GAAG,EAAE,CAAC;AAE3C,MAAM,WAAW,GAAG,IAAI,eAAe,EAAE,CAAC;AAyC1C;;;GAGG;AACH,MAAM,UAAU,4BAA4B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AI,CAAC,WAAW,KAAK,CAAC,IAAI,CAAC,uBAAuB,IAAI,SAAS,CAAC,IAAI,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,IAAI,kBAAkB,CAC/H,GACD,CACH,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,uBAAuB;AACvB,MAAM,UAAU,0BAA0B,CACxC,UAA6E,EAC7E,UAAqC,EACrC,eAAqG;IAErG,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,GAAG,UAAU,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,SAAS,EAAE,CAAC;IACtG,MAAM,EAAE,kBAAkB,EAAE,WAAW,EAAE,YAAY,EAAE,qBAAqB,EAAE,GAAG,sCAAsC,CAAC;QACtH,UAAU;QACV,MAAM;QACN,gBAAgB;KACjB,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,MAAM,IAAI,YAAY,KAAK,SAAS,IAAI,kBAAkB,KAAK,UAAU,EAAE;YAC7E,eAAe,IAAI,eAAe,CAAC,kBAAkB,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;SACnF;IACH,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,kBAAkB,EAAE,eAAe,CAAC,CAAC,CAAC;IAE5E,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,qBAAqB,EAAE,CAAC;AACpE,CAAC;AAWD;;;GAGG;AACH,MAAM,UAAU,4BAA4B,CAAC,KAAwC;IACnF,OAAO,CACL,eAAK,SAAS,EAAC,8BAA8B,aAC3C,eAAM,SAAS,EAAC,qBAAqB,YAAE,KAAK,CAAC,KAAK,GAAQ,EAC1D,eAAM,SAAS,EAAC,mBAAmB,YAAE,KAAK,CAAC,OAAO,GAAQ,IACtD,CACP,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport classNames from \"classnames\";\nimport { useEffect } from \"react\";\nimport { TreeImageLoader, TreeNodeRenderer } from \"@itwin/components-react\";\nimport { Checkbox } from \"@itwin/itwinui-react\";\nimport { PresentationTreeNodeRenderer, useControlledPresentationTreeFiltering } from \"@itwin/presentation-components\";\nimport { TreeRenderer } from \"./common/TreeRenderer\";\n\nimport type { NodeCheckboxRenderProps } from \"@itwin/core-react\";\nimport type { TreeRendererBaseProps, TreeRendererProps } from \"./common/TreeRenderer\";\nimport type { AbstractTreeNodeLoaderWithProvider, TreeNodeRendererProps } from \"@itwin/components-react\";\nimport type { IPresentationTreeDataProvider, PresentationTreeNodeRendererProps } from \"@itwin/presentation-components\";\nimport type { VisibilityTreeFilterInfo } from \"./common/Types\";\n/**\n * These constants are taken from `@itwin/core-react`.\n * Defines the size in pixels of the expansion toggle.\n * It is used to keep same hierarchy nodes with children and nodes without children in the same line.\n * @note This value applies only to the leaf nodes.\n */\nconst EXPANSION_TOGGLE_WIDTH = 24;\nconst EXPANDED_EXPANSION_TOGGLE_WIDTH = 42;\n\nconst imageLoader = new TreeImageLoader();\n\n/**\n * Props for visibility tree renderer.\n * @public\n */\nexport interface VisibilityTreeRendererProps extends TreeRendererBaseProps {\n /** Props for single node renderer. */\n nodeRendererProps: VisibilityTreeNodeRendererProps;\n}\n\n/**\n * Props for visibility tree node renderer.\n * @public\n */\nexport interface VisibilityTreeNodeRendererProps {\n /**\n * Specifies whether the icon at the left of the node label should be rendered.\n */\n iconsEnabled: boolean;\n /**\n * Specifies whether node description should be enabled.\n */\n descriptionEnabled: boolean;\n /**\n * Defines the offset in pixels of how much each hierarchy level should be offset to the right from the checkbox.\n * Defaults to `20`.\n */\n levelOffset?: number;\n /**\n * Specifies whether the root node be expanded at all times.\n * Defaults to `false`.\n */\n disableRootNodeCollapse?: boolean;\n /**\n * Specifies whether the nodes should be enlarged (less dense and larger content).\n * Is `false` by default\n */\n isEnlarged?: boolean;\n}\n\n/**\n * Creates Visibility tree renderer which renders nodes with eye checkbox.\n * @public\n */\nexport function createVisibilityTreeRenderer({ nodeRendererProps, ...restProps }: VisibilityTreeRendererProps) {\n return function VisibilityTreeRenderer(treeProps: TreeRendererProps) {\n return <TreeRenderer {...treeProps} {...restProps} nodeRenderer={createVisibilityTreeNodeRenderer(nodeRendererProps)} />;\n };\n}\n\n/**\n * Creates node renderer which renders node with eye checkbox.\n * @public\n */\nexport function createVisibilityTreeNodeRenderer({\n levelOffset = 20,\n disableRootNodeCollapse = false,\n descriptionEnabled,\n iconsEnabled,\n}: VisibilityTreeNodeRendererProps) {\n return function VisibilityTreeNodeRenderer(treeNodeProps: TreeNodeRendererProps) {\n const nodeOffset = treeNodeProps.node.depth * levelOffset + (treeNodeProps.node.numChildren === 0 ? EXPANSION_TOGGLE_WIDTH : 0);\n return (\n <TreeNodeRenderer\n {...treeNodeProps}\n node={{ ...treeNodeProps.node, depth: 0, numChildren: 1 }} // if we want to disable TreeNodeRenderer style calculations for tree nodes, we need to override these values.\n checkboxRenderer={(checkboxProps: NodeCheckboxRenderProps) => (\n <div className=\"visibility-tree-checkbox-container\" style={{ marginRight: `${nodeOffset}px` }}>\n <VisibilityTreeNodeCheckbox {...checkboxProps} />\n </div>\n )}\n descriptionEnabled={descriptionEnabled}\n imageLoader={iconsEnabled ? imageLoader : undefined}\n className={classNames(\n \"with-checkbox\",\n (treeNodeProps.node.numChildren === 0 || (disableRootNodeCollapse && treeNodeProps.node.parentId === undefined)) && \"disable-expander\",\n treeNodeProps.className,\n )}\n />\n );\n };\n}\n\n/**\n * Checkbox renderer that renders an eye.\n * @public\n */\nexport function VisibilityTreeNodeCheckbox(props: NodeCheckboxRenderProps) {\n return (\n <Checkbox\n className=\"visibility-tree-checkbox\"\n variant=\"eyeball\"\n checked={props.checked}\n onChange={(e) => props.onChange(e.currentTarget.checked)}\n onClick={props.onClick}\n disabled={props.disabled}\n title={props.title}\n />\n );\n}\n\n/**\n * Props for [[FilterableVisibilityTreeNodeRenderer]].\n * @beta\n */\nexport type FilterableVisibilityTreeNodeRendererProps = Omit<PresentationTreeNodeRendererProps, \"descriptionEnabled\"> & VisibilityTreeNodeRendererProps;\n\n/**\n * Creates node renderer which renders node with eye checkbox and hierarchy level filtering actions.\n * @beta\n */\nexport function FilterableVisibilityTreeNodeRenderer({\n levelOffset = 20,\n disableRootNodeCollapse,\n descriptionEnabled,\n isEnlarged,\n ...restProps\n}: FilterableVisibilityTreeNodeRendererProps) {\n const expansionToggleWidth = isEnlarged ? EXPANDED_EXPANSION_TOGGLE_WIDTH : EXPANSION_TOGGLE_WIDTH;\n const nodeOffset = restProps.node.depth * levelOffset + (restProps.node.numChildren === 0 ? expansionToggleWidth : 0);\n\n return (\n <PresentationTreeNodeRenderer\n {...restProps}\n checkboxRenderer={(checkboxProps: NodeCheckboxRenderProps) => (\n <div className=\"visibility-tree-checkbox-container\" style={{ marginRight: `${nodeOffset}px` }}>\n <VisibilityTreeNodeCheckbox {...checkboxProps} />\n </div>\n )}\n descriptionEnabled={descriptionEnabled}\n imageLoader={imageLoader}\n className={classNames(\n \"with-checkbox\",\n (restProps.node.numChildren === 0 || (disableRootNodeCollapse && restProps.node.parentId === undefined)) && \"disable-expander\",\n )}\n />\n );\n}\n\n/**\n * Filters data provider used in supplied node loader and invokes onFilterApplied when filtering is completed.\n * @public\n * @deprecated in 2.0.0. Use [[useVisibilityTree]] instead.\n */\n// istanbul ignore next\nexport function 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 { filteredNodeLoader, isFiltering, matchesCount, nodeHighlightingProps } = useControlledPresentationTreeFiltering({\n nodeLoader,\n filter,\n activeMatchIndex,\n });\n\n useEffect(() => {\n if (filter && matchesCount !== undefined && filteredNodeLoader !== nodeLoader) {\n onFilterApplied && onFilterApplied(filteredNodeLoader.dataProvider, matchesCount);\n }\n }, [filter, matchesCount, nodeLoader, filteredNodeLoader, onFilterApplied]);\n\n return { filteredNodeLoader, isFiltering, nodeHighlightingProps };\n}\n\n/**\n * Properties for [[VisibilityTreeNoFilteredData]] component.\n * @public\n */\nexport interface VisibilityTreeNoFilteredDataProps {\n title: string;\n message: string;\n}\n\n/**\n * Renders message that no nodes was found for filter.\n * @public\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"]}
|
|
1
|
+
{"version":3,"file":"VisibilityTreeRenderer.js","sourceRoot":"","sources":["../../../../src/components/trees/VisibilityTreeRenderer.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,4BAA4B,EAAE,sCAAsC,EAAE,MAAM,gCAAgC,CAAC;AACtH,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAOrD;;;;;GAKG;AACH,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAClC,MAAM,+BAA+B,GAAG,EAAE,CAAC;AAE3C,MAAM,WAAW,GAAG,IAAI,eAAe,EAAE,CAAC;AA6C1C;;;GAGG;AACH,MAAM,UAAU,4BAA4B,CAAC,EAAE,iBAAiB,EAAE,GAAG,SAAS,EAA+B;IAC3G,OAAO,SAAS,sBAAsB,CAAC,SAA4B;QACjE,OAAO,KAAC,YAAY,OAAK,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AC,OAAO,GAAQ,IACtD,CACP,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport classNames from \"classnames\";\nimport { useEffect } from \"react\";\nimport { TreeImageLoader, TreeNodeRenderer } from \"@itwin/components-react\";\nimport { Checkbox } from \"@itwin/itwinui-react\";\nimport { PresentationTreeNodeRenderer, useControlledPresentationTreeFiltering } from \"@itwin/presentation-components\";\nimport { TreeRenderer } from \"./common/TreeRenderer\";\n\nimport type { NodeCheckboxRenderProps } from \"@itwin/core-react\";\nimport type { TreeRendererBaseProps, TreeRendererProps } from \"./common/TreeRenderer\";\nimport type { AbstractTreeNodeLoaderWithProvider, TreeNodeRendererProps } from \"@itwin/components-react\";\nimport type { IPresentationTreeDataProvider, PresentationTreeNodeRendererProps } from \"@itwin/presentation-components\";\nimport type { VisibilityTreeFilterInfo } from \"./common/Types\";\n/**\n * These constants are taken from `@itwin/core-react`.\n * Defines the size in pixels of the expansion toggle.\n * It is used to keep same hierarchy nodes with children and nodes without children in the same line.\n * @note This value applies only to the leaf nodes.\n */\nconst EXPANSION_TOGGLE_WIDTH = 24;\nconst EXPANDED_EXPANSION_TOGGLE_WIDTH = 42;\n\nconst imageLoader = new TreeImageLoader();\n\n/**\n * Props for visibility tree renderer.\n * @public\n */\nexport interface VisibilityTreeRendererProps extends TreeRendererBaseProps {\n /** Props for single node renderer. */\n nodeRendererProps: VisibilityTreeNodeRendererProps;\n}\n\n/**\n * Props for visibility tree node renderer.\n * @public\n */\nexport interface VisibilityTreeNodeRendererProps {\n /**\n * Specifies whether the icon at the left of the node label should be rendered.\n */\n iconsEnabled: boolean;\n /**\n * Specifies whether node description should be enabled.\n */\n descriptionEnabled: boolean;\n /**\n * Defines the offset in pixels of how much each hierarchy level should be offset to the right from the checkbox.\n * Defaults to `20`.\n */\n levelOffset?: number;\n /**\n * Specifies whether the root node be expanded at all times.\n * Defaults to `false`.\n */\n disableRootNodeCollapse?: boolean;\n /**\n * Specifies whether the nodes should be enlarged (less dense and larger content).\n * Is `false` by default\n */\n isEnlarged?: boolean;\n /**\n * Callback called when visibility is toggled using a checkbox.\n */\n onVisibilityToggled?: (enabled: boolean) => void;\n}\n\n/**\n * Creates Visibility tree renderer which renders nodes with eye checkbox.\n * @public\n */\nexport function createVisibilityTreeRenderer({ nodeRendererProps, ...restProps }: VisibilityTreeRendererProps) {\n return function VisibilityTreeRenderer(treeProps: TreeRendererProps) {\n return <TreeRenderer {...treeProps} {...restProps} nodeRenderer={createVisibilityTreeNodeRenderer(nodeRendererProps)} />;\n };\n}\n\n/**\n * Creates node renderer which renders node with eye checkbox.\n * @public\n */\nexport function createVisibilityTreeNodeRenderer({\n levelOffset = 20,\n disableRootNodeCollapse = false,\n descriptionEnabled,\n iconsEnabled,\n onVisibilityToggled,\n}: VisibilityTreeNodeRendererProps) {\n return function VisibilityTreeNodeRenderer(treeNodeProps: TreeNodeRendererProps) {\n const nodeOffset = treeNodeProps.node.depth * levelOffset + (treeNodeProps.node.numChildren === 0 ? EXPANSION_TOGGLE_WIDTH : 0);\n return (\n <TreeNodeRenderer\n {...treeNodeProps}\n node={{ ...treeNodeProps.node, depth: 0, numChildren: 1 }} // if we want to disable TreeNodeRenderer style calculations for tree nodes, we need to override these values.\n checkboxRenderer={(checkboxProps: NodeCheckboxRenderProps) => (\n <div className=\"visibility-tree-checkbox-container\" style={{ marginRight: `${nodeOffset}px` }}>\n <VisibilityTreeNodeCheckbox {...checkboxProps} onVisibilityToggled={onVisibilityToggled} />\n </div>\n )}\n descriptionEnabled={descriptionEnabled}\n imageLoader={iconsEnabled ? imageLoader : undefined}\n className={classNames(\n \"with-checkbox\",\n (treeNodeProps.node.numChildren === 0 || (disableRootNodeCollapse && treeNodeProps.node.parentId === undefined)) && \"disable-expander\",\n treeNodeProps.className,\n )}\n />\n );\n };\n}\n\ninterface VisibilityTreeNodeCheckboxProps extends NodeCheckboxRenderProps {\n onVisibilityToggled?: (enabled: boolean) => void;\n}\n\n/**\n * Checkbox renderer that renders an eye.\n * @public\n */\nexport function VisibilityTreeNodeCheckbox(props: VisibilityTreeNodeCheckboxProps) {\n return (\n <Checkbox\n className=\"visibility-tree-checkbox\"\n variant=\"eyeball\"\n checked={props.checked}\n onChange={(e) => {\n props.onVisibilityToggled?.(e.currentTarget.checked);\n props.onChange(e.currentTarget.checked);\n }}\n onMouseDown={(e) => e.stopPropagation()}\n onClick={props.onClick}\n disabled={props.disabled}\n title={props.title}\n />\n );\n}\n\n/**\n * Props for [[FilterableVisibilityTreeNodeRenderer]].\n * @beta\n */\nexport type FilterableVisibilityTreeNodeRendererProps = Omit<PresentationTreeNodeRendererProps, \"descriptionEnabled\"> & VisibilityTreeNodeRendererProps;\n\n/**\n * Creates node renderer which renders node with eye checkbox and hierarchy level filtering actions.\n * @beta\n */\nexport function FilterableVisibilityTreeNodeRenderer({\n levelOffset = 20,\n disableRootNodeCollapse,\n descriptionEnabled,\n isEnlarged,\n onVisibilityToggled,\n ...restProps\n}: FilterableVisibilityTreeNodeRendererProps) {\n const expansionToggleWidth = isEnlarged ? EXPANDED_EXPANSION_TOGGLE_WIDTH : EXPANSION_TOGGLE_WIDTH;\n const nodeOffset = restProps.node.depth * levelOffset + (restProps.node.numChildren === 0 ? expansionToggleWidth : 0);\n\n return (\n <PresentationTreeNodeRenderer\n {...restProps}\n checkboxRenderer={(checkboxProps: NodeCheckboxRenderProps) => (\n <div className=\"visibility-tree-checkbox-container\" style={{ marginRight: `${nodeOffset}px` }}>\n <VisibilityTreeNodeCheckbox {...checkboxProps} onVisibilityToggled={onVisibilityToggled} />\n </div>\n )}\n descriptionEnabled={descriptionEnabled}\n imageLoader={imageLoader}\n className={classNames(\n \"with-checkbox\",\n (restProps.node.numChildren === 0 || (disableRootNodeCollapse && restProps.node.parentId === undefined)) && \"disable-expander\",\n )}\n />\n );\n}\n\n/**\n * Filters data provider used in supplied node loader and invokes onFilterApplied when filtering is completed.\n * @public\n * @deprecated in 2.0.0. Use [[useVisibilityTree]] instead.\n */\n// istanbul ignore next\nexport function 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 { filteredNodeLoader, isFiltering, matchesCount, nodeHighlightingProps } = useControlledPresentationTreeFiltering({\n nodeLoader,\n filter,\n activeMatchIndex,\n });\n\n useEffect(() => {\n if (filter && matchesCount !== undefined && filteredNodeLoader !== nodeLoader) {\n onFilterApplied && onFilterApplied(filteredNodeLoader.dataProvider, matchesCount);\n }\n }, [filter, matchesCount, nodeLoader, filteredNodeLoader, onFilterApplied]);\n\n return { filteredNodeLoader, isFiltering, nodeHighlightingProps };\n}\n\n/**\n * Properties for [[VisibilityTreeNoFilteredData]] component.\n * @public\n */\nexport interface VisibilityTreeNoFilteredDataProps {\n title: string;\n message: string;\n}\n\n/**\n * Renders message that no nodes was found for filter.\n * @public\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"]}
|
|
@@ -38,6 +38,19 @@ export interface CategoryTreeProps extends BaseFilterableTreeProps {
|
|
|
38
38
|
* @beta
|
|
39
39
|
*/
|
|
40
40
|
hierarchyLevelConfig?: HierarchyLevelConfig;
|
|
41
|
+
/**
|
|
42
|
+
* Callback that is invoked when performance of tracked feature is measured.
|
|
43
|
+
* @param featureId ID of the feature.
|
|
44
|
+
* @param elapsedTime Elapsed time of the feature.
|
|
45
|
+
* @beta
|
|
46
|
+
*/
|
|
47
|
+
onPerformanceMeasured?: (featureId: string, elapsedTime: number) => void;
|
|
48
|
+
/**
|
|
49
|
+
* Callback that is invoked when a tracked feature is used.
|
|
50
|
+
* @param featureId ID of the feature.
|
|
51
|
+
* @beta
|
|
52
|
+
*/
|
|
53
|
+
onFeatureUsed?: (feature: string) => void;
|
|
41
54
|
}
|
|
42
55
|
/**
|
|
43
56
|
* Tree which displays and manages display of categories contained in an iModel.
|
|
@@ -12,9 +12,12 @@ import { PresentationTree } from "@itwin/presentation-components";
|
|
|
12
12
|
import { Presentation } from "@itwin/presentation-frontend";
|
|
13
13
|
import { TreeWidget } from "../../../TreeWidget";
|
|
14
14
|
import { FilterableTreeRenderer } from "../common/TreeRenderer";
|
|
15
|
+
import { useFeatureReporting } from "../common/UseFeatureReporting";
|
|
16
|
+
import { usePerformanceReporting } from "../common/UsePerformanceReporting";
|
|
15
17
|
import { useVisibilityTreeState } from "../common/UseVisibilityTreeState";
|
|
16
18
|
import { addCustomTreeNodeItemLabelRenderer, combineTreeNodeItemCustomizations } from "../common/Utils";
|
|
17
19
|
import { createVisibilityTreeRenderer, FilterableVisibilityTreeNodeRenderer, VisibilityTreeNoFilteredData } from "../VisibilityTreeRenderer";
|
|
20
|
+
import { CategoriesTreeComponent } from "./CategoriesTreeComponent";
|
|
18
21
|
import { CategoryVisibilityHandler } from "./CategoryVisibilityHandler";
|
|
19
22
|
const PAGING_SIZE = 20;
|
|
20
23
|
/**
|
|
@@ -29,13 +32,18 @@ export const RULESET_CATEGORIES = require("./Categories.json"); // eslint-disabl
|
|
|
29
32
|
export function CategoryTree(props) {
|
|
30
33
|
// istanbul ignore next
|
|
31
34
|
const viewManager = props.viewManager ?? IModelApp.viewManager;
|
|
32
|
-
const { activeView, allViewports, categoryVisibilityHandler, onFilterApplied, density, hierarchyLevelConfig } = props;
|
|
35
|
+
const { activeView, allViewports, categoryVisibilityHandler, onFilterApplied, density, hierarchyLevelConfig, onPerformanceMeasured, onFeatureUsed } = props;
|
|
33
36
|
const visibilityHandler = useCategoryVisibilityHandler(viewManager, props.iModel, props.categories, activeView, allViewports, categoryVisibilityHandler);
|
|
34
37
|
const onFilterChange = useCallback((dataProvider, matchesCount) => {
|
|
35
38
|
if (onFilterApplied && dataProvider && matchesCount !== undefined) {
|
|
36
39
|
onFilterApplied(dataProvider, matchesCount);
|
|
37
40
|
}
|
|
38
41
|
}, [onFilterApplied]);
|
|
42
|
+
const { reportUsage } = useFeatureReporting({ treeIdentifier: CategoriesTreeComponent.id, onFeatureUsed });
|
|
43
|
+
const { onNodeLoaded } = usePerformanceReporting({
|
|
44
|
+
treeIdentifier: CategoriesTreeComponent.id,
|
|
45
|
+
onPerformanceMeasured,
|
|
46
|
+
});
|
|
39
47
|
const state = useVisibilityTreeState({
|
|
40
48
|
imodel: props.iModel,
|
|
41
49
|
ruleset: RULESET_CATEGORIES,
|
|
@@ -46,11 +54,14 @@ export function CategoryTree(props) {
|
|
|
46
54
|
onFilterChange,
|
|
47
55
|
hierarchyLevelSizeLimit: hierarchyLevelConfig?.sizeLimit,
|
|
48
56
|
enableHierarchyAutoUpdate: true,
|
|
57
|
+
onNodeLoaded,
|
|
58
|
+
reportUsage,
|
|
49
59
|
});
|
|
50
60
|
useEffect(() => {
|
|
51
61
|
setViewType(activeView); // eslint-disable-line @typescript-eslint/no-floating-promises
|
|
52
62
|
}, [activeView]);
|
|
53
63
|
const baseRendererProps = {
|
|
64
|
+
reportUsage,
|
|
54
65
|
contextMenuItems: props.contextMenuItems,
|
|
55
66
|
nodeLabelRenderer: props.nodeLabelRenderer,
|
|
56
67
|
density: props.density,
|
|
@@ -58,6 +69,7 @@ export function CategoryTree(props) {
|
|
|
58
69
|
iconsEnabled: false,
|
|
59
70
|
descriptionEnabled: true,
|
|
60
71
|
levelOffset: 10,
|
|
72
|
+
onVisibilityToggled: () => reportUsage({ featureId: "visibility-change", reportInteraction: true }),
|
|
61
73
|
},
|
|
62
74
|
};
|
|
63
75
|
const noFilteredDataRenderer = useCallback(() => {
|
|
@@ -73,7 +85,7 @@ export function CategoryTree(props) {
|
|
|
73
85
|
: createVisibilityTreeRenderer(baseRendererProps), descriptionsEnabled: true, noDataRenderer: isFilterApplied ? noFilteredDataRenderer : undefined }), overlay] }));
|
|
74
86
|
}
|
|
75
87
|
function CategoriesTreeNodeRenderer(props) {
|
|
76
|
-
return (_jsx(FilterableVisibilityTreeNodeRenderer, { ...props, iconsEnabled: false, descriptionEnabled: true, levelOffset: 10, isEnlarged: props.density === "enlarged" }));
|
|
88
|
+
return (_jsx(FilterableVisibilityTreeNodeRenderer, { ...props, iconsEnabled: false, descriptionEnabled: true, levelOffset: 10, isEnlarged: props.density === "enlarged", onVisibilityToggled: () => props.reportUsage?.({ featureId: "visibility-change", reportInteraction: true }) }));
|
|
77
89
|
}
|
|
78
90
|
function useCategoryVisibilityHandler(viewManager, imodel, categories, activeView, allViewports, visibilityHandler) {
|
|
79
91
|
const [state, setState] = useState();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CategoriesTree.js","sourceRoot":"","sources":["../../../../../src/components/trees/category-tree/CategoriesTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,4BAA4B,CAAC;AACpC,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EAAE,kCAA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,CAAC;IAEnF,OAAO,iBAAiB,IAAI,KAAK,CAAC;AACpC,CAAC;AAED,KAAK,UAAU,WAAW,CAAC,UAAoB;IAC7C,MAAM,IAAI,GAAG,UAAU,CAAC,IAAwB,CAAC;IACjD,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IAC3C,MAAM,YAAY,CAAC,YAAY,CAAC,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;AAC9F,CAAC;AAED,MAAM,qBAAqB,GAAG,iCAAiC,CAAC,CAAC,kCAAkC,CAAC,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\nimport \"../VisibilityTreeBase.scss\";\nimport classNames from \"classnames\";\nimport { useCallback, useEffect, useState } from \"react\";\nimport { SelectionMode } from \"@itwin/components-react\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { PresentationTree } from \"@itwin/presentation-components\";\nimport { Presentation } from \"@itwin/presentation-frontend\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { FilterableTreeRenderer } from \"../common/TreeRenderer\";\nimport { useVisibilityTreeState } from \"../common/UseVisibilityTreeState\";\nimport { addCustomTreeNodeItemLabelRenderer, combineTreeNodeItemCustomizations } from \"../common/Utils\";\nimport { createVisibilityTreeRenderer, FilterableVisibilityTreeNodeRenderer, VisibilityTreeNoFilteredData } from \"../VisibilityTreeRenderer\";\nimport { CategoryVisibilityHandler } from \"./CategoryVisibilityHandler\";\n\nimport type { IModelConnection, SpatialViewState, ViewManager, Viewport } from \"@itwin/core-frontend\";\nimport type { Ruleset } from \"@itwin/presentation-common\";\nimport type { IFilteredPresentationTreeDataProvider, PresentationTreeNodeRendererProps } from \"@itwin/presentation-components\";\nimport type { BaseFilterableTreeProps, HierarchyLevelConfig } from \"../common/Types\";\nimport type { CategoryInfo } from \"./CategoryVisibilityHandler\";\nconst PAGING_SIZE = 20;\n\n/**\n * Presentation rules used by ControlledCategoriesTree\n * @internal\n */\nexport const RULESET_CATEGORIES: Ruleset = require(\"./Categories.json\"); // eslint-disable-line @typescript-eslint/no-var-requires\n\n/**\n * Properties for the [[CategoryTree]] component\n * @public\n */\nexport interface CategoryTreeProps extends BaseFilterableTreeProps {\n /** Flag for accommodating all viewports */\n allViewports?: boolean;\n /** Active viewport */\n activeView: Viewport;\n /**\n * Available iModel categories\n */\n categories: CategoryInfo[];\n /**\n * Custom category visibility handler to use for testing\n * @internal\n */\n categoryVisibilityHandler?: CategoryVisibilityHandler;\n /**\n * Custom view manager to use for testing\n * @internal\n */\n viewManager?: ViewManager;\n /**\n * Props for configuring hierarchy level.\n * @beta\n */\n hierarchyLevelConfig?: HierarchyLevelConfig;\n}\n\n/**\n * Tree which displays and manages display of categories contained in an iModel.\n * @public\n */\nexport function CategoryTree(props: CategoryTreeProps) {\n // istanbul ignore next\n const viewManager = props.viewManager ?? IModelApp.viewManager;\n const { activeView, allViewports, categoryVisibilityHandler, onFilterApplied, density, hierarchyLevelConfig } = props;\n\n const visibilityHandler = useCategoryVisibilityHandler(viewManager, props.iModel, props.categories, activeView, allViewports, categoryVisibilityHandler);\n const onFilterChange = useCallback(\n (dataProvider?: IFilteredPresentationTreeDataProvider, matchesCount?: number) => {\n if (onFilterApplied && dataProvider && matchesCount !== undefined) {\n onFilterApplied(dataProvider, matchesCount);\n }\n },\n [onFilterApplied],\n );\n const state = useVisibilityTreeState({\n imodel: props.iModel,\n ruleset: RULESET_CATEGORIES,\n pagingSize: PAGING_SIZE,\n visibilityHandler,\n customizeTreeNodeItem,\n filterInfo: props.filterInfo,\n onFilterChange,\n hierarchyLevelSizeLimit: hierarchyLevelConfig?.sizeLimit,\n enableHierarchyAutoUpdate: true,\n });\n\n useEffect(() => {\n setViewType(activeView); // eslint-disable-line @typescript-eslint/no-floating-promises\n }, [activeView]);\n\n const baseRendererProps = {\n contextMenuItems: props.contextMenuItems,\n nodeLabelRenderer: props.nodeLabelRenderer,\n density: props.density,\n nodeRendererProps: {\n iconsEnabled: false,\n descriptionEnabled: true,\n levelOffset: 10,\n },\n };\n\n const noFilteredDataRenderer = useCallback(() => {\n return (\n <VisibilityTreeNoFilteredData\n title={TreeWidget.translate(\"categoriesTree.noCategoryFound\")}\n message={TreeWidget.translate(\"categoriesTree.noMatchingCategoryNames\")}\n />\n );\n }, []);\n\n if (!state) {\n return null;\n }\n\n const isFilterApplied = state.filteringResult?.filteredProvider !== undefined;\n const overlay = state.filteringResult?.isFiltering ? <div className=\"filteredTreeOverlay\" /> : undefined;\n return (\n <div className={classNames(\"tree-widget-visibility-tree-base\", \"tree-widget-tree-container\")}>\n <PresentationTree\n width={props.width}\n height={props.height}\n state={state}\n selectionMode={props.selectionMode ?? SelectionMode.None}\n treeRenderer={\n hierarchyLevelConfig?.isFilteringEnabled\n ? (rendererProps) => (\n <FilterableTreeRenderer\n {...rendererProps}\n {...baseRendererProps}\n nodeLoader={state.nodeLoader}\n nodeRenderer={(nodeProps) => <CategoriesTreeNodeRenderer {...nodeProps} density={density} />}\n />\n )\n : createVisibilityTreeRenderer(baseRendererProps)\n }\n descriptionsEnabled={true}\n noDataRenderer={isFilterApplied ? noFilteredDataRenderer : undefined}\n />\n {overlay}\n </div>\n );\n}\n\nfunction CategoriesTreeNodeRenderer(props: PresentationTreeNodeRendererProps & { density?: \"default\" | \"enlarged\" }) {\n return (\n <FilterableVisibilityTreeNodeRenderer\n {...props}\n iconsEnabled={false}\n descriptionEnabled={true}\n levelOffset={10}\n isEnlarged={props.density === \"enlarged\"}\n />\n );\n\n}\n\nfunction useCategoryVisibilityHandler(\n viewManager: ViewManager,\n imodel: IModelConnection,\n categories: CategoryInfo[],\n activeView: Viewport,\n allViewports?: boolean,\n visibilityHandler?: CategoryVisibilityHandler,\n) {\n const [state, setState] = useState<CategoryVisibilityHandler>();\n\n useEffect(() => {\n if (visibilityHandler) {\n return;\n }\n\n const defaultHandler = new CategoryVisibilityHandler({ viewManager, imodel, categories, activeView, allViewports });\n setState(defaultHandler);\n return () => {\n defaultHandler.dispose();\n };\n }, [viewManager, imodel, categories, activeView, allViewports, visibilityHandler]);\n\n return visibilityHandler ?? state;\n}\n\nasync function setViewType(activeView: Viewport) {\n const view = activeView.view as SpatialViewState;\n const viewType = view.is3d() ? \"3d\" : \"2d\";\n await Presentation.presentation.vars(RULESET_CATEGORIES.id).setString(\"ViewType\", viewType);\n}\n\nconst customizeTreeNodeItem = combineTreeNodeItemCustomizations([addCustomTreeNodeItemLabelRenderer]);\n"]}
|
|
1
|
+
{"version":3,"file":"CategoriesTree.js","sourceRoot":"","sources":["../../../../../src/components/trees/category-tree/CategoriesTree.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,4BAA4B,CAAC;AACpC,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EAAE,kCAAkC,EAAE,iCAAi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J,CAAC;AAED,SAAS,4BAA4B,CACnC,WAAwB,EACxB,MAAwB,EACxB,UAA0B,EAC1B,UAAoB,EACpB,YAAsB,EACtB,iBAA6C;IAE7C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,EAA6B,CAAC;IAEhE,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,iBAAiB,EAAE;YACrB,OAAO;SACR;QAED,MAAM,cAAc,GAAG,IAAI,yBAAyB,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC,CAAC;QACpH,QAAQ,CAAC,cAAc,CAAC,CAAC;QACzB,OAAO,GAAG,EAAE;YACV,cAAc,CAAC,OAAO,EAAE,CAAC;QAC3B,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAEnF,OAAO,iBAAiB,IAAI,KAAK,CAAC;AACpC,CAAC;AAED,KAAK,UAAU,WAAW,CAAC,UAAoB;IAC7C,MAAM,IAAI,GAAG,UAAU,CAAC,IAAwB,CAAC;IACjD,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IAC3C,MAAM,YAAY,CAAC,YAAY,CAAC,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;AAC9F,CAAC;AAED,MAAM,qBAAqB,GAAG,iCAAiC,CAAC,CAAC,kCAAkC,CAAC,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\nimport \"../VisibilityTreeBase.scss\";\nimport classNames from \"classnames\";\nimport { useCallback, useEffect, useState } from \"react\";\nimport { SelectionMode } from \"@itwin/components-react\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { PresentationTree } from \"@itwin/presentation-components\";\nimport { Presentation } from \"@itwin/presentation-frontend\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { FilterableTreeRenderer } from \"../common/TreeRenderer\";\nimport { useFeatureReporting } from \"../common/UseFeatureReporting\";\nimport { usePerformanceReporting } from \"../common/UsePerformanceReporting\";\nimport { useVisibilityTreeState } from \"../common/UseVisibilityTreeState\";\nimport { addCustomTreeNodeItemLabelRenderer, combineTreeNodeItemCustomizations } from \"../common/Utils\";\nimport { createVisibilityTreeRenderer, FilterableVisibilityTreeNodeRenderer, VisibilityTreeNoFilteredData } from \"../VisibilityTreeRenderer\";\nimport { CategoriesTreeComponent } from \"./CategoriesTreeComponent\";\nimport { CategoryVisibilityHandler } from \"./CategoryVisibilityHandler\";\n\nimport type { FilterableTreeNodeRendererProps } from \"../common/TreeRenderer\";\nimport type { IModelConnection, SpatialViewState, ViewManager, Viewport } from \"@itwin/core-frontend\";\nimport type { Ruleset } from \"@itwin/presentation-common\";\nimport type { IFilteredPresentationTreeDataProvider } from \"@itwin/presentation-components\";\nimport type { BaseFilterableTreeProps, HierarchyLevelConfig } from \"../common/Types\";\nimport type { CategoryInfo } from \"./CategoryVisibilityHandler\";\nconst PAGING_SIZE = 20;\n\n/**\n * Presentation rules used by ControlledCategoriesTree\n * @internal\n */\nexport const RULESET_CATEGORIES: Ruleset = require(\"./Categories.json\"); // eslint-disable-line @typescript-eslint/no-var-requires\n\n/**\n * Properties for the [[CategoryTree]] component\n * @public\n */\nexport interface CategoryTreeProps extends BaseFilterableTreeProps {\n /** Flag for accommodating all viewports */\n allViewports?: boolean;\n /** Active viewport */\n activeView: Viewport;\n /**\n * Available iModel categories\n */\n categories: CategoryInfo[];\n /**\n * Custom category visibility handler to use for testing\n * @internal\n */\n categoryVisibilityHandler?: CategoryVisibilityHandler;\n /**\n * Custom view manager to use for testing\n * @internal\n */\n viewManager?: ViewManager;\n /**\n * Props for configuring hierarchy level.\n * @beta\n */\n hierarchyLevelConfig?: HierarchyLevelConfig;\n /**\n * Callback that is invoked when performance of tracked feature is measured.\n * @param featureId ID of the feature.\n * @param elapsedTime Elapsed time of the feature.\n * @beta\n */\n onPerformanceMeasured?: (featureId: string, elapsedTime: number) => void;\n /**\n * Callback that is invoked when a tracked feature is used.\n * @param featureId ID of the feature.\n * @beta\n */\n onFeatureUsed?: (feature: string) => void;\n}\n\n/**\n * Tree which displays and manages display of categories contained in an iModel.\n * @public\n */\nexport function CategoryTree(props: CategoryTreeProps) {\n // istanbul ignore next\n const viewManager = props.viewManager ?? IModelApp.viewManager;\n const { activeView, allViewports, categoryVisibilityHandler, onFilterApplied, density, hierarchyLevelConfig, onPerformanceMeasured, onFeatureUsed } = props;\n\n const visibilityHandler = useCategoryVisibilityHandler(viewManager, props.iModel, props.categories, activeView, allViewports, categoryVisibilityHandler);\n const onFilterChange = useCallback(\n (dataProvider?: IFilteredPresentationTreeDataProvider, matchesCount?: number) => {\n if (onFilterApplied && dataProvider && matchesCount !== undefined) {\n onFilterApplied(dataProvider, matchesCount);\n }\n },\n [onFilterApplied],\n );\n\n const { reportUsage } = useFeatureReporting({ treeIdentifier: CategoriesTreeComponent.id, onFeatureUsed });\n const { onNodeLoaded } = usePerformanceReporting({\n treeIdentifier: CategoriesTreeComponent.id,\n onPerformanceMeasured,\n });\n\n const state = useVisibilityTreeState({\n imodel: props.iModel,\n ruleset: RULESET_CATEGORIES,\n pagingSize: PAGING_SIZE,\n visibilityHandler,\n customizeTreeNodeItem,\n filterInfo: props.filterInfo,\n onFilterChange,\n hierarchyLevelSizeLimit: hierarchyLevelConfig?.sizeLimit,\n enableHierarchyAutoUpdate: true,\n onNodeLoaded,\n reportUsage,\n });\n\n useEffect(() => {\n setViewType(activeView); // eslint-disable-line @typescript-eslint/no-floating-promises\n }, [activeView]);\n\n const baseRendererProps = {\n reportUsage,\n contextMenuItems: props.contextMenuItems,\n nodeLabelRenderer: props.nodeLabelRenderer,\n density: props.density,\n nodeRendererProps: {\n iconsEnabled: false,\n descriptionEnabled: true,\n levelOffset: 10,\n onVisibilityToggled: () => reportUsage({ featureId: \"visibility-change\", reportInteraction: true }),\n },\n };\n\n const noFilteredDataRenderer = useCallback(() => {\n return (\n <VisibilityTreeNoFilteredData\n title={TreeWidget.translate(\"categoriesTree.noCategoryFound\")}\n message={TreeWidget.translate(\"categoriesTree.noMatchingCategoryNames\")}\n />\n );\n }, []);\n\n if (!state) {\n return null;\n }\n\n const isFilterApplied = state.filteringResult?.filteredProvider !== undefined;\n const overlay = state.filteringResult?.isFiltering ? <div className=\"filteredTreeOverlay\" /> : undefined;\n return (\n <div className={classNames(\"tree-widget-visibility-tree-base\", \"tree-widget-tree-container\")}>\n <PresentationTree\n width={props.width}\n height={props.height}\n state={state}\n selectionMode={props.selectionMode ?? SelectionMode.None}\n treeRenderer={\n hierarchyLevelConfig?.isFilteringEnabled\n ? (rendererProps) => (\n <FilterableTreeRenderer\n {...rendererProps}\n {...baseRendererProps}\n nodeLoader={state.nodeLoader}\n nodeRenderer={(nodeProps) => <CategoriesTreeNodeRenderer {...nodeProps} density={density} />}\n />\n )\n : createVisibilityTreeRenderer(baseRendererProps)\n }\n descriptionsEnabled={true}\n noDataRenderer={isFilterApplied ? noFilteredDataRenderer : undefined}\n />\n {overlay}\n </div>\n );\n}\n\ninterface CategoriesTreeNodeRendererProps extends FilterableTreeNodeRendererProps {\n density?: \"default\" | \"enlarged\";\n}\n\nfunction CategoriesTreeNodeRenderer(props: CategoriesTreeNodeRendererProps) {\n return (\n <FilterableVisibilityTreeNodeRenderer\n {...props}\n iconsEnabled={false}\n descriptionEnabled={true}\n levelOffset={10}\n isEnlarged={props.density === \"enlarged\"}\n onVisibilityToggled={() => props.reportUsage?.({ featureId: \"visibility-change\", reportInteraction: true })}\n />\n );\n}\n\nfunction useCategoryVisibilityHandler(\n viewManager: ViewManager,\n imodel: IModelConnection,\n categories: CategoryInfo[],\n activeView: Viewport,\n allViewports?: boolean,\n visibilityHandler?: CategoryVisibilityHandler,\n) {\n const [state, setState] = useState<CategoryVisibilityHandler>();\n\n useEffect(() => {\n if (visibilityHandler) {\n return;\n }\n\n const defaultHandler = new CategoryVisibilityHandler({ viewManager, imodel, categories, activeView, allViewports });\n setState(defaultHandler);\n return () => {\n defaultHandler.dispose();\n };\n }, [viewManager, imodel, categories, activeView, allViewports, visibilityHandler]);\n\n return visibilityHandler ?? state;\n}\n\nasync function setViewType(activeView: Viewport) {\n const view = activeView.view as SpatialViewState;\n const viewType = view.is3d() ? \"3d\" : \"2d\";\n await Presentation.presentation.vars(RULESET_CATEGORIES.id).setString(\"ViewType\", viewType);\n}\n\nconst customizeTreeNodeItem = combineTreeNodeItemCustomizations([addCustomTreeNodeItemLabelRenderer]);\n"]}
|
|
@@ -4,6 +4,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
4
4
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
6
|
import "../VisibilityTreeBase.scss";
|
|
7
|
+
import classNames from "classnames";
|
|
7
8
|
import { Fragment, useEffect, useState } from "react";
|
|
8
9
|
import { useActiveIModelConnection, useActiveViewport } from "@itwin/appui-react";
|
|
9
10
|
import { IModelApp } from "@itwin/core-frontend";
|
|
@@ -16,7 +17,6 @@ import { useTreeFilteringState } from "../../TreeFilteringState";
|
|
|
16
17
|
import { AutoSizer } from "../../utils/AutoSizer";
|
|
17
18
|
import { CategoryTree } from "./CategoriesTree";
|
|
18
19
|
import { CategoryVisibilityHandler, hideAllCategories, invertAllCategories, showAllCategories, useCategories } from "./CategoryVisibilityHandler";
|
|
19
|
-
import classNames from "classnames";
|
|
20
20
|
/**
|
|
21
21
|
* A component that renders [[CategoriesTree]] and a header with filtering capabilities
|
|
22
22
|
* and header buttons.
|
|
@@ -71,11 +71,11 @@ function CategoriesTreeComponentImpl(props) {
|
|
|
71
71
|
})();
|
|
72
72
|
}, [filteredProvider]);
|
|
73
73
|
return (_jsxs("div", { className: "tree-widget-tree-with-header", children: [_jsx(TreeHeader, { onFilterClear: searchOptions.onFilterCancel, onFilterStart: searchOptions.onFilterStart, onSelectedChanged: searchOptions.onResultSelectedChanged, resultCount: searchOptions.matchedResultCount, selectedIndex: searchOptions.activeMatchIndex, density: props.density, children: props.headerButtons
|
|
74
|
-
? props.headerButtons.map((btn, index) => _jsx(Fragment, { children: btn({ viewport: props.viewport, categories, filteredCategories }) }, index))
|
|
74
|
+
? props.headerButtons.map((btn, index) => (_jsx(Fragment, { children: btn({ viewport: props.viewport, categories, filteredCategories, density: props.density, onFeatureUsed: props.onFeatureUsed }) }, index)))
|
|
75
75
|
: [
|
|
76
|
-
_jsx(ShowAllButton, { viewport: props.viewport, categories: categories, filteredCategories: filteredCategories, density: props.density }, "show-all-btn"),
|
|
77
|
-
_jsx(HideAllButton, { viewport: props.viewport, categories: categories, filteredCategories: filteredCategories, density: props.density }, "hide-all-btn"),
|
|
78
|
-
_jsx(InvertAllButton, { viewport: props.viewport, categories: categories, filteredCategories: filteredCategories, density: props.density }, "invert-all-btn"),
|
|
76
|
+
_jsx(ShowAllButton, { viewport: props.viewport, categories: categories, filteredCategories: filteredCategories, density: props.density, onFeatureUsed: props.onFeatureUsed }, "show-all-btn"),
|
|
77
|
+
_jsx(HideAllButton, { viewport: props.viewport, categories: categories, filteredCategories: filteredCategories, density: props.density, onFeatureUsed: props.onFeatureUsed }, "hide-all-btn"),
|
|
78
|
+
_jsx(InvertAllButton, { viewport: props.viewport, categories: categories, filteredCategories: filteredCategories, density: props.density, onFeatureUsed: props.onFeatureUsed }, "invert-all-btn"),
|
|
79
79
|
] }), _jsx("div", { className: contentClassName, children: _jsx(AutoSizer, { children: ({ width, height }) => (_jsx(CategoryTree, { ...props, categories: categories, width: width, height: height, filterInfo: { filter: filterString, activeMatchIndex: searchOptions.activeMatchIndex }, onFilterApplied: onFilterApplied, activeView: props.viewport })) }) })] }));
|
|
80
80
|
}
|
|
81
81
|
async function getFilteredCategories(filteredProvider) {
|
|
@@ -96,12 +96,21 @@ async function getFilteredCategories(filteredProvider) {
|
|
|
96
96
|
return filteredCategories;
|
|
97
97
|
}
|
|
98
98
|
function ShowAllButton(props) {
|
|
99
|
-
return (_jsx(IconButton, { size: props.density === "enlarged" ? "large" : "small", styleType: "borderless", title: TreeWidget.translate("showAll"), onClick: () =>
|
|
99
|
+
return (_jsx(IconButton, { size: props.density === "enlarged" ? "large" : "small", styleType: "borderless", title: TreeWidget.translate("showAll"), onClick: () => {
|
|
100
|
+
props.onFeatureUsed?.(`${CategoriesTreeComponent.id}-showall`);
|
|
101
|
+
void showAllCategories((props.filteredCategories ?? props.categories).map((category) => category.categoryId), props.viewport);
|
|
102
|
+
}, children: _jsx(SvgVisibilityShow, {}) }));
|
|
100
103
|
}
|
|
101
104
|
function HideAllButton(props) {
|
|
102
|
-
return (_jsx(IconButton, { size: props.density === "enlarged" ? "large" : "small", styleType: "borderless", title: TreeWidget.translate("hideAll"), onClick: () =>
|
|
105
|
+
return (_jsx(IconButton, { size: props.density === "enlarged" ? "large" : "small", styleType: "borderless", title: TreeWidget.translate("hideAll"), onClick: () => {
|
|
106
|
+
props.onFeatureUsed?.(`${CategoriesTreeComponent.id}-hideall`);
|
|
107
|
+
void hideAllCategories((props.filteredCategories ?? props.categories).map((category) => category.categoryId), props.viewport);
|
|
108
|
+
}, children: _jsx(SvgVisibilityHide, {}) }));
|
|
103
109
|
}
|
|
104
110
|
function InvertAllButton(props) {
|
|
105
|
-
return (_jsx(IconButton, { title: TreeWidget.translate("invert"), size: props.density === "enlarged" ? "large" : "small", styleType: "borderless", onClick: () =>
|
|
111
|
+
return (_jsx(IconButton, { title: TreeWidget.translate("invert"), size: props.density === "enlarged" ? "large" : "small", styleType: "borderless", onClick: () => {
|
|
112
|
+
props.onFeatureUsed?.(`${CategoriesTreeComponent.id}-invert`);
|
|
113
|
+
void invertAllCategories(props.filteredCategories ?? props.categories, props.viewport);
|
|
114
|
+
}, children: _jsx(SvgVisibilityHalf, {}) }));
|
|
106
115
|
}
|
|
107
116
|
//# sourceMappingURL=CategoriesTreeComponent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CategoriesTreeComponent.js","sourceRoot":"","sources":["../../../../../src/components/trees/category-tree/CategoriesTreeComponent.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,4BAA4B,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAClF,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACrG,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAOlJ,OAAO,UAAU,MAAM,YAAY,CAAC;AAoCpC;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,KAAmC,EAAE,EAAE;IAC7E,MAAM,MAAM,GAAG,y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AK,CAAC,UAAU,EAAE,KAAK,CAAC,QAAQ,CAAC,YAErG,KAAC,iBAAiB,KAAG,GACV,CACd,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport \"../VisibilityTreeBase.scss\";\nimport { Fragment, useEffect, useState } from \"react\";\nimport { useActiveIModelConnection, useActiveViewport } from \"@itwin/appui-react\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { SvgVisibilityHalf, SvgVisibilityHide, SvgVisibilityShow } from \"@itwin/itwinui-icons-react\";\nimport { IconButton } from \"@itwin/itwinui-react\";\nimport { isPresentationTreeNodeItem } from \"@itwin/presentation-components\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { TreeHeader } from \"../../tree-header/TreeHeader\";\nimport { useTreeFilteringState } from \"../../TreeFilteringState\";\nimport { AutoSizer } from \"../../utils/AutoSizer\";\nimport { CategoryTree } from \"./CategoriesTree\";\nimport { CategoryVisibilityHandler, hideAllCategories, invertAllCategories, showAllCategories, useCategories } from \"./CategoryVisibilityHandler\";\n\nimport type { IModelConnection, ScreenViewport } from \"@itwin/core-frontend\";\nimport type { IPresentationTreeDataProvider } from \"@itwin/presentation-components\";\nimport type { TreeHeaderButtonProps } from \"../../tree-header/TreeHeader\";\nimport type { CategoryTreeProps } from \"./CategoriesTree\";\nimport type { CategoryInfo } from \"./CategoryVisibilityHandler\";\nimport classNames from \"classnames\";\n\n/**\n * Props that get passed to [[CategoriesTreeComponent]] header button renderer.\n * @see CategoriesTreeComponentProps.headerButtons\n * @public\n */\nexport interface CategoriesTreeHeaderButtonProps extends TreeHeaderButtonProps {\n /** A list of categories available in the iModel */\n categories: CategoryInfo[];\n /** In case the tree is filtered, a list of filtered categories. */\n filteredCategories?: CategoryInfo[];\n}\n\n/**\n * Props for [[CategoriesTreeComponent]].\n * @public\n */\nexport interface CategoriesTreeComponentProps\n extends Omit<\n CategoryTreeProps,\n \"iModel\" | \"activeView\" | \"width\" | \"height\" | \"filterInfo\" | \"onFilterApplied\" | \"categories\" | \"categoryVisibilityHandler\" | \"viewManager\"\n > {\n /**\n * Renderers of header buttons. Defaults to:\n * ```ts\n * [\n * CategoriesTreeComponent.ShowAllButton,\n * CategoriesTreeComponent.HideAllButton,\n * CategoriesTreeComponent.InvertAllButton,\n * ]\n * ```\n */\n headerButtons?: Array<(props: CategoriesTreeHeaderButtonProps) => React.ReactNode>;\n}\n\n/**\n * A component that renders [[CategoriesTree]] and a header with filtering capabilities\n * and header buttons.\n * @public\n */\nexport const CategoriesTreeComponent = (props: CategoriesTreeComponentProps) => {\n const iModel = useActiveIModelConnection();\n const viewport = useActiveViewport();\n\n if (!iModel || !viewport) {\n return null;\n }\n\n return <CategoriesTreeComponentImpl {...props} iModel={iModel} viewport={viewport} />;\n};\n\n/**\n * Renders a \"Show all\" button that enables display of all categories and their subcategories.\n * @public\n */\nCategoriesTreeComponent.ShowAllButton = ShowAllButton;\n\n/**\n * Renders a \"Hide all\" button that disables display of all categories.\n * @public\n */\nCategoriesTreeComponent.HideAllButton = HideAllButton;\n\n/**\n * Renders an \"Invert all\" button that inverts display of all categories.\n * @public\n */\nCategoriesTreeComponent.InvertAllButton = InvertAllButton;\n\n/**\n * Id of the component. May be used when a creating a [[TreeDefinition]] for [[SelectableTree]].\n * @public\n */\nCategoriesTreeComponent.id = \"categories-tree\";\n\n/**\n * Label of the component. May be used when a creating a [[TreeDefinition]] for [[SelectableTree]].\n * @public\n */\nCategoriesTreeComponent.getLabel = () => TreeWidget.translate(\"categories\");\n\nfunction CategoriesTreeComponentImpl(props: CategoriesTreeComponentProps & { iModel: IModelConnection; viewport: ScreenViewport }) {\n const categories = useCategories(IModelApp.viewManager, props.iModel, props.viewport);\n const [filteredCategories, setFilteredCategories] = useState<CategoryInfo[]>();\n const { searchOptions, filterString, onFilterApplied, filteredProvider } = useTreeFilteringState();\n const contentClassName = classNames(\"tree-widget-tree-content\", props.density === \"enlarged\" && \"enlarge\");\n\n useEffect(() => {\n void (async () => {\n if (filteredProvider) {\n setFilteredCategories(await getFilteredCategories(filteredProvider));\n } else {\n setFilteredCategories(undefined);\n }\n })();\n }, [filteredProvider]);\n\n return (\n <div className=\"tree-widget-tree-with-header\">\n <TreeHeader\n onFilterClear={searchOptions.onFilterCancel}\n onFilterStart={searchOptions.onFilterStart}\n onSelectedChanged={searchOptions.onResultSelectedChanged}\n resultCount={searchOptions.matchedResultCount}\n selectedIndex={searchOptions.activeMatchIndex}\n density={props.density}\n >\n {props.headerButtons\n ? props.headerButtons.map((btn, index) => <Fragment key={index}>{btn({ viewport: props.viewport, categories, filteredCategories })}</Fragment>)\n : [\n <ShowAllButton\n viewport={props.viewport}\n categories={categories}\n filteredCategories={filteredCategories}\n key=\"show-all-btn\"\n density={props.density}\n />,\n <HideAllButton\n viewport={props.viewport}\n categories={categories}\n filteredCategories={filteredCategories}\n key=\"hide-all-btn\"\n density={props.density}\n />,\n <InvertAllButton\n viewport={props.viewport}\n categories={categories}\n filteredCategories={filteredCategories}\n key=\"invert-all-btn\"\n density={props.density}\n />,\n ]}\n </TreeHeader>\n <div className={contentClassName}>\n <AutoSizer>\n {({ width, height }) => (\n <CategoryTree\n {...props}\n categories={categories}\n width={width}\n height={height}\n filterInfo={{ filter: filterString, activeMatchIndex: searchOptions.activeMatchIndex }}\n onFilterApplied={onFilterApplied}\n activeView={props.viewport}\n />\n )}\n </AutoSizer>\n </div>\n </div>\n );\n}\n\nasync function getFilteredCategories(filteredProvider: IPresentationTreeDataProvider) {\n const filteredCategories: CategoryInfo[] = [];\n const nodes = await filteredProvider.getNodes();\n for (const node of nodes) {\n if (!isPresentationTreeNodeItem(node)) {\n continue;\n }\n const filteredCategoryId = CategoryVisibilityHandler.getInstanceIdFromTreeNodeKey(node.key);\n const filteredSubCategoriesIds = node.hasChildren\n ? (await filteredProvider.getNodes(node))\n .filter(isPresentationTreeNodeItem)\n .map((child) => CategoryVisibilityHandler.getInstanceIdFromTreeNodeKey(child.key))\n : [];\n filteredCategories.push({ categoryId: filteredCategoryId, subCategoryIds: filteredSubCategoriesIds });\n }\n return filteredCategories;\n}\n\nfunction ShowAllButton(props: CategoriesTreeHeaderButtonProps) {\n return (\n <IconButton\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"showAll\")}\n onClick={() =>\n void showAllCategories(\n (props.filteredCategories ?? props.categories).map((category) => category.categoryId),\n props.viewport,\n )\n }\n >\n <SvgVisibilityShow />\n </IconButton>\n );\n}\n\nfunction HideAllButton(props: CategoriesTreeHeaderButtonProps) {\n return (\n <IconButton\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"hideAll\")}\n onClick={() =>\n void hideAllCategories(\n (props.filteredCategories ?? props.categories).map((category) => category.categoryId),\n props.viewport,\n )\n }\n >\n <SvgVisibilityHide />\n </IconButton>\n );\n}\n\nfunction InvertAllButton(props: CategoriesTreeHeaderButtonProps) {\n return (\n <IconButton\n title={TreeWidget.translate(\"invert\")}\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n onClick={() => void invertAllCategories(props.filteredCategories ?? props.categories, props.viewport)}\n >\n <SvgVisibilityHalf />\n </IconButton>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CategoriesTreeComponent.js","sourceRoot":"","sources":["../../../../../src/components/trees/category-tree/CategoriesTreeComponent.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,4BAA4B,CAAC;AACpC,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAClF,OAAO,EAAE,S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AAC,iBAAiB,KAAG,GACV,CACd,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport \"../VisibilityTreeBase.scss\";\nimport classNames from \"classnames\";\nimport { Fragment, useEffect, useState } from \"react\";\nimport { useActiveIModelConnection, useActiveViewport } from \"@itwin/appui-react\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { SvgVisibilityHalf, SvgVisibilityHide, SvgVisibilityShow } from \"@itwin/itwinui-icons-react\";\nimport { IconButton } from \"@itwin/itwinui-react\";\nimport { isPresentationTreeNodeItem } from \"@itwin/presentation-components\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { TreeHeader } from \"../../tree-header/TreeHeader\";\nimport { useTreeFilteringState } from \"../../TreeFilteringState\";\nimport { AutoSizer } from \"../../utils/AutoSizer\";\nimport { CategoryTree } from \"./CategoriesTree\";\nimport { CategoryVisibilityHandler, hideAllCategories, invertAllCategories, showAllCategories, useCategories } from \"./CategoryVisibilityHandler\";\n\nimport type { IModelConnection, ScreenViewport } from \"@itwin/core-frontend\";\nimport type { IPresentationTreeDataProvider } from \"@itwin/presentation-components\";\nimport type { TreeHeaderButtonProps } from \"../../tree-header/TreeHeader\";\nimport type { CategoryTreeProps } from \"./CategoriesTree\";\nimport type { CategoryInfo } from \"./CategoryVisibilityHandler\";\n/**\n * Props that get passed to [[CategoriesTreeComponent]] header button renderer.\n * @see CategoriesTreeComponentProps.headerButtons\n * @public\n */\nexport interface CategoriesTreeHeaderButtonProps extends TreeHeaderButtonProps {\n /** A list of categories available in the iModel */\n categories: CategoryInfo[];\n /** In case the tree is filtered, a list of filtered categories. */\n filteredCategories?: CategoryInfo[];\n}\n\n/**\n * Props for [[CategoriesTreeComponent]].\n * @public\n */\nexport interface CategoriesTreeComponentProps\n extends Omit<\n CategoryTreeProps,\n \"iModel\" | \"activeView\" | \"width\" | \"height\" | \"filterInfo\" | \"onFilterApplied\" | \"categories\" | \"categoryVisibilityHandler\" | \"viewManager\"\n > {\n /**\n * Renderers of header buttons. Defaults to:\n * ```ts\n * [\n * CategoriesTreeComponent.ShowAllButton,\n * CategoriesTreeComponent.HideAllButton,\n * CategoriesTreeComponent.InvertAllButton,\n * ]\n * ```\n */\n headerButtons?: Array<(props: CategoriesTreeHeaderButtonProps) => React.ReactNode>;\n}\n\n/**\n * A component that renders [[CategoriesTree]] and a header with filtering capabilities\n * and header buttons.\n * @public\n */\nexport const CategoriesTreeComponent = (props: CategoriesTreeComponentProps) => {\n const iModel = useActiveIModelConnection();\n const viewport = useActiveViewport();\n\n if (!iModel || !viewport) {\n return null;\n }\n\n return <CategoriesTreeComponentImpl {...props} iModel={iModel} viewport={viewport} />;\n};\n\n/**\n * Renders a \"Show all\" button that enables display of all categories and their subcategories.\n * @public\n */\nCategoriesTreeComponent.ShowAllButton = ShowAllButton;\n\n/**\n * Renders a \"Hide all\" button that disables display of all categories.\n * @public\n */\nCategoriesTreeComponent.HideAllButton = HideAllButton;\n\n/**\n * Renders an \"Invert all\" button that inverts display of all categories.\n * @public\n */\nCategoriesTreeComponent.InvertAllButton = InvertAllButton;\n\n/**\n * Id of the component. May be used when a creating a [[TreeDefinition]] for [[SelectableTree]].\n * @public\n */\nCategoriesTreeComponent.id = \"categories-tree\";\n\n/**\n * Label of the component. May be used when a creating a [[TreeDefinition]] for [[SelectableTree]].\n * @public\n */\nCategoriesTreeComponent.getLabel = () => TreeWidget.translate(\"categories\");\n\nfunction CategoriesTreeComponentImpl(props: CategoriesTreeComponentProps & { iModel: IModelConnection; viewport: ScreenViewport }) {\n const categories = useCategories(IModelApp.viewManager, props.iModel, props.viewport);\n const [filteredCategories, setFilteredCategories] = useState<CategoryInfo[]>();\n const { searchOptions, filterString, onFilterApplied, filteredProvider } = useTreeFilteringState();\n const contentClassName = classNames(\"tree-widget-tree-content\", props.density === \"enlarged\" && \"enlarge\");\n\n useEffect(() => {\n void (async () => {\n if (filteredProvider) {\n setFilteredCategories(await getFilteredCategories(filteredProvider));\n } else {\n setFilteredCategories(undefined);\n }\n })();\n }, [filteredProvider]);\n\n return (\n <div className=\"tree-widget-tree-with-header\">\n <TreeHeader\n onFilterClear={searchOptions.onFilterCancel}\n onFilterStart={searchOptions.onFilterStart}\n onSelectedChanged={searchOptions.onResultSelectedChanged}\n resultCount={searchOptions.matchedResultCount}\n selectedIndex={searchOptions.activeMatchIndex}\n density={props.density}\n >\n {props.headerButtons\n ? props.headerButtons.map((btn, index) => (\n <Fragment key={index}>\n {btn({ viewport: props.viewport, categories, filteredCategories, density: props.density, onFeatureUsed: props.onFeatureUsed })}\n </Fragment>\n ))\n : [\n <ShowAllButton\n viewport={props.viewport}\n categories={categories}\n filteredCategories={filteredCategories}\n key=\"show-all-btn\"\n density={props.density}\n onFeatureUsed={props.onFeatureUsed}\n />,\n <HideAllButton\n viewport={props.viewport}\n categories={categories}\n filteredCategories={filteredCategories}\n key=\"hide-all-btn\"\n density={props.density}\n onFeatureUsed={props.onFeatureUsed}\n />,\n <InvertAllButton\n viewport={props.viewport}\n categories={categories}\n filteredCategories={filteredCategories}\n key=\"invert-all-btn\"\n density={props.density}\n onFeatureUsed={props.onFeatureUsed}\n />,\n ]}\n </TreeHeader>\n <div className={contentClassName}>\n <AutoSizer>\n {({ width, height }) => (\n <CategoryTree\n {...props}\n categories={categories}\n width={width}\n height={height}\n filterInfo={{ filter: filterString, activeMatchIndex: searchOptions.activeMatchIndex }}\n onFilterApplied={onFilterApplied}\n activeView={props.viewport}\n />\n )}\n </AutoSizer>\n </div>\n </div>\n );\n}\n\nasync function getFilteredCategories(filteredProvider: IPresentationTreeDataProvider) {\n const filteredCategories: CategoryInfo[] = [];\n const nodes = await filteredProvider.getNodes();\n for (const node of nodes) {\n if (!isPresentationTreeNodeItem(node)) {\n continue;\n }\n const filteredCategoryId = CategoryVisibilityHandler.getInstanceIdFromTreeNodeKey(node.key);\n const filteredSubCategoriesIds = node.hasChildren\n ? (await filteredProvider.getNodes(node))\n .filter(isPresentationTreeNodeItem)\n .map((child) => CategoryVisibilityHandler.getInstanceIdFromTreeNodeKey(child.key))\n : [];\n filteredCategories.push({ categoryId: filteredCategoryId, subCategoryIds: filteredSubCategoriesIds });\n }\n return filteredCategories;\n}\n\nfunction ShowAllButton(props: CategoriesTreeHeaderButtonProps) {\n return (\n <IconButton\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"showAll\")}\n onClick={() => {\n props.onFeatureUsed?.(`${CategoriesTreeComponent.id}-showall`);\n void showAllCategories(\n (props.filteredCategories ?? props.categories).map((category) => category.categoryId),\n props.viewport,\n );\n }}\n >\n <SvgVisibilityShow />\n </IconButton>\n );\n}\n\nfunction HideAllButton(props: CategoriesTreeHeaderButtonProps) {\n return (\n <IconButton\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n title={TreeWidget.translate(\"hideAll\")}\n onClick={() => {\n props.onFeatureUsed?.(`${CategoriesTreeComponent.id}-hideall`);\n void hideAllCategories(\n (props.filteredCategories ?? props.categories).map((category) => category.categoryId),\n props.viewport,\n );\n }}\n >\n <SvgVisibilityHide />\n </IconButton>\n );\n}\n\nfunction InvertAllButton(props: CategoriesTreeHeaderButtonProps) {\n return (\n <IconButton\n title={TreeWidget.translate(\"invert\")}\n size={props.density === \"enlarged\" ? \"large\" : \"small\"}\n styleType=\"borderless\"\n onClick={() => {\n props.onFeatureUsed?.(`${CategoriesTreeComponent.id}-invert`);\n void invertAllCategories(props.filteredCategories ?? props.categories, props.viewport);\n }}\n >\n <SvgVisibilityHalf />\n </IconButton>\n );\n}\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { TreeEventHandler } from "@itwin/components-react";
|
|
2
|
+
import type { AbstractTreeNodeLoaderWithProvider, TreeCheckboxStateChangeEventArgs, TreeNodeEventArgs, TreeSelectionModificationEventArgs, TreeSelectionReplacementEventArgs } from "@itwin/components-react";
|
|
3
|
+
import type { IPresentationTreeDataProvider } from "@itwin/presentation-components";
|
|
4
|
+
export interface ReportingTreeEventHandlerProps {
|
|
5
|
+
nodeLoader: AbstractTreeNodeLoaderWithProvider<IPresentationTreeDataProvider>;
|
|
6
|
+
eventHandler: TreeEventHandler;
|
|
7
|
+
reportUsage: (props: {
|
|
8
|
+
reportInteraction: boolean;
|
|
9
|
+
}) => void;
|
|
10
|
+
}
|
|
11
|
+
export declare class ReportingTreeEventHandler extends TreeEventHandler {
|
|
12
|
+
protected _eventHandler: TreeEventHandler;
|
|
13
|
+
protected _reportUsage: (props: {
|
|
14
|
+
reportInteraction: boolean;
|
|
15
|
+
}) => void;
|
|
16
|
+
constructor(props: ReportingTreeEventHandlerProps);
|
|
17
|
+
dispose(): void;
|
|
18
|
+
onNodeExpanded(props: TreeNodeEventArgs): void;
|
|
19
|
+
onNodeCollapsed(props: TreeNodeEventArgs): void;
|
|
20
|
+
onSelectionModified(props: TreeSelectionModificationEventArgs): import("@itwin/components-react").Subscription | undefined;
|
|
21
|
+
onSelectionReplaced(props: TreeSelectionReplacementEventArgs): import("@itwin/components-react").Subscription | undefined;
|
|
22
|
+
onCheckboxStateChanged(props: TreeCheckboxStateChangeEventArgs): import("@itwin/components-react").Subscription | undefined;
|
|
23
|
+
onDelayedNodeClick(props: TreeNodeEventArgs): void;
|
|
24
|
+
onNodeDoubleClick(props: TreeNodeEventArgs): void;
|
|
25
|
+
onNodeEditorActivated(props: TreeNodeEventArgs): void;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=ReportingTreeEventHandler.d.ts.map
|
|
@@ -0,0 +1,47 @@
|
|
|
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 { TreeEventHandler } from "@itwin/components-react";
|
|
6
|
+
export class ReportingTreeEventHandler extends TreeEventHandler {
|
|
7
|
+
constructor(props) {
|
|
8
|
+
super({ modelSource: props.nodeLoader.modelSource, nodeLoader: props.nodeLoader });
|
|
9
|
+
this._eventHandler = props.eventHandler;
|
|
10
|
+
this._reportUsage = props.reportUsage;
|
|
11
|
+
}
|
|
12
|
+
dispose() {
|
|
13
|
+
this._eventHandler.dispose();
|
|
14
|
+
super.dispose();
|
|
15
|
+
}
|
|
16
|
+
onNodeExpanded(props) {
|
|
17
|
+
this._reportUsage({ reportInteraction: true });
|
|
18
|
+
this._eventHandler.onNodeExpanded(props);
|
|
19
|
+
}
|
|
20
|
+
onNodeCollapsed(props) {
|
|
21
|
+
this._reportUsage({ reportInteraction: true });
|
|
22
|
+
this._eventHandler.onNodeCollapsed(props);
|
|
23
|
+
}
|
|
24
|
+
onSelectionModified(props) {
|
|
25
|
+
this._reportUsage({ reportInteraction: true });
|
|
26
|
+
return this._eventHandler.onSelectionModified(props);
|
|
27
|
+
}
|
|
28
|
+
onSelectionReplaced(props) {
|
|
29
|
+
this._reportUsage({ reportInteraction: true });
|
|
30
|
+
return this._eventHandler.onSelectionReplaced(props);
|
|
31
|
+
}
|
|
32
|
+
onCheckboxStateChanged(props) {
|
|
33
|
+
return this._eventHandler.onCheckboxStateChanged(props);
|
|
34
|
+
}
|
|
35
|
+
onDelayedNodeClick(props) {
|
|
36
|
+
this._eventHandler.onDelayedNodeClick(props);
|
|
37
|
+
}
|
|
38
|
+
onNodeDoubleClick(props) {
|
|
39
|
+
this._reportUsage({ reportInteraction: true });
|
|
40
|
+
this._eventHandler.onNodeDoubleClick(props);
|
|
41
|
+
}
|
|
42
|
+
onNodeEditorActivated(props) {
|
|
43
|
+
this._reportUsage({ reportInteraction: true });
|
|
44
|
+
this._eventHandler.onNodeEditorActivated(props);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=ReportingTreeEventHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReportingTreeEventHandler.js","sourceRoot":"","sources":["../../../../../src/components/trees/common/ReportingTreeEventHandler.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAgB3D,MAAM,OAAO,yBAA0B,SAAQ,gBAAgB;IAI7D,YAAY,KAAqC;QAC/C,KAAK,CAAC,EAAE,WAAW,EAAE,KAAK,CAAC,UAAU,CAAC,WAAW,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC;QACnF,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,YAAY,CAAC;QACxC,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,WAAW,CAAC;IACxC,CAAC;IAEM,OAAO;QACZ,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC;QAC7B,KAAK,CAAC,OAAO,EAAE,CAAC;IAClB,CAAC;IAEe,cAAc,CAAC,KAAwB;QACrD,IAAI,CAAC,YAAY,CAAC,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/C,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;IAEe,eAAe,CAAC,KAAwB;QACtD,IAAI,CAAC,YAAY,CAAC,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/C,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;IAC5C,CAAC;IAEe,mBAAmB,CAAC,KAAyC;QAC3E,IAAI,CAAC,YAAY,CAAC,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/C,OAAO,IAAI,CAAC,aAAa,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;IACvD,CAAC;IAEe,mBAAmB,CAAC,KAAwC;QAC1E,IAAI,CAAC,YAAY,CAAC,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/C,OAAO,IAAI,CAAC,aAAa,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;IACvD,CAAC;IAEe,sBAAsB,CAAC,KAAuC;QAC5E,OAAO,IAAI,CAAC,aAAa,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC;IAC1D,CAAC;IAEe,kBAAkB,CAAC,KAAwB;QACzD,IAAI,CAAC,aAAa,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;IAC/C,CAAC;IAEe,iBAAiB,CAAC,KAAwB;QACxD,IAAI,CAAC,YAAY,CAAC,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/C,IAAI,CAAC,aAAa,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAC9C,CAAC;IAEe,qBAAqB,CAAC,KAAwB;QAC5D,IAAI,CAAC,YAAY,CAAC,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/C,IAAI,CAAC,aAAa,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC;IAClD,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 { TreeEventHandler } from \"@itwin/components-react\";\n\nimport type {\n AbstractTreeNodeLoaderWithProvider,\n TreeCheckboxStateChangeEventArgs,\n TreeNodeEventArgs,\n TreeSelectionModificationEventArgs,\n TreeSelectionReplacementEventArgs,\n} from \"@itwin/components-react\";\nimport type { IPresentationTreeDataProvider } from \"@itwin/presentation-components\";\nexport interface ReportingTreeEventHandlerProps {\n nodeLoader: AbstractTreeNodeLoaderWithProvider<IPresentationTreeDataProvider>;\n eventHandler: TreeEventHandler;\n reportUsage: (props: { reportInteraction: boolean }) => void;\n}\n\nexport class ReportingTreeEventHandler extends TreeEventHandler {\n protected _eventHandler: TreeEventHandler;\n protected _reportUsage: (props: { reportInteraction: boolean }) => void;\n\n constructor(props: ReportingTreeEventHandlerProps) {\n super({ modelSource: props.nodeLoader.modelSource, nodeLoader: props.nodeLoader });\n this._eventHandler = props.eventHandler;\n this._reportUsage = props.reportUsage;\n }\n\n public dispose() {\n this._eventHandler.dispose();\n super.dispose();\n }\n\n public override onNodeExpanded(props: TreeNodeEventArgs) {\n this._reportUsage({ reportInteraction: true });\n this._eventHandler.onNodeExpanded(props);\n }\n\n public override onNodeCollapsed(props: TreeNodeEventArgs) {\n this._reportUsage({ reportInteraction: true });\n this._eventHandler.onNodeCollapsed(props);\n }\n\n public override onSelectionModified(props: TreeSelectionModificationEventArgs) {\n this._reportUsage({ reportInteraction: true });\n return this._eventHandler.onSelectionModified(props);\n }\n\n public override onSelectionReplaced(props: TreeSelectionReplacementEventArgs) {\n this._reportUsage({ reportInteraction: true });\n return this._eventHandler.onSelectionReplaced(props);\n }\n\n public override onCheckboxStateChanged(props: TreeCheckboxStateChangeEventArgs) {\n return this._eventHandler.onCheckboxStateChanged(props);\n }\n\n public override onDelayedNodeClick(props: TreeNodeEventArgs) {\n this._eventHandler.onDelayedNodeClick(props);\n }\n\n public override onNodeDoubleClick(props: TreeNodeEventArgs) {\n this._reportUsage({ reportInteraction: true });\n this._eventHandler.onNodeDoubleClick(props);\n }\n\n public override onNodeEditorActivated(props: TreeNodeEventArgs) {\n this._reportUsage({ reportInteraction: true });\n this._eventHandler.onNodeEditorActivated(props);\n }\n}\n"]}
|