@itwin/tree-widget-react 0.6.0 → 0.6.2

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.
Files changed (45) hide show
  1. package/lib/cjs/components/trees/CategoriesVisibilityUtils.d.ts +20 -0
  2. package/lib/cjs/components/trees/CategoriesVisibilityUtils.js +121 -0
  3. package/lib/cjs/components/trees/CategoriesVisibilityUtils.js.map +1 -0
  4. package/lib/cjs/components/trees/VisibilityTreeEventHandler.d.ts +1 -0
  5. package/lib/cjs/components/trees/VisibilityTreeEventHandler.js +19 -4
  6. package/lib/cjs/components/trees/VisibilityTreeEventHandler.js.map +1 -1
  7. package/lib/cjs/components/trees/category-tree/Categories.json +1 -0
  8. package/lib/cjs/components/trees/category-tree/CategoriesTree.d.ts +0 -10
  9. package/lib/cjs/components/trees/category-tree/CategoriesTree.js +1 -28
  10. package/lib/cjs/components/trees/category-tree/CategoriesTree.js.map +1 -1
  11. package/lib/cjs/components/trees/category-tree/CategoriesTreeComponent.js +10 -5
  12. package/lib/cjs/components/trees/category-tree/CategoriesTreeComponent.js.map +1 -1
  13. package/lib/cjs/components/trees/category-tree/CategoryVisibilityHandler.d.ts +2 -6
  14. package/lib/cjs/components/trees/category-tree/CategoryVisibilityHandler.js +10 -87
  15. package/lib/cjs/components/trees/category-tree/CategoryVisibilityHandler.js.map +1 -1
  16. package/lib/cjs/components/trees/models-tree/Hierarchy.GroupedByClass.json +1 -2
  17. package/lib/cjs/components/trees/models-tree/Hierarchy.json +1 -2
  18. package/lib/cjs/components/trees/models-tree/ModelsTree.d.ts +0 -6
  19. package/lib/cjs/components/trees/models-tree/ModelsTree.js +4 -22
  20. package/lib/cjs/components/trees/models-tree/ModelsTree.js.map +1 -1
  21. package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.js +13 -3
  22. package/lib/cjs/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
  23. package/lib/esm/components/trees/CategoriesVisibilityUtils.d.ts +20 -0
  24. package/lib/esm/components/trees/CategoriesVisibilityUtils.js +113 -0
  25. package/lib/esm/components/trees/CategoriesVisibilityUtils.js.map +1 -0
  26. package/lib/esm/components/trees/VisibilityTreeEventHandler.d.ts +1 -0
  27. package/lib/esm/components/trees/VisibilityTreeEventHandler.js +19 -4
  28. package/lib/esm/components/trees/VisibilityTreeEventHandler.js.map +1 -1
  29. package/lib/esm/components/trees/category-tree/Categories.json +1 -0
  30. package/lib/esm/components/trees/category-tree/CategoriesTree.d.ts +0 -10
  31. package/lib/esm/components/trees/category-tree/CategoriesTree.js +1 -26
  32. package/lib/esm/components/trees/category-tree/CategoriesTree.js.map +1 -1
  33. package/lib/esm/components/trees/category-tree/CategoriesTreeComponent.js +11 -6
  34. package/lib/esm/components/trees/category-tree/CategoriesTreeComponent.js.map +1 -1
  35. package/lib/esm/components/trees/category-tree/CategoryVisibilityHandler.d.ts +2 -6
  36. package/lib/esm/components/trees/category-tree/CategoryVisibilityHandler.js +8 -84
  37. package/lib/esm/components/trees/category-tree/CategoryVisibilityHandler.js.map +1 -1
  38. package/lib/esm/components/trees/models-tree/Hierarchy.GroupedByClass.json +1 -2
  39. package/lib/esm/components/trees/models-tree/Hierarchy.json +1 -2
  40. package/lib/esm/components/trees/models-tree/ModelsTree.d.ts +0 -6
  41. package/lib/esm/components/trees/models-tree/ModelsTree.js +4 -22
  42. package/lib/esm/components/trees/models-tree/ModelsTree.js.map +1 -1
  43. package/lib/esm/components/trees/models-tree/ModelsTreeComponent.js +13 -3
  44. package/lib/esm/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
  45. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CategoriesVisibilityUtils.js","sourceRoot":"","sources":["../../../../src/components/trees/CategoriesVisibilityUtils.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAIlE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,C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,MAAM,EAAE;QACV,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,SAAS,EAAE,cAAc,CAAC,kBAAkB,EAAE,CAAC,CAAC;QACtG,uBAAuB;QACvB,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,WAAW,EAAE;YACnC,MAAM,cAAc,GAAG,MAAM,CAAC,aAAa,CAAC,gBAAgB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACrE,UAAU,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,QAAQ,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC;SAChG;KACF;IAED,OAAO,UAAU,CAAC;AACpB,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*--------------------------------------------------------------------------------------------*/\nimport { PerModelCategoryVisibility } from \"@itwin/core-frontend\";\nimport type { IModelConnection, ViewManager, Viewport } from \"@itwin/core-frontend\";\nimport type { Category } from \"./category-tree/CategoryVisibilityHandler\";\nimport type { Id64String } from \"@itwin/core-bentley\";\nimport { QueryRowFormat } from \"@itwin/core-common\";\n\nconst EMPTY_CATEGORIES_ARRAY: Category[] = [];\n\n/**\n * Toggles visibility of categories to show or hide.\n * @alpha\n */\nexport async function toggleAllCategories(viewManager: ViewManager, imodel: IModelConnection, display: boolean, viewport?: Viewport, forAllViewports?: boolean, categoryIds?: Id64String[]) {\n if (categoryIds) {\n enableCategory(viewManager, imodel, categoryIds, display, forAllViewports ?? false);\n }\n\n // istanbul ignore next\n const activeView = viewport ?? viewManager.getFirstOpenView();\n const ids = await getCategories(imodel, activeView);\n\n // istanbul ignore else\n if (ids.length > 0) {\n enableCategory(viewManager, imodel, ids, display, forAllViewports ?? false);\n }\n}\n\n/**\n * Gets ids of all categories from specified imodel and viewport.\n * @alpha\n */\nexport async function getCategories(imodel: IModelConnection, viewport?: Viewport) {\n const categories = await loadCategoriesFromViewport(imodel, viewport);\n return categories.map((category) => category.key);\n}\n\n/** Changes category display in the viewport */\nexport function enableCategory(viewManager: ViewManager, imodel: IModelConnection, ids: string[], enabled: boolean, forAllViewports: boolean, enableAllSubCategories = true) {\n if (!viewManager.selectedView)\n return;\n\n const updateViewport = (vp: Viewport) => {\n // Only act on viewports that are both 3D or both 2D. Important if we have multiple viewports opened and we\n // are using 'allViewports' property\n if (viewManager.selectedView && viewManager.selectedView.view.is3d() === vp.view.is3d()) {\n vp.changeCategoryDisplay(ids, enabled, enableAllSubCategories);\n\n // remove category overrides per model\n const modelsContainingOverrides: string[] = [];\n for (const ovr of vp.perModelCategoryVisibility) {\n // istanbul ignore else\n if (ids.findIndex((id) => id === ovr.categoryId) !== -1)\n modelsContainingOverrides.push(ovr.modelId);\n }\n vp.perModelCategoryVisibility.setOverride(modelsContainingOverrides, ids, PerModelCategoryVisibility.Override.None);\n\n // changeCategoryDisplay only enables subcategories, it does not disabled them. So we must do that ourselves.\n if (false === enabled) {\n ids.forEach((id) => {\n const subCategoryIds = imodel.subcategories.getSubCategories(id);\n // istanbul ignore else\n if (subCategoryIds) {\n subCategoryIds.forEach((subCategoryId) => enableSubCategory(viewManager, subCategoryId, false, forAllViewports));\n }\n });\n }\n }\n };\n\n // This property let us act on all viewports or just on the selected one, configurable by the app\n if (forAllViewports) {\n for (const viewport of viewManager) {\n updateViewport(viewport);\n }\n } else {\n updateViewport(viewManager.selectedView);\n }\n}\n\n/** Changes subcategory display in the viewport */\nexport function enableSubCategory(viewManager: ViewManager, key: string, enabled: boolean, forAllViewports?: boolean) {\n if (!viewManager.selectedView)\n return;\n\n const updateViewport = (vp: Viewport) => {\n // Only act on viewports that are both 3D or both 2D. Important if we have multiple viewports opened and we\n // are using 'allViewports' property\n if (viewManager.selectedView && viewManager.selectedView.view.is3d() === vp.view.is3d()) {\n vp.changeSubCategoryDisplay(key, enabled);\n }\n };\n\n // This property let us act on all viewports or just on the selected one, configurable by the app\n if (forAllViewports) {\n for (const viewport of viewManager) {\n updateViewport(viewport);\n }\n } else {\n updateViewport(viewManager.selectedView);\n }\n}\n\n/** @internal */\nexport async function loadCategoriesFromViewport(iModel?: IModelConnection, vp?: Viewport) {\n if (!vp)\n return EMPTY_CATEGORIES_ARRAY;\n\n // Query categories and add them to state\n const selectUsedSpatialCategoryIds = \"SELECT DISTINCT Category.Id as id from BisCore.GeometricElement3d WHERE Category.Id IN (SELECT ECInstanceId from BisCore.SpatialCategory)\";\n const selectUsedDrawingCategoryIds = \"SELECT DISTINCT Category.Id as id from BisCore.GeometricElement2d WHERE Model.Id=? AND Category.Id IN (SELECT ECInstanceId from BisCore.DrawingCategory)\";\n const ecsql = vp.view.is3d() ? selectUsedSpatialCategoryIds : selectUsedDrawingCategoryIds;\n const ecsql2 = `SELECT ECInstanceId as id, UserLabel as label, CodeValue as code FROM ${vp.view.is3d() ? \"BisCore.SpatialCategory\" : \"BisCore.DrawingCategory\"} WHERE ECInstanceId IN (${ecsql})`;\n\n const categories: Category[] = [];\n\n // istanbul ignore else\n if (iModel) {\n const rowIterator = iModel.query(ecsql2, undefined, { rowFormat: QueryRowFormat.UseJsPropertyNames });\n // istanbul ignore next\n for await (const row of rowIterator) {\n const subCategoryIds = iModel.subcategories.getSubCategories(row.id);\n categories.push({ key: row.id, children: (subCategoryIds) ? [...subCategoryIds] : undefined });\n }\n }\n\n return categories;\n}\n"]}
@@ -50,6 +50,7 @@ export declare class VisibilityTreeEventHandler extends UnifiedSelectionTreeEven
50
50
  private _visibilityHandler;
51
51
  private _selectionPredicate?;
52
52
  private _listeners;
53
+ private _isChangingVisibility;
53
54
  constructor(params: VisibilityTreeEventHandlerParams);
54
55
  dispose(): void;
55
56
  private filterSelectionItems;
@@ -22,10 +22,17 @@ export class VisibilityTreeEventHandler extends UnifiedSelectionTreeEventHandler
22
22
  this._listeners = new Array();
23
23
  this._visibilityHandler = params.visibilityHandler;
24
24
  this._selectionPredicate = params.selectionPredicate;
25
+ this._isChangingVisibility = false;
25
26
  if (this._visibilityHandler) {
26
- this._listeners.push(this._visibilityHandler.onVisibilityChange.addListener(async (nodeIds, visibilityStatus) => this.updateCheckboxes(nodeIds, visibilityStatus)));
27
+ this._listeners.push(this._visibilityHandler.onVisibilityChange.addListener(async (nodeIds, visibilityStatus) => {
28
+ if (this._isChangingVisibility)
29
+ return;
30
+ void this.updateCheckboxes(nodeIds, visibilityStatus);
31
+ }));
27
32
  }
28
- this._listeners.push(this.modelSource.onModelChanged.addListener(async ([_, changes]) => this.updateCheckboxes([...changes.addedNodeIds, ...changes.modifiedNodeIds])));
33
+ this._listeners.push(this.modelSource.onModelChanged.addListener(async ([_, changes]) => {
34
+ void this.updateCheckboxes([...changes.addedNodeIds, ...changes.modifiedNodeIds]);
35
+ }));
29
36
  this.updateCheckboxes(); // eslint-disable-line @typescript-eslint/no-floating-promises
30
37
  }
31
38
  dispose() {
@@ -56,12 +63,19 @@ export class VisibilityTreeEventHandler extends UnifiedSelectionTreeEventHandler
56
63
  return super.onSelectionReplaced({ replacements: filteredReplacements });
57
64
  }
58
65
  onCheckboxStateChanged(event) {
66
+ const handleStateChanged = () => {
67
+ this._isChangingVisibility = false;
68
+ void this.updateCheckboxes();
69
+ };
59
70
  // istanbul ignore if
60
71
  if (!this._visibilityHandler)
61
72
  return undefined;
62
73
  from(event.stateChanges)
63
74
  .pipe(mergeMap((changes) => this.changeVisibility(changes)))
64
- .subscribe();
75
+ .subscribe({
76
+ complete: handleStateChanged,
77
+ error: handleStateChanged,
78
+ });
65
79
  return undefined;
66
80
  }
67
81
  changeVisibility(changes) {
@@ -70,8 +84,9 @@ export class VisibilityTreeEventHandler extends UnifiedSelectionTreeEventHandler
70
84
  // istanbul ignore if
71
85
  if (!this._visibilityHandler)
72
86
  return EMPTY;
87
+ this._isChangingVisibility = true;
73
88
  return from(this._visibilityHandler.changeVisibility(nodeItem, this.getNodeKey(nodeItem), newState === CheckBoxState.On));
74
- }));
89
+ }, 1));
75
90
  }
76
91
  async updateCheckboxes(affectedNodes, visibilityStatus) {
77
92
  const changes = await (affectedNodes ? this.collectAffectedNodesCheckboxInfos(affectedNodes, visibilityStatus) : this.collectAllNodesCheckboxInfos(visibilityStatus));
@@ -1 +1 @@
1
- {"version":3,"file":"VisibilityTreeEventHandler.js","sourceRoot":"","sources":["../../../../src/components/trees/VisibilityTreeEventHandler.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AACrD,OAAO,EAAE,GAAG,EAAE,MAAM,6BAA6B,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAE,gCAAgC,EAAE,MAAM,gCAAgC,CAAC;AAkDlF;;;GAGG;AACH,MAAM,OAAO,0BAA2B,SAAQ,gCAAgC;IAK9E,YAAY,MAAwC;QAClD,KAAK,CAAC,MAAM,CAAC,CAAC;QAHR,eAAU,GAAG,IAAI,KAAK,EAAc,CAAC;QAI3C,IAAI,CAAC,kBAAkB,GAAG,MAAM,CAAC,iBAAiB,CAAC;QACnD,IAAI,CAAC,mBAAmB,GAAG,MAAM,CAAC,kBAAkB,CAAC;QAErD,IAAI,IAAI,CAAC,kBAAkB,EAAE;YAC3B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,kBAAkB,CAAC,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,gBAAgB,EAAE,EAAE,CAAC,IAAI,CAAC,gBAAgB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AI,KAAK;YACtC,SAAS,EAAE,IAAI;YACf,OAAO,EAAE,MAAM,CAAC,OAAO;SACxB,CAAC;IACJ,CAAC;CACF;AAED,MAAM,8BAA8B,GAAG,CAAC,MAAwB,EAAE,EAAE;IAClE,QAAQ,MAAM,CAAC,KAAK,EAAE;QACpB,KAAK,SAAS;YACZ,OAAO,aAAa,CAAC,EAAE,CAAC;QAC1B,uBAAuB;QACvB,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 { EMPTY } from \"rxjs/internal/observable/empty\";\nimport { from } from \"rxjs/internal/observable/from\";\nimport { map } from \"rxjs/internal/operators/map\";\nimport { mergeMap } from \"rxjs/internal/operators/mergeMap\";\nimport { toRxjsObservable } from \"@itwin/components-react\";\nimport { CheckBoxState, isPromiseLike } from \"@itwin/core-react\";\nimport { UnifiedSelectionTreeEventHandler } from \"@itwin/presentation-components\";\nimport type {\n CheckBoxInfo, CheckboxStateChange, TreeCheckboxStateChangeEventArgs, TreeModelNode, TreeNodeItem,\n TreeSelectionModificationEventArgs, TreeSelectionReplacementEventArgs,\n} from \"@itwin/components-react\";\nimport type { BeEvent, IDisposable } from \"@itwin/core-bentley\";\nimport type { NodeKey } from \"@itwin/presentation-common\";\nimport type { UnifiedSelectionTreeEventHandlerParams } from \"@itwin/presentation-components\";\n\n/**\n * Data structure that describes instance visibility status.\n * @alpha\n */\nexport interface VisibilityStatus {\n state: \"visible\" | \"partial\" | \"hidden\";\n isDisabled?: boolean;\n tooltip?: string;\n}\n\n/**\n * Type definition of visibility change event listener.\n * @alpha\n */\nexport type VisibilityChangeListener = (nodeIds?: string[], visibilityStatus?: Map<string, VisibilityStatus>) => void;\n\n/**\n * Visibility handler used to change or get visibility of instances represented by the tree node.\n * @alpha\n */\nexport interface IVisibilityHandler extends IDisposable {\n getVisibilityStatus(node: TreeNodeItem, nodeKey: NodeKey): VisibilityStatus | Promise<VisibilityStatus>;\n changeVisibility(node: TreeNodeItem, nodeKey: NodeKey, shouldDisplay: boolean): Promise<void>;\n onVisibilityChange: BeEvent<VisibilityChangeListener>;\n}\n\n/**\n * Type definition of predicate used to decide if node can be selected.\n * @alpha\n */\nexport type VisibilityTreeSelectionPredicate = (key: NodeKey, node: TreeNodeItem) => boolean;\n\n/**\n * Parameters for [[VisibilityTreeEventHandler]]\n * @alpha\n */\nexport interface VisibilityTreeEventHandlerParams extends UnifiedSelectionTreeEventHandlerParams {\n visibilityHandler: IVisibilityHandler | undefined;\n selectionPredicate?: VisibilityTreeSelectionPredicate;\n}\n\n/**\n * Base event handler for visibility tree.\n * @alpha\n */\nexport class VisibilityTreeEventHandler extends UnifiedSelectionTreeEventHandler {\n private _visibilityHandler: IVisibilityHandler | undefined;\n private _selectionPredicate?: VisibilityTreeSelectionPredicate;\n private _listeners = new Array<() => void>();\n\n constructor(params: VisibilityTreeEventHandlerParams) {\n super(params);\n this._visibilityHandler = params.visibilityHandler;\n this._selectionPredicate = params.selectionPredicate;\n\n if (this._visibilityHandler) {\n this._listeners.push(this._visibilityHandler.onVisibilityChange.addListener(async (nodeIds, visibilityStatus) => this.updateCheckboxes(nodeIds, visibilityStatus)));\n }\n\n this._listeners.push(this.modelSource.onModelChanged.addListener(async ([_, changes]) => this.updateCheckboxes([...changes.addedNodeIds, ...changes.modifiedNodeIds])));\n this.updateCheckboxes(); // eslint-disable-line @typescript-eslint/no-floating-promises\n }\n\n public override dispose() {\n super.dispose();\n this._listeners.forEach((disposeFunc) => disposeFunc());\n }\n\n private filterSelectionItems(items: TreeNodeItem[]) {\n // istanbul ignore if\n if (!this._selectionPredicate)\n return items;\n\n return items.filter((item) => this._selectionPredicate!(this.getNodeKey(item), item));\n }\n\n public override onSelectionModified({ modifications }: TreeSelectionModificationEventArgs) {\n const filteredModification = toRxjsObservable(modifications).pipe(\n map(({ selectedNodeItems, deselectedNodeItems }) => {\n return {\n selectedNodeItems: this.filterSelectionItems(selectedNodeItems),\n deselectedNodeItems: this.filterSelectionItems(deselectedNodeItems),\n };\n }),\n );\n return super.onSelectionModified({ modifications: filteredModification });\n }\n\n public override onSelectionReplaced({ replacements }: TreeSelectionReplacementEventArgs) {\n const filteredReplacements = toRxjsObservable(replacements).pipe(\n map(({ selectedNodeItems }) => {\n return {\n selectedNodeItems: this.filterSelectionItems(selectedNodeItems),\n };\n }),\n );\n return super.onSelectionReplaced({ replacements: filteredReplacements });\n }\n\n public override onCheckboxStateChanged(event: TreeCheckboxStateChangeEventArgs) {\n // istanbul ignore if\n if (!this._visibilityHandler)\n return undefined;\n\n from(event.stateChanges)\n .pipe(\n mergeMap((changes) => this.changeVisibility(changes)),\n )\n .subscribe();\n return undefined;\n }\n\n private changeVisibility(changes: CheckboxStateChange[]) {\n return from(changes)\n .pipe(\n mergeMap(({ nodeItem, newState }) => {\n // istanbul ignore if\n if (!this._visibilityHandler)\n return EMPTY;\n return from(this._visibilityHandler.changeVisibility(nodeItem, this.getNodeKey(nodeItem), newState === CheckBoxState.On));\n }),\n );\n }\n\n private async updateCheckboxes(affectedNodes?: string[], visibilityStatus?: Map<string, VisibilityStatus>) {\n const changes = await (affectedNodes ? this.collectAffectedNodesCheckboxInfos(affectedNodes, visibilityStatus) : this.collectAllNodesCheckboxInfos(visibilityStatus));\n this.updateModel(changes);\n }\n\n private updateModel(changes: Map<string, CheckBoxInfo>) {\n this.modelSource.modifyModel((model) => {\n for (const [nodeId, checkboxInfo] of changes) {\n const node = model.getNode(nodeId);\n // istanbul ignore if\n if (!node)\n continue;\n\n node.checkbox.isDisabled = checkboxInfo.isDisabled;\n node.checkbox.isVisible = checkboxInfo.isVisible;\n node.checkbox.state = checkboxInfo.state;\n node.checkbox.tooltip = checkboxInfo.tooltip;\n }\n });\n }\n\n private async collectAffectedNodesCheckboxInfos(affectedNodes: string[], visibilityStatus?: Map<string, VisibilityStatus>) {\n const nodeStates = new Map<string, CheckBoxInfo>();\n if (affectedNodes.length === 0)\n return nodeStates;\n\n await Promise.all(affectedNodes.map(async (nodeId) => {\n const node = this.modelSource.getModel().getNode(nodeId);\n // istanbul ignore else\n if (node)\n nodeStates.set(nodeId, await this.getNodeCheckBoxInfo(node, visibilityStatus));\n }));\n return nodeStates;\n }\n\n private async collectAllNodesCheckboxInfos(visibilityStatus?: Map<string, VisibilityStatus>) {\n const nodeStates = new Map<string, CheckBoxInfo>();\n for (const node of this.modelSource.getModel().iterateTreeModelNodes()) {\n nodeStates.set(node.id, await this.getNodeCheckBoxInfo(node, visibilityStatus));\n }\n return nodeStates;\n }\n\n private async getNodeCheckBoxInfo(node: TreeModelNode, visibilityStatus?: Map<string, VisibilityStatus>): Promise<CheckBoxInfo> {\n if (!this._visibilityHandler)\n return { ...node.checkbox, isVisible: false };\n\n const result = visibilityStatus?.get(node.id) ?? this._visibilityHandler.getVisibilityStatus(node.item, this.getNodeKey(node.item));\n\n if (isPromiseLike(result))\n return this.createCheckboxInfo(await result);\n return this.createCheckboxInfo(result);\n }\n\n private createCheckboxInfo(status: VisibilityStatus): CheckBoxInfo {\n return {\n state: visibilityStateToCheckboxState(status),\n isDisabled: status.isDisabled || false,\n isVisible: true,\n tooltip: status.tooltip,\n };\n }\n}\n\nconst visibilityStateToCheckboxState = (status: VisibilityStatus) => {\n switch (status.state) {\n case \"visible\":\n return CheckBoxState.On;\n // istanbul ignore next\n case \"partial\":\n return CheckBoxState.Partial;\n case \"hidden\":\n default:\n return CheckBoxState.Off;\n }\n};\n"]}
1
+ {"version":3,"file":"VisibilityTreeEventHandler.js","sourceRoot":"","sources":["../../../../src/components/trees/VisibilityTreeEventHandler.ts"],"names":[],"mappings":"AAAA;;;+FAG+F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AAM,CAAC;YAC7C,UAAU,EAAE,MAAM,CAAC,UAAU,IAAI,KAAK;YACtC,SAAS,EAAE,IAAI;YACf,OAAO,EAAE,MAAM,CAAC,OAAO;SACxB,CAAC;IACJ,CAAC;CACF;AAED,MAAM,8BAA8B,GAAG,CAAC,MAAwB,EAAE,EAAE;IAClE,QAAQ,MAAM,CAAC,KAAK,EAAE;QACpB,KAAK,SAAS;YACZ,OAAO,aAAa,CAAC,EAAE,CAAC;QAC1B,uBAAuB;QACvB,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 { EMPTY } from \"rxjs/internal/observable/empty\";\nimport { from } from \"rxjs/internal/observable/from\";\nimport { map } from \"rxjs/internal/operators/map\";\nimport { mergeMap } from \"rxjs/internal/operators/mergeMap\";\nimport { toRxjsObservable } from \"@itwin/components-react\";\nimport { CheckBoxState, isPromiseLike } from \"@itwin/core-react\";\nimport { UnifiedSelectionTreeEventHandler } from \"@itwin/presentation-components\";\nimport type {\n CheckBoxInfo, CheckboxStateChange, TreeCheckboxStateChangeEventArgs, TreeModelNode, TreeNodeItem,\n TreeSelectionModificationEventArgs, TreeSelectionReplacementEventArgs,\n} from \"@itwin/components-react\";\nimport type { BeEvent, IDisposable } from \"@itwin/core-bentley\";\nimport type { NodeKey } from \"@itwin/presentation-common\";\nimport type { UnifiedSelectionTreeEventHandlerParams } from \"@itwin/presentation-components\";\n\n/**\n * Data structure that describes instance visibility status.\n * @alpha\n */\nexport interface VisibilityStatus {\n state: \"visible\" | \"partial\" | \"hidden\";\n isDisabled?: boolean;\n tooltip?: string;\n}\n\n/**\n * Type definition of visibility change event listener.\n * @alpha\n */\nexport type VisibilityChangeListener = (nodeIds?: string[], visibilityStatus?: Map<string, VisibilityStatus>) => void;\n\n/**\n * Visibility handler used to change or get visibility of instances represented by the tree node.\n * @alpha\n */\nexport interface IVisibilityHandler extends IDisposable {\n getVisibilityStatus(node: TreeNodeItem, nodeKey: NodeKey): VisibilityStatus | Promise<VisibilityStatus>;\n changeVisibility(node: TreeNodeItem, nodeKey: NodeKey, shouldDisplay: boolean): Promise<void>;\n onVisibilityChange: BeEvent<VisibilityChangeListener>;\n}\n\n/**\n * Type definition of predicate used to decide if node can be selected.\n * @alpha\n */\nexport type VisibilityTreeSelectionPredicate = (key: NodeKey, node: TreeNodeItem) => boolean;\n\n/**\n * Parameters for [[VisibilityTreeEventHandler]]\n * @alpha\n */\nexport interface VisibilityTreeEventHandlerParams extends UnifiedSelectionTreeEventHandlerParams {\n visibilityHandler: IVisibilityHandler | undefined;\n selectionPredicate?: VisibilityTreeSelectionPredicate;\n}\n\n/**\n * Base event handler for visibility tree.\n * @alpha\n */\nexport class VisibilityTreeEventHandler extends UnifiedSelectionTreeEventHandler {\n private _visibilityHandler: IVisibilityHandler | undefined;\n private _selectionPredicate?: VisibilityTreeSelectionPredicate;\n private _listeners = new Array<() => void>();\n 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\n if (this._visibilityHandler) {\n this._listeners.push(this._visibilityHandler.onVisibilityChange.addListener(async (nodeIds, visibilityStatus) => {\n if (this._isChangingVisibility)\n return;\n void this.updateCheckboxes(nodeIds, visibilityStatus);\n }));\n }\n\n this._listeners.push(this.modelSource.onModelChanged.addListener(async ([_, changes]) => {\n void this.updateCheckboxes([...changes.addedNodeIds, ...changes.modifiedNodeIds]);\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 return items.filter((item) => this._selectionPredicate!(this.getNodeKey(item), item));\n }\n\n public override onSelectionModified({ modifications }: TreeSelectionModificationEventArgs) {\n const filteredModification = toRxjsObservable(modifications).pipe(\n map(({ selectedNodeItems, deselectedNodeItems }) => {\n return {\n selectedNodeItems: this.filterSelectionItems(selectedNodeItems),\n deselectedNodeItems: this.filterSelectionItems(deselectedNodeItems),\n };\n }),\n );\n return super.onSelectionModified({ modifications: filteredModification });\n }\n\n public override onSelectionReplaced({ replacements }: TreeSelectionReplacementEventArgs) {\n const filteredReplacements = toRxjsObservable(replacements).pipe(\n map(({ selectedNodeItems }) => {\n return {\n selectedNodeItems: this.filterSelectionItems(selectedNodeItems),\n };\n }),\n );\n return super.onSelectionReplaced({ replacements: filteredReplacements });\n }\n\n public override onCheckboxStateChanged(event: TreeCheckboxStateChangeEventArgs) {\n const handleStateChanged = () => {\n this._isChangingVisibility = false;\n void this.updateCheckboxes();\n };\n // istanbul ignore if\n if (!this._visibilityHandler)\n return undefined;\n\n from(event.stateChanges)\n .pipe(\n mergeMap((changes) => this.changeVisibility(changes)),\n )\n .subscribe({\n 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 // istanbul ignore if\n if (!this._visibilityHandler)\n return EMPTY;\n this._isChangingVisibility = true;\n return from(this._visibilityHandler.changeVisibility(nodeItem, this.getNodeKey(nodeItem), newState === CheckBoxState.On));\n }, 1),\n );\n }\n\n private async updateCheckboxes(affectedNodes?: string[], visibilityStatus?: Map<string, VisibilityStatus>) {\n const changes = await (affectedNodes ? this.collectAffectedNodesCheckboxInfos(affectedNodes, visibilityStatus) : this.collectAllNodesCheckboxInfos(visibilityStatus));\n this.updateModel(changes);\n }\n\n private updateModel(changes: Map<string, CheckBoxInfo>) {\n this.modelSource.modifyModel((model) => {\n for (const [nodeId, checkboxInfo] of changes) {\n const node = model.getNode(nodeId);\n // istanbul ignore if\n if (!node)\n continue;\n\n node.checkbox.isDisabled = checkboxInfo.isDisabled;\n node.checkbox.isVisible = checkboxInfo.isVisible;\n node.checkbox.state = checkboxInfo.state;\n node.checkbox.tooltip = checkboxInfo.tooltip;\n }\n });\n }\n\n private async collectAffectedNodesCheckboxInfos(affectedNodes: string[], visibilityStatus?: Map<string, VisibilityStatus>) {\n const nodeStates = new Map<string, CheckBoxInfo>();\n if (affectedNodes.length === 0)\n return nodeStates;\n\n await Promise.all(affectedNodes.map(async (nodeId) => {\n const node = this.modelSource.getModel().getNode(nodeId);\n // istanbul ignore else\n if (node)\n nodeStates.set(nodeId, await this.getNodeCheckBoxInfo(node, visibilityStatus));\n }));\n return nodeStates;\n }\n\n private async collectAllNodesCheckboxInfos(visibilityStatus?: Map<string, VisibilityStatus>) {\n const nodeStates = new Map<string, CheckBoxInfo>();\n for (const node of this.modelSource.getModel().iterateTreeModelNodes()) {\n nodeStates.set(node.id, await this.getNodeCheckBoxInfo(node, visibilityStatus));\n }\n return nodeStates;\n }\n\n private async getNodeCheckBoxInfo(node: TreeModelNode, visibilityStatus?: Map<string, VisibilityStatus>): Promise<CheckBoxInfo> {\n if (!this._visibilityHandler)\n return { ...node.checkbox, isVisible: false };\n\n const result = visibilityStatus?.get(node.id) ?? this._visibilityHandler.getVisibilityStatus(node.item, this.getNodeKey(node.item));\n\n if (isPromiseLike(result))\n return this.createCheckboxInfo(await result);\n return this.createCheckboxInfo(result);\n }\n\n private createCheckboxInfo(status: VisibilityStatus): CheckBoxInfo {\n return {\n state: visibilityStateToCheckboxState(status),\n isDisabled: status.isDisabled || false,\n isVisible: true,\n tooltip: status.tooltip,\n };\n }\n}\n\nconst visibilityStateToCheckboxState = (status: VisibilityStatus) => {\n switch (status.state) {\n case \"visible\":\n return CheckBoxState.On;\n // istanbul ignore next\n case \"partial\":\n return CheckBoxState.Partial;\n case \"hidden\":\n default:\n return CheckBoxState.Off;\n }\n};\n"]}
@@ -88,6 +88,7 @@
88
88
  "direction": "Forward"
89
89
  }
90
90
  ],
91
+ "instanceFilter": "NOT this.IsPrivate",
91
92
  "groupByClass": false,
92
93
  "groupByLabel": false
93
94
  }
@@ -52,14 +52,4 @@ export interface CategoryTreeProps {
52
52
  * @public
53
53
  */
54
54
  export declare function CategoryTree(props: CategoryTreeProps): JSX.Element;
55
- /**
56
- * Toggles visibility of categories to show or hide.
57
- * @alpha
58
- */
59
- export declare function toggleAllCategories(viewManager: ViewManager, imodel: IModelConnection, display: boolean, viewport?: Viewport, forAllViewports?: boolean, filteredProvider?: IPresentationTreeDataProvider): Promise<void>;
60
- /**
61
- * Gets ids of all categories or categories from filtered data provider.
62
- * @alpha
63
- */
64
- export declare function getCategories(imodel: IModelConnection, viewport?: Viewport, filteredProvider?: IPresentationTreeDataProvider): Promise<string[]>;
65
55
  //# sourceMappingURL=CategoriesTree.d.ts.map
@@ -12,7 +12,7 @@ import { Presentation } from "@itwin/presentation-frontend";
12
12
  import { TreeWidget } from "../../../TreeWidget";
13
13
  import { VisibilityTreeEventHandler } from "../VisibilityTreeEventHandler";
14
14
  import { useVisibilityTreeFiltering, useVisibilityTreeRenderer, VisibilityTreeNoFilteredData } from "../VisibilityTreeRenderer";
15
- import { CategoryVisibilityHandler, loadCategoriesFromViewport, useCategories } from "./CategoryVisibilityHandler";
15
+ import { CategoryVisibilityHandler, useCategories } from "./CategoryVisibilityHandler";
16
16
  const PAGING_SIZE = 20;
17
17
  /**
18
18
  * Presentation rules used by ControlledCategoriesTree
@@ -68,29 +68,4 @@ async function setViewType(activeView) {
68
68
  const viewType = view.is3d() ? "3d" : "2d";
69
69
  await Presentation.presentation.vars(RULESET_CATEGORIES.id).setString("ViewType", viewType);
70
70
  }
71
- /**
72
- * Toggles visibility of categories to show or hide.
73
- * @alpha
74
- */
75
- export async function toggleAllCategories(viewManager, imodel, display, viewport, forAllViewports, filteredProvider) {
76
- // istanbul ignore next
77
- const activeView = viewport !== null && viewport !== void 0 ? viewport : viewManager.getFirstOpenView();
78
- const ids = await getCategories(imodel, activeView, filteredProvider);
79
- // istanbul ignore else
80
- if (ids.length > 0) {
81
- CategoryVisibilityHandler.enableCategory(viewManager, imodel, ids, display, forAllViewports !== null && forAllViewports !== void 0 ? forAllViewports : false);
82
- }
83
- }
84
- /**
85
- * Gets ids of all categories or categories from filtered data provider.
86
- * @alpha
87
- */
88
- export async function getCategories(imodel, viewport, filteredProvider) {
89
- if (filteredProvider) {
90
- const nodes = await filteredProvider.getNodes();
91
- return nodes.map((node) => CategoryVisibilityHandler.getInstanceIdFromTreeNodeKey(filteredProvider.getNodeKey(node)));
92
- }
93
- const categories = await loadCategoriesFromViewport(imodel, viewport);
94
- return categories.map((category) => category.key);
95
- }
96
71
  //# sourceMappingURL=CategoriesTree.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CategoriesTree.js","sourceRoot":"","sources":["../../../../../src/components/trees/category-tree/CategoriesTree.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,uBAAuB,CAAC;AAC/B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACtF,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,0BAA0B,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AC,EAAE;QAClB,yBAAyB,CAAC,cAAc,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,eAAe,aAAf,eAAe,cAAf,eAAe,GAAI,KAAK,CAAC,CAAC;KACvG;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,MAAwB,EAAE,QAAmB,EAAE,gBAAgD;IACjI,IAAI,gBAAgB,EAAE;QACpB,MAAM,KAAK,GAAG,MAAM,gBAAgB,CAAC,QAAQ,EAAE,CAAC;QAChD,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,yBAAyB,CAAC,4BAA4B,CAAC,gBAAgB,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KACvH;IAED,MAAM,UAAU,GAAG,MAAM,0BAA0B,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACtE,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;AACpD,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 \"./CategoriesTree.scss\";\nimport * as React from \"react\";\nimport { ControlledTree, SelectionMode, useTreeModel } from \"@itwin/components-react\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { useDisposable } from \"@itwin/core-react\";\nimport { usePresentationTreeNodeLoader } from \"@itwin/presentation-components\";\nimport { Presentation } from \"@itwin/presentation-frontend\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { VisibilityTreeEventHandler } from \"../VisibilityTreeEventHandler\";\nimport { useVisibilityTreeFiltering, useVisibilityTreeRenderer, VisibilityTreeNoFilteredData } from \"../VisibilityTreeRenderer\";\nimport { CategoryVisibilityHandler, loadCategoriesFromViewport, useCategories } from \"./CategoryVisibilityHandler\";\nimport type { IModelConnection, SpatialViewState, ViewManager, Viewport } from \"@itwin/core-frontend\";\nimport type { Ruleset } from \"@itwin/presentation-common\";\nimport type { IPresentationTreeDataProvider } from \"@itwin/presentation-components\";\nimport type { VisibilityTreeFilterInfo } from \"../Common\";\nimport type { Category } from \"./CategoryVisibilityHandler\";\n\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 {\n /** Flag for accommodating all viewports */\n allViewports?: boolean;\n /** Active viewport */\n activeView?: Viewport;\n /**\n * An IModel to pull data from\n */\n iModel: IModelConnection;\n /** Width of the component */\n width: number;\n /** Height of the component */\n height: number;\n /**\n * Information for tree filtering.\n * @alpha\n */\n filterInfo?: VisibilityTreeFilterInfo;\n /**\n * Callback invoked when tree is filtered.\n */\n onFilterApplied?: (filteredDataProvider: IPresentationTreeDataProvider, matchesCount: number) => void;\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\n/**\n * Tree which displays and manages categories contained in an iModel.\n * @public\n */\nexport function CategoryTree(props: CategoryTreeProps) {\n const { nodeLoader } = usePresentationTreeNodeLoader({\n imodel: props.iModel,\n ruleset: RULESET_CATEGORIES,\n pagingSize: PAGING_SIZE,\n });\n\n const { filteredNodeLoader, isFiltering, nodeHighlightingProps } = useVisibilityTreeFiltering(nodeLoader, props.filterInfo, props.onFilterApplied);\n // istanbul ignore next\n const viewManager = props.viewManager ?? IModelApp.viewManager;\n const { activeView, allViewports, categoryVisibilityHandler } = props;\n const currentActiveView = activeView ?? viewManager.getFirstOpenView();\n const categories = useCategories(viewManager, props.iModel, currentActiveView);\n const visibilityHandler = useCategoryVisibilityHandler(viewManager, props.iModel, categories, currentActiveView, allViewports, categoryVisibilityHandler);\n\n React.useEffect(() => {\n setViewType(currentActiveView); // eslint-disable-line @typescript-eslint/no-floating-promises\n }, [currentActiveView]);\n\n const eventHandler = useDisposable(React.useCallback(() => new VisibilityTreeEventHandler({\n nodeLoader: filteredNodeLoader,\n visibilityHandler,\n collapsedChildrenDisposalEnabled: true,\n }), [filteredNodeLoader, visibilityHandler]));\n\n const treeModel = useTreeModel(filteredNodeLoader.modelSource);\n const treeRenderer = useVisibilityTreeRenderer(false, true);\n const overlay = isFiltering ? <div className=\"filteredTreeOverlay\" /> : undefined;\n const filterApplied = filteredNodeLoader !== nodeLoader;\n\n const noFilteredDataRenderer = React.useCallback(() => {\n return <VisibilityTreeNoFilteredData\n title={TreeWidget.translate(\"categoriesTree.noCategoryFound\")}\n message={TreeWidget.translate(\"categoriesTree.noMatchingCategoryNames\")}\n />;\n }, []);\n\n return (\n <div className=\"tree-widget-categories-tree\">\n <ControlledTree\n nodeLoader={filteredNodeLoader}\n model={treeModel}\n selectionMode={SelectionMode.None}\n eventsHandler={eventHandler}\n treeRenderer={treeRenderer}\n descriptionsEnabled={true}\n nodeHighlightingProps={nodeHighlightingProps}\n noDataRenderer={filterApplied ? noFilteredDataRenderer : undefined}\n width={props.width}\n height={props.height}\n />\n {overlay}\n </div>\n );\n}\n\nfunction useCategoryVisibilityHandler(viewManager: ViewManager, imodel: IModelConnection, categories: Category[], activeView?: Viewport, allViewports?: boolean, visibilityHandler?: CategoryVisibilityHandler) {\n return useDisposable(React.useCallback(\n () =>\n // istanbul ignore next\n visibilityHandler ?? new CategoryVisibilityHandler({ viewManager, imodel, categories, activeView, allViewports }),\n [viewManager, imodel, categories, activeView, allViewports, visibilityHandler]),\n );\n}\n\nasync function setViewType(activeView?: Viewport) {\n if (!activeView)\n return;\n\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\n/**\n * Toggles visibility of categories to show or hide.\n * @alpha\n */\nexport async function toggleAllCategories(viewManager: ViewManager, imodel: IModelConnection, display: boolean, viewport?: Viewport, forAllViewports?: boolean, filteredProvider?: IPresentationTreeDataProvider) {\n // istanbul ignore next\n const activeView = viewport ?? viewManager.getFirstOpenView();\n const ids = await getCategories(imodel, activeView, filteredProvider);\n\n // istanbul ignore else\n if (ids.length > 0) {\n CategoryVisibilityHandler.enableCategory(viewManager, imodel, ids, display, forAllViewports ?? false);\n }\n}\n\n/**\n * Gets ids of all categories or categories from filtered data provider.\n * @alpha\n */\nexport async function getCategories(imodel: IModelConnection, viewport?: Viewport, filteredProvider?: IPresentationTreeDataProvider) {\n if (filteredProvider) {\n const nodes = await filteredProvider.getNodes();\n return nodes.map((node) => CategoryVisibilityHandler.getInstanceIdFromTreeNodeKey(filteredProvider.getNodeKey(node)));\n }\n\n const categories = await loadCategoriesFromViewport(imodel, viewport);\n return categories.map((category) => category.key);\n}\n"]}
1
+ {"version":3,"file":"CategoriesTree.js","sourceRoot":"","sources":["../../../../../src/components/trees/category-tree/CategoriesTree.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,uBAAuB,CAAC;AAC/B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACtF,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AA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K,CAAC,MAAM,GACpB;QACD,OAAO,CACJ,CACP,CAAC;AACJ,CAAC;AAED,SAAS,4BAA4B,CAAC,WAAwB,EAAE,MAAwB,EAAE,UAAsB,EAAE,UAAqB,EAAE,YAAsB,EAAE,iBAA6C;IAC5M,OAAO,aAAa,CAAC,KAAK,CAAC,WAAW,CACpC,GAAG,EAAE;IACH,uBAAuB;IACvB,iBAAiB,aAAjB,iBAAiB,cAAjB,iBAAiB,GAAI,IAAI,yBAAyB,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC,EACnH,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,iBAAiB,CAAC,CAAC,CAChF,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,WAAW,CAAC,UAAqB;IAC9C,IAAI,CAAC,UAAU;QACb,OAAO;IAET,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","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 \"./CategoriesTree.scss\";\nimport * as React from \"react\";\nimport { ControlledTree, SelectionMode, useTreeModel } from \"@itwin/components-react\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { useDisposable } from \"@itwin/core-react\";\nimport { usePresentationTreeNodeLoader } from \"@itwin/presentation-components\";\nimport { Presentation } from \"@itwin/presentation-frontend\";\nimport { TreeWidget } from \"../../../TreeWidget\";\nimport { VisibilityTreeEventHandler } from \"../VisibilityTreeEventHandler\";\nimport { useVisibilityTreeFiltering, useVisibilityTreeRenderer, VisibilityTreeNoFilteredData } from \"../VisibilityTreeRenderer\";\nimport { CategoryVisibilityHandler, useCategories } from \"./CategoryVisibilityHandler\";\nimport type { IModelConnection, SpatialViewState, ViewManager, Viewport } from \"@itwin/core-frontend\";\nimport type { Ruleset } from \"@itwin/presentation-common\";\nimport type { IPresentationTreeDataProvider } from \"@itwin/presentation-components\";\nimport type { VisibilityTreeFilterInfo } from \"../Common\";\nimport type { Category } from \"./CategoryVisibilityHandler\";\n\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 {\n /** Flag for accommodating all viewports */\n allViewports?: boolean;\n /** Active viewport */\n activeView?: Viewport;\n /**\n * An IModel to pull data from\n */\n iModel: IModelConnection;\n /** Width of the component */\n width: number;\n /** Height of the component */\n height: number;\n /**\n * Information for tree filtering.\n * @alpha\n */\n filterInfo?: VisibilityTreeFilterInfo;\n /**\n * Callback invoked when tree is filtered.\n */\n onFilterApplied?: (filteredDataProvider: IPresentationTreeDataProvider, matchesCount: number) => void;\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\n/**\n * Tree which displays and manages categories contained in an iModel.\n * @public\n */\nexport function CategoryTree(props: CategoryTreeProps) {\n const { nodeLoader } = usePresentationTreeNodeLoader({\n imodel: props.iModel,\n ruleset: RULESET_CATEGORIES,\n pagingSize: PAGING_SIZE,\n });\n\n const { filteredNodeLoader, isFiltering, nodeHighlightingProps } = useVisibilityTreeFiltering(nodeLoader, props.filterInfo, props.onFilterApplied);\n // istanbul ignore next\n const viewManager = props.viewManager ?? IModelApp.viewManager;\n const { activeView, allViewports, categoryVisibilityHandler } = props;\n const currentActiveView = activeView ?? viewManager.getFirstOpenView();\n const categories = useCategories(viewManager, props.iModel, currentActiveView);\n const visibilityHandler = useCategoryVisibilityHandler(viewManager, props.iModel, categories, currentActiveView, allViewports, categoryVisibilityHandler);\n\n React.useEffect(() => {\n setViewType(currentActiveView); // eslint-disable-line @typescript-eslint/no-floating-promises\n }, [currentActiveView]);\n\n const eventHandler = useDisposable(React.useCallback(() => new VisibilityTreeEventHandler({\n nodeLoader: filteredNodeLoader,\n visibilityHandler,\n collapsedChildrenDisposalEnabled: true,\n }), [filteredNodeLoader, visibilityHandler]));\n\n const treeModel = useTreeModel(filteredNodeLoader.modelSource);\n const treeRenderer = useVisibilityTreeRenderer(false, true);\n const overlay = isFiltering ? <div className=\"filteredTreeOverlay\" /> : undefined;\n const filterApplied = filteredNodeLoader !== nodeLoader;\n\n const noFilteredDataRenderer = React.useCallback(() => {\n return <VisibilityTreeNoFilteredData\n title={TreeWidget.translate(\"categoriesTree.noCategoryFound\")}\n message={TreeWidget.translate(\"categoriesTree.noMatchingCategoryNames\")}\n />;\n }, []);\n\n return (\n <div className=\"tree-widget-categories-tree\">\n <ControlledTree\n nodeLoader={filteredNodeLoader}\n model={treeModel}\n selectionMode={SelectionMode.None}\n eventsHandler={eventHandler}\n treeRenderer={treeRenderer}\n descriptionsEnabled={true}\n nodeHighlightingProps={nodeHighlightingProps}\n noDataRenderer={filterApplied ? noFilteredDataRenderer : undefined}\n width={props.width}\n height={props.height}\n />\n {overlay}\n </div>\n );\n}\n\nfunction useCategoryVisibilityHandler(viewManager: ViewManager, imodel: IModelConnection, categories: Category[], activeView?: Viewport, allViewports?: boolean, visibilityHandler?: CategoryVisibilityHandler) {\n return useDisposable(React.useCallback(\n () =>\n // istanbul ignore next\n visibilityHandler ?? new CategoryVisibilityHandler({ viewManager, imodel, categories, activeView, allViewports }),\n [viewManager, imodel, categories, activeView, allViewports, visibilityHandler]),\n );\n}\n\nasync function setViewType(activeView?: Viewport) {\n if (!activeView)\n return;\n\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"]}
@@ -6,8 +6,9 @@ import "./CategoriesTree.scss";
6
6
  import React, { useCallback } from "react";
7
7
  import { useActiveIModelConnection, useActiveViewport } from "@itwin/appui-react";
8
8
  import { IModelApp } from "@itwin/core-frontend";
9
- import { CategoryTree, getCategories, toggleAllCategories } from "./CategoriesTree";
9
+ import { CategoryTree } from "./CategoriesTree";
10
10
  import { CategoryVisibilityHandler } from "./CategoryVisibilityHandler";
11
+ import { enableCategory, getCategories, toggleAllCategories } from "../CategoriesVisibilityUtils";
11
12
  import { TreeHeaderComponent } from "../../header/TreeHeader";
12
13
  import { useTreeFilteringState } from "../../TreeFilteringState";
13
14
  import { AutoSizer } from "../../utils/AutoSizer";
@@ -18,17 +19,17 @@ export function CategoriesTreeComponent(props) {
18
19
  const showAll = useCallback(async () => {
19
20
  if (!iModel)
20
21
  return;
21
- return toggleAllCategories(IModelApp.viewManager, iModel, true, undefined, true, filteredProvider);
22
+ return toggleAllCategories(IModelApp.viewManager, iModel, true, undefined, true, filteredProvider ? await getFilteredCategories(filteredProvider) : undefined);
22
23
  }, [iModel, filteredProvider]);
23
24
  const hideAll = useCallback(async () => {
24
25
  if (!iModel)
25
26
  return;
26
- return toggleAllCategories(IModelApp.viewManager, iModel, false, undefined, true, filteredProvider);
27
+ return toggleAllCategories(IModelApp.viewManager, iModel, false, undefined, true, filteredProvider ? await getFilteredCategories(filteredProvider) : undefined);
27
28
  }, [iModel, filteredProvider]);
28
29
  const invert = useCallback(async () => {
29
30
  if (!iModel || !viewport)
30
31
  return;
31
- const ids = await getCategories(iModel, viewport, filteredProvider);
32
+ const ids = filteredProvider ? await getFilteredCategories(filteredProvider) : await getCategories(iModel, viewport);
32
33
  const enabled = [];
33
34
  const disabled = [];
34
35
  for (const id of ids) {
@@ -40,13 +41,17 @@ export function CategoriesTreeComponent(props) {
40
41
  }
41
42
  }
42
43
  // Disable enabled
43
- CategoryVisibilityHandler.enableCategory(IModelApp.viewManager, iModel, enabled, false, true);
44
+ enableCategory(IModelApp.viewManager, iModel, enabled, false, true);
44
45
  // Enable disabled
45
- CategoryVisibilityHandler.enableCategory(IModelApp.viewManager, iModel, disabled, true, true);
46
+ enableCategory(IModelApp.viewManager, iModel, disabled, true, true);
46
47
  }, [iModel, viewport, filteredProvider]);
47
48
  return (React.createElement(React.Fragment, null, iModel && viewport &&
48
49
  React.createElement(React.Fragment, null,
49
50
  React.createElement(TreeHeaderComponent, { searchOptions: searchOptions, showAll: showAll, hideAll: hideAll, invert: invert }),
50
51
  React.createElement(AutoSizer, null, ({ width, height }) => (React.createElement(CategoryTree, { ...props, iModel: iModel, width: width, height: height, filterInfo: { filter: filterString, activeMatchIndex }, onFilterApplied: onFilterApplied }))))));
51
52
  }
53
+ async function getFilteredCategories(filteredProvider) {
54
+ const nodes = await filteredProvider.getNodes();
55
+ return nodes.map((node) => CategoryVisibilityHandler.getInstanceIdFromTreeNodeKey(filteredProvider.getNodeKey(node)));
56
+ }
52
57
  //# sourceMappingURL=CategoriesTreeComponent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CategoriesTreeComponent.js","sourceRoot":"","sources":["../../../../../src/components/trees/category-tree/CategoriesTreeComponent.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAClF,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAA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EAAE,CAAC;QAC7B,MAAM,QAAQ,GAAa,EAAE,CAAC;QAC9B,KAAK,MAAM,EAAE,IAAI,GAAG,EAAE;YACpB,IAAI,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,EAAE;gBACnC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;aAClB;iBAAM;gBACL,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;aACnB;SACF;QACD,kBAAkB;QAClB,yBAAyB,CAAC,cAAc,CACtC,SAAS,CAAC,WAAW,EACrB,MAAM,EACN,OAAO,EACP,KAAK,EACL,IAAI,CACL,CAAC;QACF,kBAAkB;QAClB,yBAAyB,CAAC,cAAc,CACtC,SAAS,CAAC,WAAW,EACrB,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,IAAI,CACL,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAEzC,OAAO,CACL,0CACG,MAAM,IAAI,QAAQ;QACjB;YACE,oBAAC,mBAAmB,IAClB,aAAa,EAAE,aAAa,EAC5B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,GACd;YACF,oBAAC,SAAS,QACP,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CACtB,oBAAC,YAAY,OACP,KAAK,EACT,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,gBAAgB,EAAE,EACtD,eAAe,EAAE,eAAe,GAChC,CACH,CACS,CACX,CAEJ,CACJ,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*--------------------------------------------------------------------------------------------*/\nimport \"./CategoriesTree.scss\";\nimport React, { useCallback } from \"react\";\nimport { useActiveIModelConnection, useActiveViewport } from \"@itwin/appui-react\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { CategoryTree, getCategories, toggleAllCategories } from \"./CategoriesTree\";\nimport { CategoryVisibilityHandler } from \"./CategoryVisibilityHandler\";\nimport { TreeHeaderComponent } from \"../../header/TreeHeader\";\nimport { useTreeFilteringState } from \"../../TreeFilteringState\";\nimport { AutoSizer } from \"../../utils/AutoSizer\";\nimport type { CategoriesTreeProps } from \"../../../types\";\n\nexport function CategoriesTreeComponent(props: CategoriesTreeProps) {\n const iModel = useActiveIModelConnection();\n const viewport = useActiveViewport();\n\n const {\n searchOptions,\n filterString,\n activeMatchIndex,\n onFilterApplied,\n filteredProvider,\n } = useTreeFilteringState();\n\n const showAll = useCallback(async () => {\n if (!iModel) return;\n\n return toggleAllCategories(\n IModelApp.viewManager,\n iModel,\n true,\n undefined,\n true,\n filteredProvider\n );\n }, [iModel, filteredProvider]);\n\n const hideAll = useCallback(async () => {\n if (!iModel) return;\n return toggleAllCategories(\n IModelApp.viewManager,\n iModel,\n false,\n undefined,\n true,\n filteredProvider\n );\n }, [iModel, filteredProvider]);\n\n const invert = useCallback(async () => {\n if (!iModel || !viewport) return;\n\n const ids = await getCategories(iModel, viewport, filteredProvider);\n const enabled: string[] = [];\n const disabled: string[] = [];\n for (const id of ids) {\n if (viewport.view.viewsCategory(id)) {\n enabled.push(id);\n } else {\n disabled.push(id);\n }\n }\n // Disable enabled\n CategoryVisibilityHandler.enableCategory(\n IModelApp.viewManager,\n iModel,\n enabled,\n false,\n true\n );\n // Enable disabled\n CategoryVisibilityHandler.enableCategory(\n IModelApp.viewManager,\n iModel,\n disabled,\n true,\n true\n );\n }, [iModel, viewport, filteredProvider]);\n\n return (\n <>\n {iModel && viewport &&\n <>\n <TreeHeaderComponent\n searchOptions={searchOptions}\n showAll={showAll}\n hideAll={hideAll}\n invert={invert}\n />\n <AutoSizer>\n {({ width, height }) => (\n <CategoryTree\n {...props}\n iModel={iModel}\n width={width}\n height={height}\n filterInfo={{ filter: filterString, activeMatchIndex }}\n onFilterApplied={onFilterApplied}\n />\n )}\n </AutoSizer>\n </>\n }\n </>\n );\n}\n"]}
1
+ {"version":3,"file":"CategoriesTreeComponent.js","sourceRoot":"","sources":["../../../../../src/components/trees/category-tree/CategoriesTreeComponent.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAClF,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAClG,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAIlD,MAAM,UAAU,uBAAuB,CAAC,KAA0B;IAChE,MAAM,MAAM,GAAG,yBAAyB,EAAE,CAAC;IAC3C,MAAM,QAAQ,GAAG,iBAAiB,EAAE,CAAC;IAErC,MAAM,EACJ,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,gBAAgB,GACjB,GAAG,qBAAqB,EAAE,CAAC;IAE5B,MAAM,OAAO,GAAG,WAAW,CAAC,KAAK,IAAI,EAAE;QACrC,IAAI,CAAC,MAAM;YAAE,OAAO;QAEpB,OAAO,mBAAmB,CACxB,SAAS,CAAC,WAAW,EACrB,MAAM,EACN,IAAI,EACJ,SAAS,EACT,IAAI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AC,WAAW,EACrB,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,IAAI,CACL,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAEzC,OAAO,CACL,0CACG,MAAM,IAAI,QAAQ;QACjB;YACE,oBAAC,mBAAmB,IAClB,aAAa,EAAE,aAAa,EAC5B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,GACd;YACF,oBAAC,SAAS,QACP,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CACtB,oBAAC,YAAY,OACP,KAAK,EACT,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,gBAAgB,EAAE,EACtD,eAAe,EAAE,eAAe,GAChC,CACH,CACS,CACX,CAEJ,CACJ,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,qBAAqB,CAAC,gBAA+C;IAClF,MAAM,KAAK,GAAG,MAAM,gBAAgB,CAAC,QAAQ,EAAE,CAAC;IAChD,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,yBAAyB,CAAC,4BAA4B,CAAC,gBAAgB,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACxH,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*--------------------------------------------------------------------------------------------*/\nimport \"./CategoriesTree.scss\";\nimport React, { useCallback } from \"react\";\nimport { useActiveIModelConnection, useActiveViewport } from \"@itwin/appui-react\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { CategoryTree } from \"./CategoriesTree\";\nimport { CategoryVisibilityHandler } from \"./CategoryVisibilityHandler\";\nimport { enableCategory, getCategories, toggleAllCategories } from \"../CategoriesVisibilityUtils\";\nimport { TreeHeaderComponent } from \"../../header/TreeHeader\";\nimport { useTreeFilteringState } from \"../../TreeFilteringState\";\nimport { AutoSizer } from \"../../utils/AutoSizer\";\nimport type { CategoriesTreeProps } from \"../../../types\";\nimport type { IPresentationTreeDataProvider } from \"@itwin/presentation-components\";\n\nexport function CategoriesTreeComponent(props: CategoriesTreeProps) {\n const iModel = useActiveIModelConnection();\n const viewport = useActiveViewport();\n\n const {\n searchOptions,\n filterString,\n activeMatchIndex,\n onFilterApplied,\n filteredProvider,\n } = useTreeFilteringState();\n\n const showAll = useCallback(async () => {\n if (!iModel) return;\n\n return toggleAllCategories(\n IModelApp.viewManager,\n iModel,\n true,\n undefined,\n true,\n filteredProvider ? await getFilteredCategories(filteredProvider) : undefined,\n );\n }, [iModel, filteredProvider]);\n\n const hideAll = useCallback(async () => {\n if (!iModel) return;\n return toggleAllCategories(\n IModelApp.viewManager,\n iModel,\n false,\n undefined,\n true,\n filteredProvider ? await getFilteredCategories(filteredProvider) : undefined,\n );\n }, [iModel, filteredProvider]);\n\n const invert = useCallback(async () => {\n if (!iModel || !viewport) return;\n const ids = filteredProvider ? await getFilteredCategories(filteredProvider) : await getCategories(iModel, viewport);\n const enabled: string[] = [];\n const disabled: string[] = [];\n for (const id of ids) {\n if (viewport.view.viewsCategory(id)) {\n enabled.push(id);\n } else {\n disabled.push(id);\n }\n }\n // Disable enabled\n enableCategory(\n IModelApp.viewManager,\n iModel,\n enabled,\n false,\n true\n );\n // Enable disabled\n enableCategory(\n IModelApp.viewManager,\n iModel,\n disabled,\n true,\n true\n );\n }, [iModel, viewport, filteredProvider]);\n\n return (\n <>\n {iModel && viewport &&\n <>\n <TreeHeaderComponent\n searchOptions={searchOptions}\n showAll={showAll}\n hideAll={hideAll}\n invert={invert}\n />\n <AutoSizer>\n {({ width, height }) => (\n <CategoryTree\n {...props}\n iModel={iModel}\n width={width}\n height={height}\n filterInfo={{ filter: filterString, activeMatchIndex }}\n onFilterApplied={onFilterApplied}\n />\n )}\n </AutoSizer>\n </>\n }\n </>\n );\n}\n\nasync function getFilteredCategories(filteredProvider: IPresentationTreeDataProvider) {\n const nodes = await filteredProvider.getNodes();\n return nodes.map((node) => CategoryVisibilityHandler.getInstanceIdFromTreeNodeKey(filteredProvider.getNodeKey(node)));\n}\n"]}
@@ -8,8 +8,6 @@ import type { IVisibilityHandler, VisibilityChangeListener, VisibilityStatus } f
8
8
  * @internal
9
9
  */
10
10
  export declare function useCategories(viewManager: ViewManager, imodel: IModelConnection, view?: Viewport): Category[];
11
- /** @internal */
12
- export declare function loadCategoriesFromViewport(iModel?: IModelConnection, vp?: Viewport): Promise<Category[]>;
13
11
  /**
14
12
  * Data structure that describes category.
15
13
  * @alpha
@@ -46,9 +44,7 @@ export declare class CategoryVisibilityHandler implements IVisibilityHandler {
46
44
  private onViewedCategoriesChanged;
47
45
  private onVisibilityChangeInternal;
48
46
  static getInstanceIdFromTreeNodeKey(nodeKey: NodeKey): string;
49
- /** Changes category display in the viewport */
50
- static enableCategory(viewManager: ViewManager, imodel: IModelConnection, ids: string[], enabled: boolean, forAllViewports: boolean, enableAllSubCategories?: boolean): void;
51
- /** Changes subcategory display in the viewport */
52
- static enableSubCategory(viewManager: ViewManager, key: string, enabled: boolean, forAllViewports?: boolean): void;
47
+ enableCategory(ids: string[], enabled: boolean, enableAllSubCategories?: boolean): void;
48
+ enableSubCategory(key: string, enabled: boolean): void;
53
49
  }
54
50
  //# sourceMappingURL=CategoryVisibilityHandler.d.ts.map
@@ -5,9 +5,8 @@
5
5
  import * as React from "react";
6
6
  import { useAsyncValue } from "@itwin/components-react";
7
7
  import { BeEvent } from "@itwin/core-bentley";
8
- import { QueryRowFormat } from "@itwin/core-common";
9
- import { PerModelCategoryVisibility } from "@itwin/core-frontend";
10
8
  import { NodeKey } from "@itwin/presentation-common";
9
+ import { enableCategory, enableSubCategory, loadCategoriesFromViewport } from "../CategoriesVisibilityUtils";
11
10
  const EMPTY_CATEGORIES_ARRAY = [];
12
11
  /**
13
12
  * Loads categories from viewport or uses provided list of categories.
@@ -19,27 +18,6 @@ export function useCategories(viewManager, imodel, view) {
19
18
  const categoriesPromise = React.useMemo(async () => loadCategoriesFromViewport(imodel, currentView), [imodel, currentView]);
20
19
  return (_a = useAsyncValue(categoriesPromise)) !== null && _a !== void 0 ? _a : EMPTY_CATEGORIES_ARRAY;
21
20
  }
22
- /** @internal */
23
- export async function loadCategoriesFromViewport(iModel, vp) {
24
- if (!vp)
25
- return EMPTY_CATEGORIES_ARRAY;
26
- // Query categories and add them to state
27
- const selectUsedSpatialCategoryIds = "SELECT DISTINCT Category.Id as id from BisCore.GeometricElement3d WHERE Category.Id IN (SELECT ECInstanceId from BisCore.SpatialCategory)";
28
- const selectUsedDrawingCategoryIds = "SELECT DISTINCT Category.Id as id from BisCore.GeometricElement2d WHERE Model.Id=? AND Category.Id IN (SELECT ECInstanceId from BisCore.DrawingCategory)";
29
- const ecsql = vp.view.is3d() ? selectUsedSpatialCategoryIds : selectUsedDrawingCategoryIds;
30
- const ecsql2 = `SELECT ECInstanceId as id, UserLabel as label, CodeValue as code FROM ${vp.view.is3d() ? "BisCore.SpatialCategory" : "BisCore.DrawingCategory"} WHERE ECInstanceId IN (${ecsql})`;
31
- const categories = [];
32
- // istanbul ignore else
33
- if (iModel) {
34
- const rowIterator = iModel.query(ecsql2, undefined, { rowFormat: QueryRowFormat.UseJsPropertyNames });
35
- // istanbul ignore next
36
- for await (const row of rowIterator) {
37
- const subCategoryIds = iModel.subcategories.getSubCategories(row.id);
38
- categories.push({ key: row.id, children: (subCategoryIds) ? [...subCategoryIds] : undefined });
39
- }
40
- }
41
- return categories;
42
- }
43
21
  /** @alpha */
44
22
  export class CategoryVisibilityHandler {
45
23
  constructor(params) {
@@ -84,12 +62,12 @@ export class CategoryVisibilityHandler {
84
62
  const parentId = (_a = this.getParent(childId)) === null || _a === void 0 ? void 0 : _a.key;
85
63
  // make sure parent category is enabled
86
64
  if (shouldDisplay && parentId)
87
- CategoryVisibilityHandler.enableCategory(this._viewManager, this._imodel, [parentId], true, this._useAllViewports, false);
88
- CategoryVisibilityHandler.enableSubCategory(this._viewManager, childId, shouldDisplay, this._useAllViewports);
65
+ this.enableCategory([parentId], true, false);
66
+ this.enableSubCategory(childId, shouldDisplay);
89
67
  return;
90
68
  }
91
69
  const instanceId = CategoryVisibilityHandler.getInstanceIdFromTreeNodeKey(nodeKey);
92
- CategoryVisibilityHandler.enableCategory(this._viewManager, this._imodel, [instanceId], shouldDisplay, true);
70
+ this.enableCategory([instanceId], shouldDisplay, true);
93
71
  }
94
72
  getSubCategoryVisibility(id) {
95
73
  const parentItem = this.getParent(id);
@@ -124,65 +102,11 @@ export class CategoryVisibilityHandler {
124
102
  static getInstanceIdFromTreeNodeKey(nodeKey) {
125
103
  return (NodeKey.isInstancesNodeKey(nodeKey) && nodeKey.instanceKeys.length > 0) ? nodeKey.instanceKeys[0].id : /* istanbul ignore next */ "";
126
104
  }
127
- /** Changes category display in the viewport */
128
- static enableCategory(viewManager, imodel, ids, enabled, forAllViewports, enableAllSubCategories = true) {
129
- if (!viewManager.selectedView)
130
- return;
131
- const updateViewport = (vp) => {
132
- // Only act on viewports that are both 3D or both 2D. Important if we have multiple viewports opened and we
133
- // are using 'allViewports' property
134
- if (viewManager.selectedView && viewManager.selectedView.view.is3d() === vp.view.is3d()) {
135
- vp.changeCategoryDisplay(ids, enabled, enableAllSubCategories);
136
- // remove category overrides per model
137
- const modelsContainingOverrides = [];
138
- for (const ovr of vp.perModelCategoryVisibility) {
139
- // istanbul ignore else
140
- if (ids.findIndex((id) => id === ovr.categoryId) !== -1)
141
- modelsContainingOverrides.push(ovr.modelId);
142
- }
143
- vp.perModelCategoryVisibility.setOverride(modelsContainingOverrides, ids, PerModelCategoryVisibility.Override.None);
144
- // changeCategoryDisplay only enables subcategories, it does not disabled them. So we must do that ourselves.
145
- if (false === enabled) {
146
- ids.forEach((id) => {
147
- const subCategoryIds = imodel.subcategories.getSubCategories(id);
148
- // istanbul ignore else
149
- if (subCategoryIds) {
150
- subCategoryIds.forEach((subCategoryId) => CategoryVisibilityHandler.enableSubCategory(viewManager, subCategoryId, false, forAllViewports));
151
- }
152
- });
153
- }
154
- }
155
- };
156
- // This property let us act on all viewports or just on the selected one, configurable by the app
157
- if (forAllViewports) {
158
- for (const viewport of viewManager) {
159
- updateViewport(viewport);
160
- }
161
- }
162
- else {
163
- updateViewport(viewManager.selectedView);
164
- }
105
+ enableCategory(ids, enabled, enableAllSubCategories = true) {
106
+ enableCategory(this._viewManager, this._imodel, ids, enabled, this._useAllViewports, enableAllSubCategories);
165
107
  }
166
- /** Changes subcategory display in the viewport */
167
- static enableSubCategory(viewManager, key, enabled, forAllViewports) {
168
- if (!viewManager.selectedView)
169
- return;
170
- const updateViewport = (vp) => {
171
- // Only act on viewports that are both 3D or both 2D. Important if we have multiple viewports opened and we
172
- // are using 'allViewports' property
173
- if (viewManager.selectedView && viewManager.selectedView.view.is3d() === vp.view.is3d()) {
174
- vp.changeSubCategoryDisplay(key, enabled);
175
- }
176
- };
177
- // This property let us act on all viewports or just on the selected one, configurable by the app
178
- if (forAllViewports) {
179
- for (const viewport of viewManager) {
180
- updateViewport(viewport);
181
- }
182
- }
183
- else {
184
- updateViewport(viewManager.selectedView);
185
- }
108
+ enableSubCategory(key, enabled) {
109
+ enableSubCategory(this._viewManager, key, enabled, this._useAllViewports);
186
110
  }
187
111
  }
188
112
  //# sourceMappingURL=CategoryVisibilityHandler.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CategoryVisibilityHandler.js","sourceRoot":"","sources":["../../../../../src/components/trees/category-tree/CategoryVisibilityHandler.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC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G,EAAE,OAAO,CAAC,CAAC;aAC3C;QACH,CAAC,CAAC;QAEF,iGAAiG;QACjG,IAAI,eAAe,EAAE;YACnB,KAAK,MAAM,QAAQ,IAAI,WAAW,EAAE;gBAClC,cAAc,CAAC,QAAQ,CAAC,CAAC;aAC1B;SACF;aAAM;YACL,cAAc,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;SAC1C;IACH,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 * as React from \"react\";\nimport { useAsyncValue } from \"@itwin/components-react\";\nimport { BeEvent } from \"@itwin/core-bentley\";\nimport { QueryRowFormat } from \"@itwin/core-common\";\nimport { PerModelCategoryVisibility } from \"@itwin/core-frontend\";\nimport { NodeKey } from \"@itwin/presentation-common\";\nimport type { IModelConnection, ViewManager, Viewport } from \"@itwin/core-frontend\";\nimport type { TreeNodeItem } from \"@itwin/components-react\";\nimport type { IVisibilityHandler, VisibilityChangeListener, VisibilityStatus } from \"../VisibilityTreeEventHandler\";\n\nconst EMPTY_CATEGORIES_ARRAY: Category[] = [];\n\n/**\n * Loads categories from viewport or uses provided list of categories.\n * @internal\n */\nexport function useCategories(viewManager: ViewManager, imodel: IModelConnection, view?: Viewport) {\n const currentView = view || viewManager.getFirstOpenView();\n const categoriesPromise = React.useMemo(async () => loadCategoriesFromViewport(imodel, currentView), [imodel, currentView]);\n return useAsyncValue(categoriesPromise) ?? EMPTY_CATEGORIES_ARRAY;\n}\n\n/** @internal */\nexport async function loadCategoriesFromViewport(iModel?: IModelConnection, vp?: Viewport) {\n if (!vp)\n return EMPTY_CATEGORIES_ARRAY;\n\n // Query categories and add them to state\n const selectUsedSpatialCategoryIds = \"SELECT DISTINCT Category.Id as id from BisCore.GeometricElement3d WHERE Category.Id IN (SELECT ECInstanceId from BisCore.SpatialCategory)\";\n const selectUsedDrawingCategoryIds = \"SELECT DISTINCT Category.Id as id from BisCore.GeometricElement2d WHERE Model.Id=? AND Category.Id IN (SELECT ECInstanceId from BisCore.DrawingCategory)\";\n const ecsql = vp.view.is3d() ? selectUsedSpatialCategoryIds : selectUsedDrawingCategoryIds;\n const ecsql2 = `SELECT ECInstanceId as id, UserLabel as label, CodeValue as code FROM ${vp.view.is3d() ? \"BisCore.SpatialCategory\" : \"BisCore.DrawingCategory\"} WHERE ECInstanceId IN (${ecsql})`;\n\n const categories: Category[] = [];\n\n // istanbul ignore else\n if (iModel) {\n const rowIterator = iModel.query(ecsql2, undefined, { rowFormat: QueryRowFormat.UseJsPropertyNames });\n // istanbul ignore next\n for await (const row of rowIterator) {\n const subCategoryIds = iModel.subcategories.getSubCategories(row.id);\n categories.push({ key: row.id, children: (subCategoryIds) ? [...subCategoryIds] : undefined });\n }\n }\n\n return categories;\n}\n\n/**\n * Data structure that describes category.\n * @alpha\n */\nexport interface Category {\n key: string;\n children?: string[];\n}\n\n/** @alpha */\nexport interface CategoryVisibilityHandlerParams {\n viewManager: ViewManager;\n imodel: IModelConnection;\n categories: Category[];\n activeView?: Viewport;\n allViewports?: boolean;\n}\n\n/** @alpha */\nexport class CategoryVisibilityHandler implements IVisibilityHandler {\n private _viewManager: ViewManager;\n private _imodel: IModelConnection;\n private _pendingVisibilityChange: any | undefined;\n private _activeView?: Viewport;\n private _useAllViewports: boolean;\n private _categories: Category[];\n\n constructor(params: CategoryVisibilityHandlerParams) {\n this._viewManager = params.viewManager;\n this._imodel = params.imodel;\n this._activeView = params.activeView;\n // istanbul ignore next\n this._useAllViewports = params.allViewports ?? false;\n this._categories = params.categories;\n if (this._activeView) {\n this._activeView.onDisplayStyleChanged.addListener(this.onDisplayStyleChanged);\n this._activeView.onViewedCategoriesChanged.addListener(this.onViewedCategoriesChanged);\n }\n }\n\n public dispose() {\n if (this._activeView) {\n this._activeView.onDisplayStyleChanged.removeListener(this.onDisplayStyleChanged);\n this._activeView.onViewedCategoriesChanged.removeListener(this.onViewedCategoriesChanged);\n }\n clearTimeout(this._pendingVisibilityChange);\n }\n\n public onVisibilityChange = new BeEvent<VisibilityChangeListener>();\n\n public getVisibilityStatus(node: TreeNodeItem, nodeKey: NodeKey): VisibilityStatus {\n const instanceId = CategoryVisibilityHandler.getInstanceIdFromTreeNodeKey(nodeKey);\n return { state: node.parentId ? this.getSubCategoryVisibility(instanceId) : this.getCategoryVisibility(instanceId) };\n }\n\n public async changeVisibility(node: TreeNodeItem, nodeKey: NodeKey, shouldDisplay: boolean): Promise<void> {\n // handle subcategory visibility change\n if (node.parentId) {\n const childId = CategoryVisibilityHandler.getInstanceIdFromTreeNodeKey(nodeKey);\n // istanbul ignore next\n const parentId = this.getParent(childId)?.key;\n\n // make sure parent category is enabled\n if (shouldDisplay && parentId)\n CategoryVisibilityHandler.enableCategory(this._viewManager, this._imodel, [parentId], true, this._useAllViewports, false);\n\n CategoryVisibilityHandler.enableSubCategory(this._viewManager, childId, shouldDisplay, this._useAllViewports);\n return;\n }\n\n const instanceId = CategoryVisibilityHandler.getInstanceIdFromTreeNodeKey(nodeKey);\n CategoryVisibilityHandler.enableCategory(this._viewManager, this._imodel, [instanceId], shouldDisplay, true);\n }\n\n public getSubCategoryVisibility(id: string) {\n const parentItem = this.getParent(id);\n if (!parentItem || !this._activeView)\n return \"hidden\";\n\n const isVisible = this._activeView.view.viewsCategory(parentItem.key) && this._activeView.isSubCategoryVisible(id);\n return isVisible ? \"visible\" : \"hidden\";\n }\n\n public getCategoryVisibility(id: string) {\n if (!this._activeView)\n return \"hidden\";\n return this._activeView.view.viewsCategory(id) ? \"visible\" : \"hidden\";\n }\n\n public getParent(key: string): Category | undefined {\n for (const category of this._categories) {\n // istanbul ignore else\n if (category.children) {\n if (category.children.indexOf(key) !== -1)\n return category;\n }\n }\n\n return undefined;\n }\n\n // eslint-disable-next-line @typescript-eslint/naming-convention\n private onDisplayStyleChanged = () => {\n this.onVisibilityChangeInternal();\n };\n\n // eslint-disable-next-line @typescript-eslint/naming-convention\n private onViewedCategoriesChanged = () => {\n this.onVisibilityChangeInternal();\n };\n\n private onVisibilityChangeInternal() {\n if (this._pendingVisibilityChange)\n return;\n\n this._pendingVisibilityChange = setTimeout(() => {\n this.onVisibilityChange.raiseEvent();\n this._pendingVisibilityChange = undefined;\n }, 0);\n }\n\n public static getInstanceIdFromTreeNodeKey(nodeKey: NodeKey) {\n return (NodeKey.isInstancesNodeKey(nodeKey) && nodeKey.instanceKeys.length > 0) ? nodeKey.instanceKeys[0].id : /* istanbul ignore next */ \"\";\n }\n\n /** Changes category display in the viewport */\n public static enableCategory(viewManager: ViewManager, imodel: IModelConnection, ids: string[], enabled: boolean, forAllViewports: boolean, enableAllSubCategories = true) {\n if (!viewManager.selectedView)\n return;\n\n const updateViewport = (vp: Viewport) => {\n // Only act on viewports that are both 3D or both 2D. Important if we have multiple viewports opened and we\n // are using 'allViewports' property\n if (viewManager.selectedView && viewManager.selectedView.view.is3d() === vp.view.is3d()) {\n vp.changeCategoryDisplay(ids, enabled, enableAllSubCategories);\n\n // remove category overrides per model\n const modelsContainingOverrides: string[] = [];\n for (const ovr of vp.perModelCategoryVisibility) {\n // istanbul ignore else\n if (ids.findIndex((id) => id === ovr.categoryId) !== -1)\n modelsContainingOverrides.push(ovr.modelId);\n }\n vp.perModelCategoryVisibility.setOverride(modelsContainingOverrides, ids, PerModelCategoryVisibility.Override.None);\n\n // changeCategoryDisplay only enables subcategories, it does not disabled them. So we must do that ourselves.\n if (false === enabled) {\n ids.forEach((id) => {\n const subCategoryIds = imodel.subcategories.getSubCategories(id);\n // istanbul ignore else\n if (subCategoryIds) {\n subCategoryIds.forEach((subCategoryId) => CategoryVisibilityHandler.enableSubCategory(viewManager, subCategoryId, false, forAllViewports));\n }\n });\n }\n }\n };\n\n // This property let us act on all viewports or just on the selected one, configurable by the app\n if (forAllViewports) {\n for (const viewport of viewManager) {\n updateViewport(viewport);\n }\n } else {\n updateViewport(viewManager.selectedView);\n }\n }\n\n /** Changes subcategory display in the viewport */\n public static enableSubCategory(viewManager: ViewManager, key: string, enabled: boolean, forAllViewports?: boolean) {\n if (!viewManager.selectedView)\n return;\n\n const updateViewport = (vp: Viewport) => {\n // Only act on viewports that are both 3D or both 2D. Important if we have multiple viewports opened and we\n // are using 'allViewports' property\n if (viewManager.selectedView && viewManager.selectedView.view.is3d() === vp.view.is3d()) {\n vp.changeSubCategoryDisplay(key, enabled);\n }\n };\n\n // This property let us act on all viewports or just on the selected one, configurable by the app\n if (forAllViewports) {\n for (const viewport of viewManager) {\n updateViewport(viewport);\n }\n } else {\n updateViewport(viewManager.selectedView);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"CategoryVisibilityHandler.js","sourceRoot":"","sources":["../../../../../src/components/trees/category-tree/CategoryVisibilityHandler.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAIrD,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAE7G,MAAM,sBAAsB,GAAe,EAAE,CAAC;AAE9C;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,WAAwB,EAAE,MAAwB,EAAE,IAAe;;IAC/F,MAAM,WAAW,GAAG,IAAI,IAAI,WAAW,CAAC,gBAAgB,EAAE,CAAC;IAC3D,MAAM,iBAAiB,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,0BAA0B,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC;IAC5H,OAAO,MAAA,aAAa,CAAC,iBAAiB,CAAC,mCAAI,sBAAsB,CAAC;AACpE,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AAY,EAAE,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,gBAAgB,EAAE,sBAAsB,CAAC,CAAC;IAC/G,CAAC;IAEM,iBAAiB,CAAC,GAAW,EAAE,OAAgB;QACpD,iBAAiB,CAAC,IAAI,CAAC,YAAY,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAC5E,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 * as React from \"react\";\nimport { useAsyncValue } from \"@itwin/components-react\";\nimport { BeEvent } from \"@itwin/core-bentley\";\nimport { NodeKey } from \"@itwin/presentation-common\";\nimport type { IModelConnection, ViewManager, Viewport } from \"@itwin/core-frontend\";\nimport type { TreeNodeItem } from \"@itwin/components-react\";\nimport type { IVisibilityHandler, VisibilityChangeListener, VisibilityStatus } from \"../VisibilityTreeEventHandler\";\nimport { enableCategory, enableSubCategory, loadCategoriesFromViewport } from \"../CategoriesVisibilityUtils\";\n\nconst EMPTY_CATEGORIES_ARRAY: Category[] = [];\n\n/**\n * Loads categories from viewport or uses provided list of categories.\n * @internal\n */\nexport function useCategories(viewManager: ViewManager, imodel: IModelConnection, view?: Viewport) {\n const currentView = view || viewManager.getFirstOpenView();\n const categoriesPromise = React.useMemo(async () => loadCategoriesFromViewport(imodel, currentView), [imodel, currentView]);\n return useAsyncValue(categoriesPromise) ?? EMPTY_CATEGORIES_ARRAY;\n}\n\n/**\n * Data structure that describes category.\n * @alpha\n */\nexport interface Category {\n key: string;\n children?: string[];\n}\n\n/** @alpha */\nexport interface CategoryVisibilityHandlerParams {\n viewManager: ViewManager;\n imodel: IModelConnection;\n categories: Category[];\n activeView?: Viewport;\n allViewports?: boolean;\n}\n\n/** @alpha */\nexport class CategoryVisibilityHandler implements IVisibilityHandler {\n private _viewManager: ViewManager;\n private _imodel: IModelConnection;\n private _pendingVisibilityChange: any | undefined;\n private _activeView?: Viewport;\n private _useAllViewports: boolean;\n private _categories: Category[];\n\n constructor(params: CategoryVisibilityHandlerParams) {\n this._viewManager = params.viewManager;\n this._imodel = params.imodel;\n this._activeView = params.activeView;\n // istanbul ignore next\n this._useAllViewports = params.allViewports ?? false;\n this._categories = params.categories;\n if (this._activeView) {\n this._activeView.onDisplayStyleChanged.addListener(this.onDisplayStyleChanged);\n this._activeView.onViewedCategoriesChanged.addListener(this.onViewedCategoriesChanged);\n }\n }\n\n public dispose() {\n if (this._activeView) {\n this._activeView.onDisplayStyleChanged.removeListener(this.onDisplayStyleChanged);\n this._activeView.onViewedCategoriesChanged.removeListener(this.onViewedCategoriesChanged);\n }\n clearTimeout(this._pendingVisibilityChange);\n }\n\n public onVisibilityChange = new BeEvent<VisibilityChangeListener>();\n\n public getVisibilityStatus(node: TreeNodeItem, nodeKey: NodeKey): VisibilityStatus {\n const instanceId = CategoryVisibilityHandler.getInstanceIdFromTreeNodeKey(nodeKey);\n return { state: node.parentId ? this.getSubCategoryVisibility(instanceId) : this.getCategoryVisibility(instanceId) };\n }\n\n public async changeVisibility(node: TreeNodeItem, nodeKey: NodeKey, shouldDisplay: boolean): Promise<void> {\n // handle subcategory visibility change\n if (node.parentId) {\n const childId = CategoryVisibilityHandler.getInstanceIdFromTreeNodeKey(nodeKey);\n // istanbul ignore next\n const parentId = this.getParent(childId)?.key;\n\n // make sure parent category is enabled\n if (shouldDisplay && parentId)\n this.enableCategory([parentId], true, false);\n\n this.enableSubCategory(childId, shouldDisplay);\n return;\n }\n\n const instanceId = CategoryVisibilityHandler.getInstanceIdFromTreeNodeKey(nodeKey);\n this.enableCategory([instanceId], shouldDisplay, true);\n }\n\n public getSubCategoryVisibility(id: string) {\n const parentItem = this.getParent(id);\n if (!parentItem || !this._activeView)\n return \"hidden\";\n\n const isVisible = this._activeView.view.viewsCategory(parentItem.key) && this._activeView.isSubCategoryVisible(id);\n return isVisible ? \"visible\" : \"hidden\";\n }\n\n public getCategoryVisibility(id: string) {\n if (!this._activeView)\n return \"hidden\";\n return this._activeView.view.viewsCategory(id) ? \"visible\" : \"hidden\";\n }\n\n public getParent(key: string): Category | undefined {\n for (const category of this._categories) {\n // istanbul ignore else\n if (category.children) {\n if (category.children.indexOf(key) !== -1)\n return category;\n }\n }\n\n return undefined;\n }\n\n // eslint-disable-next-line @typescript-eslint/naming-convention\n private onDisplayStyleChanged = () => {\n this.onVisibilityChangeInternal();\n };\n\n // eslint-disable-next-line @typescript-eslint/naming-convention\n private onViewedCategoriesChanged = () => {\n this.onVisibilityChangeInternal();\n };\n\n private onVisibilityChangeInternal() {\n if (this._pendingVisibilityChange)\n return;\n\n this._pendingVisibilityChange = setTimeout(() => {\n this.onVisibilityChange.raiseEvent();\n this._pendingVisibilityChange = undefined;\n }, 0);\n }\n\n public static getInstanceIdFromTreeNodeKey(nodeKey: NodeKey) {\n return (NodeKey.isInstancesNodeKey(nodeKey) && nodeKey.instanceKeys.length > 0) ? nodeKey.instanceKeys[0].id : /* istanbul ignore next */ \"\";\n }\n\n public enableCategory(ids: string[], enabled: boolean, enableAllSubCategories = true) {\n enableCategory(this._viewManager, this._imodel, ids, enabled, this._useAllViewports, enableAllSubCategories);\n }\n\n public enableSubCategory(key: string, enabled: boolean) {\n enableSubCategory(this._viewManager, key, enabled, this._useAllViewports);\n }\n}\n"]}
@@ -266,7 +266,7 @@
266
266
  }
267
267
  }
268
268
  ],
269
- "instanceFilter": "this.Model.Id = parent.parent.ECInstanceId ANDALSO this.Parent = NULL ANDALSO (NOT HasVariable(\"filtered-element-ids\") OR GetVariableIntValues(\"filtered-element-ids\").AnyMatch(id => id = this.ECInstanceId))",
269
+ "instanceFilter": "this.Model.Id = parent.parent.ECInstanceId ANDALSO this.Parent = NULL",
270
270
  "groupByClass": true,
271
271
  "groupByLabel": false
272
272
  }
@@ -300,7 +300,6 @@
300
300
  }
301
301
  }
302
302
  ],
303
- "instanceFilter": "NOT HasVariable(\"filtered-element-ids\") OR GetVariableIntValues(\"filtered-element-ids\").AnyMatch(id => id = this.ECInstanceId)",
304
303
  "groupByClass": true,
305
304
  "groupByLabel": false
306
305
  }
@@ -266,7 +266,7 @@
266
266
  }
267
267
  }
268
268
  ],
269
- "instanceFilter": "this.Model.Id = parent.parent.ECInstanceId ANDALSO this.Parent = NULL ANDALSO (NOT HasVariable(\"filtered-element-ids\") OR GetVariableIntValues(\"filtered-element-ids\").AnyMatch(id => id = this.ECInstanceId))",
269
+ "instanceFilter": "this.Model.Id = parent.parent.ECInstanceId ANDALSO this.Parent = NULL",
270
270
  "groupByClass": false,
271
271
  "groupByLabel": false
272
272
  }
@@ -300,7 +300,6 @@
300
300
  }
301
301
  }
302
302
  ],
303
- "instanceFilter": "NOT HasVariable(\"filtered-element-ids\") OR GetVariableIntValues(\"filtered-element-ids\").AnyMatch(id => id = this.ECInstanceId)",
304
303
  "groupByClass": false,
305
304
  "groupByLabel": false
306
305
  }